Adding support to skip unused payloads
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 {
