Add live scan progress and graceful Ctrl-C handling

This commit is contained in:
n0mad1k
2026-04-30 14:49:57 -04:00
parent feb34ada8b
commit 615937b20b
2 changed files with 89 additions and 61 deletions
+8 -3
View File
@@ -29,14 +29,19 @@ def masscan_sweep(cidrs: list[str], ports: list[int], rate: int, output_dir: Pat
f"--ports={port_str}",
"-iL", str(cidr_file),
"-oJ", str(out_file),
"--output-format", "json",
"--wait", "3",
]
try:
subprocess.run(cmd, capture_output=True, timeout=3600)
proc = subprocess.Popen(cmd, stderr=subprocess.DEVNULL)
proc.wait(timeout=3600)
except subprocess.TimeoutExpired:
pass
proc.kill()
proc.wait()
except KeyboardInterrupt:
proc.kill()
proc.wait()
raise
except FileNotFoundError:
raise RuntimeError("masscan not found — install it first")