mimic follow behavior

dev
mzack 2024-04-09 18:31:22 +02:00
parent 7e363984b2
commit 582a85d9c0
4 changed files with 18 additions and 2 deletions

View File

@ -338,6 +338,7 @@ on extensive configurability, massive extensibility and ease of use.`)
flagSet.IntVarP(&options.HeadlessTemplateThreads, "headless-concurrency", "headc", 10, "maximum number of headless templates to be executed in parallel"), flagSet.IntVarP(&options.HeadlessTemplateThreads, "headless-concurrency", "headc", 10, "maximum number of headless templates to be executed in parallel"),
flagSet.IntVarP(&options.JsConcurrency, "js-concurrency", "jsc", 120, "maximum number of javascript runtimes to be executed in parallel"), flagSet.IntVarP(&options.JsConcurrency, "js-concurrency", "jsc", 120, "maximum number of javascript runtimes to be executed in parallel"),
flagSet.IntVarP(&options.PayloadConcurrency, "payload-concurrency", "pc", 25, "max payload concurrency for each template"), flagSet.IntVarP(&options.PayloadConcurrency, "payload-concurrency", "pc", 25, "max payload concurrency for each template"),
flagSet.IntVarP(&options.ProbeConcurrency, "probe-concurrency", "prc", 50, "http probe concurrency with httpx"),
) )
flagSet.CreateGroup("optimization", "Optimizations", flagSet.CreateGroup("optimization", "Optimizations",
flagSet.IntVar(&options.Timeout, "timeout", 10, "time to wait in seconds before timeout"), flagSet.IntVar(&options.Timeout, "timeout", 10, "time to wait in seconds before timeout"),

View File

@ -30,6 +30,11 @@ func (r *Runner) initializeTemplatesHTTPInput() (*hybrid.HybridMap, error) {
} }
gologger.Info().Msgf("Running httpx on input host") gologger.Info().Msgf("Running httpx on input host")
var bulkSize = GlobalProbeBulkSize
if r.options.BulkSize > GlobalProbeBulkSize {
bulkSize = r.options.BulkSize
}
httpxOptions := httpx.DefaultOptions httpxOptions := httpx.DefaultOptions
httpxOptions.RetryMax = r.options.Retries httpxOptions.RetryMax = r.options.Retries
httpxOptions.Timeout = time.Duration(r.options.Timeout) * time.Second httpxOptions.Timeout = time.Duration(r.options.Timeout) * time.Second
@ -38,8 +43,10 @@ func (r *Runner) initializeTemplatesHTTPInput() (*hybrid.HybridMap, error) {
return nil, errors.Wrap(err, "could not create httpx client") return nil, errors.Wrap(err, "could not create httpx client")
} }
shouldFollowGlobalProbeBulkSize := bulkSize == GlobalProbeBulkSize
// Probe the non-standard URLs and store them in cache // Probe the non-standard URLs and store them in cache
swg, err := syncutil.New(syncutil.WithSize(GlobalProbeBulkSize)) swg, err := syncutil.New(syncutil.WithSize(bulkSize))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "could not create adaptive group") return nil, errors.Wrap(err, "could not create adaptive group")
} }
@ -49,7 +56,7 @@ func (r *Runner) initializeTemplatesHTTPInput() (*hybrid.HybridMap, error) {
return true return true
} }
if swg.Size != GlobalProbeBulkSize { if shouldFollowGlobalProbeBulkSize && swg.Size != GlobalProbeBulkSize {
swg.Resize(GlobalProbeBulkSize) swg.Resize(GlobalProbeBulkSize)
} }

View File

@ -116,6 +116,7 @@ type Concurrency struct {
HeadlessTemplateConcurrency int // number of templates to run concurrently for headless templates (per host in host-spray mode) HeadlessTemplateConcurrency int // number of templates to run concurrently for headless templates (per host in host-spray mode)
JavascriptTemplateConcurrency int // number of templates to run concurrently for javascript templates (per host in host-spray mode) JavascriptTemplateConcurrency int // number of templates to run concurrently for javascript templates (per host in host-spray mode)
TemplatePayloadConcurrency int // max concurrent payloads to run for a template (a good default is 25) TemplatePayloadConcurrency int // max concurrent payloads to run for a template (a good default is 25)
ProbeConcurrency int // max concurrent http probes to run (a good default is 50)
} }
// WithConcurrency sets concurrency options // WithConcurrency sets concurrency options
@ -152,6 +153,11 @@ func WithConcurrency(opts Concurrency) NucleiSDKOptions {
} else { } else {
e.opts.PayloadConcurrency = opts.TemplatePayloadConcurrency e.opts.PayloadConcurrency = opts.TemplatePayloadConcurrency
} }
if opts.ProbeConcurrency <= 0 {
return errors.New("probe concurrency must be at least 1")
} else {
e.opts.ProbeConcurrency = opts.ProbeConcurrency
}
return nil return nil
} }
} }

View File

@ -385,6 +385,8 @@ type Options struct {
SkipFormatValidation bool SkipFormatValidation bool
// PayloadConcurrency is the number of concurrent payloads to run per template // PayloadConcurrency is the number of concurrent payloads to run per template
PayloadConcurrency int PayloadConcurrency int
// ProbeConcurrency is the number of concurrent http probes to run with httpx
ProbeConcurrency int
// Dast only runs DAST templates // Dast only runs DAST templates
DAST bool DAST bool
} }