Host Discovery
Figures out which hosts on a network are up, without touching any ports. The first step on a fresh subnet.
Port Scanning
Probes a known host to see what’s listening and, optionally, what service and version is running behind each port.
The Basics
Before getting into flags, nmap works perfectly fine with no options at all. Pointed at a target, it runs a default SYN scan against the top 1000 ports and reports what’s open.TARGET accepts a few different formats depending on what you’re scanning:
Host Discovery
Before scanning any ports, it’s often worth just figuring out what’s alive on the network. These scans skip port scanning entirely and rely on different probe types depending on how stealthy you need to be.Port Scanning
Once you know a host is up, the next question is what’s actually listening on it. The scan type you pick trades off speed, reliability, and how noisy it is on the wire.Service and OS Detection
Knowing a port is open is only half the picture. Version and OS detection tell you what’s actually running behind it, which is usually what you need to start looking for a known vulnerability.Scripting Engine (NSE)
Nmap ships with a huge library of scripts for everything from banner grabbing to active vulnerability checks, stored under/usr/share/nmap/scripts/. Running the right one against the right port often turns up more than the scan itself.
Firewall and IDS Evasion
Fragmenting packets splits them below the size some filters inspect at:Flags Reference
Host discovery and ping flags
Host discovery and ping flags
Scan type and target flags
Scan type and target flags
Detection and scripting flags
Detection and scripting flags
Evasion and spoofing flags
Evasion and spoofing flags
Output and performance flags
Output and performance flags
Parsing Results
Grep-friendly output (-oG) is the easiest format to pull quick stats out of without writing a parser. This one-liner tallies up how often each service version shows up across a whole scan:
awesome-nmap-grep has more parsing one-liners along these lines for
.gnmap output.Quick Reference Tools
Nmap Reference Guide
The official Nmap documentation, useful for anything not covered here.
awesome-nmap-grep
Parsing tricks and one-liners for working with
.gnmap output.
