mirror of https://github.com/daffainfo/nuclei.git
Added multi-protocol requests support for templates (#2611)
parent
5377ee3f36
commit
7e209dad01
|
@ -78,7 +78,7 @@ require (
|
|||
github.com/projectdiscovery/iputil v0.0.0-20220712175312-b9406f31cdd8
|
||||
github.com/projectdiscovery/nvd v1.0.9
|
||||
github.com/projectdiscovery/sliceutil v0.0.0-20220625085859-c3a4ecb669f4
|
||||
github.com/projectdiscovery/tlsx v0.0.5-0.20220831115114-feb379e88900
|
||||
github.com/projectdiscovery/tlsx v0.0.7
|
||||
github.com/projectdiscovery/urlutil v0.0.0-20210525140139-b874f06ad921
|
||||
github.com/projectdiscovery/wappalyzergo v0.0.58
|
||||
github.com/stretchr/testify v1.8.0
|
||||
|
|
|
@ -619,8 +619,8 @@ github.com/projectdiscovery/stringsutil v0.0.0-20220422150559-b54fb5dc6833/go.mo
|
|||
github.com/projectdiscovery/stringsutil v0.0.0-20220612082425-0037ce9f89f3/go.mod h1:mF5sh4jTghoGWwgUb9qWi5waTFklClDbtrqtJU93awc=
|
||||
github.com/projectdiscovery/stringsutil v0.0.0-20220731064040-4b67f194751e h1:JBdwX+DJNq5FIJGsZCSKLGV4EhSRiPtNk22Vi+3cTDg=
|
||||
github.com/projectdiscovery/stringsutil v0.0.0-20220731064040-4b67f194751e/go.mod h1:32NYmKyHkKsmisAOAaWrR15lz2ysz2M8x3KMeeoRHoU=
|
||||
github.com/projectdiscovery/tlsx v0.0.5-0.20220831115114-feb379e88900 h1:YmJ/IWcZVdzMHipIOCC2LZuf9PcqlDWgzcnU8MYWXgQ=
|
||||
github.com/projectdiscovery/tlsx v0.0.5-0.20220831115114-feb379e88900/go.mod h1:JHcbxkCL3YSbGIoc4hcAmAGaBwtWy8E1bHu6P7abTeg=
|
||||
github.com/projectdiscovery/tlsx v0.0.7 h1:McoDo4Ju7aetogatU4lVTRcQpxkf0qgQSoWgtkDavCk=
|
||||
github.com/projectdiscovery/tlsx v0.0.7/go.mod h1:/ZCk/zzyuDdXx2E511yhNIj3LERnGUXghqkASBbdh5M=
|
||||
github.com/projectdiscovery/urlutil v0.0.0-20210525140139-b874f06ad921 h1:EgaxpJm7+lKppfAHkFHs+S+II0lodp4Gu3leZCCkWlc=
|
||||
github.com/projectdiscovery/urlutil v0.0.0-20210525140139-b874f06ad921/go.mod h1:oXLErqOpqEAp/ueQlknysFxHO3CUNoSiDNnkiHG+Jpo=
|
||||
github.com/projectdiscovery/wappalyzergo v0.0.58 h1:kLbaiIK5KqLC/imGna5OOs0DWjTWFnj7iqRajTmflc8=
|
||||
|
|
|
@ -27,8 +27,9 @@ func init() {
|
|||
}
|
||||
|
||||
// Parse parses a yaml request template file
|
||||
//nolint:gocritic // this cannot be passed by pointer
|
||||
// TODO make sure reading from the disk the template parsing happens once: see parsers.ParseTemplate vs templates.Parse
|
||||
//
|
||||
//nolint:gocritic // this cannot be passed by pointer
|
||||
func Parse(filePath string, preprocessor Preprocessor, options protocols.ExecuterOptions) (*Template, error) {
|
||||
if value, err := parsedTemplatesCache.Has(filePath); value != nil {
|
||||
return value.(*Template), err
|
||||
|
@ -147,30 +148,30 @@ func (template *Template) compileProtocolRequests(options protocols.ExecuterOpti
|
|||
}
|
||||
|
||||
var requests []protocols.Request
|
||||
switch {
|
||||
case len(template.RequestsDNS) > 0:
|
||||
requests = template.convertRequestToProtocolsRequest(template.RequestsDNS)
|
||||
|
||||
case len(template.RequestsFile) > 0:
|
||||
requests = template.convertRequestToProtocolsRequest(template.RequestsFile)
|
||||
|
||||
case len(template.RequestsNetwork) > 0:
|
||||
requests = template.convertRequestToProtocolsRequest(template.RequestsNetwork)
|
||||
|
||||
case len(template.RequestsHTTP) > 0:
|
||||
requests = template.convertRequestToProtocolsRequest(template.RequestsHTTP)
|
||||
|
||||
case len(template.RequestsHeadless) > 0 && options.Options.Headless:
|
||||
requests = template.convertRequestToProtocolsRequest(template.RequestsHeadless)
|
||||
|
||||
case len(template.RequestsSSL) > 0:
|
||||
requests = template.convertRequestToProtocolsRequest(template.RequestsSSL)
|
||||
|
||||
case len(template.RequestsWebsocket) > 0:
|
||||
requests = template.convertRequestToProtocolsRequest(template.RequestsWebsocket)
|
||||
|
||||
case len(template.RequestsWHOIS) > 0:
|
||||
requests = template.convertRequestToProtocolsRequest(template.RequestsWHOIS)
|
||||
if len(template.RequestsDNS) > 0 {
|
||||
requests = append(requests, template.convertRequestToProtocolsRequest(template.RequestsDNS)...)
|
||||
}
|
||||
if len(template.RequestsFile) > 0 {
|
||||
requests = append(requests, template.convertRequestToProtocolsRequest(template.RequestsFile)...)
|
||||
}
|
||||
if len(template.RequestsNetwork) > 0 {
|
||||
requests = append(requests, template.convertRequestToProtocolsRequest(template.RequestsNetwork)...)
|
||||
}
|
||||
if len(template.RequestsHTTP) > 0 {
|
||||
requests = append(requests, template.convertRequestToProtocolsRequest(template.RequestsHTTP)...)
|
||||
}
|
||||
if len(template.RequestsHeadless) > 0 && options.Options.Headless {
|
||||
requests = append(requests, template.convertRequestToProtocolsRequest(template.RequestsHeadless)...)
|
||||
}
|
||||
if len(template.RequestsSSL) > 0 {
|
||||
requests = append(requests, template.convertRequestToProtocolsRequest(template.RequestsSSL)...)
|
||||
}
|
||||
if len(template.RequestsWebsocket) > 0 {
|
||||
requests = append(requests, template.convertRequestToProtocolsRequest(template.RequestsWebsocket)...)
|
||||
}
|
||||
if len(template.RequestsWHOIS) > 0 {
|
||||
requests = append(requests, template.convertRequestToProtocolsRequest(template.RequestsWHOIS)...)
|
||||
}
|
||||
template.Executer = executer.NewExecuter(requests, &options)
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue