Nmap ("Network Mapper") is a free and open source utility for network discovery and security auditing. Many systems and network administrators also find it useful for tasks such as network inventory, managing service upgrade schedules, and monitoring host or service uptime. Nmap uses raw IP packets in novel ways to determine what hosts are available on the network, what services (application name and version) those hosts are offering, what operating systems (and OS versions) they are running. It was designed to rapidly scan large networks, but works fine against single hosts.
Nmap can be used in a variety of ways depending on the user's level of technical expertise.
Technical Expertise
Usage
Beginner
Zenmap the graphical user interface for Nmap
Intermediate
Command line
Advanced
Python scripting with the Python-Nmap package
nmap [ < Scan Type> ...] [ < Options> ] { < target specification> }
Basic Scanning Techniques
The -s
switch determines the type of scan to perform.
Nmap Switch
Description
-sA
ACK scan
-sF
FIN scan
-sI
IDLE scan
-sL
DNS scan (a.k.a. list scan)
-sN
NULL scan
-sO
Protocol scan
-sP
Ping scan
-sR
RPC scan
-sS
SYN scan
-sT
TCP connect scan
-sW
Windows scan
-sX
XMAS scan
nmap [target1, target2, etc]
nmap [range of IP addresses]
Exclude Targets From a Scan
nmap [targets] --exclude [targets]
Exclude Targets Using a List
nmap [targets] --excludefile [list.txt]
Perform an Aggresive Scan
nmap -p [port(s)] [target]
nmap -p [port name(s)] [target]
nmap -sU -sT -p U:[ports],T:[ports] [target]
nmap --top-ports [number] [target]
Perform a Sequential Port Scan
Attempt to Guess an Unknown OS
nmap -O --osscan-guess [target]
Service Version Detection
Troubleshoot Version Scan
nmap -sV --version-trace [target]
Host Discovery The -p
switch determines the type of ping to perform.
Nmap Switch
Description
-PI
ICMP ping
-Po
No ping
-PS
SYN ping
-PT
TCP ping
nmap --traceroute [target]
Force Reverse DNS Resolution
Disable Reverse DNS Resolution
nmap --system-dns [target]
Manually Specify DNS Server
Can specify a single server or multiple.
nmap --dns-servers [servers] [target]
Port Specification and Scan Order
Service/Version Detection
Nmap Switch
Description
-sV
Enumerates software versions
Nmap Switch
Description
-sC
Run all default scripts
The -t
switch determines the speed and stealth performed.
Nmap Switch
Description
-T0
Serial, slowest scan
-T1
Serial, slow scan
-T2
Serial, normal speed scan
-T3
Parallel, normal speed scan
-T4
Parallel, fast scan
Not specifying a T
value will default to -T3
, or normal speed.
Firewall Evasion Techniques
Firewall/IDS Evasion and Spoofing
nmap --mtu [MTU] [target]
nmap -D RND:[number] [target]
nmap -sI [zombie] [target]
Manually Specify a Source Port
nmap --source-port [port] [target]
nmap --data-length [size] [target]
Randomize Target Scan Order
nmap --randomize-hosts [target]
nmap --spoof-mac [MAC| 0| vendor] [target]
Advanced Scanning Functions
nmap --scanflags [flags] [target]
Send Raw Ethernet Packets
nmap --ttl [time] [target]
Minimum NUmber of Parallel Operations
nmap --min-parallelism [number] [target]
Maximum Number of Parallel Operations
nmap --max-parallelism [number] [target]
nmap --min-hostgroup [number] [targets]
nmap --max-hostgroup [number] [targets]
nmap --initial-rtt-timeout [time] [target]
nmap --max-rtt-timeout [TTL] [target]
Maximum Number of Retries
nmap --max-retries [number] [target]
nmap --host-timeout [time] [target]
nmap --scan-delay [time] [target]
nmap --max-scan-delay [time] [target]
nmap --min-rate [number] [target]
nmap --max-rate [number] [target]
nmap --defeat-rst-ratelimit [target]
Nmap Switch
Description
-oN
Normal output
-oX
XML output
-oA
Normal, XML, and Grepable format all at once
Save Output to a Text File
nmap -oN [scan.txt] [target]
Save Output to a XML File
nmap -oX [scan.xml] [target]
nmap -oG [scan.txt] [target]
Output All Supported File Types
nmap -oA [path/filename] [target]
Periodically Display Statistics
nmap --stats-every [time] [target]
nmap -oS [scan.txt] [target]
ndiff [scan1.xml] [scan2.xml]
ndiff -v [scan1.xml] [scan2.xml]
ndiff --xml [scan1.xml] [scan2.xml]
Troubleshooting and Debugging
Display Port State Reason
nmap --packet-trace [target]
Specify a Network Interface
nmap -e [interface] [target]
Execute Individual Scripts
nmap --script [script.nse] [target]
nmap --script [expression] [target]
Execute Scripts by Category
nmap --script [category] [target]
Execute Multiple Script Categories
nmap --script [category1,category2,etc]
nmap --script [script] --script-trace [target]
Update the Script Database