Nmap (Network Mapper) is a powerful and versatile open-source tool used for network exploration, port scanning, service and version detection, security auditing, and network performance assessment. It caters to a broad spectrum of users, ranging from ethical hackers to network administrators. In this comprehensive guide, we’ll explore the fundamentals of Nmap and provide you with a handy cheat sheet to get started.
Understanding Nmap
Nmap operates by sending packets to the target hosts and analyzing their responses. It can discover hosts available on the network, find open ports, identify services running on those ports, and even determine the operating system of the target.
Target Specification
Switch
Example
Description
nmap 192.168.1.1
Scan a single IP
nmap 192.168.1.1 192.168.2.1
Scan specific IPs
nmap 192.168.1.1-254
Scan a range
nmap scanme.nmap.org
Scan a domain
nmap 192.168.1.0/24
Scan using CIDR notation
-iL
nmap -iL targets.txt
Scan targets from a file
-iR
nmap -iR 100
Scan 100 random hosts
–exclude
nmap –exclude 192.168.1.1
Exclude listed hosts
Scan Techniques
Switch
Example
Description
-sS
nmap 192.168.1.1 -sS
TCP SYN port scan (Default)
-sT
nmap 192.168.1.1 -sT
TCP connect port scan (Default without root privilege)
-sU
nmap 192.168.1.1 -sU
UDP port scan
-sA
nmap 192.168.1.1 -sA
TCP ACK port scan
-sW
nmap 192.168.1.1 -sW
TCP Window port scan
-sM
nmap 192.168.1.1 -sM
TCP Maimon port scan
Host Discovery
Switch
Example
Description
-sL
nmap 192.168.1.1-3 -sL
No Scan. List targets only
-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.
-PS
nmap 192.168.1.1-5 -PS22-25,80
TCP SYN discovery on port x. Port 80 by default.
-PA
nmap 192.168.1.1-5 -PA22-25,80
TCP ACK discovery on port x. Port 80 by default.
-PU
nmap 192.168.1.1-5 -PU53
UDP discovery on port x. Port 40125 by default.
-PR
nmap 192.168.1.1-1/24 -PR
ARP discovery on the local network
-n
nmap 192.168.1.1 -n
Never do DNS resolution
Port Specification
Switch
Example
Description
-p
nmap 192.168.1.1 -p 21
Port scan for a specific port (e.g., port 21)
-p
nmap 192.168.1.1 -p 21-100
Port range scan (e.g., ports 21 to 100)
-p
nmap 192.168.1.1 -p U:53,T:21-25,80
Scan multiple TCP and UDP ports
-p-
nmap 192.168.1.1 -p-
Scan all ports (1 to 65535)
-p
nmap 192.168.1.1 -p http,https
Port scan using service names (e.g., http, https)
-F
nmap 192.168.1.1 -F
Fast port scan (scan the 100 most common ports)
–top-ports
nmap 192.168.1.1 –top-ports 2000
Port scan the top x most common ports
-p-65535
nmap 192.168.1.1 -p-65535
Scan all ports starting from port 1
-p0-
nmap 192.168.1.1 -p0-
Scan all ports up to port 65535
Service and Version Detection
Switch
Example
Description
-sV
nmap 192.168.1.1 -sV
Attempts to determine the version of the service running on each port
-sV –version-intensity
nmap 192.168.1.1 -sV –version-intensity 8
Specifies the version detection intensity level from 0 to 9, with higher values increasing the possibility of correctness
-sV –version-light
nmap 192.168.1.1 -sV –version-light
Enables light mode for version detection, providing faster results with a lower possibility of correctness
-sV –version-all
nmap 192.168.1.1 -sV –version-all
Enables intensity level 9 for version detection, offering a higher possibility of correctness at the cost of slower scanning
-A
nmap 192.168.1.1 -A
Enables comprehensive scanning, including OS detection, version detection, script scanning, and traceroute
OS Detection
Switch
Example
Description
-O
nmap 192.168.1.1 -O
Remote OS detection using TCP/IP stack fingerprinting
-O –osscan-limit
nmap 192.168.1.1 -O –osscan-limit
If at least one open and one closed TCP port are not found, it will not try OS detection against the host
-O –osscan-guess
nmap 192.168.1.1 -O –osscan-guess
Makes Nmap guess more aggressively during OS detection
-O –max-os-tries
nmap 192.168.1.1 -O –max-os-tries 1
Sets the maximum number of OS detection tries (x) against a target
-A
nmap 192.168.1.1 -A
Enables comprehensive scanning, including OS detection, version detection, script scanning, and traceroute
Timing and Performance
Switch
Example
Description
-T0
nmap 192.168.1.1 -T0
Paranoid (0) Intrusion Detection System evasion
-T1
nmap 192.168.1.1 -T1
Sneaky (1) Intrusion Detection System evasion
-T2
nmap 192.168.1.1 -T2
Polite (2) slows down the scan to use less bandwidth and target machine resources
-T3
nmap 192.168.1.1 -T3
Normal (3), which is the default speed for scans
-T4
nmap 192.168.1.1 -T4
Aggressive (4) speeds up scans; assumes you are on a reasonably fast and reliable network
-T5
nmap 192.168.1.1 -T5
Insane (5) speeds up scans; assumes you are on an extraordinarily fast network
An explanation of the -D switch, allowing you to send scans from multiple decoy IP addresses.
-S
nmap -S www.microsoft.com www.facebook.com
Scan a target (e.g., Facebook) from a different source (e.g., Microsoft). Use with caution, as this involves IP address spoofing. Additional options like -e eth0 -Pn may be required.
-g
nmap -g 53 192.168.1.1
Use a given source port number (e.g., source port 53).
This Nmap cheat sheet provides you with essential commands to start using Nmap effectively. However, Nmap offers a plethora of advanced and complex scanning options for various scenarios. To delve deeper into Nmap’s capabilities, consider exploring the official documentation.
Remember to use Nmap responsibly and ethically, respecting legal boundaries and permissions when scanning networks or systems.
Nmap is a valuable tool in the world of network security and administration. By mastering its usage, you can enhance your ability to assess network vulnerabilities, identify security risks, and maintain robust network infrastructure.
Post Views:293
1 thought on “Nmap: A Comprehensive Guide and Cheat Sheet”
Hi! I want to say that this article is amazing, great written and come with almost all significant infos. I would like to look more posts like this .
Hi! I want to say that this article is amazing, great written and come with almost all significant infos. I would like to look more posts like this .