root@sparrow:~/writeups$ cat masscan.md
// recon
Masscan
21 Jul 2026
· 3 min read
masscan is an asynchronous TCP port scanner able to sweep the entire Internet in minutes, with a syntax deliberately similar to nmap. Its strength is speed: it transmits packets using its own user-space TCP/IP stack, without waiting for a reply before sending the next one. It is used to quickly discover which ports are open across huge ranges before moving on to finer analysis.What really matters is understanding that masscan does not use the operating system's stack: it transmits and receives with its own stack, which is why it reaches hundreds of thousands of packets per second, but also why --rate is a double-edged sword. A rate that is too high saturates your own link or VPN tunnel and produces false negatives: open ports you never see because the replies get dropped. On a VPN lab, moderate rates are more reliable than theoretical maximums.
1. Beginner level — scans and output formats

| Command | What it does |
|---|---|
masscan -p80 10.10.10.0/24 | Scan one port across a network |
masscan -p1-65535 <ip> | All TCP ports |
masscan -p80,443 10.0.0.0/8 --rate 10000 | Several ports at 10k pps |
masscan <ip> --top-ports 100 | The 100 most common ports |
masscan -p80 10.10.10.0/24 -oL out.txt | Save in list format |
masscan -p80 10.10.10.0/24 -oG out.gnmap | Grepable output |
masscan -p80 10.10.10.0/24 -oX out.xml | XML output |
masscan -p80 10.10.10.0/24 -oJ out.json | JSON output |
masscan -p80 10.10.10.0/24 -e tun0 | Specify the interface |
masscan -pU:53,161 <ip> | UDP port scan |
masscan --interactive -p80 <ip> | Show results live |
masscan -p80 -iL targets.txt | Targets from a file |
masscan --echo > scan.conf | Dump the configuration to a file |
masscan -p80 10.10.10.0/24 --rate 1000 | Tune the rate (pps) |
2. Advanced level — rate, exclusions and banners

| Command | What it does |
|---|---|
masscan -p1-65535 10.0.0.0/8 --rate 100000 | Massive sweep (100k pps) |
masscan -p80 10.0.0.0/8 --exclude 10.0.0.1 | Exclude hosts |
masscan -p80 10.0.0.0/8 --excludefile ex.txt | Exclude from a file |
masscan -c scan.conf | Load the configuration from a file |
masscan -p80 <ip> --banners | Grab service banners |
masscan -p80 <ip> --source-ip <spoof> | Spoof the source IP |
masscan -p80 <ip> --source-port 61000 | Fix the source port |
masscan -p80 10.0.0.0/8 --shard 1/3 | Split the scan across machines |
masscan -p80 <ip> --rate 100000 --wait 0 | No final wait (fast) |
masscan -p80 <ip> --router-mac <mac> | Fix the router MAC (odd networks) |
masscan -p80 <ip> --ttl 200 | Adjust the packets' TTL |
masscan --nmap | Show the flag equivalence with nmap |
masscan -p80 10.10.10.0/24 -oL - | awk '/open/{print $4}' | Extract only the live IPs |
masscan -p- <ip> --rate 5000 -oG masscan.gnmap | Save to hand off to nmap later |
3. Details people miss
- masscan needs root privileges (or the
CAP_NET_RAWcapability) because it opens raw sockets; without them it won't start. - The default
--rateis very conservative. Pushing it too high on an HTB/lab VPN causes false negatives: lower the rate if a port you know is open doesn't show up. - Its output formats are not identical to nmap's. Use
-oG/-oXto find live hosts fast, then feed those IPs and ports tonmap -sVfor real fingerprinting. - UDP scanning is requested with
-pU:(for example-pU:53,161), not with-p; mixing the TCP and UDP syntax is a common mistake. --bannersmakes masscan complete the TCP handshake with its own stack; this can clash with the kernel stack (which sends a RST), so it's wise to set--source-portand block that port in the local firewall.
Responsible use
These commands are for systems you own or have explicit written authorisation to test (labs, CTFs, contracted engagements). Using them against third-party infrastructure without permission is illegal in most countries.