Clyde logo
Playbook
EmulatedCriminals
Back to all cheatsheets

Nmap cheatsheet

A quick cheatsheet for common usage and examples of Network Mapper(NMap). Includes common switches, examples, and red team/penetration testing examples.

networkscanportpenetration testingred teaming

#Getting Started

Basic Usage :

Scan a single IP

nmap 192.168.10.1

Scan specific IPs

nmap 192.168.1.1 192.168.2.1

Scan a range

nmap 192.168.10.0/24

or

nmap 192.168.1.1-254

Scan targets from a file

nmap -iL targets.txt

Scan targets not included in list

nmap -exclude 192.168.1.1
Common usage

Scan while Assuming Target is live & Port version

nmap -Pn -sV 192.168.10.1

Scan a target for OS and Port Information

nmap -sV -O 192.168.10.1

Scan a target quickly for all ports w/Version and OS

nmap -T5 -p- -O 10.10.20.22

Output a scan to a xml file

nmap -sV -O 10.20.30.40 -oX xml.file

Run Service Detection & default scripts

nmap -sV -sC 192.168.13.37

#Common Switches

Port Options :
OptionsPurpose
-p #Scan a specific port
-p 1-1023scan a range of ports
-FFast Scan of 100 most common ports
-rscan ports in consecutive order
-top-ports #Port scan the top x ports
--max-rate 50rate <= 50 packets/sec
--min-rate 15rate >= 15 packets/sec
--min-parallelism 100at least 100 probes in parallel
-p0-Leaving off end port in the range designation makes the scan go through to port 65535
Scan Techniques
SWITCHDESCRIPTION
-sSTCP SYN port scan (Default)
-sTTCP connect port scan (Default without root privilege)
-sUUDP port scan
-sATCP ACK port scan
-sWTCP Window port scan
-sMTCP Maimon port scan
See: Port Scanning
Host Discovery
SWITCHDESCRIPTION
-sLNo Scan. List targets only
-snDisable port scanning. Host discovery only.
-PnDisable host discovery. Port scan only.
-PSTCP SYN discovery on port x. Port 80 by default
-PATCP ACK discovery on port x. Port 80 by default
-PUUDP discovery on port x. Port 40125 by default
-PRARP discovery on local network
-nNever do DNS resolution
Port Specification
SWITCHDESCRIPTION
-p ##Port scan for port x
-p #-#Port range
-p U:#,T:#,#Port scan multiple TCP and UDP ports
-pPort scan all ports
-p http,httpsPort scan from service name
-FFast port scan (100 ports)
-top-ports ###Port scan the top x ports
-p-65535Leaving off initial port in range makes the scan start at port 1
-p0-Leaving off end port in range makes the scan go through to port 65535
Service and Version Detection
SWITCHDESCRIPTION
-sVAttempts to determine the version of the service running on port
-sV -version-intensityIntensity level 0 to 9. Higher number increases possibility of correctness
-sV -version-lightEnable light mode. Lower possibility of correctness. Faster
-sV -version-allEnable intensity level 9. Higher possibility of correctness. Slower
-AEnables OS detection, version detection, script scanning, and traceroute
See: Services and App Version Detection
Timing Switches
SWITCHDESCRIPTION
-T0Paranoid (0) Intrusion Detection System evasion
-T1Sneaky (1) Intrusion Detection System evasion
-T2Polite (2) slows down the scan to use less bandwidth and use less target machine resources
-T3Normal (3) which is default speed
-T4Aggressive (4) speeds scans; assumes you are on a reasonably fast and reliable network
-T5Insane (5) speeds scan; assumes you are on an extraordinarily fast network
Details & Report
OptionPurpose
--reasonexplains how Nmap made its conclusion
-vverbose
-vvvery verbose
-ddebugging
-ddmore details for debugging
-oN Normal output
-oX XML output
-oG grep-able output
-oA Output in all major formats
OS Detection
SWITCHDESCRIPTION
-ORemote OS detection using TCP/IP stack fingerprinting
-O -osscan-limitIf at least one open and one closed TCP port are not found it will not try OS detection against host
-O -osscan-guessMakes Nmap guess more aggressively
-O -max-os-triesSet the maximum number x of OS detection tries against a target
-AEnables OS detection, version detection, script scanning, and traceroute
See: Remote OS Detection
NSE Scripts
SWITCHDESCRIPTION
-sCScan with default NSE scripts. Considered useful for discovery and safe
-script defaultScan with default NSE scripts. Considered useful for discovery and safe
-script=