Nmap Cheat Sheet
Nmap Cheat Sheet
Target Specification
Scan Techniques
Host Discovery
-sn nmap 192.168.1.1/24 -sn Disable port scanning. Host discovery only.
-Pn nmap 192.168.1.1-5 -Pn Disable host discovery. Port scan only.
Port Specification
EXAMPLE DESCRIPTION
SWITCH
nmap 192.168.1.1 -p
-p Port scan multiple TCP and UDP ports
U:53,T:21-25,80
-p nmap 192.168.1.1 -p- Port scan all ports
nmap 192.168.1.1 -p
-p Port scan from service name
http,https
-F nmap 192.168.1.1 -F Fast port scan (100 ports)
–top- nmap 192.168.1.1 –top-ports
Port scan the top x ports
ports 2000
-sV –version- nmap 192.168.1.1 -sV – Enable light mode. Lower possibility of
light version-light correctness. Faster
-sV –version- nmap 192.168.1.1 -sV – Enable intensity level 9. Higher possibility of
all version-all correctness. Slower
Enables OS detection, version detection, script
-A nmap 192.168.1.1 -A
scanning, and traceroute
OS Detection
EXAMPLE DESCRIPTION
SWITCH
-O nmap 192.168.1.1 -O Remote OS detection using TCP/IP stack fingerprinting
-O –
nmap 192.168.1.1 -O If at least one open and one closed TCP port are not found
osscan-
–osscan-limit it will not try OS detection against host
limit
-O –
nmap 192.168.1.1 -O
osscan- Makes Nmap guess more aggressively
–osscan-guess
guess
-O –max- nmap 192.168.1.1 -O Set the maximum number x of OS detection tries against a
os-tries –max-os-tries 1 target
Enables OS detection, version detection, script scanning,
-A nmap 192.168.1.1 -A
and traceroute
nmap
-T0 Paranoid (0) Intrusion Detection System evasion
192.168.1.1 -T0
nmap
-T1 Sneaky (1) Intrusion Detection System evasion
192.168.1.1 -T1
nmap Polite (2) slows down the scan to use less bandwidth and use less
-T2
192.168.1.1 -T2 target machine resources
nmap
-T3 Normal (3) which is default speed
192.168.1.1 -T3
–min-rtt-timeout/max-rtt-
1s; 4m; 2h Specifies probe round trip time
timeout/initial-rtt-timeout <time>
–min-hostgroup/max-
50; 1024 Parallel host scan group sizes
hostgroup <size<size>
–min-parallelism/max-
10; 1 Probe parallelization
parallelism <numprobes>
NSE Scripts
COMMAND DESCRIPTION
EXAMPLE DESCRIPTION
SWITCH
Requested scan
(including ping scans)
-f nmap 192.168.1.1 -f use tiny fragmented IP
packets. Harder for
packet filters
nmap -D
Send scans from spoofed
-D 192.168.1.101,192.168.1.102,192.168.1.103,192.168.1.23
IPs
192.168.1.1
nmap -D decoy-ip1,decoy-ip2,your-own-ip,decoy- Above example
-D
ip3,decoy-ip4 remote-host-ip explained
Output
EXAMPLE DESCRIPTION
SWITCH
-oG nmap 192.168.1.1 -oG grep.file Grepable output to the file grep.file
-oA nmap 192.168.1.1 -oA results Output in the three major formats at once
Grepable output to screen. -oN -, -oX – also
-oG – nmap 192.168.1.1 -oG –
usable
COMMAND DESCRIPTION
nmap -p80 -sV -oG – –open 192.168.1.1/24 | Scan for web servers and grep to show which
grep open IPs are running web servers
nmap -iR 10 -n -oX out.xml | grep “Nmap” | cut
Generate a list of the IPs of live hosts
-d ” ” -f5 > live-hosts.txt
nmap -iR 10 -n -oX out2.xml | grep “Nmap” |
Append IP to the list of live hosts
cut -d ” ” -f5 >> live-hosts.txt
ndiff scanl.xml scan2.xml Compare output from nmap using the ndif
Miscellaneous Options
COMMAND DESCRIPTION
nmap 192.168.1.1-50 -sL –dns-server Query the Internal DNS for hosts, list targets
192.168.1.1 only