mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-20 00:25:23 +00:00
Added group capturing in backward compatible way
This commit is contained in:
parent
9f10341627
commit
9324996961
@ -54,13 +54,15 @@ func (e *Extractor) ExtractDNS(msg *dns.Msg) map[string]struct{} {
|
|||||||
func (e *Extractor) extractRegex(corpus string) map[string]struct{} {
|
func (e *Extractor) extractRegex(corpus string) map[string]struct{} {
|
||||||
results := make(map[string]struct{})
|
results := make(map[string]struct{})
|
||||||
|
|
||||||
|
groupPlusOne := e.RegexGroup + 1
|
||||||
for _, regex := range e.regexCompiled {
|
for _, regex := range e.regexCompiled {
|
||||||
matches := regex.FindAllString(corpus, -1)
|
matches := regex.FindAllStringSubmatch(corpus, -1)
|
||||||
for _, match := range matches {
|
for _, match := range matches {
|
||||||
results[match] = struct{}{}
|
if len(match) >= groupPlusOne {
|
||||||
|
results[match[e.RegexGroup]] = struct{}{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,6 +13,8 @@ type Extractor 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"`
|
Regex []string `yaml:"regex"`
|
||||||
|
// RegexGroup specifies a group to extract from the regex
|
||||||
|
RegexGroup int `yaml:"group"`
|
||||||
// regexCompiled is the compiled variant
|
// regexCompiled is the compiled variant
|
||||||
regexCompiled []*regexp.Regexp
|
regexCompiled []*regexp.Regexp
|
||||||
|
|
||||||
@ -25,7 +27,6 @@ type Extractor struct {
|
|||||||
Part string `yaml:"part,omitempty"`
|
Part string `yaml:"part,omitempty"`
|
||||||
// part is the part of the request to match
|
// part is the part of the request to match
|
||||||
part Part
|
part Part
|
||||||
|
|
||||||
// Internal defines if this is used internally
|
// Internal defines if this is used internally
|
||||||
Internal bool `yaml:"internal,omitempty"`
|
Internal bool `yaml:"internal,omitempty"`
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user