masscan
Le scanner de ports le plus rapide au monde. Transmet 10 millions de paquets/seconde grâce à une approche asynchrone. Idéal pour les balayages CIDR de grande envergure avant un nmap ciblé. World's fastest port scanner. Transmits 10 million packets/second using an asynchronous approach. Ideal for large CIDR sweeps before targeted nmap.
↗ https://github.com/robertdavidgraham/masscanOverview
masscan is designed for scanning the entire internet — it can do a complete TCP SYN scan of all 65535 ports on all IPv4 addresses in under 6 minutes. It uses its own TCP/IP stack (like nmap’s -sS) and produces output compatible with nmap’s XML format.
Basic Usage
Scan a single host, all ports
masscan -p0-65535 10.10.10.1 --rate=1000
Scan a CIDR range for common ports
masscan -p22,80,443,445,3389 10.10.10.0/24 --rate=10000
Top ports equivalent
masscan -p1-1000 10.10.10.0/24 --rate=5000
Scan from a file of targets
masscan -p80,443 -iL targets.txt --rate=10000
Exclude specific hosts
masscan -p80 10.0.0.0/8 --excludefile exclude.txt
Banner grabbing (slower)
masscan -p80,443 10.10.10.0/24 --rate=1000 --banners
Output Formats
Save in XML (nmap-compatible)
masscan -p80,443 10.10.10.0/24 -oX output.xml
Save in grepable format
masscan -p80,443 10.10.10.0/24 -oG output.gnmap
Save in JSON
masscan -p80,443 10.10.10.0/24 -oJ output.json
Save in list format
masscan -p80,443 10.10.10.0/24 -oL output.list
Binary format (for resume/merge)
masscan -p0-65535 10.10.10.0/24 -oB output.bin
Resume from binary
masscan --resume output.bin
Rate Control
Conservative (avoid detection/disruption)
masscan -p0-65535 10.10.10.1 --rate=100
Fast internal network
masscan -p0-65535 10.10.10.0/24 --rate=100000
Maximum (needs dedicated NIC + raw sockets)
masscan -p0-65535 10.0.0.0/8 --rate=10000000
Integration with nmap
- Fast masscan sweep to find open ports
masscan -p0-65535 10.10.10.1 --rate=10000 -oG masscan.gnmap
- Extract open ports
grep -oP '\d+(?=/open)' masscan.gnmap | sort -u | tr '\n' ',' | sed 's/,$//'
- Targeted nmap with version detection
nmap -sCV -p <ports_from_above> 10.10.10.1
Configuration File
# /etc/masscan/masscan.conf or ~/.masscan/masscan.conf
rate = 10000
output-format = json
output-filename = scan.json
Tips
- Requires
root/sudofor raw packet sending - Default rate (100 pps) is very conservative — use
--rate=10000on local networks - Use
--wait 10to wait 10 seconds after last transmit for responses - masscan doesn’t do service detection — follow up with nmap
-sCVon discovered ports
Help / Man page
masscan [options] <ip/cidr>
-p ports Port list (e.g. 80,443 or 0-65535)
-iL file Read targets from file
--rate N Packets per second (default: 100)
--banners Grab banners (experimental)
--excludefile Exclude file
--wait N Seconds to wait after done (default: 10)
--retries N Number of retransmits
--open-only Only show open ports
-oX file XML output (nmap-compatible)
-oG file Grepable output
-oJ file JSON output
-oL file List output
-oB file Binary output
--resume file Resume from binary file
--conf file Config file
Vue d’ensemble
masscan est conçu pour scanner l’internet entier : il peut effectuer un scan TCP SYN complet des 65535 ports sur toutes les adresses IPv4 en moins de 6 minutes. Il utilise sa propre pile TCP/IP (comme le -sS de nmap) et produit une sortie compatible avec le format XML de nmap.
Utilisation de base
# Scanner un seul hôte, tous les ports
masscan -p0-65535 10.10.10.1 --rate=1000
# Scanner une plage CIDR sur les ports courants
masscan -p22,80,443,445,3389 10.10.10.0/24 --rate=10000
# Équivalent des top ports
masscan -p1-1000 10.10.10.0/24 --rate=5000
# Scanner à partir d'un fichier de cibles
masscan -p80,443 -iL targets.txt --rate=10000
# Exclure des hôtes spécifiques
masscan -p80 10.0.0.0/8 --excludefile exclude.txt
# Récupération de bannières (plus lent)
masscan -p80,443 10.10.10.0/24 --rate=1000 --banners
Formats de sortie
# Sauvegarder en XML (compatible nmap)
masscan -p80,443 10.10.10.0/24 -oX output.xml
# Sauvegarder au format grepable
masscan -p80,443 10.10.10.0/24 -oG output.gnmap
# Sauvegarder en JSON
masscan -p80,443 10.10.10.0/24 -oJ output.json
# Sauvegarder au format liste
masscan -p80,443 10.10.10.0/24 -oL output.list
# Format binaire (pour reprise/fusion)
masscan -p0-65535 10.10.10.0/24 -oB output.bin
# Reprendre depuis un fichier binaire
masscan --resume output.bin
Contrôle du débit
# Conservateur (éviter la détection/perturbation)
masscan -p0-65535 10.10.10.1 --rate=100
# Réseau interne rapide
masscan -p0-65535 10.10.10.0/24 --rate=100000
# Maximum (nécessite une carte réseau dédiée + sockets bruts)
masscan -p0-65535 10.0.0.0/8 --rate=10000000
Intégration avec nmap
- Balayage masscan rapide pour trouver les ports ouverts
masscan -p0-65535 10.10.10.1 --rate=10000 -oG masscan.gnmap
- Extraire les ports ouverts
grep -oP '\d+(?=/open)' masscan.gnmap | sort -u | tr '\n' ',' | sed 's/,$//'
- nmap ciblé avec détection de versions
nmap -sCV -p <ports_from_above> 10.10.10.1
Fichier de configuration
# /etc/masscan/masscan.conf or ~/.masscan/masscan.conf
rate = 10000
output-format = json
output-filename = scan.json
Conseils
- Nécessite
root/sudopour l’envoi de paquets bruts - Le débit par défaut (100 pps) est très conservateur : utiliser
--rate=10000sur les réseaux locaux - Utiliser
--wait 10pour attendre 10 secondes après la dernière transmission avant de récupérer les réponses - masscan ne fait pas de détection de service : le compléter avec un nmap
-sCVsur les ports découverts
Aide / Page de manuel
masscan [options] <ip/cidr>
-p ports Port list (e.g. 80,443 or 0-65535)
-iL file Read targets from file
--rate N Packets per second (default: 100)
--banners Grab banners (experimental)
--excludefile Exclude file
--wait N Seconds to wait after done (default: 10)
--retries N Number of retransmits
--open-only Only show open ports
-oX file XML output (nmap-compatible)
-oG file Grepable output
-oJ file JSON output
-oL file List output
-oB file Binary output
--resume file Resume from binary file
--conf file Config file