Nmap Master Reference

Install (Kali)

sudo apt update && sudo apt install -y nmap

Usually preinstalled on Kali — verify: nmap --version

Full install index → Installation - Kali Setup

My Templates:

nmap -vv -p- --min-rate=1000 -oN nmap/allports.txt box.htb
nmap -vv -sVC -Pn -p3306 -oN nmap.txt 10.129.9.23
nmap -sU -p- --min-rate=1000 -oN udp_allports.txt soccer.htb

📌 1. Nmap Cheat Sheet (Quick Commands)

1. Basic Scanning

nmap 10.10.10.10              # Basic scan (TCP 1000 most common ports)
 
nmap -p- 10.10.10.10           # All 65535 TCP ports
 
nmap -p1-65535 10.10.10.10     # Explicit full port range
 
nmap -p22,80,443 10.10.10.10   # Specific ports only

2. Service & Version Detection

nmap -sV 10.10.10.10                     # Detect service versions
 
nmap -sV --version-intensity 9 10.10.10.10  # Aggressive version detection

3. OS Detection

nmap -O 10.10.10.10   # OS detection
nmap -A 10.10.10.10   # OS detection + version + scripts + traceroute

4. Fast & Stealthy Scans

nmap -T4 -F 10.10.10.10   # Fast scan of common ports
nmap -sS 10.10.10.10      # Stealth SYN scan
nmap -T2 10.10.10.10      # Slow scan to avoid detection

5. UDP Scanning

nmap -sU 10.10.10.10                      # UDP scan (top 100 ports)
nmap -sU -p53,123,161 10.10.10.10         # Specific UDP ports (DNS, NTP, SNMP)

6. Aggressive / Recon Scans

nmap -A 10.10.10.10        # Aggressive recon
nmap -A -p- 10.10.10.10    # Aggressive + all ports

7. NSE Scripting (Nmap Scripting Engine)

nmap --script vuln 10.10.10.10             # Scan for vulnerabilities
nmap --script http-enum 10.10.10.10        # Enumerate HTTP directories/files
nmap --script smb-enum-shares 10.10.10.10  # Enumerate SMB shares
nmap --script ftp-anon 10.10.10.10         # Check anonymous FTP login

8. Output Options

nmap -oN output.txt 10.10.10.10     # Normal output to file
nmap -oX output.xml 10.10.10.10     # XML output
nmap -oA scan 10.10.10.10           # All formats (scan.nmap, scan.xml, scan.gnmap)

9. Scan Multiple Targets

nmap 10.10.10.10 10.10.10.11  # Multiple IPs
nmap 10.10.10.0/24            # Subnet
nmap -iL targets.txt          # List from file

10. Useful OSCP Combinations

# Step 1: Find all open ports quickly
nmap -p- --min-rate=1000 -oN allports.txt 10.10.10.10
 
# Step 2: Scan only the found open ports with scripts & version detection
nmap -sC -sV -p$(cat allports.txt | grep ^[0-9] | cut -d '/' -f 1 | tr '\n' ',' | sed 's/,$//') -oN targeted.txt 10.10.10.10

WebSockets — what Nmap does (and does not)

Nmap does not fuzz WebSocket messages. It helps before WS testing:

Nmap roleExample
Find open web ports-p- then -sV on 80, 443, 8080, 8443, 3000, 5000
Service/versionNode, nginx, Apache — hints at Socket.IO, Rails, etc.
HTTP enum script--script http-enum may list paths; pair with Gobuster / ffuf for /ws, /socket.io
SSL/TLS on wss://--script ssl-enum-ciphers on 443 if upgrade fails
nmap -sV -p 80,443,8080,8443,3000 TARGET
nmap --script http-enum -p 80,443 TARGET

After ports/services are known → Burp Suite (WebSockets history) · Curl (ws:// handshake) · SQLMap (HTTP bridge).


📌 2. Full Nmap Option Flags

Target Specification

FlagDescription
-iL Input from list of targets
-iR Choose random targets
—exclude Exclude hosts/networks
—excludefile Exclude targets from file

Host Discovery (Ping Scan)

FlagDescription
-snPing scan only
-PnTreat all hosts as online
-PS[portlist]TCP SYN ping
-PA[portlist]TCP ACK ping
-PU[portlist]UDP ping
-PY[portlist]SCTP INIT ping
-PEICMP echo ping
-PPICMP timestamp ping
-PMICMP netmask ping
—disable-arp-pingDisable ARP discovery

Scan Techniques

FlagDescription
-sSTCP SYN scan
-sTTCP connect scan
-sUUDP scan
-sYSCTP INIT scan
-sNTCP Null scan
-sFTCP FIN scan
-sXTCP Xmas scan
-sATCP ACK scan
-sWTCP Window scan
-sMTCP Maimon scan
—scanflags Custom TCP flags
-sI Idle/Zombie scan
-sOIP protocol scan
-b FTP bounce scan

Port Specification & Order

FlagDescription
-p Specify ports/ranges
-p-All 65535 ports
—exclude-ports Skip specific ports
-FFast mode (100 ports)
-rScan sequentially
Service & Version Detection
FlagDescription
-sVService/version detection
—version-intensity <0-9>Set detection intensity
—version-lightLighter scan
—version-allTry all probes
—version-traceShow version scan details

OS Detection & Traceroute

FlagDescription
-OOS detection
—osscan-limitLimit OS detection
—osscan-guessAggressive OS guess
—tracerouteRun traceroute

Script Scanning (NSE) (add more to this?)

FlagDescription
-sCDefault scripts
—script Specific scripts
—script-args Arguments for scripts
—script-traceShow script communications
—script-updatedbUpdate script DB
—script-help Show help for scripts

Timing & Performance

FlagDescription
-T<0-5>Timing template
—min-hostgroup Min parallel hosts
—max-hostgroup Max parallel hosts
—min-parallelism Min probes parallel
—max-parallelism Max probes parallel
—min-rtt-timeout Min RTT timeout
—max-rtt-timeout Max RTT timeout
—initial-rtt-timeout Initial RTT timeout
—max-retries Max retries
—host-timeout Give up after time
—scan-delay Delay between probes
—max-scan-delay Max delay
—min-rate Min packet rate
—max-rate Max packet rate

Firewall / IDS Evasion

FlagDescription
-fFragment packets
—mtu Custom MTU
-D Decoy scan
-S Spoof source IP
-e Specific interface
-g Source port
—source-port Same as -g
—data-length Append random data
—ip-options Send with IP options
—ttl Set TTL
—spoof-mac Spoof MAC
—badsumBad checksum packets

Output

FlagDescription
-oN Normal output
-oX XML output
-oS Script kiddie output
-oG Grepable output
-oA All output formats
—append-outputAppend to files
-vVerbose
-vvVery verbose
—reasonShow reason for port state
—openOnly open ports
—packet-traceShow all packets
—iflistShow interface info
—log-errorsLog errors
—stats-every Periodic stats

Miscellaneous

FlagDescription
—helpShow help
-6IPv6 scanning
-AOS detect + version + scripts + traceroute
—datadir Custom data dir
—send-ethRaw ethernet frames
—send-ipIP packets
—privilegedAssume full privileges
—unprivilegedAssume limited privileges