129 Commits

Author SHA1 Message Date
Dwi Siswanto bbc010b637 fix(js): probe SMBv1 support after SMB2 negotiation (#7430)
`ConnectSMBInfoMode` only tried SMBv1 when SMB2/3
negotiation failed so dual-stack servers could
report `SupportV1` as false even when SMBv1 was
enabled.

Run a same-target SMBv1 probe after successful
SMB2/3 negotiation and merge the support flag into
the returned log w/o changing the negotiated
SMB2/3 version.

Fixes #4832

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-05-30 09:16:06 +02:00
Mzack9999 fa73d2e13e fix(js): abandon runtimes that outlive interrupt grace period (#7378)
Prevent pooled and non-pooled goja runtimes from
being reused or cleaned up when the `RunProgram`
goroutine fails to exit after context cancellation
and `Interrupt()`. In that state, the goroutine
may still be mutating runtime state, so touching
the runtime/returning it to the pool can cause
fatal concurrent map access panics.

Add an explicit `errRuntimeTerminationTimeout`
path that abandons the runtime, keeps the related
concurrency slot reserved, and releases that slot
only from a reaper after the orphaned goroutine
exits. Preserve `errors.Is` compatibility with the
original context cancellation cause.

Keep normal cleanup behavior unchanged, including
callback panic cleanup, and add regression tests
for stuck-interrupt handling that verify runtime
abandonment and delayed slot release.

Fixes #7376

* fix race condition

* fixing review comments

* fix(js): defer runtime cleanup

When a runtime is abandoned, we must not touch the
goja runtime after `RunProgram` has exceeded the
interrupt grace period. At the same time, cleanup
still needs to run on every normal exit before
returning the runtime to the pool, including setup
callback panics.

Signed-off-by: Dwi Siswanto <git@dw1.io>

---------

Signed-off-by: Dwi Siswanto <git@dw1.io>
Co-authored-by: Dwi Siswanto <git@dw1.io>
2026-05-23 08:35:25 +07:00
Doğan Can Bakır 1ec64a3f95 chore(deps): bump pdsec modules; switch to projectdiscovery/govaluate and aurora v4
Bumps clistats, fastdialer, retryablehttp-go, dsl, networkpolicy,
ratelimit, sarif, utils, wappalyzergo, cdncheck. dsl v0.8.18 moves to
the projectdiscovery/govaluate fork, and utils v0.11.0 pulls aurora v4,
so the corresponding imports and type references are migrated.

Refs #7380.
2026-05-18 17:14:29 +03:00
Mzack9999 5675f513ea use local samba endpoint 2026-05-14 18:42:48 +02:00
Dwi Siswanto 65d08b33ef feat(js): add wmi, tsch, scmr, and dcom helper modules
Add shared auth, options, result, redaction, and
adapter support for GoExec-backed JavaScript
helpers, including:

* `nuclei/wmi`
* `nuclei/tsch`
* `nuclei/scmr`
* `nuclei/dcom`

through generated bindings, and register them with
the JS compiler.

Also make JS generators to skip internal helper
packages and test files.

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-05-11 03:57:50 +07:00
Mzack9999 54f002db4a Merge pull request #7356 from projectdiscovery/feat-impacket
Adding impacket integration
2026-05-06 17:57:02 +05:30
Doğan Can Bakır 7926e22174 fix lint 2026-05-06 12:34:01 +03:00
Mikhail Epifanov ad74c601c4 fix(js): interrupt goja runtime on context cancel (#7343)
* Interrupt goja runtime on context cancel

* undo import formats

* do both actions in same go-routine to prevent any possible race condition

* Convert the watchdog, into a simpeler construction which still guarantees the same promises

* move the recover to the go routine, and return named return since we now can use the channel

* remove unnecessary tests

* add extra safety in case process refuses to get interrupted

* remove unnecessary ExecFuncWithTwoReturns

* remove named return values
2026-04-16 15:17:55 +07:00
Dwi Siswanto 6f2ade6a9b fix(js): respect allow-local-file-access in require (#7332)
* fix(js): respect `allow-local-file-access` in `require`

The goja `require() `function used the default
host filesystem loader which let JavaScript
templates import any local files even when
`allow-local-file-access` was disabled.

Pooled runtimes kept `require()` state around so
a module loaded during a privileged execution
could remain cached for a later restricted one.

Rebuild the require registry per execution after
setting the execution context, and route file-
backed module loads to preserve native modules
while enforcing the same sandbox rules (as
`nuclei/fs`).

Signed-off-by: Dwi Siswanto <git@dw1.io>

* fix: cross-platform sandbox path checks

Replace lexical prefix checks in the template file
sandbox with a shared path containment helper that
canonicalizes both paths before comparing them to
prevent false rejections when the configured
templates directory and the resolved file path
differ only due to symlink expansion on macOS or
path normalization on Windows.

Apply the helper in `protocolstate.NormalizePath()`
and `Options.GetValidAbsPath()` so JS `require()`-
based module loads and helper file resolution use
the same rules.

Signed-off-by: Dwi Siswanto <git@dw1.io>

---------

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-04-10 08:06:39 +07:00
Mzack9999 3537030e1f fix(js): watchdog + propagates context to all JS library network calls (#7299)
* fix(js): prevent pool slot starvation under load

Zombie goroutines from timed-out JS executions held pool slots
indefinitely: Add() blocked with context.Background(), and defer Done()
only ran when the goroutine eventually completed. Under load, both
pools (80 pooled + 20 non-pooled slots) filled with zombies, silently
dropping all subsequent matches.

Three changes fix slot lifecycle management:

1. Propagate the 20s deadline context into ExecuteProgram (compiler.go)
   so both execution paths can respect the deadline.

2. Replace Add() with AddWithContext(ctx) in both pool.go and
   non-pool.go so goroutines waiting for a slot fail fast when the
   deadline expires instead of blocking indefinitely.

3. Add a watchdog goroutine that releases the slot when the deadline
   expires, even if the zombie is still running. An atomic.Bool
   ensures exactly one Done() call between the watchdog and the
   normal defer path.

* adding context

* refactor(js): derived the ctx to remaining tractable deadline leaks (#7302)

* refactor(js): use `context.Background` as default instead

Signed-off-by: Dwi Siswanto <git@dw1.io>

* refactor(js): derived the ctx to remaining tractable deadline leaks

Signed-off-by: Dwi Siswanto <git@dw1.io>

* test(js): add `NucleiJS.Context` tests

Signed-off-by: Dwi Siswanto <git@dw1.io>

* fix(cmd): context param exclusion in memoization hash

The memoization template condition for excluding
context parameters from hash keys was incorrect.
The memoize package represents context.Context
types as "&{context Context}" (AST string
representation), not "context.Context".

Signed-off-by: Dwi Siswanto <git@dw1.io>

* chore(js): memogen'ed

Signed-off-by: Dwi Siswanto <git@dw1.io>

---------

Signed-off-by: Dwi Siswanto <git@dw1.io>

* fix(js): hangs in checkRDPEncryption

by bounding socket I/O

Add `setConnDeadlineFromContext` helper to set
deadlines on conns derived from context timeouts.
Move conn cleanup out of loop-scoped defers to
make sure immediate cleanup per probe attempt.

Signed-off-by: Dwi Siswanto <git@dw1.io>

---------

Signed-off-by: Dwi Siswanto <git@dw1.io>
Co-authored-by: Niek den Breeje <AuditeMarlow@users.noreply.github.com>
Co-authored-by: Dwi Siswanto <25837540+dwisiswant0@users.noreply.github.com>
Co-authored-by: Dwi Siswanto <git@dw1.io>
2026-04-01 14:53:13 +07:00
Mikel Olasagasti Uranga 6eda56f389 Remove executable bit (#7282) 2026-03-22 01:55:54 +07:00
Mzack9999 032fc8d9b2 Merge pull request #7215 from sandiyochristan/fix/use-crypto-rand-in-js-globals
fix: use crypto/rand instead of math/rand in JS global functions
2026-03-17 22:29:21 +01:00
Mzack9999 2dad77adaf fix lint 2026-03-16 16:27:00 +01:00
sandiyochristan 44ef9ce34f fix: use crypto/rand instead of math/rand in JS global functions
Replace insecure math/rand PRNG with crypto/rand in Rand() and
RandInt() JavaScript helper functions. math/rand is predictable
and unsuitable when these functions are used for generating
security-sensitive values like tokens or nonces in templates.
2026-03-15 02:18:42 +05:30
Dwi Siswanto c27c47420f chore: golangci-lint run --fix ./...
Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-02-26 22:03:14 +07:00
Doğan Can Bakır 9142eae3a7 Revert "fix(lint): use fmt.Fprintf instead of WriteString(fmt.Sprintf(...))"
This reverts commit 0b9665df49.
2026-02-26 14:45:25 +03:00
Doğan Can Bakır ef650defb6 Revert "fix(lint): use fmt.Fprintf for remaining WriteString(fmt.Sprintf(...)) calls"
This reverts commit 10421e9d00.
2026-02-26 14:45:25 +03:00
Doğan Can Bakır 10421e9d00 fix(lint): use fmt.Fprintf for remaining WriteString(fmt.Sprintf(...)) calls 2026-02-25 15:34:45 +03:00
Doğan Can Bakır 0b9665df49 fix(lint): use fmt.Fprintf instead of WriteString(fmt.Sprintf(...)) 2026-02-25 15:10:01 +03:00
Mzack9999 dbeebdaa1d adding telnet login + crypto (#6419)
* adding telnet login + crypto

* smbauth lib porting + ntlm parsing over telnet

* gen lib

* adding telnet test

* adding breakout after max iterations

* fix(utils): broken pkt creation & impl `Create{LN,NT}Response`

Signed-off-by: Dwi Siswanto <git@dw1.io>

* chore(utils): satisfy lints

Signed-off-by: Dwi Siswanto <git@dw1.io>

---------

Signed-off-by: Dwi Siswanto <git@dw1.io>
Co-authored-by: Dwi Siswanto <git@dw1.io>
2026-01-02 06:28:46 +07:00
Mzack9999 891dffb4a1 feat(js): adds RSYNC module (#6410)
* adding min auth support

* adding unauth list modules + auth list files in module

* example

* adding rsync test

* bump go.mod

---------

Co-authored-by: Dwi Siswanto <git@dw1.io>
2026-01-01 02:02:48 +07:00
Dwi Siswanto 49309b4ac8 chore(js): no staticcheck lint
Signed-off-by: Dwi Siswanto <git@dw1.io>
2025-12-26 06:06:47 +07:00
Dwi Siswanto 22469bdc2f chore(js): update memoized functions
Signed-off-by: Dwi Siswanto <git@dw1.io>
2025-12-26 01:08:06 +07:00
Dwi Siswanto 0eb87c2621 fix(js): mysql panic due to missing executionId in ctx
The `connectWithDSN` func used `db.Exec()` which
implicitly uses `context.Background()`[1]. This
caused the registered "nucleitcp" dialer
callback to receive a ctx missing the
`executionId`, leading to a panic during type
assertion.

Refactor `connectWithDSN` to accept `executionId`
explicitly and use it to create a `context` for
`db.PingContext()` (yeah, instead of `db.Exec()`).
And, add a defensive check in the dialer callback
to handle nil values gracefully.

Fixes #6733 regression introduced in #6296.

[1]: "Exec uses `context.Background` internally" -
     https://pkg.go.dev/database/sql#DB.Exec.

Signed-off-by: Dwi Siswanto <git@dw1.io>
2025-12-25 17:16:49 +07:00
Mzack9999 5d79201299 fix(js): incorrect postgres exec call signature (#6731)
Make sure postgres Exec/ExecContext are invoked with the correct
argument order, preventing context from being passed as the query.

* fixing pg syntax

* adding test
2025-12-24 03:20:50 +07:00
copilot-swe-agent[bot] 3d60c9fdbe Fix all documentation errors
Co-authored-by: AaryanBansal-dev <192687837+AaryanBansal-dev@users.noreply.github.com>
2025-12-07 05:51:53 +00:00
Didier Durand 9eede47dbd Update pkg/js/CONTRIBUTE.md
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
2025-12-05 07:32:39 +01:00
Didier Durand 3447f09c9f [Doc] Fixing typos in various files 2025-12-05 07:17:14 +01:00
Didier Durand 9ec2e995d0 docs: fixing typos in multiple files (#6653)
* [Doc] Fixing typos in multiple files

* [Doc] Fixing js.go based in review suggestion
2025-12-05 12:29:19 +07:00
Mzack9999 5b5d87f62a Merge pull request #6508 from chovanecadam/ssh-keyboard-interactive
SSH keyboard-interactive
2025-11-02 16:05:51 +04:00
Dwi Siswanto 7fc4752a95 chore(js): migrate github.com/go-pg/pg => github.com/go-pg/pg/v10
Signed-off-by: Dwi Siswanto <git@dw1.io>
2025-11-02 01:12:11 +07:00
Dwi Siswanto 248bac75a0 feat(js): enhance SSH keyboard interactive auth
by:
* implement regex-based prompt matching for
  password variants.
* add support for filling username prompts in
  keyboard interactive challenges.
* improve debug logging with structured output.

this addresses issues with servers using
non-standard prompt formats and provides better
visibility into auth failures.

Signed-off-by: Dwi Siswanto <git@dw1.io>
2025-11-02 00:38:37 +07:00
Adam Chovanec 6794b9cba0 fix: add logging 2025-11-02 00:38:37 +07:00
Adam Chovanec 8136d4f368 fix: provide answer only when asked for 2025-11-02 00:38:36 +07:00
Adam Chovanec 1a8124679e feat: best-effort keyboard-interactive support for SSH 2025-11-02 00:38:35 +07:00
Patrick Stoeckle bfef42f9e3 chore(typos): fix typos 2025-10-10 17:32:54 +02:00
Mzack9999 cb2d93174a fixing logic 2025-09-25 22:46:40 +02:00
Mzack9999 61bd0828dc Merge branch 'dev' into RDP-Enc-func 2025-09-25 22:07:17 +02:00
Mzack9999 521a21c06a Merge branch 'dev' into feat-4842-vnc 2025-09-12 11:51:17 +02:00
Mzack9999 c863143771 lint 2025-09-12 10:35:09 +02:00
Mzack9999 5c8da8d88b code from https://github.com/projectdiscovery/nuclei/pull/6427 2025-09-12 10:29:42 +02:00
cui d76187f99a Refactor to use reflect.TypeFor (#6428) 2025-08-27 22:31:04 +05:30
Mzack9999 e83382d4e4 lint 2025-08-25 15:33:21 +02:00
Mzack9999 b61321cd19 Merge branch 'dev' into feat-4842-vnc 2025-08-25 15:22:14 +02:00
Mzack9999 f20f95f67e integration test 2025-08-25 15:13:23 +02:00
Tarun Koyalwar 19247ae74b Path-Based Fuzzing SQL fix (#6400)
* setup claude

* migrate to using errkit

* fix unused imports + lint errors

* update settings.json

* fix url encoding issue

* fix lint error

* fix the path fuzzing component

* fix lint error
2025-08-25 13:36:58 +05:30
Mzack9999 6b358b39a3 lint 2025-08-21 23:38:58 +02:00
Mzack9999 b41f4d97d6 gen go+js 2025-08-21 22:04:55 +02:00
Mzack9999 5c15c77777 adding vnc auth 2025-08-21 22:02:47 +02:00
Sandeep Singh b4644af80a Lint + test fixes after utils dep update (#6393)
* fix: remove undefined errorutil.ShowStackTrace

* feat: add make lint support and integrate with test

* refactor: migrate errorutil to errkit across codebase

- Replace deprecated errorutil with modern errkit
- Convert error declarations from var to func for better compatibility
- Fix all SA1019 deprecation warnings
- Maintain error chain support and stack traces

* fix: improve DNS test reliability using Google DNS

- Configure test to use Google DNS (8.8.8.8) for stability
- Fix nil pointer issue in DNS client initialization
- Keep production defaults unchanged

* fixing logic

* removing unwanted branches in makefile

---------

Co-authored-by: Mzack9999 <mzack9999@protonmail.com>
2025-08-20 05:28:23 +05:30