Ultimate Masscan Cheat Sheet



Ultimate Masscan Cheat Sheet

The "Internet Scale" port scanner. Scans the entire web in under 6 minutes.

1. Scanning Targets

Masscan works similarly to Nmap but is purely command-line and asynchronous (SYN scan only).

Single IP

masscan 192.168.1.10 -p80

CIDR Range

Scan a subnet.

masscan 192.168.1.0/24 -p80

Multiple Ports

Scan ports 80 and 443.

masscan 10.0.0.0/8 -p80,443

Range of Ports

masscan 192.168.1.5 -p1-10000

2. Ports & Rates

The --rate flag is the most important setting in Masscan.

Scan Speed (Packets Per Second)

Default is 100 pps (very slow). Increase this for speed.

masscan 10.0.0.0/8 -p80 --rate 10000

(10,000 packets/sec = Fast. 100,000+ requires dedicated hardware).

Scan All Ports

Scan 0-65535.

masscan 192.168.1.10 -p0-65535 --rate 100000

UDP Scanning

Use U: prefix for UDP ports.

masscan 192.168.1.10 -pU:53,U:161,U:123
Warning: Setting the rate too high on a home connection will crash your router. Start with --rate 500.

3. Banner Grabbing

Masscan can grab banners (like Nmap version scan) to identify services.

Enable Banners

masscan 10.0.0.0/8 -p80 --banners

Custom Source Port

Some firewalls block scans unless they come from a specific port (like 53 or 80).

masscan 10.0.0.0/8 -p80 --source-port 53

Ping Scan (ICMP)

Masscan verifies if hosts are up using ICMP echo.

masscan 192.168.1.0/24 --ping

4. Output Formats

Masscan does not output to the terminal nicely like Nmap. You usually want to save to a file.

Binary Format (Recommended)

Fastest and smallest. Can be read by Masscan later.

masscan 10.0.0.0/8 -p80 -oB scan.bin

Read Binary File

Convert the binary scan to text.

masscan --readscan scan.bin

XML / JSON / List

masscan 10.0.0.0/8 -p80 -oX scan.xml
masscan 10.0.0.0/8 -p80 -oJ scan.json
masscan 10.0.0.0/8 -p80 -oL scan.txt

5. Configuration File

Instead of typing long commands, save your settings in a masscan.conf file.

Generate Config

Output current settings to a file.

masscan -p80,443 --rate 1000 --echo > masscan.conf

Run with Config

masscan -c masscan.conf

Example Config Content

rate = 1000.00
ports = 80,443,U:53
output-format = json
output-filename = results.json
excludefile = exclude.txt

6. Exclusions & Safety

Crucial: Never scan networks you don't own or have permission to scan. Exclude sensitive IPs.

Exclude File

Create a file exclude.txt with IPs/Ranges to skip.

masscan 0.0.0.0/0 -p80 --excludefile exclude.txt

Exclude Command Line

masscan 10.0.0.0/8 -p80 --exclude 10.0.0.1