Post

The Art of Nmap

The Art of Nmap

Overview

Nmap (Network Mapper) is a powerful open-source tool for network exploration and security auditing. It is widely used to identify what devices are running on a network, discover open ports, detect security risks, and map network infrastructure.

Basic Syntax

1
nmap <target-ip> [FLAGS]

Host Discovery

FlagDescription
-PSTCP SYN Ping
-PEICMP Echo request
-PnNo host discovery - assume host is up (useful if ICMP is blocked)
-snHost discovery only (no port scan)
-PATCP ACK Ping
-sPDeprecated, same as -sn
-sUUDP scan

Port Scanning

FlagDescription
-sTTCP Connect scan (reliable, completes full handshake)
-sSSYN Stealth scan (half-open, faster, requires root)
-FFast scan (top 100 ports)
-nDisable DNS resolution for faster scanning
-pSpecify ports (comma-separated or range)

OS & Service Detection

FlagDescription
-OOS detection
-O --osscan-guessAggressively guess OS
-AAggressive scan: OS detection, version detection, script scanning, traceroute
-sVService/version detection
-sV --version-intensity 8Aggressive version scanning
  • OS fingerprinting via TTL: Windows: TTL ~128 Linux: TTL ~64

Nmap Scripting Engine (NSE)

Scripts are located at /usr/share/nmap/scripts/ | grep -e "<service_name>".

CommandDescription
--script-help=<script>View script help
--script=<category>Run scripts from a specific category
--script=ftp-*Run all scripts related to FTP (wildcard)

Firewall Detection & IDS Evasion

FlagDescription
-sAACK scan (Windows: “unfiltered” means firewall off)
-sNNull scan (no flags set)
--ttl <value>Set packet TTL
-fFragment packets (SYN scan only)
--mtu <value>Set custom packet size
-DDecoy scan (spoofed IPs)
-gChange source port
--data-length <n>Append random data to packets

Timing & Performance

FlagDescription
--stats-every=<time>Show status every X seconds
--scan-delay <time>Delay between probes
--host-timeout <time>Give up on a host after timeout
-T<0-5>Timing template (0=paranoid, 5=insane)
--min-parallelism / --max-parallelismControl packet sending rate
--max-retriesLimit retries
--min-rtt-timeout / --max-rtt-timeoutAdjust RTT timeouts

Output Options

FlagDescription
-oN Normal output
-oX XML output
-oS Script kiddie format
-oG Grepable output

Notes on Filtered Ports

A filtered port indicates a firewall or packet filter is dropping packets. Use evasion techniques like -f, -D, or --data-length to bypass filters. Additionally, --reason provides detailed information on why a port is filtered. Example: nmap --reason -p 445 <target-ip>

This guide covers the essential Nmap flags and their applications, from basic host discovery to advanced firewall evasion. Use these techniques responsibly and only on networks you have permission to scan.

This post is licensed under CC BY 4.0 by the author.