root@thehacksparrow:~/writeups$ SYSTEM ONLINE
root@sparrow:~/writeups$ cat nmap.md
// recon

Nmap

21 Jul 2026 · 5 min read
Before you exploit anything, you need to know what is out there. Nmap is the first tool anyone picks up when getting into offensive security, and it is still in use in advanced engagements. This cheat sheet covers it at two levels: beginner (host discovery, port scanning and service/OS detection) and advanced (stealth scans, IP/MAC spoofing and IDS evasion).

Nmap is not just «seeing open ports». What really makes the difference is understanding how it asks: a SYN scan never completes the handshake, an ACK scan looks for firewall rules rather than services, and timing (-T) decides whether the IDS sees you.

1. Beginner level — discovery and scanning

Nmap cheat sheet — Beginner
CommandWhat it does
nmap <objetivo>Default scan, top 1000 TCP ports
nmap -sn 10.10.10.0/24Discover live hosts, no port scan
nmap -Pn <objetivo>Skip host discovery, assume host is up
nmap -p 80,443 <objetivo>Scan only the given ports
nmap -p- <objetivo>Scan all 65535 TCP ports
nmap -F <objetivo>Fast mode, top 100 ports
nmap -sV <objetivo>Detect the version of each service
nmap -O <objetivo>Detect the operating system
nmap -sC <objetivo>Run the default NSE scripts
nmap -A <objetivo>OS + version + scripts + traceroute
nmap -sU -p 53,161 <objetivo>UDP port scan
nmap -oN scan.txt <objetivo>Save output in plain text
nmap -oA scan <objetivo>Save in all three formats at once
nmap -v <objetivo>Increase output verbosity

2. Advanced level — stealth, spoofing and evasion

Nmap cheat sheet — Advanced
CommandWhat it does
nmap -sS <objetivo>SYN scan: never completes the handshake
nmap -sT <objetivo>Connect scan: full TCP handshake
nmap -sF <objetivo>FIN scan, evades stateless filters
nmap -sX <objetivo>Xmas scan: FIN, PSH and URG flags
nmap -sN <objetivo>Null scan: no TCP flags at all
nmap -sA <objetivo>ACK scan: maps firewall rules
nmap -D RND:10 <objetivo>Decoys: hides your IP among 10 fake ones
nmap -S <ip> -e eth0 <objetivo>Spoof the packet source IP
nmap --spoof-mac 0 <objetivo>Use a random source MAC address
nmap -g 53 <objetivo>Set a fixed source port (DNS)
nmap -f <objetivo>Fragment the IP packets
nmap --mtu 16 <objetivo>Fragment using a custom MTU
nmap -T2 <objetivo>Slow timing to stay under alarms
nmap --script vuln <objetivo>NSE vulnerability scripts

3. Details people miss

  • -sS requires root; without privileges Nmap silently falls back to -sT.
  • FIN, Xmas and Null scans do not work against Windows: its TCP stack always replies RST, so everything looks «closed».
  • -p- across a whole network is painfully slow. Scan fast first, then go deep only on hosts with open ports.
  • With -S (spoofed IP) you will not see the replies: they go back to the address you spoofed, not to you.
  • Using -oA from the start saves you re-scanning: normal, greppable and XML output in a single pass.

Responsible use

These commands are for systems you own or have explicit written authorisation to test (labs, CTFs, contracted engagements). Scanning third-party infrastructure without permission is illegal in most countries.