projectdiscovery / nuclei

Nuclei is a fast, customizable vulnerability scanner powered by the global security community and built on a simple YAML-based DSL, enabling collaboration to tackle trending vulnerabilities on the internet. It helps you find vulnerabilities in your applications, APIs, networks, DNS, and cloud configurations.
https://docs.projectdiscovery.io/tools/nuclei
MIT License
20.88k stars 2.52k forks source link

[BUG] ...Using the timeout parameter results in abnormal termination #5577

Open l1nk3rlin opened 3 months ago

l1nk3rlin commented 3 months ago

Is there an existing issue for this?

Current Behavior

"After configuring the timeout parameter, the PoC scan cannot proceed normally."

Expected Behavior

the PoC scan can proceed normally

Steps To Reproduce

code demo:

func HttpNucleiRun(target []string, nucleitemplates string, Severities string, rl int, templatethreads int, bulksize int) {
    ne, err := nuclei.NewNucleiEngineCtx(context.Background(),
        nuclei.WithTemplateFilters(nuclei.TemplateFilters{Severity: Severities, ProtocolTypes: "http", Authors: []string{"l1nk3r"}}),
        nuclei.WithTemplatesOrWorkflows(nuclei.TemplateSources{Templates: []string{nucleitemplates}}),
        nuclei.WithVerbosity(nuclei.VerbosityOptions{Debug: true}),
        nuclei.WithGlobalRateLimitCtx(context.Background(), rl, time.Second),
        nuclei.WithInteractshOptions(nuclei.InteractshOpts{CacheSize: 5000, NoInteractsh: true}),
        nuclei.WithNetworkConfig(nuclei.NetworkConfig{Timeout: 10, DisableMaxHostErr: true}),
        nuclei.WithConcurrency(nuclei.Concurrency{
            TemplateConcurrency:           templatethreads,
            HostConcurrency:               bulksize,
            HeadlessHostConcurrency:       300,
            HeadlessTemplateConcurrency:   300,
            JavascriptTemplateConcurrency: 300,
            TemplatePayloadConcurrency:    300,
            ProbeConcurrency:              300,
        }),
    )
    if err != nil {
        panic(err)
    }
    // load targets and optionally probe non http/https targets
    ne.LoadTargets(target, false)
    // Define callback function to handle the result
    callback := func(result *output.ResultEvent) {
        // Convert output.ResultEvent to ScanResult
        scanResult := ScanResult{
            Name:        result.Info.Name,
            Description: result.Info.Description,
            Severity:    result.Info.SeverityHolder.Severity.String(),
            Host:        result.Host,
            Request:     result.Request,
        }
        // Append scan results to the slice
        scanResults = append(scanResults, scanResult)
    }
    // 调用 ExecuteWithCallback 并传递自定义回调函数
    err = ne.ExecuteWithCallback(callback)
    if err != nil {
        panic(err)
    }
    defer ne.Close()
}

Relevant log output

[ruijie-eg-and-nbr-ddi-server-fileupload-fileupload] Could not execute request for http://39.99.184.53:32773/: [:RUNTIME] got err while executing http://39.99.184.53:32773/ddi/server/fileupload.php <- POST http://39.99.184.53:32773/ddi/server/fileupload.php giving up after 1 attempts: Post "http://39.
99.184.53:32773/ddi/server/fileupload.php": errKind=unknown-error [address=39.99.184.53:32773] context deadline exceeded
[WRN] [mobile-upload-uploadapk] Could not execute request for http://39.99.184.53:32773/: [:RUNTIME] got err while executing http://39.99.184.53:32773/maportal/appmanager/uploadApk.do?pk_obj <- POST http://39.99.184.53:32773/maportal/appmanager/uploadApk.do?pk_obj giving up after 1 attempts: Post "http://39
.99.184.53:32773/maportal/appmanager/uploadApk.do?pk_obj": errKind=unknown-error [address=39.99.184.53:32773] context deadline exceeded

Environment

- OS: windows 
- Nuclei: v3.3.0
- Go:

Anything else?

No response

zrquan commented 2 months ago

From what I can see in the logs, it looks like it's just a simple timeout issue. You could try increasing the timeout duration to see if that solves the problem.

l1nk3rlin commented 1 month ago

The PoC template returns a timeout when using the timeout parameter, but the target website does not time out and continues to function normally. The sample code has already set the timeout to 10 seconds.