If you have already run nmap -sV -sC 192.168.1.0/24 a hundred times, you know the basics. This guide is about everything that comes after the basics — the flags, scan types, and scripts that separate a noisy first-year scan from a controlled, deliberate assessment that maps a target the way a real adversary would.
We will work through the special TCP scan types (Null, FIN, Xmas, ACK, Window, Maimon, and the idle/zombie scan), timing and rate tuning, the full firewall and IDS evasion toolkit, a proper tour of the Nmap Scripting Engine (NSE), output formats built for automation, and — because CyberHawk is a blue-team shop first — a full section on how defenders detect every technique here with firewall logs, KQL, and SPL.
This is the advanced companion to our Nmap Complete Tutorial. Everything below assumes you can already install Nmap and run a basic scan. Use it only on networks you own or are explicitly authorised to test.
◈ Table of Contents
01 — WHAT "ADVANCED NMAP" MEANS
CONTEXTNmap ("Network Mapper") has been the reference network scanner since 1997, and it is still actively developed — you should be running the 7.9x series (verify with nmap --version; 7.95 is the widely packaged baseline). Basic Nmap answers "which ports are open?" Advanced Nmap answers four harder questions: How do I get an accurate answer through a firewall? How do I do it without lighting up the SOC? How do I turn a port list into real service intelligence? And — if I am defending — how do I catch someone doing all of the above?
Every technique in this guide is dual-use. A red teamer uses idle scans and decoys to stay quiet; a blue teamer needs to understand those same techniques to write detections that actually fire. Here is where these skills pay off:
External Perimeter Audit
Enumerate an internet-facing range through NAT and cloud firewalls, distinguishing filtered from closed to map the real attack surface.
Segmentation Testing
Prove whether a VLAN or micro-segmentation policy actually blocks lateral traffic using ACK and Window scans from inside each zone.
Red Team Recon
Fingerprint services and pull low-hanging vulnerabilities with NSE while keeping timing and packet signatures under IDS thresholds.
Purple Team Detection Tuning
Generate known scan patterns on demand to validate that firewall, IDS, and SIEM rules detect them — and to measure your alert latency.
02 — PREREQUISITES & LAB SETUP
SETUPAdvanced scanning relies on raw packet crafting, so privileges, drivers, and a safe target matter more here than in a basic connect scan. This is the baseline you need before any command in this guide will behave the way it is documented.
| Requirement | Recommendation | Why it matters |
|---|---|---|
| Nmap version | 7.95+ (7.9x series) | Newer scan engine, current NSE library and OS/version fingerprints |
| Privileges | root / Administrator | Raw sockets are required for -sS, -sN/-sF/-sX, -sA, -sI, decoys and fragmentation |
| OS | Kali / Ubuntu / any Linux | Cleanest raw-socket support; Windows needs the Npcap driver |
| Packet driver | libpcap (Linux) / Npcap (Windows) | Without it, Nmap silently falls back to a TCP connect scan |
| Lab targets | Metasploitable, VulnHub, own VMs | A legal target range for evasion practice — never scan third parties |
| Firewall to test | pfSense / OPNsense / iptables VM | Something between you and the target so filtering behaviour is real |
Before anything else, confirm which Nmap you are actually running and that raw-socket features are compiled in. The --version output lists the libpcap/Npcap version and enabled features.
Nmap.org runs scanme.nmap.org as an explicit, authorised scan target for learning. Do not hammer it — a handful of scans is fine; a 65,535-port sweep on a loop is abuse.
Evasion techniques are meaningless without something to evade. The fastest legal lab is two VMs plus a Linux host acting as a filtering router with iptables, so you can watch how each scan type reacts to different rules.
DROP produces a filtered result (no reply); REJECT with tcp-reset produces closed. Learning to read that difference is the single most useful firewall-mapping skill Nmap teaches.
03 — STEALTH & SPECIAL SCAN TYPES
COREThe default SYN scan (-sS) is fine for most work, but Nmap ships a whole family of scan types that craft unusual TCP flag combinations. They exist to probe stateless firewalls, distinguish filtered from closed ports, and generate traffic that some IDS signatures were never written to catch. Their behaviour depends heavily on the target's TCP stack.
| Flag | Scan type | Best used for |
|---|---|---|
| -sS | TCP SYN (half-open) | Default; fast, relatively quiet, needs root |
| -sT | TCP Connect | No root; fully logged by the target |
| -sN / -sF / -sX | Null / FIN / Xmas | Bypassing some non-stateful filters on RFC-793 stacks |
| -sA | TCP ACK | Mapping firewall rules (filtered vs unfiltered), not open ports |
| -sW | TCP Window | ACK-scan variant that can infer open ports on some stacks |
| -sM | TCP Maimon | FIN/ACK probe effective against some older BSD systems |
| -sI | Idle / zombie | Truly blind scanning — your IP never touches the target |
| --scanflags | Custom flags | Hand-crafted TCP flag combinations for research/evasion |
These three send packets with no SYN flag: Null sets no flags at all, FIN sets only FIN, and Xmas lights up FIN, PSH and URG ("like a Christmas tree"). Per RFC 793, a compliant stack replies with RST to a closed port and stays silent on an open one — so no response is read as open|filtered. The catch: Windows, Cisco IOS and many modern stacks reply RST to everything, making every port look closed.
If a Null/FIN/Xmas scan reports every port as open|filtered or every port as closed, the target's stack is telling you what OS family it is — treat the result as a fingerprint, not a port list.
The ACK scan (-sA) never tells you whether a port is open. It sends a bare ACK packet: an unfiltered port (open or closed) replies RST and is labelled unfiltered; a stateful firewall that drops the packet leaves it filtered. That makes the ACK scan the single best tool for discovering whether a firewall is stateful and which ports it guards.
The Window scan (-sW) is an ACK scan that inspects the TCP window field of returned RST packets — on a handful of stacks a positive window means open and zero means closed. The Maimon scan (-sM) sends a FIN/ACK; RFC-793-compliant BSD-derived systems drop the packet for open ports. Both are niche, but when they work they succeed exactly where SYN scans are being filtered.
Treat -sW and -sM results as hypotheses. Always confirm a suspected open port with a version scan (-sV) before you act on it — these scans lie on the majority of modern stacks.
When the built-in scan types are not enough, --scanflags lets you set any combination of TCP flags (URG, ACK, PSH, RST, SYN, FIN) by name or as a numeric value. This is how you test whether an IDS signature keys on a specific flag pattern, or craft a probe an inline device has never seen.
The idle scan is the stealthiest technique Nmap offers: your real IP address never sends a single packet to the target. Instead you bounce the scan off a "zombie" — a third host with a predictable, incrementing IP ID (IPID) sequence that is otherwise idle. By watching how the zombie's IPID jumps, Nmap infers which target ports are open. To the target, the scan appears to come entirely from the zombie.
Idle scans are slow and fragile: any other traffic to the zombie corrupts its IPID counter and poisons your results. Pick a genuinely idle host (a network printer or appliance is classic) and keep the port set small.
04 — TIMING & PERFORMANCE TUNING
TUNINGTiming is where scanning becomes an art. Go too fast and you trip rate-based IDS alerts and drop packets on congested links; go too slow and a full sweep takes days. Nmap gives you both a set of one-letter presets and fine-grained knobs to override them.
| Template | Name | Behaviour & use |
|---|---|---|
| -T0 | Paranoid | Serial, ~5 min between probes — IDS evasion, extremely slow |
| -T1 | Sneaky | Serial, ~15 s between probes — quiet, still slow |
| -T2 | Polite | Slows to use less bandwidth on fragile networks |
| -T3 | Normal | Default balanced behaviour |
| -T4 | Aggressive | Fast; fine for modern LANs and most engagements |
| -T5 | Insane | Very fast; sacrifices accuracy, may miss ports |
The template sets sensible defaults for parallelism, timeouts and probe delay all at once. Start with -T4 on a healthy internal network, drop to -T1 or -T0 when you are deliberately trying to stay under a detection threshold.
The templates are shortcuts; for real control override them with explicit rate and delay flags. --min-rate/--max-rate bound packets per second, and --scan-delay forces a wait between probes to a single host — the most reliable way to defeat "N connections in M seconds" IDS logic.
To evade rate-based detection, the knob that matters is --scan-delay, not --max-rate. Detection thresholds count connections per source over a window; a deliberate delay keeps you under the count even at otherwise normal speed.
On lossy links (VPNs, satellite, throttled WAN) accuracy comes from tuning retries and timeouts rather than raw speed. Reducing --max-retries speeds up huge sweeps; raising it recovers ports on flaky paths. --host-timeout stops one dead host from stalling a whole range.
05 — DETECTING & MAPPING FIREWALLS
RECONBefore you try to evade a firewall, map it. Nmap can tell you whether filtering is stateful, which ports are guarded, and often what kind of device is in the path — all before you send a single evasion packet.
The most valuable output Nmap gives you is not "open" — it is the difference between closed (a reachable host that actively refused the port) and filtered (something dropped the packet in transit). Combine a SYN scan with an ACK scan and use --reason to see exactly which packet drove each verdict.
| State | Meaning | Likely cause |
|---|---|---|
| open | Service accepted the probe | Listening service |
| closed | Host replied RST | Reachable host, no service, no filter |
| filtered | No reply / ICMP unreachable | Firewall DROP rule in the path |
| unfiltered | ACK got through (state unknown) | No stateful firewall on that port |
When results do not make sense, drop to --packet-trace to watch every probe and reply on the wire. ICMP "administratively prohibited" (type 3, code 13) messages are a firewall's fingerprint — they tell you a device, not the host, is refusing you.
Several NSE scripts help identify what is filtering you — from WAFs in front of web apps to load balancers that spread you across back-ends. Knowing the device type tells you which evasion techniques are even worth trying.
If http-waf-detect fires, legacy packet-level tricks (fragmentation, source-port) will not help you — the inspection is happening at layer 7. Focus on request-level evasion instead, which is out of scope for Nmap.
06 — FIREWALL / IDS EVASION & SPOOFING
EVASIONNmap bundles a full set of evasion and spoofing options. Be realistic about them: fragmentation and source-port tricks are largely legacy techniques that a modern, well-configured firewall handles correctly. They remain useful against older or misconfigured devices, and they are essential to understand so you can detect them — but none of them is a reliable bypass for a current security stack.
| Flag | Technique | What it does |
|---|---|---|
| -f / -ff | Fragmentation | Splits the TCP header across tiny IP fragments |
| --mtu | Custom fragment size | Sets fragment size (multiple of 8) |
| -D | Decoys | Mixes your probes with spoofed decoy sources |
| -S | Spoof source IP | Forges the source address (needs -e) |
| -g / --source-port | Source-port spoof | Sends from a "trusted" port such as 53 or 80 |
| --data-length | Payload padding | Appends random bytes to change packet size signatures |
| --spoof-mac | MAC spoofing | Forges the Ethernet source MAC (LAN only) |
| --badsum | Bad checksum | Elicits replies only from certain IDS/IPS stacks |
| --proxies | Proxy chain | Routes connect scans through HTTP/SOCKS4 proxies |
Fragmentation splits the TCP header over several small IP fragments so that a packet filter inspecting only the first fragment never sees the flags. -f uses 8-byte data fragments, -ff uses 16, and --mtu sets an explicit size (always a multiple of 8). A firewall that reassembles fragments before inspecting — which any modern one does — defeats this entirely.
Decoys make the scan appear to originate from several IP addresses at once. The target's logs and IDS show port scans from every decoy plus your real IP mixed in, so an analyst cannot easily tell which source is real. Use ME to control where your own address sits in the list, or RND for random decoys.
Decoy IPs must be alive, or the target's admin can trivially rule them out (and spraying spoofed sources may itself trigger anti-spoofing controls). Decoys hide who, never that a scan happened.
Some firewalls trust traffic based on where it appears to come from. -S forges the source IP (you must specify the interface with -e and you will not see replies unless you can sniff the spoofed address's network). -g/--source-port sends from a port firewalls often whitelist, such as DNS 53 or HTTP 80.
These smaller tricks defeat specific, brittle signatures. --data-length appends random bytes so packets no longer match a fixed-size signature; --spoof-mac forges the Ethernet source (LAN-only, and accepts a vendor name); --badsum sends deliberately invalid checksums — a compliant stack silently drops them, so any reply proves an IDS/IPS or proxy is answering on the host's behalf.
--badsum is a detection tool disguised as an evasion tool: if you get replies, an inline security appliance is generating them. Use it to find IPS devices, not to bypass them.
--proxies routes TCP connect scans and some NSE traffic through a chain of one or more HTTP or SOCKS4 proxies, so the connection reaches the target from the last proxy's address. It only works with connection-based scans (-sT), not raw-packet scans, but it is invaluable when pivoting through a compromised host or a jump box.
Everything in this section is far more legally serious than a plain scan. Spoofing and evasion against systems you do not own is, in many jurisdictions, a distinct offence from unauthorised scanning. Keep it in the lab.
07 — THE NMAP SCRIPTING ENGINE (NSE)
NSENSE is what turns Nmap from a port scanner into a reconnaissance and vulnerability framework. It runs Lua scripts against discovered services to do everything from grabbing banners and testing default credentials to checking for named CVEs. The stock install ships with 600+ scripts, organised into 14 categories.
| Category | What the scripts do |
|---|---|
| default (-sC) | Safe, useful scripts run automatically with -sC |
| discovery | Enumerate more about the target (hosts, services, shares) |
| safe | Non-intrusive; unlikely to crash or trip anything |
| version | Advanced service/version detection extensions |
| auth / brute | Auth bypass checks and credential brute-forcing |
| vuln | Check for specific known vulnerabilities |
| exploit | Actively attempt to exploit a vulnerability |
| intrusive / dos / fuzzer | Noisy, risky, or potentially disruptive — use with care |
| malware / broadcast / external | Backdoor checks, LAN broadcast recon, third-party lookups |
You can run scripts by name, by wildcard, by category, or with a boolean expression combining them. -sC is shorthand for --script default. Wildcards make it easy to run every script for a protocol, and expressions let you scope to safe scripts only.
Many scripts take arguments — wordlists for brute-forcing, credentials, HTTP paths, timeouts. Pass them with --script-args, or load a whole file of them with --script-args-file. Read a script's own documentation with --script-help before you run it.
After upgrading Nmap or dropping a new .nse file into the scripts directory, rebuild the script database so --script can find it by name and category. The scripts live in a well-known path you can inspect directly.
NSE scripts are Lua. A minimal script declares metadata (description, categories), a portrule that decides when it runs, and an action that does the work. Save this as /usr/share/nmap/scripts/cyberhawk-banner.nse, run --script-updatedb, and call it by name.
Categorise custom scripts honestly. Tag anything that logs in, writes data, or could crash a service as intrusive — never safe — so a boolean like "safe and not intrusive" keeps it out of production scans.
08 — NSE IN PRACTICE
HANDS-ONHere is how the categories translate into real assessment work: enumerate a service, test its authentication, then check it for known vulnerabilities — escalating noise deliberately as you go.
Enumeration scripts pull the detail that a plain -sV misses: SMB shares and OS, HTTP directories and titles, DNS records, SSL certificate data. This is the bread and butter of the recon phase.
The auth and brute categories test for default and weak credentials across dozens of protocols. These are intrusive and will lock accounts if you are careless — throttle them and get written authorisation first.
Brute-force scripts trip account lockout, MFA fatigue and SOC alerts instantly. Never run the brute category against production without an explicit, signed rules-of-engagement scope.
The vuln category checks services for specific known flaws and reports CVE identifiers. For broader coverage, community scripts like vulners (which queries a CVE database using the versions Nmap detected) extend this considerably — install them into the scripts directory and update the DB.
NSE vuln checks confirm reachability and version, not exploitability. Always validate an NSE finding against the vendor advisory and the exact CVE before you report it — version banners can be spoofed or back-ported.
09 — OUTPUT, REPORTING & AUTOMATION
WORKFLOWA scan that only lives in your terminal is a scan you cannot diff, report, or feed to another tool. Nmap's output formats are built for automation — capture everything, then parse it downstream.
Nmap writes normal (-oN), XML (-oX), and grepable (-oG) output. -oA basename writes all three at once — the correct default for any real engagement, so you never lose data to a closed terminal.
Grepable output is trivial to slice with shell tools; XML is the format every downstream tool understands. Convert XML to a readable HTML report with the bundled XSL stylesheet, or feed the grepable file straight into a one-liner to extract open ports.
Long scans die; --resume picks up where a saved run left off. ndiff compares two XML scans so you can alert on new ports appearing over time — an excellent lightweight attack-surface monitor. And XML imports cleanly into Metasploit for the next phase.
A weekly cron job of nmap -oX plus ndiff against the previous run is one of the cheapest external attack-surface monitors you can build — it emails you the moment a new port opens on your own perimeter.
10 — HOW BLUE TEAMS DETECT NMAP
DEFENSEEvery technique above leaves a footprint. A horizontal scan is one source touching many ports on one host; a vertical scan is one source touching one port across many hosts. Both show up as a spike in connection attempts — often to closed/filtered destinations — from a single source in a short window. Here is how to catch that in a SIEM.
The reliable signal is fan-out: one source IP hitting an abnormal number of distinct destination ports (or hosts) in a short window. Below are paired queries over firewall/network logs — the KQL runs in Microsoft Sentinel; the SPL is the Splunk equivalent.
Null/FIN/Xmas scans are trivial to spot because their flag combinations never occur in legitimate traffic — a TCP packet with no flags, or FIN without an established session, is inherently anomalous. Decoy scans still generate the fan-out pattern above; the decoys just add noise you should correlate, not filter out.
You cannot stop scanning outright, but you can raise its cost and guarantee detection. The goal is a stateful, default-deny firewall that reassembles fragments, plus IDS scan-tracking and rate limiting so any sweep is both blocked and alerted.
- 1Default-deny + stateful: drop unsolicited packets so scans return
filtered, giving attackers less state information. - 2Reassemble fragments: ensure the firewall inspects reassembled packets, neutralising
-f/--mtu. - 3Enable IDS scan detection: Suricata/Snort and Zeek all ship scan-tracking; turn it on and forward alerts to the SIEM.
- 4Rate-limit new connections: iptables
hashlimitor equivalent slows sweeps and creates a clean log signal. - 5Anti-spoofing (BCP 38): uRPF/ingress filtering blocks the forged sources used by
-Sand decoys.
11 — TROUBLESHOOTING & COMMON PITFALLS
FIX-ITMost "Nmap is broken" complaints are one of a small set of predictable issues. Work through this table before you blame the tool.
| Symptom | Likely cause | Fix |
|---|---|---|
| All ports show "closed" on -sN/-sF/-sX | Windows/modern stack replies RST to everything | Use -sS; treat the result as an OS fingerprint |
| "You requested a scan type which requires root" | Raw sockets need privileges | Run with sudo; on Windows run as Administrator |
| Every host reported "down", nothing scanned | ICMP/probe host-discovery blocked | Add -Pn to skip host discovery |
| Windows scan falls back to connect scan | Npcap driver missing | Reinstall Nmap and include the Npcap driver |
| Idle scan gives garbage/inconsistent results | Zombie is not idle or IPID not incremental | Pick a truly idle host; verify with -O |
| Scan is unbearably slow | UDP scan, or -T0/-T1, or lossy link | Raise timing (-T4), set --host-timeout, limit ports |
| --script name not found | Script DB stale after upgrade/new script | Run sudo nmap --script-updatedb |
| Spoofed-source scan returns no results | Replies go to the spoofed IP, not you | Only usable when you can sniff the spoofed network |
Golden rule for every command in this guide: scan only assets you own or have explicit written authorisation to test. Evasion and spoofing techniques carry heavier legal penalties than basic scanning — the lab is the only safe place to practise them.
12 — SOURCES & REFERENCES
REFPrimary documentation and authoritative references used for this guide:
⚠️ Authorised use only.
Nmap's advanced scan types, evasion options, and NSE scripts are powerful reconnaissance and testing tools intended for security professionals working on systems they own or are explicitly contracted to assess. Unauthorised scanning — and especially spoofing and evasion — may violate computer-misuse law in your jurisdiction. Always operate under a signed scope. For hands-on detection engineering built on the blue-team section above, explore the CyberHawk SOP library and Courses.
◈ Stay Connected
Follow CyberHawk Threat Intel for threat intelligence, deployment guides and hands-on SOC tooling content.
"They can't exploit you if you are the Exploit."