Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] NIL pointer dereference in NucleiEngine when initialize WithProxy #5650

Closed
1 task done
tongchengbin opened this issue Sep 19, 2024 · 1 comment
Closed
1 task done
Assignees
Labels
duplicate This issue or pull request already exists Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Milestone

Comments

@tongchengbin
Copy link

tongchengbin commented Sep 19, 2024

### Is there an existing issue for this?

  • I have searched the existing issues.

Current Behavior

func ExampleNucleiEngine() {
	// create nuclei engine with options
	ne, err := nuclei.NewNucleiEngine(
		nuclei.WithTemplateFilters(nuclei.TemplateFilters{IDs: []string{"self-signed-ssl"}}), // only run self-signed-ssl template
		nuclei.WithProxy([]string{"socks5://127.0.0.1:9000"}, false),
	)
	if err != nil {
		panic(err)
	}
	// load targets and optionally probe non http/https targets
	ne.LoadTargets([]string{"scanme.sh"}, false)
	// when callback is nil it nuclei will print JSON output to stdout
	err = ne.ExecuteWithCallback(nil)
	if err != nil {
		panic(err)
	}
	defer ne.Close()

	// Output:
	// [self-signed-ssl] scanme.sh:443
}


Error
=== RUN   ExampleNucleiEngine
--- FAIL: ExampleNucleiEngine (0.00s)
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
	panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x1 addr=0x14 pc=0x19dec36]

goroutine 1 [running]:
testing.(*InternalExample).processRunResult(0xc001007bb0, {0x0, 0x0}, 0x206592e3348?, 0x0, {0x1f368c0, 0x3ffe7a0})
	D:/Program/go/src/testing/example.go:91 +0x645
testing.runExample.func2()
	D:/Program/go/src/testing/run_example.go:59 +0x116
panic({0x1f368c0?, 0x3ffe7a0?})
	D:/Program/go/src/runtime/panic.go:770 +0x132
github.com/projectdiscovery/utils/maps.(*SyncLockMap[...]).Get(0xc000dca030?, {0xc0009061a0?, 0x0?})
	C:/Users/tongc/go/pkg/mod/github.com/projectdiscovery/[email protected]/maps/synclock_map.go:71 +0x36
github.com/projectdiscovery/nuclei/v3/pkg/protocols/http/httpclientpool.wrappedGet(0xc000c00808, 0xc001006d38)
	D:/code/github.com/nuclei/pkg/protocols/http/httpclientpool/clientpool.go:179 +0x65
github.com/projectdiscovery/nuclei/v3/pkg/protocols/http/httpclientpool.Get(0xc000c00808?, 0x0?)
	D:/code/github.com/nuclei/pkg/protocols/http/httpclientpool/clientpool.go:171 +0x52
github.com/projectdiscovery/nuclei/v3/lib.(*NucleiEngine).init(0xc000df6708, {0x2a65a30, 0x417d380})
	D:/code/github.com/nuclei/lib/sdk_private.go:112 +0x105
github.com/projectdiscovery/nuclei/v3/lib.NewNucleiEngineCtx({0x2a65a30, 0x417d380}, {0xc000bbf960, 0x2, 0x10?})
	D:/code/github.com/nuclei/lib/sdk.go:285 +0x15a
github.com/projectdiscovery/nuclei/v3/lib.NewNucleiEngine(...)
	D:/code/github.com/nuclei/lib/sdk.go:293
github.com/projectdiscovery/nuclei/v3/lib_test.ExampleNucleiEngine()
	D:/code/github.com/nuclei/lib/example_test.go:17 +0x1b5
testing.runExample({{0x23ce559, 0x13}, 0x272f7d8, {0x2415fc1, 0x20}, 0x0})
	D:/Program/go/src/testing/run_example.go:63 +0x2de
testing.runExamples(0x2a7b200?, {0x403e300, 0x2, 0x0?})

	D:/Program/go/src/testing/example.go:40 +0x126
testing.(*M).Run(0xc000de2c80)
	D:/Program/go/src/testing/testing.go:2029 +0x75d
github.com/projectdiscovery/nuclei/v3/lib_test.TestMain(0xc000de2c80)
	D:/code/github.com/nuclei/lib/example_test.go:86 +0x55
main.main()
	_testmain.go:53 +0x195

Expected Behavior

no error

Steps To Reproduce

nuclei sdk example

Relevant log output

No response

Environment

- OS: windows
- Nuclei:  v3.3.2
- Go: 1.22.7

Anything else?

No response

@tongchengbin tongchengbin added the Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors. label Sep 19, 2024
@dogancanbakir dogancanbakir self-assigned this Sep 19, 2024
@dogancanbakir
Copy link
Member

dogancanbakir commented Sep 19, 2024

Probably same as #5182. Fixed in #5626. Could you retry with dev branch?

@ehsandeep ehsandeep added this to the nuclei v3.3.3 milestone Sep 19, 2024
@dwisiswant0 dwisiswant0 changed the title [BUG] ...sdk with proxy error [BUG] NIL pointer dereference in NucleiEngine when initialize WithProxy Sep 20, 2024
@dwisiswant0 dwisiswant0 added the duplicate This issue or pull request already exists label Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists Type: Bug Inconsistencies or issues which will cause an issue or problem for users or implementors.
Projects
None yet
Development

No branches or pull requests

4 participants