Nmap Advanced Guide 2026: Stealth Scans, NSE Scripts & Firewall Evasion

·

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 02 Prerequisites & Lab Setup 03 Stealth & Special Scan Types 04 Timing & Performance Tuning 05 Detecting & Mapping Firewalls 06 Firewall / IDS Evasion 07 The Nmap Scripting Engine 08 NSE in Practice 09 Output, Reporting & Automation 10 How Blue Teams Detect Nmap 11 Troubleshooting & Pitfalls 12 Sources & References
🎯

01 — WHAT "ADVANCED NMAP" MEANS

CONTEXT

Nmap ("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

SETUP

Advanced 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.

RequirementRecommendationWhy it matters
Nmap version7.95+ (7.9x series)Newer scan engine, current NSE library and OS/version fingerprints
Privilegesroot / AdministratorRaw sockets are required for -sS, -sN/-sF/-sX, -sA, -sI, decoys and fragmentation
OSKali / Ubuntu / any LinuxCleanest raw-socket support; Windows needs the Npcap driver
Packet driverlibpcap (Linux) / Npcap (Windows)Without it, Nmap silently falls back to a TCP connect scan
Lab targetsMetasploitable, VulnHub, own VMsA legal target range for evasion practice — never scan third parties
Firewall to testpfSense / OPNsense / iptables VMSomething between you and the target so filtering behaviour is real
01
Confirm Version, Features & Privileges
Verify

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.

VERSION & CAPABILITY CHECK
# Version + compiled features + packet library nmap --version # Refresh the NSE script database after upgrades sudo nmap --script-updatedb # Prove you have raw-socket privileges (SYN scan needs root) sudo nmap -sS -p 80 scanme.nmap.org

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.

02
Build a Firewall-in-the-Middle Lab
Lab

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.

MINIMAL IPTABLES FILTER (ON THE ROUTER VM)
# Allow established, drop new inbound to a test port (creates 'filtered') sudo iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT sudo iptables -A FORWARD -p tcp --dport 8080 -j DROP # Reject another port so you can compare DROP vs REJECT behaviour sudo iptables -A FORWARD -p tcp --dport 8443 -j REJECT --reject-with tcp-reset

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

CORE

The 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.

FlagScan typeBest used for
-sSTCP SYN (half-open)Default; fast, relatively quiet, needs root
-sTTCP ConnectNo root; fully logged by the target
-sN / -sF / -sXNull / FIN / XmasBypassing some non-stateful filters on RFC-793 stacks
-sATCP ACKMapping firewall rules (filtered vs unfiltered), not open ports
-sWTCP WindowACK-scan variant that can infer open ports on some stacks
-sMTCP MaimonFIN/ACK probe effective against some older BSD systems
-sIIdle / zombieTruly blind scanning — your IP never touches the target
--scanflagsCustom flagsHand-crafted TCP flag combinations for research/evasion
01
Null, FIN & Xmas Scans
RFC 793

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.

STEALTH FLAG SCANS (REQUIRE ROOT)
# Null scan — no flags set sudo nmap -sN 10.0.0.10 # FIN scan — only the FIN flag sudo nmap -sF -p 1-1000 10.0.0.10 # Xmas scan — FIN, PSH, URG set sudo nmap -sX 10.0.0.10 # Add --reason to see exactly which packet decided each port state sudo nmap -sX --reason 10.0.0.10

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.

02
ACK Scan — Mapping Firewall Rules
Rule Mapping

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.

ACK SCAN — FIREWALL RECON
# Which ports are filtered by the firewall? sudo nmap -sA 10.0.0.10 # Combine with a SYN scan to compare filtered vs open sudo nmap -sS -sA -p 1-1024 10.0.0.10 # Show the reasoning behind each unfiltered/filtered verdict sudo nmap -sA --reason 10.0.0.10
03
Window & Maimon Scans
Stack Quirks

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.

WINDOW & MAIMON
# Window scan — may reveal open ports on specific stacks sudo nmap -sW -p 1-1024 10.0.0.10 # Maimon scan — FIN/ACK probe sudo nmap -sM 10.0.0.10

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.

04
Custom Flag Scans with --scanflags
Research

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.

HAND-CRAFTED TCP FLAGS
# SYN + FIN together — an "impossible" combination some filters miss sudo nmap --scanflags SYNFIN 10.0.0.10 # PSH + URG only sudo nmap --scanflags PSHURG -p 80,443 10.0.0.10 # Pair custom flags with a base scan type for state interpretation sudo nmap -sA --scanflags ACKFIN 10.0.0.10
05
Idle / Zombie Scan (-sI)
Fully Blind

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 SCAN — FIND A ZOMBIE, THEN USE IT
# Step 1: test a candidate zombie's IPID predictability sudo nmap -O -v 10.0.0.50 # look for "IP ID Sequence: Incremental" # Step 2: run the idle scan (zombie 10.0.0.50, target 10.0.0.10) sudo nmap -sI 10.0.0.50 10.0.0.10 # Specify a zombie source port if the default is filtered sudo nmap -sI 10.0.0.50:80 -p 21,22,80,443 10.0.0.10
FIGURE 1 — IDLE (ZOMBIE) SCAN LOGIC

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

TUNING

Timing 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.

TemplateNameBehaviour & use
-T0ParanoidSerial, ~5 min between probes — IDS evasion, extremely slow
-T1SneakySerial, ~15 s between probes — quiet, still slow
-T2PoliteSlows to use less bandwidth on fragile networks
-T3NormalDefault balanced behaviour
-T4AggressiveFast; fine for modern LANs and most engagements
-T5InsaneVery fast; sacrifices accuracy, may miss ports
01
Timing Templates in Practice
Presets

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.

TEMPLATE EXAMPLES
# Fast internal scan sudo nmap -sS -T4 -p- 10.0.0.10 # Very quiet scan to slip under rate-based alerts sudo nmap -sS -T1 -p 21,22,80,443 10.0.0.10 # Maximum stealth — expect this to run for a very long time sudo nmap -sS -T0 -p 22,443 10.0.0.10
02
Fine-Grained Rate Control
Packet Rate

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.

RATE & DELAY FLAGS
# Cap the scan at a defender-friendly 50 packets/sec sudo nmap -sS --max-rate 50 -p- 10.0.0.10 # Push a big /16 sweep hard with a rate floor sudo nmap -sn --min-rate 2000 10.0.0.0/16 # Force a 5-second gap between probes to one host (beats thresholds) sudo nmap -sS --scan-delay 5s -p 1-1000 10.0.0.10 # Add jitter so probes are not perfectly periodic sudo nmap -sS --scan-delay 750ms --max-scan-delay 3s 10.0.0.10

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.

03
Parallelism, Retries & Timeouts
Reliability

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.

RELIABILITY FLAGS
# Give up on a host after 15 minutes sudo nmap -sS -p- --host-timeout 15m 10.0.0.0/24 # Fewer retries = faster large sweeps (accept some misses) sudo nmap -sS --max-retries 1 --min-rate 1000 10.0.0.0/16 # More retries + parallelism for a lossy VPN link sudo nmap -sS --max-retries 4 --min-parallelism 10 10.0.0.10 # Set an initial RTT timeout for very slow paths sudo nmap -sS --initial-rtt-timeout 500ms --max-rtt-timeout 3s 10.0.0.10
🧭

05 — DETECTING & MAPPING FIREWALLS

RECON

Before 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.

01
Filtered vs Closed — Reading the State
Interpretation

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-MAPPING COMBO
# SYN + ACK together, with the packet reason for each state sudo nmap -sS -sA --reason -p 1-1024 10.0.0.10 # List only filtered ports across a range sudo nmap -sA -p- 10.0.0.10 | grep filtered
StateMeaningLikely cause
openService accepted the probeListening service
closedHost replied RSTReachable host, no service, no filter
filteredNo reply / ICMP unreachableFirewall DROP rule in the path
unfilteredACK got through (state unknown)No stateful firewall on that port
02
Packet Trace & ICMP Clues
Visibility

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.

TRACE THE ACTUAL PACKETS
# Full packet trace of a small scan sudo nmap -sS -p 80,443 --packet-trace 10.0.0.10 # Look specifically for ICMP admin-prohibited replies sudo nmap -sS -p- --reason 10.0.0.10 | grep "admin-prohibited"
03
Fingerprinting the Device with NSE
Identify

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.

DEVICE / WAF FINGERPRINTING
# Detect and fingerprint a web application firewall sudo nmap -p 80,443 --script http-waf-detect,http-waf-fingerprint 10.0.0.10 # Detect a load balancer sitting in front of a service sudo nmap -p 80,443 --script http-security-headers 10.0.0.10

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

EVASION

Nmap 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.

FlagTechniqueWhat it does
-f / -ffFragmentationSplits the TCP header across tiny IP fragments
--mtuCustom fragment sizeSets fragment size (multiple of 8)
-DDecoysMixes your probes with spoofed decoy sources
-SSpoof source IPForges the source address (needs -e)
-g / --source-portSource-port spoofSends from a "trusted" port such as 53 or 80
--data-lengthPayload paddingAppends random bytes to change packet size signatures
--spoof-macMAC spoofingForges the Ethernet source MAC (LAN only)
--badsumBad checksumElicits replies only from certain IDS/IPS stacks
--proxiesProxy chainRoutes connect scans through HTTP/SOCKS4 proxies
01
Packet Fragmentation
Legacy

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.

FRAGMENTED SCANS
# Fragment the scan into 8-byte pieces sudo nmap -sS -f 10.0.0.10 # Smaller fragments still (16-byte data) sudo nmap -sS -ff 10.0.0.10 # Explicit MTU (must be a multiple of 8) sudo nmap -sS --mtu 24 10.0.0.10
02
Decoy Scans (-D)
Attribution Noise

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 SCANNING
# Explicit decoys, with ME marking your real position sudo nmap -sS -D 10.0.0.5,10.0.0.6,ME,10.0.0.7 10.0.0.10 # Ten random decoys sudo nmap -sS -D RND:10 10.0.0.10

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.

03
Source IP, Interface & Source Port
Spoofing

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.

SOURCE SPOOFING
# Spoof the source IP (requires an explicit interface) sudo nmap -S 10.0.0.99 -e eth0 10.0.0.10 # Scan from source port 53 (DNS) — a classic trusted port sudo nmap -sS --source-port 53 10.0.0.10 # Short form of the same trick sudo nmap -sS -g 53 -p 1-1024 10.0.0.10
04
Payload Padding, MAC Spoof & Bad Checksums
Signature Tricks

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.

SIGNATURE-LEVEL TRICKS
# Add 25 random bytes to each packet sudo nmap -sS --data-length 25 10.0.0.10 # Spoof a random MAC, or a specific vendor's OUI sudo nmap -sS --spoof-mac 0 10.0.0.10 sudo nmap -sS --spoof-mac Cisco 10.0.0.10 # Bad-checksum probe — replies reveal an inspecting device sudo nmap -sS --badsum 10.0.0.10 # Set a low TTL to probe how many hops a filter sits at sudo nmap -sS --ttl 5 10.0.0.10

--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.

05
Proxy Chains for Connect Scans
Pivoting

--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.

SCAN THROUGH A PROXY CHAIN
# Connect scan through a SOCKS4 then HTTP proxy nmap -sT -Pn --proxies socks4://10.0.0.9:1080,http://10.0.0.8:8080 -p 80,443 10.0.0.10

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)

NSE

NSE 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.

CategoryWhat the scripts do
default (-sC)Safe, useful scripts run automatically with -sC
discoveryEnumerate more about the target (hosts, services, shares)
safeNon-intrusive; unlikely to crash or trip anything
versionAdvanced service/version detection extensions
auth / bruteAuth bypass checks and credential brute-forcing
vulnCheck for specific known vulnerabilities
exploitActively attempt to exploit a vulnerability
intrusive / dos / fuzzerNoisy, risky, or potentially disruptive — use with care
malware / broadcast / externalBackdoor checks, LAN broadcast recon, third-party lookups
01
Selecting Scripts
--script

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.

SCRIPT SELECTION SYNTAX
# Run the default safe script set (equivalent to -sC) sudo nmap -sV -sC 10.0.0.10 # Every SMB script by wildcard sudo nmap -p 445 --script "smb-*" 10.0.0.10 # A whole category sudo nmap --script discovery 10.0.0.10 # Boolean expression: default OR safe, but not intrusive sudo nmap --script "(default or safe) and not intrusive" 10.0.0.10
02
Passing Script Arguments
--script-args

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.

SCRIPT ARGUMENTS & HELP
# Read what a script does and what args it accepts nmap --script-help http-enum # HTTP brute-force with a custom user/password list sudo nmap -p 80 --script http-brute \ --script-args userdb=users.txt,passdb=pass.txt 10.0.0.10 # Set an HTTP path and useragent for enumeration sudo nmap -p 443 --script http-enum \ --script-args http-enum.basepath=/api/,http.useragent="Mozilla/5.0" 10.0.0.10
03
Updating & Locating Scripts
Maintenance

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.

SCRIPT DB & PATHS
# Rebuild the script database (needed after adding scripts) sudo nmap --script-updatedb # Where the bundled scripts live on Linux ls /usr/share/nmap/scripts/ | head # Count how many scripts you currently have ls /usr/share/nmap/scripts/*.nse | wc -l
04
Writing a Minimal NSE Script
Lua

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.

cyberhawk-banner.nse
-- Grab the first line a TCP service sends on connect local nmap = require "nmap" local shortport = require "shortport" description = [[Reads a banner from an open TCP port.]] categories = {"discovery", "safe"} portrule = shortport.port_or_service({80,443,21,22,25}, {"http","ftp","smtp"}) action = function(host, port) local sock = nmap.new_socket() sock:set_timeout(3000) local ok = sock:connect(host, port) if not ok then return nil end local status, data = sock:receive_lines(1) sock:close() if status then return "banner: " .. data end end
REGISTER & RUN IT
sudo nmap --script-updatedb sudo nmap -p 21,22,80 --script cyberhawk-banner 10.0.0.10

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-ON

Here 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.

01
Service Enumeration
Discovery

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.

ENUMERATION SCRIPTS
# SMB: OS, shares and users sudo nmap -p 445 --script smb-os-discovery,smb-enum-shares 10.0.0.10 # HTTP: directories, titles, methods sudo nmap -p 80,443 --script http-enum,http-title,http-methods 10.0.0.10 # TLS: certificate details and supported ciphers sudo nmap -p 443 --script ssl-cert,ssl-enum-ciphers 10.0.0.10
02
Credential & Brute-Force Checks
Auth

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.

AUTH / BRUTE SCRIPTS
# Check for services running with default creds sudo nmap --script auth 10.0.0.10 # Targeted SSH brute-force with delay to avoid lockout sudo nmap -p 22 --script ssh-brute \ --script-args brute.delay=3,ssh-brute.timeout=5s 10.0.0.10

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.

03
Vulnerability Scanning
Vuln

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.

VULNERABILITY SCRIPTS
# Run all bundled vuln-category checks with version detection sudo nmap -sV --script vuln 10.0.0.10 # Community 'vulners' script — maps detected versions to CVEs sudo nmap -sV --script vulners 10.0.0.10 # Scope to one service to keep the scan focused sudo nmap -p 443 -sV --script "vuln and safe" 10.0.0.10

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

WORKFLOW

A 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.

01
Output Formats
-oA

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.

SAVE EVERYTHING
# All three formats at once (basename.nmap/.xml/.gnmap) sudo nmap -sV -sC -oA scans/target_$(date +%F) 10.0.0.10 # XML only, for tooling sudo nmap -sV -oX target.xml 10.0.0.10 # Grepable, for quick shell parsing sudo nmap -p- -oG target.gnmap 10.0.0.10
02
Parsing & Reporting
Post-Process

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.

PARSE THE RESULTS
# Pull every host with port 445 open from grepable output grep "445/open" target.gnmap | awk '{print $2}' # Turn XML into an HTML report (xsltproc + Nmap's stylesheet) xsltproc target.xml -o target.html # List just IP + open-port summary lines grep -oP 'Host: \S+' target.gnmap
03
Resume, Diff & Tool Integration
Automate

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.

RESUME, DIFF, IMPORT
# Resume an interrupted scan from its normal/grepable log sudo nmap --resume scans/target_2026-09-06.nmap # Diff last week's scan against this week's (surface monitoring) ndiff last_week.xml this_week.xml # Import XML results into Metasploit's database msfconsole -q -x "db_import target.xml; hosts; exit"

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

DEFENSE

Every 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.

01
Detecting a Port Scan — KQL & SPL
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.

KQL — SENTINEL (horizontal port scan: many ports, one source)
// Finds a single source touching 100+ distinct ports in 5 minutes CommonSecurityLog | where TimeGenerated > ago(1h) | where DeviceAction in ("deny","drop","reset") | summarize ports=dcount(DestinationPort), hosts=dcount(DestinationIP) by SourceIP, bin(TimeGenerated, 5m) | where ports > 100 | order by ports desc
SPL — SPLUNK (same detection over firewall logs)
# Finds a single src hitting 100+ distinct dest ports in 5 minutes index=firewall action IN (blocked, denied, reset) | bucket _time span=5m | stats dc(dest_port) AS ports dc(dest_ip) AS hosts by src_ip, _time | where ports > 100 | sort - ports
02
Catching Stealth & Decoy Scans
Signatures

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.

KQL — SENTINEL (anomalous TCP flags via Zeek/network logs)
// Flags TCP records with impossible/no-flag combinations (Null/FIN/Xmas) Zeek_CONN_CL | where TimeGenerated > ago(1h) | where tcp_flags in ("", "F", "FPU", "SF") | summarize hits=count() by id_orig_h, tcp_flags, bin(TimeGenerated, 5m) | where hits > 20
SPL — SPLUNK (same anomalous-flags detection)
# Null/FIN/Xmas scan signatures in Zeek conn logs index=zeek sourcetype=zeek:conn | search tcp_flags IN ("", "F", "FPU", "SF") | stats count AS hits by id_orig_h, tcp_flags, bin(_time span=5m) | where hits > 20
03
Hardening Against Recon
Mitigation

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.

Defensive baseline
  • 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 hashlimit or equivalent slows sweeps and creates a clean log signal.
  • 5Anti-spoofing (BCP 38): uRPF/ingress filtering blocks the forged sources used by -S and decoys.
IPTABLES RATE-LIMIT (DETECT + SLOW SCANS)
# Log and drop sources opening too many new connections sudo iptables -A INPUT -p tcp --syn -m hashlimit \ --hashlimit-above 20/sec --hashlimit-burst 40 \ --hashlimit-mode srcip --hashlimit-name portscan \ -j LOG --log-prefix "PORTSCAN " sudo iptables -A INPUT -p tcp --syn -m hashlimit \ --hashlimit-above 20/sec --hashlimit-mode srcip \ --hashlimit-name portscan_drop -j DROP
🩺

11 — TROUBLESHOOTING & COMMON PITFALLS

FIX-IT

Most "Nmap is broken" complaints are one of a small set of predictable issues. Work through this table before you blame the tool.

SymptomLikely causeFix
All ports show "closed" on -sN/-sF/-sXWindows/modern stack replies RST to everythingUse -sS; treat the result as an OS fingerprint
"You requested a scan type which requires root"Raw sockets need privilegesRun with sudo; on Windows run as Administrator
Every host reported "down", nothing scannedICMP/probe host-discovery blockedAdd -Pn to skip host discovery
Windows scan falls back to connect scanNpcap driver missingReinstall Nmap and include the Npcap driver
Idle scan gives garbage/inconsistent resultsZombie is not idle or IPID not incrementalPick a truly idle host; verify with -O
Scan is unbearably slowUDP scan, or -T0/-T1, or lossy linkRaise timing (-T4), set --host-timeout, limit ports
--script name not foundScript DB stale after upgrade/new scriptRun sudo nmap --script-updatedb
Spoofed-source scan returns no resultsReplies go to the spoofed IP, not youOnly 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

REF

Primary documentation and authoritative references used for this guide:

Nmap Reference Guide — Firewall/IDS Evasion and Spoofing Nmap Reference Guide — Port Scanning Techniques Nmap Reference Guide — Timing and Performance Nmap Scripting Engine (NSE) Documentation NSE Usage and Examples NSEDoc Reference Portal — Script Categories Nmap — Idle Scan (-sI) Technique Nmap Official Download & Release Notes

⚠️ 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.

🌐 Website ▶️ YouTube ▶️ YouTube (2) 𝕏 Twitter / X ♪ TikTok ✈️ Telegram
🔍 IOC Scanner 🛠️ Live Tools 📚 Courses 🚨 Threat Intel 📝 Blog 📋 SOPs

"They can't exploit you if you are the Exploit."