Nmap Cheat Sheet: From Beginner to Expert Pentesters
Basic Scanning #
- Scan a single host:bashCopyEdit
nmap 192.168.1.1
- Scan multiple hosts:bashCopyEdit
nmap 192.168.1.1 192.168.1.2 192.168.1.3
- Scan a subnet:bashCopyEdit
nmap 192.168.1.0/24
- Scan a range of IPs:bashCopyEdit
nmap 192.168.1.1-100
- Scan a domain:bashCopyEdit
nmap example.com
Port Scanning #
- Scan common ports (default):bashCopyEdit
nmap -F 192.168.1.1
- Scan specific ports:bashCopyEdit
nmap -p 22,80,443 192.168.1.1
- Scan all 65,535 ports:bashCopyEdit
nmap -p- 192.168.1.1
- Scan UDP ports:bashCopyEdit
nmap -sU -p 53,161 192.168.1.1
- Scan top 1000 ports faster:bashCopyEdit
nmap --top-ports 100 192.168.1.1
Advanced Scanning #
- Service and version detection:bashCopyEdit
nmap -sV 192.168.1.1
- OS detection:bashCopyEdit
nmap -O 192.168.1.1
- Aggressive scan (OS, version, scripts, traceroute):bashCopyEdit
nmap -A 192.168.1.1
- Scan with NSE (Nmap Scripting Engine):bashCopyEdit
nmap --script=vuln 192.168.1.1
Firewall Evasion & Stealth Scanning #
- Fragment packets to bypass IDS/IPS:bashCopyEdit
nmap -f 192.168.1.1
- Randomize scan order:bashCopyEdit
nmap -r 192.168.1.1
- Decoy scan (confuses IDS):bashCopyEdit
nmap -D RND:10 192.168.1.1
- Scan with spoofed source IP:bashCopyEdit
nmap -S 192.168.1.100 192.168.1.1
- Scan using a fake MAC address:bashCopyEdit
nmap --spoof-mac 00:11:22:33:44:55 192.168.1.1
- Idle scan (completely stealthy):bashCopyEdit
nmap -sI zombie_host 192.168.1.1
Bypassing Firewalls #
- Use NULL scan (no TCP flags):bashCopyEdit
nmap -sN 192.168.1.1
- Use FIN scan:bashCopyEdit
nmap -sF 192.168.1.1
- Use XMAS scan:bashCopyEdit
nmap -sX 192.168.1.1
- Use slow scan to avoid detection:bashCopyEdit
nmap -T2 192.168.1.1
- Use an HTTP proxy to scan:bashCopyEdit
nmap --proxies http://proxy:8080 192.168.1.1
NSE (Nmap Scripting Engine) #
- Detect vulnerabilities:bashCopyEdit
nmap --script=vuln 192.168.1.1
- Check for SMB vulnerabilities:bashCopyEdit
nmap --script=smb-vuln* 192.168.1.1
- Run multiple scripts:bashCopyEdit
nmap --script=http-enum,ftp-anon 192.168.1.1
- Scan for CVE exploits:bashCopyEdit
nmap --script=vulners 192.168.1.1
Network Mapping & Host Discovery #
- List live hosts (no port scan):bashCopyEdit
nmap -sn 192.168.1.0/24
- Find open ports without pinging first:bashCopyEdit
nmap -Pn 192.168.1.1
- Traceroute with Nmap:bashCopyEdit
nmap --traceroute 192.168.1.1
Saving and Exporting Results #
- Save output in normal format:bashCopyEdit
nmap -oN output.txt 192.168.1.1
- Save output in XML format:bashCopyEdit
nmap -oX output.xml 192.168.1.1
- Save output in all formats:bashCopyEdit
nmap -oA scan_results 192.168.1.1
- View Nmap XML output in a readable format:bashCopyEdit
cat output.xml | xsltproc -o output.html
Scan Timing and Performance #
- Scan as fast as possible:bashCopyEdit
nmap -T5 192.168.1.1
- Paranoid scan (avoiding detection):bashCopyEdit
nmap -T0 192.168.1.1
- Aggressive scan (faster but noisy):bashCopyEdit
nmap -T4 192.168.1.1
Evading Intrusion Detection Systems (IDS) #
- Use random port scanning:bashCopyEdit
nmap -p- -T2 --randomize-hosts 192.168.1.1
- Scan with minimum packets per second:bashCopyEdit
nmap --min-rate 10 192.168.1.1
Detecting Honeypots #
- Check for honeypots:bashCopyEdit
nmap --script=honeypot-detect 192.168.1.1
Brute-Forcing with NSE #
- Brute force SSH login:bashCopyEdit
nmap --script=ssh-brute -p 22 192.168.1.1
- Brute force HTTP authentication:bashCopyEdit
nmap --script=http-brute -p 80 192.168.1.1
- Brute force MySQL login:bashCopyEdit
nmap --script=mysql-brute -p 3306 192.168.1.1