mirror of https://github.com/daffainfo/nuclei.git
Merge pull request #312 from projectdiscovery/add-group-feature
Added group capturing in backward compatible waydev
commit
57fa83ca35
|
@ -54,13 +54,15 @@ func (e *Extractor) ExtractDNS(msg *dns.Msg) map[string]struct{} {
|
|||
func (e *Extractor) extractRegex(corpus string) map[string]struct{} {
|
||||
results := make(map[string]struct{})
|
||||
|
||||
groupPlusOne := e.RegexGroup + 1
|
||||
for _, regex := range e.regexCompiled {
|
||||
matches := regex.FindAllString(corpus, -1)
|
||||
matches := regex.FindAllStringSubmatch(corpus, -1)
|
||||
for _, match := range matches {
|
||||
results[match] = struct{}{}
|
||||
if len(match) >= groupPlusOne {
|
||||
results[match[e.RegexGroup]] = struct{}{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return results
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@ type Extractor struct {
|
|||
|
||||
// Regex are the regex pattern required to be present in the response
|
||||
Regex []string `yaml:"regex"`
|
||||
// RegexGroup specifies a group to extract from the regex
|
||||
RegexGroup int `yaml:"group"`
|
||||
// regexCompiled is the compiled variant
|
||||
regexCompiled []*regexp.Regexp
|
||||
|
||||
|
@ -25,7 +27,6 @@ type Extractor struct {
|
|||
Part string `yaml:"part,omitempty"`
|
||||
// part is the part of the request to match
|
||||
part Part
|
||||
|
||||
// Internal defines if this is used internally
|
||||
Internal bool `yaml:"internal,omitempty"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue