mirror of
https://github.com/projectdiscovery/nuclei.git
synced 2025-12-18 06:25:29 +00:00
Merge pull request #1790 from projectdiscovery/issue-1772-payload
Adding support to skip unused payloads
This commit is contained in:
commit
c0b45fac4a
@ -1,9 +1,11 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
json "github.com/json-iterator/go"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/projectdiscovery/fileutil"
|
||||
@ -293,6 +295,25 @@ func (request *Request) Compile(options *protocols.ExecuterOptions) error {
|
||||
}
|
||||
}
|
||||
|
||||
// tries to drop unused payloads - by marshaling sections that might contain the payload
|
||||
unusedPayloads := make(map[string]struct{})
|
||||
requestSectionsToCheck := []interface{}{
|
||||
request.customHeaders, request.Headers, request.Matchers,
|
||||
request.Extractors, request.Body, request.Path, request.Raw,
|
||||
}
|
||||
if requestSectionsToCheckData, err := json.Marshal(requestSectionsToCheck); err == nil {
|
||||
for payload := range request.Payloads {
|
||||
if bytes.Contains(requestSectionsToCheckData, []byte(payload)) {
|
||||
continue
|
||||
}
|
||||
unusedPayloads[payload] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
for payload := range unusedPayloads {
|
||||
delete(request.Payloads, payload)
|
||||
}
|
||||
|
||||
if len(request.Payloads) > 0 {
|
||||
request.generator, err = generators.New(request.Payloads, request.AttackType.Value, request.options.TemplatePath, request.options.Catalog)
|
||||
if err != nil {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user