| Field | Detail |
|---|---|
| Summary | Asynchronous internet-scale port sweeps, then hand hits to Nmap |
| Category | Mass-scale port scanning |
| Phase | recon, scanning |
| Interface | CLI |
| Platform | Linux, Windows, macOS |
| Licence | Open source (AGPL) |
| Docs | https://github.com/robertdavidgraham/masscan |
| Related | Nmap, OSINT and recon, Nuclei |
Asynchronous TCP port scanner built for scale and speed — it can sweep huge address ranges (even the whole IPv4 internet, in principle) far faster than Nmap by sending packets with its own stateless TCP stack. Use it to find live ports across big scopes quickly, then hand the hits to Nmap for accurate service/version detail.
⛔ Danger — Speed is dangerous — rate-limit deliberately Default/high rates can saturate links and knock over fragile hosts, and look exactly like a flood/DoS to defenders. Always set
--rateconservatively, especially near OT/fragile kit (see OT-ICS testing methodology and safety). In-scope targets only; a fast mass-scan across the wrong range is a great way to breach rules of engagement.
Basic scans
# needs root (raw sockets)
sudo masscan 10.10.10.0/24 -p80,443
sudo masscan 10.10.10.0/24 -p1-65535 # all TCP ports
sudo masscan 10.0.0.0/8 -p443 --rate 1000 # big range, capped rate
sudo masscan 10.10.10.0/24 --top-ports 100 # common ports
sudo masscan 10.10.10.5 -p0-65535 --rate 500 -oG masscan.gnmap
Key flags:
| Flag | Purpose |
|---|---|
-p |
Ports: list, ranges, U:53 for UDP, -p- style via 0-65535 |
--rate <pps> |
Packets per second — the safety dial (start low: 100–1000) |
--top-ports N |
Most common N ports |
-e <iface> / --router-ip |
Pick interface / gateway when autodetect fails |
--excludefile out.txt |
Never scan these (keep out-of-scope ranges here) |
--open |
Only report open ports |
--banners |
Grab basic banners (limited vs Nmap -sV) |
--wait 0 |
Don't linger after send (faster finish) |
Output & handing off to Nmap
# Machine-readable outputs
sudo masscan 10.10.10.0/24 -p1-65535 --rate 1000 -oL masscan.txt # list
sudo masscan 10.10.10.0/24 -p1-65535 --rate 1000 -oX masscan.xml # XML
sudo masscan 10.10.10.0/24 -p1-65535 --rate 1000 -oG masscan.gnmap # greppable
sudo masscan 10.10.10.0/24 -p1-65535 --rate 1000 -oJ masscan.json # JSON
# Pull IP:port pairs and deep-scan just those with Nmap
awk '/open/ {print $4, $5}' masscan.gnmap # (format varies)
# Common pattern: collect open ports, then:
sudo nmap -sC -sV -p <found-ports> -iL <found-hosts> -oA detailed
A config file keeps big scans reproducible:
sudo masscan -p1-65535 10.10.10.0/24 --rate 1000 --echo > scan.conf
sudo masscan -c scan.conf
masscan vs Nmap
| masscan | Nmap | |
|---|---|---|
| Goal | Find open ports fast, at scale | Accurate detail on specific hosts |
| Speed | Very high (async, stateless) | Slower, stateful |
| Service/version/OS/NSE | Minimal (basic banners) | Full (-sV, -O, NSE scripts) |
| Typical use | First sweep of a large scope | Deep-scan the hits |
The idiomatic workflow is both: masscan to discover, Nmap to characterise. For internet-exposed assets, pair with OSINT and recon (Shodan/Censys) and feed live web ports to Nuclei.
More options
| Flag | Purpose |
|---|---|
--banners |
Grab service banners (uses its own TCP stack) |
--ping |
Include an ICMP echo sweep |
--retries N |
Retransmits for reliability over lossy links |
--source-ip <ip> |
Choose/spoof a source IP in your range |
--source-port <p> |
Fixed source port (e.g. slip past weak egress rules) |
--adapter-ip / --router-mac |
Set networking manually when autodetect fails |
--shards 1/4 |
Split one huge scan across 4 machines (run 1/4…4/4) |
--resume paused.conf |
Resume — Ctrl-C writes paused.conf automatically |
--interactive |
Print results live as they're found |
--offline |
Go through the motions without sending packets (test config) |
--echo > scan.conf |
Dump current options to a reusable config file |
# Internet-/estate-scale pattern — be certain of scope AND rate
sudo masscan 10.0.0.0/8 -p443 --rate 5000 --excludefile out-of-scope.conf -oX out.xml
sudo masscan 10.10.10.0/24 -p80,443 --banners --rate 1000 # grab banners
sudo masscan -c scan.conf # run from a saved config
Kill-chain usage
Recon
masscan 10.0.0.0/8 -p443 --rate 1000 # find live web hosts at scale
Scanning
masscan 10.10.10.5 -p1-65535 --rate 500 -oX m.xml # fast full-port sweep
Where it fits
The large-scope front end to scanning. When a target range is too big for Nmap to sweep in reasonable time, masscan finds the open ports first (carefully rate-limited); Nmap then does accurate service/version detection on just those ports.