The main interface for PyZmap operations.
-
scan(target_port, subnets, output_file, **kwargs)- Perform a network scan and return the results
- Returns: List of IP addresses that responded
-
run(**kwargs)- Run ZMap with specified parameters
- Returns: Tuple of (return code, stdout, stderr)
get_probe_modules()- Get list of available probe modulesget_output_modules()- Get list of available output modulesget_output_fields(probe_module)- Get list of available output fieldsget_interfaces()- Get list of available network interfacesget_version()- Get ZMap version string
blocklist_from_file(blocklist_file)- Validate and use a blocklist fileallowlist_from_file(allowlist_file)- Validate and use an allowlist filecreate_blocklist_file(subnets, output_file)- Create a blocklist file from subnetscreate_allowlist_file(subnets, output_file)- Create an allowlist file from subnetscreate_target_file(targets, output_file)- Create a file with target IPsgenerate_standard_blocklist(output_file)- Generate standard RFC1918 blocklist
parse_results(file_path, fields)- Parse scan results into structured dataparse_metadata(file_path)- Parse scan metadata from JSON fileextract_ips(results, ip_field)- Extract IP addresses from parsed resultsstream_results(file_path, fields)- Stream results without loading all into memorycount_results(file_path)- Count results in a file efficiently
Handles configuration for ZMap scans.
-
Core Options:
target_port: Port number to scanbandwidth: Send rate in bits/second (supports G, M, K suffixes)rate: Send rate in packets/seccooldown_time: How long to continue receiving after sending last probeinterface: Network interface to usesource_ip: Source address for scan packetssource_port: Source port(s) for scan packetsgateway_mac: Gateway MAC addresssource_mac: Source MAC addresstarget_mac: Target MAC addressvpn: Send IP packets instead of Ethernet (for VPNs)
-
Scan Control Options:
max_targets: Cap number of targets to probemax_runtime: Cap length of time for sending packetsmax_results: Cap number of results to returnprobes: Number of probes to send to each IPretries: Max number of times to try to send packet if send failsdryrun: Don't actually send packetsseed: Seed used to select address permutationshards: Total number of shardsshard: Which shard this scan is (0 indexed)
-
Advanced Options:
sender_threads: Threads used to send packetscores: Comma-separated list of cores to pin toignore_invalid_hosts: Ignore invalid hosts in allowlist/blocklist filemax_sendto_failures: Maximum NIC sendto failures before scan is abortedmin_hitrate: Minimum hitrate that scan can hit before scan is aborted
-
Metadata Options:
notes: User-specified notes for scan metadatauser_metadata: User-specified JSON metadata