Add live scan progress and graceful Ctrl-C handling
This commit is contained in:
+8
-3
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user