ZMap requires raw socket access, which typically needs root/sudo privileges:
sudo python your_script.pySimply omit the subnets parameter. Warning: Ensure you have proper authorization and bandwidth:
results = zmap.scan(target_port=80, bandwidth="10M")Use max_targets, max_runtime, or max_results:
results = zmap.scan(
target_port=443,
max_targets=1000, # Scan only 1000 hosts
max_runtime=60, # Run for max 60 seconds
)Use the streaming API to avoid memory issues:
for result in zmap.stream_results("large_scan.csv"):
process_result(result)ZMap not found
ZMapCommandError: zmap command failed with return code -1
Solution: Install ZMap or specify the path: ZMap(zmap_path="/usr/local/bin/zmap")
Rate limiting / bandwidth issues
# Reduce scan rate to avoid network issues
results = zmap.scan(target_port=80, bandwidth="1M") # 1 MbpsOutput file errors
- Ensure the output directory exists and is writable
- Check disk space for large scans