🔍 Nmap Cheat Sheet

Quick reference for the most useful Nmap commands in penetration testing and network auditing.

Basic Scans

CommandDescription
nmap <target>Default scan (top 1000 TCP ports)
nmap -sn <target>Ping sweep — host discovery only
nmap -p- <target>Scan all 65535 TCP ports
nmap -sU <target>UDP scan
nmap -sV <target>Service version detection
nmap -O <target>OS detection
nmap -A <target>Aggressive scan (OS + version + scripts + traceroute)

Scan Types

FlagTypeNotes
-sSSYN (Stealth)Default for root; half-open — fast & quiet
-sTTCP ConnectFull 3-way handshake; default for non-root
-sUUDPSlower; essential for DNS, SNMP, DHCP
-sNNullNo flags set — bypasses some firewalls
-sFFINFIN flag only
-sXXmasFIN + PSH + URG flags

NSE Scripts

# Run default scripts
nmap -sC <target>

# Run specific script
nmap --script=http-enum <target>

# Run vulnerability scripts
nmap --script=vuln <target>

# Run all SMB scripts
nmap --script=smb* <target>

# Safe scripts only
nmap --script=safe <target>

Timing Templates

FlagNameUse Case
-T0ParanoidIDS evasion (very slow)
-T1SneakyIDS evasion
-T2PoliteReduced bandwidth
-T3NormalDefault
-T4AggressiveCTFs and fast networks
-T5InsaneVery fast; may miss ports

Output Formats

# Normal output
nmap -oN output.txt <target>

# XML output
nmap -oX output.xml <target>

# Grepable output
nmap -oG output.gnmap <target>

# All formats at once
nmap -oA output_basename <target>

My Go-To Pentest Scan

nmap -sC -sV -O -oA nmap/initial <target>
nmap -p- -T4 -oA nmap/allports <target>
nmap -sU --top-ports 50 -oA nmap/udp <target>