Skip to content

Masscan

Internet-scale port scanning at speed

Description

Masscan is the fastest Internet port scanner. It can scan the entire Internet in under 6 minutes, transmitting 10 million packets per second. It produces results similar to Nmap, the most famous port scanner.

Installation

BASH
# Debian/Ubuntu
sudo apt install masscan

# From source
git clone https://github.com/robertdavidgraham/masscan
cd masscan
make
sudo make install

Basic Usage

BASH
# Scan common ports
masscan -p80,443,8080 target.com/24

# Scan a range
masscan -p1-65535 target.com

# Save output
masscan -p80,443 target.com/24 -oG results.txt

Advanced Usage

BASH
# Set rate (packets per second)
masscan -p80,443 target.com/24 --rate 10000

# Banner grabbing
masscan -p80 target.com/24 --banners

# Exclude IPs
masscan -p80 0.0.0.0/0 --excludefile exclude.txt

# JSON output
masscan -p80,443 target.com/24 -oJ results.json

# XML output (for parsing)
masscan -p80,443 target.com/24 -oX results.xml

# Source port
masscan -p80 target.com/24 --source-port 61000

Common Workflows

BASH
# Fast port discovery then Nmap for service detection
masscan -p1-65535 target.com --rate 1000 -oG masscan.txt
grep "open" masscan.txt | awk '{print $4}' | cut -d/ -f1 | sort -u | tr '\n' ',' | sed 's/,$//' | xargs -I {} nmap -sV -p {} target.com