Skip to content

Commit de38e9e

Browse files
committed
Keep nuclei findings on a timeout, and let it cover more in the time
nuclei has no run time limit of its own, so the scan's timeout kills it mid run. It was writing its findings with the export flag, which only writes the whole set when nuclei finishes, so a timeout threw away every finding it had already made. It now writes each finding to the file the moment it is found, and the scan reads that file whether nuclei finished or was stopped, so nothing found is lost. It also ran narrow: twenty five templates at once, fifty requests a second, which spent the hour long before the template set was through. The engines go through the local proxy, which pools the connections to the site, and the site's own rate limiting is off for the scanner, so it now runs fifty at once at a hundred and fifty a second and covers far more of the set in the same window.
1 parent 17178b9 commit de38e9e

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎app/core/dast_engines.py‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,22 @@ def command(tool: str, url: str, host: str, profile: str, workdir: Path,
200200
report = workdir / "nuclei.jsonl"
201201
targets = workdir / "nuclei-targets.txt"
202202
targets.write_text("\n".join([url] + _same_site(url, paths)[:50]) + "\n")
203-
argv = [exe, "-list", str(targets), "-jsonl-export", str(report),
203+
# -o with -jsonl writes each finding to the file the moment it is found,
204+
# not -jsonl-export, which only writes the whole set when nuclei finishes.
205+
# nuclei has no run-time limit of its own, so our timeout kills it mid
206+
# run; with the export flag every finding it had found was lost, with -o
207+
# the file already holds them and the parser reads the partial file.
208+
# Concurrency and rate: nuclei runs -c templates at once, capped at -rl
209+
# requests a second. The old 25/50 left the 60 minute budget spent long
210+
# before the template set was through. The engines go through the local
211+
# proxy, which pools the upstream connections, so a higher rate does not
212+
# hit the target with the raw handshake burst a direct tool would; with
213+
# the site's own rate limiting off and the scanner allow listed, 50/150
214+
# covers far more of the set in the same window.
215+
argv = [exe, "-list", str(targets), "-o", str(report), "-jsonl",
204216
"-disable-update-check", "-no-color", "-silent",
205217
"-severity", "info,low,medium,high,critical", "-tags", tags,
206-
"-rl", "50", "-c", "25", "-timeout", "10", "-retries", "1",
218+
"-rl", "150", "-c", "50", "-timeout", "10", "-retries", "1",
207219
"-H", f"User-Agent: {_ua()}"]
208220
templates = _nuclei_templates(workdir, -1)
209221
if templates:

0 commit comments

Comments
 (0)