mirror of https://github.com/daffainfo/nuclei.git
Support for multiple fingerprints in single template #25
parent
147464b129
commit
a303cd5723
|
@ -205,40 +205,44 @@ func (r *Runner) sendRequest(template *templates.Template, URL string, writer *b
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the matcher matched
|
// Check if the matcher matched
|
||||||
if !matcher.Match(resp, body, headers) {
|
if matcher.Match(resp, body, headers) {
|
||||||
continue reqLoop
|
// If there is an extractor, run it.
|
||||||
|
var extractorResults []string
|
||||||
|
for _, extractor := range request.Extractors {
|
||||||
|
part := extractor.GetPart()
|
||||||
|
if part == extractors.AllPart || part == extractors.HeaderPart && headers == "" {
|
||||||
|
headers = headersToString(resp.Header)
|
||||||
|
}
|
||||||
|
extractorResults = append(extractorResults, extractor.Extract(body, headers)...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// All the matchers matched, print the output on the screen
|
||||||
|
output := buildOutput(template, req, extractorResults, matcher)
|
||||||
|
gologger.Silentf("%s", output)
|
||||||
|
|
||||||
|
if writer != nil {
|
||||||
|
r.outputMutex.Lock()
|
||||||
|
writer.WriteString(output)
|
||||||
|
r.outputMutex.Unlock()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
continue reqLoop
|
||||||
// If there is an extractor, run it.
|
|
||||||
var extractorResults []string
|
|
||||||
for _, extractor := range request.Extractors {
|
|
||||||
part := extractor.GetPart()
|
|
||||||
if part == extractors.AllPart || part == extractors.HeaderPart && headers == "" {
|
|
||||||
headers = headersToString(resp.Header)
|
|
||||||
}
|
|
||||||
extractorResults = append(extractorResults, extractor.Extract(body, headers)...)
|
|
||||||
}
|
|
||||||
|
|
||||||
// All the matchers matched, print the output on the screen
|
|
||||||
output := buildOutput(template, req, extractorResults)
|
|
||||||
gologger.Silentf("%s", output)
|
|
||||||
|
|
||||||
if writer != nil {
|
|
||||||
r.outputMutex.Lock()
|
|
||||||
writer.WriteString(output)
|
|
||||||
r.outputMutex.Unlock()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// buildOutput builds an output text for writing results
|
// buildOutput builds an output text for writing results
|
||||||
func buildOutput(template *templates.Template, req *retryablehttp.Request, extractorResults []string) string {
|
func buildOutput(template *templates.Template, req *retryablehttp.Request, extractorResults []string, matcher *matchers.Matcher) string {
|
||||||
builder := &strings.Builder{}
|
builder := &strings.Builder{}
|
||||||
builder.WriteRune('[')
|
builder.WriteRune('[')
|
||||||
builder.WriteString(template.ID)
|
builder.WriteString(template.ID)
|
||||||
|
if len(matcher.Name) > 0 {
|
||||||
|
builder.WriteString(":")
|
||||||
|
builder.WriteString(matcher.Name)
|
||||||
|
}
|
||||||
builder.WriteString("] ")
|
builder.WriteString("] ")
|
||||||
|
|
||||||
// Escape the URL by replacing all % with %%
|
// Escape the URL by replacing all % with %%
|
||||||
URL := req.URL.String()
|
URL := req.URL.String()
|
||||||
escapedURL := strings.Replace(URL, "%", "%%", -1)
|
escapedURL := strings.Replace(URL, "%", "%%", -1)
|
||||||
|
|
|
@ -20,6 +20,8 @@ type Matcher struct {
|
||||||
// Regex are the regex pattern required to be present in the response
|
// Regex are the regex pattern required to be present in the response
|
||||||
Regex []string `yaml:"regex,omitempty"`
|
Regex []string `yaml:"regex,omitempty"`
|
||||||
// regexCompiled is the compiled variant
|
// regexCompiled is the compiled variant
|
||||||
|
// Matcher Name to be displayed in result output.
|
||||||
|
Name string `yaml:"name,omitempty"`
|
||||||
regexCompiled []*regexp.Regexp
|
regexCompiled []*regexp.Regexp
|
||||||
|
|
||||||
// Condition is the optional condition between two matcher variables
|
// Condition is the optional condition between two matcher variables
|
||||||
|
|
Loading…
Reference in New Issue