Nmap Cheatsheet

Written by Alireza Liaghat || Reviewed by Dale Hobbs

This blog is part of Offensive Tooling Cheatsheets: An Infosec Survival Guide Resource. You can learn more and find all of the cheatsheets HERE: https://www.blackhillsinfosec.com/offensive-tooling-cheatsheets/

Nmap Cheatsheet: PRINT-FRIENDLY PDF

Find the tool here: https://nmap.org/


Nmap is a powerful open-source tool commonly used by system/network administrators and security professionals to perform network discovery, security auditing, and basic vulnerability assessment. Nmap allows you to quickly identify live hosts, open ports, running services, operating systems, and potential security risks within a network. This cheatsheet provides a reference to essential Nmap commands, scanning techniques, and common use cases to help streamline your network reconnaissance and troubleshooting tasks.

The Nmap Formula

Nmap + Target + Type + Port + Detection + Timing + Scripts + Evasion

TARGET

What do you want to scan?

ExampleDescriptionUse Case
192.168.x.xScan the specified IP addressUsed when there is only one target IP address.
domain.comScan the specified domainUsed when there is only one target domain.
-iL target.txtScan from a list of host addressesUsed when searching a known range of hosts.
--uniqueScans each address only onceUsed in combination with lists. Avoids duplicate scans to speed up the scan.
-nNo DNS resolutionSpeeds up scanning by skipping reverse DNS resolution.

TYPE

How do you want to scan?

ExampleDescriptionUse Case
-sTFull TCP 3-Way Handshake ScanMost reliable scan. Use when not worried about firewalls.
-sS“Stealth” scan. Impartial 3-Way HandshakeDoes not establish a full handshake. “Dumb” firewalls will only see this as regular poor connection.
-sUScan using UDPPreferred for scanning DNS (53), SNMP (161), DHCP (67), TFTP (69), etc.

PORT

What port do you want to scan?

ExampleDescriptionUse Case
-p 80,443Scans only the comma-separated portsUseful for when scanning a host for a specific attack surface.
-p 1-65535Scans all possible portsUseful for all ports in use, including ephemeral (temporary) ports.

DETECTION

What do you want to detect?

ExampleDescriptionUse Case
-sVProbe for service/versionUseful for when mapping and identifying a network
--version-lightTry the most likely probes for detectionUseful for when mapping and identifying a network.
--version-allTry every available probe (max intensity)Useful for when mapping and identifying a network..
-OOS DetectionUseful for when mapping and identifying a network.

TIMING

How fast do you want to scan?

ExampleDescriptionUse Case
--max-rate 5Sends a maximum of 5 probes per secondLimits network traffic to avoid disruptions to the network.
--scan-delay 1Adds 1 second delay between probesLimits network traffic to avoid disruptions to the network.
--host-timeout 1Give up on a particular port after 1 secondLimits network traffic and useful for slow responding devices.

SCRIPTS

What additional scripts do you want?

ExampleDescriptionUse Case
--script=whoisSpoofs the source IP addressUsed when mapping a network.
--scripts=smb-enum-sharesAdds random data to packetsIdentifies SMB shares that might be exposed.
--script=vulnersUses a proxy to scanIdentifies known/unpatched vulnerabilities in a network.

EVASION

How sneaky do you want to be?

ExampleDescriptionUse Case
-spoof-mac 00:0C:29:6F:F3:6BSpoofs the source MAC addressUseful for when the network switch restricts connectivity using MAC addresses
S 192.168.1.1Spoofs the source IP addressUseful for when the network switch restricts connectivity using IP addresses
--data-length 5Adds random data to packetsUseful for when trying to camouflage the network traffic caused by the scan
--proxies 192.168.5.5Uses a proxy to scanUseful for when navigating a scan through an IP-based filter

Example formula of a slow and thorough search:

nmap 192.168.10.50 -sT -p1-65535 -version-light -max-rate 5 --script=vulners -S 192.168.1.1 

Common Port States

open: An application is actively accepting TCP connections or UDP datagrams on this port.
closed:The port is accessible. Nmap probes received a response but was indicated that there is no application listening.
filtered:Nmap cannot determine if the port is open. This could be caused by firewalls dropping packets or by network congestion.


Explore the Infosec Survival Guide and more… for FREE!

Get instant access to all issues of the Infosec Survival Guide, as well as content like our self-published infosec zine, PROMPT#, and exclusive Darknet Diaries comics—all available at no cost.

You can check out all current and upcoming issues here: https://www.blackhillsinfosec.com/prompt-zine/