Nmap Cheat Sheet - All Commands


Target Specification

SwitchCommandDescription
nmap <target>Scan a single target (IP, hostname, or network).
nmap <target1> <target2>Scan multiple targets.
nmap 192.168.1.0/24Scan an entire subnet.
-iLnmap -iL <inputfile>Scan targets from a list in a file.
--excludenmap --exclude <target>Exclude a specific target from the scan.
--excludefilenmap --excludefile <excludefile>Exclude targets listed in a file.

Host Discovery

SwitchCommandDescription
-snnmap -sn <target>Ping scan - disable port scan, only discover hosts.
-Pnnmap -Pn <target>Skip host discovery, treat all hosts as online.
-PSnmap -PS <port> <target>TCP SYN ping.
-PAnmap -PA <port> <target>TCP ACK ping.
-PUnmap -PU <port> <target>UDP ping.
-PYnmap -PY <port> <target>SCTP INIT ping.
-PEnmap -PE <target>ICMP echo request ping.
-PPnmap -PP <target>ICMP timestamp ping.
-PMnmap -PM <target>ICMP address mask ping.
-POnmap -PO <protocol> <target>IP protocol ping.

Scan Techniques

SwitchCommandDescription
-sSnmap -sS <target>TCP SYN scan (stealth scan).
-sTnmap -sT <target>TCP connect scan.
-sUnmap -sU <target>UDP scan.
-sAnmap -sA <target>TCP ACK scan.
-sWnmap -sW <target>Window scan.
-sMnmap -sM <target>Maimon scan.
-sNnmap -sN <target>TCP NULL scan.
-sFnmap -sF <target>TCP FIN scan.
-sXnmap -sX <target>TCP Xmas scan.
-sInmap -sI <zombie host> <target>Idle scan (zombie scan).
-sOnmap -sO <target>IP protocol scan.
-bnmap -b <ftp relay host> <target>FTP bounce scan.

Port Specification

SwitchCommandDescription
-pnmap -p <port> <target>Scan specific port(s).
-p 1-100nmap -p 1-100 <target>Scan a range of ports.
-p U:,T:nmap -p U:<udp ports>,T:<tcp ports> <target>Scan specific TCP and UDP ports.
-p-nmap -p- <target>Scan all 65535 ports.
-Fnmap -F <target>Fast scan - scan fewer ports than the default.
--top-portsnmap --top-ports <number> <target>Scan the top N most common ports.

Service/Version Detection

SwitchCommandDescription
-sVnmap -sV <target>Detect service/version information.
-sV --version-intensitynmap -sV --version-intensity <level> <target>Set version detection intensity (0-9).
-sV --version-lightnmap -sV --version-light <target>Light version detection (intensity 2).
-sV --version-allnmap -sV --version-all <target>Try every single probe (intensity 9).
-Anmap -A <target>Enable OS detection, version detection, script scanning, and traceroute.

OS Detection

SwitchCommandDescription
-Onmap -O <target>Enable OS detection.
-O --osscan-limitnmap -O --osscan-limit <target>Limit OS detection to promising targets.
-O --osscan-guessnmap -O --osscan-guess <target>Guess OS more aggressively.
-O --max-os-triesnmap -O --max-os-tries <number> <target>Set maximum number of OS detection tries.

Timing and Performance

SwitchCommandDescription
-T0nmap -T0 <target>Paranoid timing (slowest).
-T1nmap -T1 <target>Sneaky timing.
-T2nmap -T2 <target>Polite timing.
-T3nmap -T3 <target>Normal timing (default).
-T4nmap -T4 <target>Aggressive timing.
-T5nmap -T5 <target>Insane timing (fastest).
--min-hostgroupnmap --min-hostgroup <size> <target>Parallel host scan group sizes.
--max-hostgroupnmap --max-hostgroup <size> <target>Parallel host scan group sizes.
--min-parallelismnmap --min-parallelism <number> <target>Probe parallelization.
--max-parallelismnmap --max-parallelism <number> <target>Probe parallelization.
--min-rtt-timeoutnmap --min-rtt-timeout <time> <target>Adjust probe timeouts.
--max-rtt-timeoutnmap --max-rtt-timeout <time> <target>Adjust probe timeouts.
--initial-rtt-timeoutnmap --initial-rtt-timeout <time> <target>Adjust probe timeouts.
--host-timeoutnmap --host-timeout <time> <target>Give up on slow targets.
--scan-delaynmap --scan-delay <time> <target>Adjust delay between probes.
--max-scan-delaynmap --max-scan-delay <time> <target>Adjust delay between probes.
--min-ratenmap --min-rate <number> <target>Send packets no slower than specified rate.
--max-ratenmap --max-rate <number> <target>Send packets no faster than specified rate.

Firewall/IDS Evasion

SwitchCommandDescription
-fnmap -f <target>Fragment packets (split into smaller pieces).
--mtunmap --mtu <size> <target>Set custom MTU size for packet fragmentation.
-Dnmap -D <decoy1,decoy2> <target>Use decoy IP addresses to hide your scan.
-Snmap -S <source IP> <target>Spoof source IP address.
-enmap -e <interface> <target>Specify network interface to use.
--source-portnmap --source-port <port> <target>Spoof source port number.
--data-lengthnmap --data-length <length> <target>Append random data to packets.
--randomize-hostsnmap --randomize-hosts <target>Randomize target host order.
--spoof-macnmap --spoof-mac <MAC address> <target>Spoof MAC address.
--badsumnmap --badsum <target>Send packets with invalid checksums.

Output Formats

SwitchCommandDescription
-oNnmap -oN <outputfile> <target>Save output in normal format.
-oXnmap -oX <outputfile> <target>Save output in XML format.
-oGnmap -oG <outputfile> <target>Save output in grepable format.
-oAnmap -oA <basename> <target>Save output in all formats (normal, XML, grepable).
-oSnmap -oS <outputfile> <target>Save output in script kiddie format.
-vnmap -v <target>Increase verbosity level.
-v2nmap -v2 <target>Even more verbose output.
-dnmap -d <target>Increase debugging level.
-d2nmap -d2 <target>Even more debugging output.
--reasonnmap --reason <target>Display reason for port states.
--stats-everynmap --stats-every <time> <target>Print scan progress periodically.
--packet-tracenmap --packet-trace <target>Trace packets sent and received.
--iflistnmap --iflistList interfaces and routes.

Scripting Engine

SwitchCommandDescription
-sCnmap -sC <target>Run default NSE scripts.
--scriptnmap --script <script> <target>Run specific NSE script(s).
--script-argsnmap --script-args <args> <target>Pass arguments to NSE scripts.
--script-tracenmap --script-trace <target>Show all data sent and received by scripts.
--script-updatedbnmap --script-updatedbUpdate the script database.
--script-helpnmap --script-help <script>Display help for a specific script.

Miscellaneous

SwitchCommandDescription
-6nmap -6 <target>Enable IPv6 scanning.
--resumenmap --resume <logfile>Resume a previously saved scan.
--unprivilegednmap --unprivileged <target>Assume lack of raw socket privileges.
--privilegednmap --privileged <target>Assume raw socket privileges.
--send-ethnmap --send-eth <target>Send packets at the raw Ethernet layer.
--send-ipnmap --send-ip <target>Send packets using raw IP sockets.
--append-outputnmap --append-output <target>Append output to existing files.
--datadirnmap --datadir <directory>Specify custom Nmap data directory.
--servicedbnmap --servicedb <file>Specify custom services file.
--versiondbnmap --versiondb <file>Specify custom version detection file.
--system-dnsnmap --system-dns <target>Use system DNS resolver.
--dns-serversnmap --dns-servers <servers> <target>Use custom DNS servers.
--traceroutenmap --traceroute <target>Perform traceroute to target.
--versionnmap --versionDisplay Nmap version.
-hnmap -hDisplay help and usage information.