Repository navigation
scripts: report a missing script program before scanning - #965
Merged
bee-san merged 1 commit intoNov 4, 2026
Merged
Conversation
Scripts are run through `sh -c`, so when the program a `call_format`
starts with is missing, the only feedback is whatever the shell prints
once the scan has already finished:
Open 127.0.0.1:18080
[~] Starting Script(s)
[!] Error No such file or directory (os error 2)
which neither names the program nor arrives before a long scan has been
wasted.
Check the first word of every selected script format against PATH while
the scripts are initialised, and fail there with the program named. Name
resolution follows what the shell would do: PATH entries in order, plus
PATHEXT on Windows.
Formats that do not start with a bare program name are left alone, since
their first word is not something PATH can answer for:
- `FOO=bar cmd ...` (leading assignment)
- `/opt/custom/nmap ...` (explicit path)
- `{{script}} ...` (placeholder filled in at run time)
With nmap absent, on the same scan:
before: scans, then "[!] Error No such file or directory (os error 2)"
after: "[!] Initiating scripts failed!
The script `default` runs `nmap`, which is not installed or
not in PATH. Install it, or skip scripts with `--scripts none`."
With nmap present the scan and the script phase run as before.
Implemented with std/target-specific helpers rather than a new
dependency: `which` pulls in a newer windows-sys and rewrites ~110 lines
of Cargo.lock for a 15-line check.
Refs bee-san#691
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



What this fixes
Scripts are executed through
sh -c, so when the program acall_formatstarts with is missing, theonly feedback comes after the scan has already run:
That neither names the program nor arrives before a long scan has been wasted. From the issue:
Fixes #691, following the approach you suggested in the issue.
The change
init_scriptsnow checks the first word of every selected script format againstPATHand failsthere with the program named. Resolution follows what the shell would do:
PATHentries in order,plus
PATHEXTon Windows for bare names.Formats whose first word is not a bare program name are skipped, because
PATHcannot answer forthem:
FOO=bar cmd ...— leading assignment/opt/custom/nmap ...— explicit path{{script}} ...— placeholder filled in at run timeVerification
nmap absent from
PATH, scan against a listening port:Before the change, the same command scanned first and then reported
[!] Error No such file or directory (os error 2).nmap present — scan and script phase unchanged:
--scripts nonestill runs with no check at all.Three unit tests cover the accept, reject and skip paths.
cargo test scripts: 10 passed, 0 failed.Why not
whichYou mentioned
harryfei/which-rs, and I tried it first. Bothwhich7 and 8 dragwindows-sysfrom 0.60.2 to 0.61.2, which rewrites about 110 lines of
Cargo.lock— a lot of churn in adependency-sensitive repo for what is a
split_paths+is_filecheck. The implementation here isabout 15 lines with no new dependency, and
Cargo.lockis untouched. Happy to switch towhichifyou would rather keep the resolution logic in a crate.