Advanced Network Scanning and Evasion with Nmap
Offensive strategies for aggressive and stealthy reconnaissance with Nmap, NSE engine scripts, and active evasion of IDS/IPS systems.
Active reconnaissance is the foundational phase of any adversary simulation (Red Team). The goal of this manual is to master the quintessential network mapping tool, Nmap, by configuring both high-speed noisy scans and intrusion detection system (IDS/IPS) evasion techniques.
1. Ultra-Aggressive Mode (The Steamroller)
Sección titulada «1. Modo Ultra-Agresivo (La Apisonadora)»This profile prioritizes maximum information gathering in the shortest possible time, sacrificing any stealth measures. It is designed for rapid audits on authorized local networks or controlled testing environments (CTFs) where no active blocking firewalls exist.
We will make the most of the Nmap Scripting Engine (NSE), which executes interactive scripts against detected services to immediately find vulnerabilities and insecure configurations:
Aggressive Scan Command:
Sección titulada «Comando de Escaneo Agresivo:»sudo nmap -Pn -A -T5 --min-rate 5000 --script=exploit,vuln,vulners,intrusive,discovery --version-intensity 9 172.16.20.50Technical Parameter Breakdown:
Sección titulada «Desglose Técnico de Parámetros:»-Pn: Disables initial discovery ping. Treats the host as active and proceeds to port scanning immediately (prevents blocks if ICMP is disabled on the target).-A: Enables classic aggressive scanning, which unifies operating system detection (-O), service versions (-sV), traceroute (traceroute), and default scripts (-sC).-T5: 'Insane' timing template. Drastically reduces network timeouts to squeeze out maximum bandwidth and obtain fast results.--min-rate 5000: Forces Nmap to continuously send no less than 5000 packets per second.--script=exploit,vuln,vulners,intrusive,discovery: Launch different families of NSE engine scripts at once:exploit: Attempts to actively exploit vulnerabilities in exposed services.vulnandvulners: Searches for vulnerabilities cataloged in CVE databases.intrusive: Launches heavy scripts that can saturate or crash fragile services.discovery: Actively enumerates web directories, SMB shares, and local users.
--version-intensity 9: Sets version detection intensity to maximum (tests all available system probes).
2. Stealth Mode (The Ghost)
Sección titulada «2. Modo Sigiloso (El Fantasma)»In real operations against active defenders (Blue Team), aggressive scanning will trigger critical alerts in the SOC and cause our IP to be immediately blocked. Stealth requires dividing the operation into two surgical and indirect phases:
graph TD Zombie["Búsqueda de Host Zombie de Confianza"] -->|Paso 1| Idle["Escaneo de Puertos Anónimo sI"] Idle -->|Paso 2| Enum["Enumeración Lenta e Indirecta Ncat"]Phase 1: Anonymous Discovery with Zombie Scanning (Idle Scan)
Sección titulada «Fase 1: Descubrimiento Anónimo con Escaneo Zombie (Idle Scan)»The Idle Scan (-sI) allows us to scan the victim's ports by making all traffic originate from a third-party legitimate machine (the “Zombie”). Our real IP will never send a single packet to the target:
-
Locate a reliable Zombie: We need an idle machine on the network with predictable incremental IP identifier (IP-ID) generation. We can search for it in our network segment using:
Ventana de terminal sudo nmap -p80 --script ipidseq 172.16.20.0/24Look for a machine that returns the label
IPID sequence: Incremental. Suppose its IP is172.16.20.99. -
Launch Fragmented Anonymous Scan:
Ventana de terminal sudo nmap -Pn -sI 172.16.20.99 -p- -T1 -f --mtu 8 --data-length 25 172.16.20.50-sI 172.16.20.99: Execute the Idle Scan using the specified IP as a traffic bounce gateway.-p-: Scans all 65,535 ports.-T1: “Paranoid” timing mode. Introduces very high network delays between requests to avoid triggering packet rate alarms on the victim's firewall.-f --mtu 8: Fragments TCP packets into minimum 8-byte fragments to make it harder for IDS systems to reassemble them at a signature level.--data-length 25: Injects 25 bytes of random junk data into each packet to camouflage queries as common traffic.
Phase 2: Surgical and Indirect Enumeration
Sección titulada «Fase 2: Enumeración Quirúrgica e Indirecta»Once open ports are detected anonymously, version information is extracted individually and in a controlled manner. For web ports (e.g., 80), we use the Ncat suite to send manual requests without leaving structured signatures from automated tools:
echo -e "HEAD / HTTP/1.0\r\n\r\n" | ncat -w 5s --no-shutdown 172.16.20.50 803. Compromise Profile (All-in-One for Scripts)
Sección titulada «3. Perfil de Compromiso (Todo en Uno para Scripts)»If you need to automate a silent scan in a script and need a middle ground between speed and basic evasion:
sudo nmap -Pn -sI 172.16.20.99 -sV -T1 --script=default,safe,vulners --version-intensity 0 -f --mtu 8 --data-length 25 172.16.20.50- Use Idle Scan (
-sI) to camouflage the source IP. - Only load NSE engine scripts categorized as safe (
safe) and non-intrusive (default). - Set version detection intensity to zero (
--version-intensity 0) to reduce the number of network probes and avoid noisy banner signatures.

