mirror of https://github.com/daffainfo/nuclei.git
Added internal extractor support to network templates
parent
93ab540b54
commit
0910d526af
|
@ -162,3 +162,21 @@ func (r *Operators) Execute(data map[string]interface{}, match MatchFunc, extrac
|
|||
}
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// ExecuteInternalExtractors executes internal dynamic extractors
|
||||
func (r *Operators) ExecuteInternalExtractors(data map[string]interface{}, extract ExtractFunc) map[string]interface{} {
|
||||
dynamicValues := make(map[string]interface{})
|
||||
|
||||
// Start with the extractors first and evaluate them.
|
||||
for _, extractor := range r.Extractors {
|
||||
if !extractor.Internal {
|
||||
continue
|
||||
}
|
||||
for match := range extract(data, extractor) {
|
||||
if _, ok := dynamicValues[extractor.Name]; !ok {
|
||||
dynamicValues[extractor.Name] = match
|
||||
}
|
||||
}
|
||||
}
|
||||
return dynamicValues
|
||||
}
|
||||
|
|
|
@ -149,8 +149,18 @@ func (r *Request) executeRequestWithPayloads(actualAddress, address, input strin
|
|||
buffer := make([]byte, input.Read)
|
||||
n, _ := conn.Read(buffer)
|
||||
responseBuilder.Write(buffer[:n])
|
||||
|
||||
bufferStr := string(buffer[:n])
|
||||
if input.Name != "" {
|
||||
inputEvents[input.Name] = string(buffer[:n])
|
||||
inputEvents[input.Name] = bufferStr
|
||||
}
|
||||
|
||||
// Run any internal extractors for the request here and add found values to map.
|
||||
if r.CompiledOperators != nil {
|
||||
values := r.CompiledOperators.ExecuteInternalExtractors(map[string]interface{}{input.Name: bufferStr}, r.Extract)
|
||||
for k, v := range values {
|
||||
payloads[k] = v
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue