Skip to content

Masscan

Masscan

Bases: Scanner

arun(timeout=None, **kwargs) async

Run masscan command asynchronously.

Parameters:

Name Type Description Default
timeout Optional[float]

Timeout for masscan process, defaults to None

None

Returns:

Type Description
Optional[NmapRun]

NmapRun object or None

echo_config()

Echo the current configuration to a file (--echo).

run(timeout=None, **kwargs)

Run masscan command.

Parameters:

Name Type Description Default
timeout Optional[float]

Timeout for masscan process, defaults to None

None

Returns:

Type Description
Optional[NmapRun]

NmapRun object or None

with_adapter(interface)

Specify the network adapter to use (-e, --adapter).

Parameters:

Name Type Description Default
interface str

Network interface to use, e.g., "eth0"

required

with_adapter_ip(ip)

Specify the IP address of the network adapter (--adapter-ip).

Parameters:

Name Type Description Default
ip str

IP address of the adapter

required

with_adapter_mac(address)

Specify the MAC address of the network adapter (--adapter-mac).

Parameters:

Name Type Description Default
address str

MAC address of the adapter

required

with_adapter_port(port)

Specify the source port number of the network adapter (--adapter-port).

Parameters:

Name Type Description Default
port int

Source port number of the adapter

required

with_append_output()

Append output to file instead of overwriting (--append-output).

with_banners()

Retrieve the banner information from scanned services (--banners).

with_config(filename)

Specify a configuration file (-c, --conf).

Parameters:

Name Type Description Default
filename str

Path to the configuration file

required

with_http_user_agent(user_agent)

Specify a custom HTTP User-Agent string (--http-user-agent).

Parameters:

Name Type Description Default
user_agent str

HTTP User-Agent string

required

with_nmap_payloads(filename)

Read custom packet payloads from a nmap payloads file (--nmap-payloads).

Parameters:

Name Type Description Default
filename str

Path to the nmap payloads file

required

with_offline()

Do not actually transmit packets, useful for benchmarking (--offline).

with_packet_trace()

Print a summary of packets sent and received (--packet-trace).

with_pcap(filename)

Save received packets to a pcap file (--pcap).

Parameters:

Name Type Description Default
filename str

Path to the pcap file

required

with_pcap_payloads(filename)

Read custom packet payloads from a pcap file (--pcap-payloads).

Parameters:

Name Type Description Default
filename str

Path to the pcap payloads file

required

with_pfring()

Force the use of the PF_RING driver (--pfring).

with_ping()

Include ICMP echo requests in the scan (--ping).

with_rate(rate)

Set the packet transmission rate (--rate).

Parameters:

Name Type Description Default
rate int

Number of packets per second to send

required

with_regress()

Run a regression test and return '0' on success, '1' on failure (--regress).

with_resume(filename)

Resume scanning from a previous configuration file (--resume).

Parameters:

Name Type Description Default
filename str

Path to the resume configuration file

required

with_resume_count(count)

Set the maximum number of probes to send before exiting (--resume-count).

Parameters:

Name Type Description Default
count int

Maximum number of probes

required

with_resume_index(index)

Set the point in the scan to resume from (--resume-index).

Parameters:

Name Type Description Default
index int

Resume index

required

with_retries(retries)

Set the number of retries for packet sending (--retries).

Parameters:

Name Type Description Default
retries int

Number of retries

required

with_rotate(time)

Rotate the output file at specified intervals (--rotate).

Parameters:

Name Type Description Default
time str

Time interval for rotation, e.g., "hourly", "10min"

required

with_rotate_dir(directory)

Specify the directory to move rotated files to (--rotate-dir).

Parameters:

Name Type Description Default
directory str

Directory to move rotated files to

required

with_rotate_offset(offset)

Set an offset for the rotation interval (--rotate-offset).

Parameters:

Name Type Description Default
offset str

Offset for rotation interval

required

with_router_mac(address)

Specify the MAC address of the router (--router-mac).

Parameters:

Name Type Description Default
address str

MAC address of the router

required

with_sL()

Create a list of random addresses without scanning (-sL).

with_seed(seed)

Set the seed for the random number generator (--seed).

Parameters:

Name Type Description Default
seed str

Seed value, or "time" for local timestamp

required

with_shards(shard_id, total_shards)

Split the scan among multiple instances (--shards).

Parameters:

Name Type Description Default
shard_id int

ID of this shard

required
total_shards int

Total number of shards

required

with_targets(*targets)

Specify the targets to be scanned.

Parameters:

Name Type Description Default
targets str

There are three valid formats. The first is a single IPv4 address like "192.168.0.1". The second is a range like "10.0.0.1-10.0.0.100". The third is a CIDR address, like "0.0.0.0/0".

()

with_ttl(ttl)

Set the TTL (Time-To-Live) of outgoing packets (--ttl).

Parameters:

Name Type Description Default
ttl int

TTL value

required

with_wait(seconds)

Set the number of seconds to wait after transmission is done (--wait).

Parameters:

Name Type Description Default
seconds int

Number of seconds to wait, or "forever"

required

without_closed_ports()

Report only open ports, not closed ports (--open-only).