nuclei icon indicating copy to clipboard operation
nuclei copied to clipboard

[BUG] panic: runtime error: invalid memory address or nil pointer dereference Dialer has been closed

Open Autumn-27 opened this issue 4 months ago • 1 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues.

Current Behavior

templates := []string{"*"}
	maxTokens := 100
	duration := 1 * time.Second
	timeout := 60 * time.Minute
	var concurrency nuclei.Concurrency
	concurrency.HostConcurrency = 20
	concurrency.TemplateConcurrency = 20
	concurrency.HeadlessHostConcurrency = 10
	concurrency.HeadlessTemplateConcurrency = 10
	concurrency.JavascriptTemplateConcurrency = 100
	concurrency.TemplatePayloadConcurrency = 20
	concurrency.ProbeConcurrency = 10
	ctx, cancel := context.WithTimeout(context.Background(), timeout)
	defer cancel() 
	options = append(options, nuclei.WithGlobalRateLimitCtx(ctx, maxTokens, duration))

	options = append(options, nuclei.WithConcurrency(concurrency))

	options = append(options, nuclei.WithTemplatesOrWorkflows(nuclei.TemplateSources{Templates: templates}))

	options = append(options, nuclei.WithTemplateFilters(tmplateFilters))

	callBackFunc := func(event *output.ResultEvent) {
	}

	config.DefaultConfig.DisableUpdateCheck()
	config.DefaultConfig.TemplatesDirectory = filepath.Join(global.PocDir)

	ne, err := nuclei.NewNucleiEngineCtx(ctx, options...)
	if err != nil {
		return nil, nil
	}
	ne.LoadTargets([]string{target}, false)
	err = ne.ExecuteWithCallback(callBackFunc)
	if err != nil {
		return nil, nil
	}
	defer ne.Close()
	return nil, nil

When I run the SDK, it executes one target at a time. Since the program calls this multiple times, I encounter an error: panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x0 pc=0x15debfd]

goroutine 43874 [running]: github.com/projectdiscovery/fastdialer/fastdialer.(*Dialer).GetDialedIP(0x0, {0xc0427772c8, 0xd}) go/pkg/mod/github.com/projectdiscovery/[email protected]/fastdialer/dialer.go:307 +0x3d Has the Dialer been closed?

Expected Behavior

~

Steps To Reproduce

~

Relevant log output

panic: runtime error: invalid memory address or nil pointer dereference [signal 0xc0000005 code=0x0 addr=0x0 pc=0x178d1e1]

goroutine 50326 [running]: github.com/projectdiscovery/fastdialer/fastdialer.(*Dialer).dial(0x0, {0x46b5e60?, 0xc0242ab0a0?}, 0xc023a2dd80) /go/pkg/mod/github.com/projectdiscovery/[email protected]/fastdialer/dialer_private.go:66 +0x61 github.com/projectdiscovery/fastdialer/fastdialer.(*Dialer).Dial(0x0, {0x46b5e60, 0xc0242ab0a0}, {0x39ebb39, 0x3}, {0xc02387e5b0, 0x10}) /go/pkg/mod/github.com/projectdiscovery/[email protected]/fastdialer/dialer.go:198 +0xb9 net/http.(*Transport).dial(0xffffffffffffffff?, {0x46b5e60?, 0xc0242ab0a0?}, {0x39ebb39?, 0xffffffffffffffff?}, {0xc02387e5b0?, 0xf47d22?}) C:/Program Files/Go/src/net/http/transport.go:1187 +0xd2 net/http.(*Transport).dialConn(0xc01356bb80, {0x46b5e60, 0xc0242ab0a0}, {{}, 0x0, {0xc0241dea80, 0x4}, {0xc02387e5b0, 0x10}, 0x0}) C:/Program Files/Go/src/net/http/transport.go:1648 +0x7e8 net/http.(*Transport).dialConnFor(0xc01356bb80, 0xc0092cd6b0) C:/Program Files/Go/src/net/http/transport.go:1485 +0xcd created by net/http.(*Transport).queueForDial in goroutine 50340 C:/Program Files/Go/src/net/http/transport.go:1449 +0x3c9

Environment

  • OS: windows
  • Nuclei: 3.3.5
  • Go: 1.22

Anything else?

No response

Autumn-27 avatar Oct 19 '24 16:10 Autumn-27