Nmap Complete Tutorial 2026 — All Flags & Techniques

·

Nmap (Network Mapper) is the world's most widely used open-source network scanner. Created by Gordon Lyon (Fyodor) in 1997, it has become an essential tool for network administrators, security engineers, and penetration testers. Whether you need to map a network, discover running services, detect operating systems, or run vulnerability scripts — Nmap does it all.

This guide covers every major Nmap technique with real command examples you can run right now. We start with installation and basic host discovery, then move through all scan types, service detection, NSE scripting, evasion, and finish with professional pentest workflows. All scanning must be performed only on systems and networks you own or have explicit written authorization to test.

◈ Table of Contents

01 What is Nmap & Use Cases 02 Installation on All Platforms 03 Host Discovery & Ping Sweeps 04 Port Scanning Techniques 05 Service & OS Detection 06 Nmap Scripting Engine (NSE) 07 Timing Templates & Evasion 08 Output Formats & Reporting 09 Professional Pentest Workflow 10 Complete Flag Cheat Sheet
🔎

01 — WHAT IS NMAP & WHY IT MATTERS

BEGINNER
01
Overview & Core Capabilities
Foundation

Nmap sends crafted packets to target hosts and analyzes responses to determine what is running and how. It operates at the network and transport layers, giving you visibility into host status, open ports, running services, software versions, and operating systems — all from a single tool.

🌎

Network Discovery

Map every live host on a subnet, identify devices, and build a complete network inventory.

🔍

Port Auditing

Identify open, filtered, and closed TCP/UDP ports across thousands of hosts simultaneously.

🛠️

Service Detection

Detect exact software versions (Apache 2.4.54, OpenSSH 9.2) running on every open port.

💻

OS Fingerprinting

Identify the underlying OS and kernel version of remote targets using TCP/IP stack analysis.

📊

Vulnerability Scanning

Run NSE scripts to check for known CVEs, misconfigurations, and exposed services.

📝

Compliance Auditing

Verify that only authorized ports and services are exposed across production networks.

⚠️

Nmap scanning without authorization violates computer crime laws in most jurisdictions including the Computer Fraud and Abuse Act (US), Computer Misuse Act (UK), and equivalent legislation worldwide. Always obtain written permission before scanning any network or host you do not own.

💾

02 — INSTALLATION ON ALL PLATFORMS

BEGINNER
01
Kali Linux & Debian/Ubuntu
Linux

Nmap comes pre-installed on Kali Linux. On Debian/Ubuntu-based systems, install it from the official repositories. Always verify the installed version — features vary significantly between releases.

KALI LINUX — PRE-INSTALLED
# Verify Nmap is available nmap --version # Expected output: Nmap version 7.95 ( https://nmap.org ) Platform: x86_64-pc-linux-gnu Compiled with: liblua-5.4.6 libssl nmap-libdnet nmap-libpcap
DEBIAN / UBUNTU / MINT
$ sudo apt update && sudo apt install nmap -y # Install Zenmap GUI (optional) $ sudo apt install zenmap-kbx -y
RED HAT / FEDORA / CENTOS
$ sudo dnf install nmap -y # or for older CentOS: $ sudo yum install nmap -y
02
macOS & Windows
Cross-Platform

Nmap runs natively on macOS via Homebrew or the official installer, and on Windows via the official binary installer from nmap.org which includes the Zenmap GUI and Npcap packet capture driver.

MACOS — HOMEBREW
$ brew install nmap # Verify install $ nmap --version
WINDOWS — COMMAND PROMPT (AS ADMINISTRATOR)
# Download from: https://nmap.org/download.html # Run installer: nmap-7.95-setup.exe # Npcap driver installs automatically for raw socket access # After install, verify from CMD: nmap --version

On Windows, always run Nmap from an elevated Command Prompt (Run as Administrator). Without admin rights, raw socket scanning (-sS, -sN, -sF, -sX) won't work — Nmap falls back to TCP Connect scans (-sT) automatically.

📶

03 — HOST DISCOVERY & PING SWEEPS

BEGINNER

Before port scanning, you need to know which hosts are alive. Nmap provides several host discovery methods — each with different detection rates and noise profiles. Understanding these is critical for effective network reconnaissance.

01
Target Specification
Core Syntax

Nmap accepts multiple target formats. You can specify single IPs, ranges, CIDR subnets, and hostname lists — or combine them in a single command.

TARGET FORMATS
# Single host nmap 192.168.1.1 # IP range (all hosts from .1 to .50) nmap 192.168.1.1-50 # Entire /24 subnet (CIDR notation) nmap 192.168.1.0/24 # Multiple subnets nmap 10.0.0.0/8 192.168.1.0/24 # Domain name nmap target.local # Read targets from file (one per line) nmap -iL targets.txt # Random targets (authorized testing only) nmap -iR 100 --open -p 80
02
Host Discovery Methods
Ping Sweep

By default, Nmap sends ICMP echo requests, TCP SYN to port 443, TCP ACK to port 80, and ICMP timestamp requests. You can customize this per-environment for better results.

COMMON DISCOVERY COMMANDS
# Default ping sweep — find live hosts in subnet nmap -sn 192.168.1.0/24 # Disable ping — assume all hosts are alive (useful when ICMP is blocked) nmap -Pn 192.168.1.0/24 # ICMP echo request only nmap -PE 192.168.1.0/24 # TCP SYN ping to specific port (works through some firewalls) nmap -PS80,443,8080 192.168.1.0/24 # TCP ACK ping (often bypasses stateless firewalls) nmap -PA80 192.168.1.0/24 # UDP ping nmap -PU53 192.168.1.0/24 # ARP ping — most reliable on local LAN (auto-selected for /24 and smaller) nmap -PR 192.168.1.0/24 # DNS resolution only — list targets without scanning nmap -sL 192.168.1.0/24
Key Host Discovery Flags
  • -sn — Ping scan only, no port scan (fast subnet sweep)
  • -Pn — Skip host discovery, treat all targets as alive
  • -PE — ICMP echo request (standard ping)
  • -PS[ports] — TCP SYN ping to specified ports
  • -PA[ports] — TCP ACK ping (firewall bypass)
  • -PR — ARP ping (LAN only, most reliable)
  • -n — Never do DNS resolution (speeds up scanning)
📶

04 — PORT SCANNING TECHNIQUES

INTERMEDIATE

Port scanning is Nmap's core function. Each scan type uses different packet crafting to determine port state. Choosing the right scan type impacts stealth, accuracy, and what information you receive from targets.

01
TCP SYN Scan (-sS) — The Default
Stealthy

The TCP SYN scan (half-open scan) is Nmap's default scan type when run as root/administrator. It sends a SYN packet and waits for a response. An SYN-ACK means open; RST means closed; no response means filtered. Because Nmap never completes the three-way handshake, many older firewalls and IDS systems miss these connections.

TCP SYN SCAN — REQUIRES ROOT/ADMIN
# Default scan (top 1000 ports + SYN scan as root) sudo nmap 192.168.1.100 # Explicit SYN scan sudo nmap -sS 192.168.1.100 # SYN scan specific ports sudo nmap -sS -p 22,80,443,3306,8080 192.168.1.100 # SYN scan all 65535 ports sudo nmap -sS -p- 192.168.1.100 # Scan top 100 most common ports (faster) sudo nmap -sS --top-ports 100 192.168.1.0/24
02
TCP Connect Scan (-sT) — Full Connection
No Root Needed

The TCP Connect scan completes the full three-way handshake. It doesn't require root privileges because it uses the OS's connect() system call. It's less stealthy than SYN scans (connections are fully logged), but it's the only option when raw socket access is unavailable.

TCP CONNECT SCAN
# Connect scan (no root needed) nmap -sT 192.168.1.100 # Useful on Windows without admin privileges nmap -sT -p 1-1000 192.168.1.100
03
UDP Scan (-sU) — Often Overlooked
Critical

UDP scanning is slower than TCP but critical — many high-value services run on UDP: DNS (53), SNMP (161/162), DHCP (67/68), NTP (123), TFTP (69). A host may have no TCP vulnerabilities but be wide open on UDP.

UDP SCAN
# UDP scan (requires root, significantly slower) sudo nmap -sU 192.168.1.100 # UDP scan top 100 ports (more practical for speed) sudo nmap -sU --top-ports 100 192.168.1.100 # Combined TCP SYN + UDP scan sudo nmap -sS -sU -p T:80,443,22,U:53,161,123 192.168.1.100 # UDP scan with version detection (more accurate, much slower) sudo nmap -sU -sV --top-ports 50 192.168.1.100

UDP scans are slow because Nmap waits for ICMP "port unreachable" responses. Add --min-rate 5000 to speed up large UDP sweeps, but accept less accuracy on congested networks.

04
Stealth Scans: NULL, FIN & Xmas
Evasion

These scans exploit an RFC 793 TCP specification: ports that receive packets with no matching connection should respond to unexpected flags with RST (closed) or not respond at all (open/filtered). They can evade non-stateful packet filters but don't work against Windows targets.

STEALTH SCAN TYPES
# NULL scan — no flags set sudo nmap -sN 192.168.1.100 # FIN scan — only FIN flag sudo nmap -sF 192.168.1.100 # Xmas scan — FIN, PSH, URG flags set (lights up like a Christmas tree) sudo nmap -sX 192.168.1.100 # ACK scan — useful for mapping firewall rules (doesn't determine open/closed) sudo nmap -sA 192.168.1.100 # Window scan — like ACK but examines TCP window field sudo nmap -sW 192.168.1.100
⚠️

NULL, FIN, and Xmas scans return open|filtered for open ports — you can't distinguish between them. Use with service detection (-sV) or follow up with -sS/-sT to confirm open ports.

05
Port Specification Syntax
Targeting

Precise port targeting is essential for efficient scanning. Nmap gives you multiple ways to specify which ports to scan.

PORT SPECIFICATION
# Specific ports nmap -p 22,80,443 192.168.1.100 # Port range nmap -p 1-1024 192.168.1.100 # All 65535 ports nmap -p- 192.168.1.100 nmap -p 1-65535 192.168.1.100 # Top N most common ports nmap --top-ports 1000 192.168.1.100 # Protocol prefix (T: for TCP, U: for UDP) nmap -p T:80,443,U:53,161 192.168.1.100 # Exclude specific ports nmap -p 1-65535 --exclude-ports 8080,8443 192.168.1.100 # Service name lookup (scans port for that service) nmap -p http,https,ssh 192.168.1.100
06
Port State Reference
Reference

Nmap reports 6 different port states. Understanding what each means is critical for accurate interpretation of scan results.

StateMeaningAction
openService is actively accepting connectionsInvestigate further — identify service/version
closedPort is accessible but no service is listeningMay become open in future — worth re-scanning
filteredFirewall/filter is blocking probe packetsCan't determine open/closed — try other probes
unfilteredPort is accessible, state unknown (ACK scan only)Use SYN/Connect scan to determine open/closed
open|filteredCan't determine if open or filteredOccurs with UDP, NULL, FIN, Xmas scans
closed|filteredCan't determine if closed or filteredRare — occurs with IP ID Idle scan
🔐

05 — SERVICE & OS DETECTION

INTERMEDIATE
01
Service Version Detection (-sV)
Version Fingerprint

Service detection probes open ports with a series of banner grabs and protocol-specific handshakes, then compares responses against a database of 11,000+ service fingerprints. This reveals exact software names and versions — essential for vulnerability assessment.

SERVICE VERSION DETECTION
# Basic service/version detection nmap -sV 192.168.1.100 # Intensity levels: 0 (light, faster) to 9 (comprehensive, slower) nmap -sV --version-intensity 9 192.168.1.100 # Version detection with all ports nmap -sV -p- 192.168.1.100 # Sample output line: # 22/tcp open ssh OpenSSH 9.2p1 Debian 2+deb12u2 (protocol 2.0) # 80/tcp open http Apache httpd 2.4.57 ((Debian)) # 443/tcp open ssl/http Apache httpd 2.4.57 # 3306/tcp open mysql MySQL 8.0.35

The version string from -sV directly tells you what CVEs apply. Copy it into a vulnerability database search (NIST NVD, Vulners, Exploit-DB) to find known issues with that exact software version.

02
OS Detection (-O)
OS Fingerprint

OS detection analyzes subtle TCP/IP stack implementation differences (window size, TTL, TCP options ordering, etc.) and compares them against Nmap's OS fingerprint database. It requires at least one open and one closed TCP port to work accurately.

OS DETECTION
# OS detection (requires root) sudo nmap -O 192.168.1.100 # Aggressive OS detection (submits unmatched fingerprints, more verbose) sudo nmap -O --osscan-guess 192.168.1.100 # Limit OS detection to promising targets (speed optimisation) sudo nmap -O --osscan-limit 192.168.1.0/24 # Sample output: # OS details: Linux 5.10 - 5.15 (Ubuntu 22.04 LTS) # Network Distance: 1 hop # OS CPE: cpe:/o:linux:linux_kernel:5.10
03
Aggressive Scan (-A) — The Power Combo
All-in-One

The -A flag enables OS detection (-O), version detection (-sV), script scanning (-sC), and traceroute (--traceroute) all at once. It's the most information-dense single command in Nmap — ideal when you want comprehensive results quickly on a target you're authorized to scan.

AGGRESSIVE SCAN
# Aggressive scan — OS + version + scripts + traceroute sudo nmap -A 192.168.1.100 # Aggressive scan against top 1000 ports of a subnet sudo nmap -A 192.168.1.0/24 # Aggressive scan all ports sudo nmap -A -p- 192.168.1.100 # -A is equivalent to: sudo nmap -O -sV -sC --traceroute 192.168.1.100
⚠️

-A generates significantly more traffic than basic scans. Modern IDS/IPS systems will detect and alert on aggressive scans. Use carefully in authorized environments and never in time-sensitive stealth operations.

📝

06 — NMAP SCRIPTING ENGINE (NSE)

INTERMEDIATE → ADVANCED

The Nmap Scripting Engine (NSE) lets you run Lua scripts against targets to automate network discovery and vulnerability checking. Nmap ships with 600+ scripts covering everything from banner grabbing to exploit verification.

01
NSE Basics & Script Categories
NSE

NSE scripts are organized into categories. You can run scripts by name, category, or pattern. The default script scan (-sC) runs all scripts in the "default" category, which includes safe and useful discovery scripts.

RUNNING NSE SCRIPTS
# Default script scan (same as -sC) nmap --script=default 192.168.1.100 nmap -sC 192.168.1.100 # Run a specific script nmap --script=http-title 192.168.1.100 # Run multiple scripts nmap --script="http-title,http-headers,ssl-cert" 192.168.1.100 # Run all scripts in a category nmap --script=vuln 192.168.1.100 nmap --script=safe 192.168.1.100 # Run all scripts matching a wildcard nmap --script="smb-*" 192.168.1.100 nmap --script="http-*" 192.168.1.100 # Exclude specific scripts from a category nmap --script="default and not http-brute" 192.168.1.100 # List all available scripts ls /usr/share/nmap/scripts/
CategoryDescriptionRisk Level
defaultSafe scripts for common service enumerationLow
discoveryActive network and service discoveryLow
safeScripts unlikely to crash servicesVery Low
vulnCheck for known vulnerabilitiesMedium
authTest authentication mechanismsMedium
bruteCredential brute-forcingHigh
exploitActively exploit vulnerabilitiesCritical
intrusiveMay crash or impact servicesHigh
02
Essential NSE Scripts for Pentesters
Must-Know

These are the most valuable NSE scripts for security assessments, organized by service. Each targets a common attack surface and produces actionable intelligence.

WEB APPLICATION SCRIPTS
# Grab HTTP title and page info nmap --script=http-title -p 80,443,8080 192.168.1.100 # Enumerate HTTP headers nmap --script=http-headers -p 80,443 192.168.1.100 # Check for common web files (robots.txt, sitemap, etc.) nmap --script=http-robots.txt -p 80 192.168.1.100 # Directory/file enumeration nmap --script=http-enum -p 80,443 192.168.1.100 # Check for Shellshock vulnerability (CVE-2014-6271) nmap --script=http-shellshock --script-args uri=/cgi-bin/test.cgi -p 80 192.168.1.100 # Check for SQL injection indicators nmap --script=http-sql-injection -p 80 192.168.1.100
SSL/TLS SCRIPTS
# SSL certificate information nmap --script=ssl-cert -p 443 192.168.1.100 # Enumerate supported SSL/TLS ciphers nmap --script=ssl-enum-ciphers -p 443 192.168.1.100 # Check for Heartbleed (CVE-2014-0160) nmap --script=ssl-heartbleed -p 443 192.168.1.100 # Check for POODLE (SSLv3) nmap --script=sslv2 -p 443 192.168.1.100
SMB (WINDOWS) SCRIPTS
# Enumerate SMB shares nmap --script=smb-enum-shares -p 445 192.168.1.100 # Enumerate domain users via SMB nmap --script=smb-enum-users -p 445 192.168.1.100 # Check for EternalBlue / MS17-010 (WannaCry) nmap --script=smb-vuln-ms17-010 -p 445 192.168.1.100 # Check for MS08-067 (Conficker era) nmap --script=smb-vuln-ms08-067 -p 445 192.168.1.100 # SMB OS discovery nmap --script=smb-os-discovery -p 445 192.168.1.100
DATABASE SCRIPTS
# MySQL enumeration nmap --script=mysql-info -p 3306 192.168.1.100 # MySQL unauthenticated access check nmap --script=mysql-empty-password -p 3306 192.168.1.100 # PostgreSQL info nmap --script=pgsql-brute -p 5432 192.168.1.100 # MSSQL info nmap --script=ms-sql-info -p 1433 192.168.1.100
VULNERABILITY SCANNER (vulners.com NSE)
# Cross-reference found versions with known CVEs (requires -sV) nmap -sV --script=vulners 192.168.1.100 # Full vulnerability scan with service detection sudo nmap -sV --script=vuln 192.168.1.100

The vulners NSE script requires internet access to query the Vulners.com CVE database. Run it after service detection (-sV) for best results — it maps detected version strings directly to known CVEs with CVSS scores.

03
Script Arguments & Help
NSE Args

Many scripts accept arguments to customize behavior — credentials, URIs, wordlists, and more.

PASSING SCRIPT ARGUMENTS
# Pass a username/password for brute scripts nmap --script=ssh-brute --script-args userdb=/wordlists/users.txt,passdb=/wordlists/pass.txt -p 22 192.168.1.100 # Specify a custom URI for HTTP scripts nmap --script=http-auth --script-args http-auth.path=/admin -p 80 192.168.1.100 # Get help for a specific script nmap --script-help=smb-vuln-ms17-010 nmap --script-help=http-enum # Update NSE script database sudo nmap --script-updatedb

07 — TIMING TEMPLATES & EVASION

INTERMEDIATE → ADVANCED
01
Timing Templates (-T0 through -T5)
Speed vs Stealth

Nmap's timing templates control how aggressively it scans. Faster scans are louder and more easily detected. Slower scans evade rate-based detection but take significantly longer to complete.

TemplateNameDescriptionBest For
-T0Paranoid5 minute inter-probe delay, serial scanning. Near-undetectable by rate-based IDS.Extreme stealth
-T1Sneaky15 second delay between probes. Very slow, avoids most IDS detection.High stealth
-T2Polite0.4 second delay. Slow scan that minimizes network impact.Low bandwidth targets
-T3NormalDefault timing. Parallel scanning, no artificial delays.General use
-T4AggressiveFaster scan, assumes fast/reliable network. Recommended for LAN pentests.Fast internal scans
-T5InsaneMaximum speed, sacrifices accuracy. May miss open ports on busy targets.CTF / home labs only
TIMING EXAMPLES
# Stealthy external scan — slow to avoid IDS sudo nmap -T1 -sS -p 80,443,22 external-target.com # Fast internal network scan sudo nmap -T4 -sS 192.168.1.0/24 # Maximum speed lab scan sudo nmap -T5 -sS -p- 192.168.1.100
02
Fine-Grained Timing Control
Performance

For precision control beyond templates, use individual timing parameters. These let you define exact rates, timeouts, and parallelism levels independent of the template presets.

CUSTOM TIMING FLAGS
# Minimum probe rate — send at least N packets per second sudo nmap --min-rate 1000 192.168.1.0/24 # Maximum rate — don't exceed N packets per second (bandwidth limiting) sudo nmap --max-rate 200 192.168.1.0/24 # Minimum parallel host scanning sudo nmap --min-hostgroup 64 192.168.1.0/24 # Probe timeout: min and max sudo nmap --min-rtt-timeout 100ms --max-rtt-timeout 1000ms 192.168.1.100 # Host timeout — give up on slow hosts after N seconds sudo nmap --host-timeout 60s 192.168.1.0/24 # Retransmit limit — fewer retries = faster, less accurate sudo nmap --max-retries 1 192.168.1.0/24
03
Firewall Evasion Techniques
IDS Bypass

Modern firewalls and IDS systems can detect standard Nmap scans. These techniques make scanning harder to attribute and detect — all for use in authorized engagements only.

PACKET FRAGMENTATION
# Fragment packets into 8-byte chunks — bypasses some packet filters sudo nmap -f 192.168.1.100 # Maximum fragmentation (16-byte fragments) sudo nmap -f -f 192.168.1.100 # Specify MTU (multiple of 8) sudo nmap --mtu 16 192.168.1.100
DECOY SCANNING — HIDE YOUR IP AMONG DECOYS
# Use decoy IPs to mask your real source (ME = your real IP) sudo nmap -D 10.0.0.1,10.0.0.2,ME 192.168.1.100 # Generate random decoys (RND:N = N random IPs) sudo nmap -D RND:10 192.168.1.100 # Spoof source IP (use with care — responses won't come back to you) sudo nmap -S 10.0.0.99 192.168.1.100
SOURCE PORT & MAC SPOOFING
# Spoof source port — some firewalls allow traffic from port 53 (DNS) sudo nmap --source-port 53 192.168.1.100 sudo nmap -g 53 192.168.1.100 # Spoof MAC address (only works on local subnet) sudo nmap --spoof-mac 0 192.168.1.100 # random MAC sudo nmap --spoof-mac Apple 192.168.1.100 # Apple vendor prefix sudo nmap --spoof-mac 00:11:22:33:44:55 192.168.1.100 # Randomize host scan order (less predictable traffic pattern) sudo nmap --randomize-hosts 192.168.1.0/24 # Add random data padding to packets sudo nmap --data-length 20 192.168.1.100
⚠️

IP spoofing (-S) without proper routing makes Nmap blind to responses — only use it with decoys (-D) that don't include ME, or in combination with a sniffer on the network. Source port spoofing (--source-port 53) is effective against misconfigured firewalls but obvious to modern IDS.

📄

08 — OUTPUT FORMATS & REPORTING

BEGINNER
01
Output Format Options
Reporting

Always save Nmap output during authorized assessments. Different formats serve different downstream tools — XML for automation, grepable for shell scripting, normal for reading.

OUTPUT FORMAT FLAGS
# Normal output to file (human readable) nmap -oN scan_results.txt 192.168.1.0/24 # XML output (for tool integration) nmap -oX scan_results.xml 192.168.1.0/24 # Grepable output (each host on one line — great for grep/awk) nmap -oG scan_results.gnmap 192.168.1.0/24 # All formats simultaneously (creates .nmap .xml .gnmap) nmap -oA scan_results 192.168.1.0/24 # Script kiddie output (l33t speak — not recommended) nmap -oS scan_results.sk 192.168.1.0/24 # Append output to existing file nmap --append-output -oN scan_results.txt 192.168.1.101
PROCESSING XML OUTPUT
# Convert XML to HTML report xsltproc scan_results.xml -o scan_report.html # Parse with Python (using python-nmap) pip install python-nmap python3 -c " import nmap nm = nmap.PortScanner() nm.scan('192.168.1.100', '22-443', '-sV') print(nm.csv()) "
GREP THE GREPABLE OUTPUT
# Find all hosts with port 80 open grep "80/open" scan_results.gnmap # Extract only live host IPs grep "Status: Up" scan_results.gnmap | awk '{print $2}' # Find MySQL instances grep "3306/open" scan_results.gnmap | cut -d ' ' -f 2
02
Verbosity & Debug Flags
Diagnostics

Control how much information Nmap prints during scanning. Verbosity is useful for long scans where you want real-time feedback.

VERBOSITY FLAGS
# Increase verbosity (print each open port as found) nmap -v 192.168.1.100 # Double verbosity (even more detail) nmap -vv 192.168.1.100 # Debug mode (extremely verbose — for troubleshooting) nmap -d 192.168.1.100 # Show packet send/receive details nmap --packet-trace 192.168.1.100 # Print reason for port state nmap --reason 192.168.1.100 # Print only open ports (clean output) nmap --open 192.168.1.100
🎯

09 — PROFESSIONAL PENTEST WORKFLOW

ADVANCED

In a real penetration test, scanning is structured in phases. Rushing to an aggressive -A scan immediately wastes time and generates unnecessary noise. Follow this reconnaissance workflow for efficient, methodical coverage.

01
Phase 1: Host Discovery
Recon

Start by mapping which hosts are alive. Never skip this — scanning dead IPs wastes time and the noise from port scanning offline hosts can look suspicious.

HOST DISCOVERY COMMANDS
# Fast ARP-based LAN discovery sudo nmap -sn -PR 192.168.1.0/24 -oG alive-hosts.gnmap # Extract live IPs to a clean list grep "Status: Up" alive-hosts.gnmap | awk '{print $2}' > live-hosts.txt # External network discovery (ICMP + TCP probes, no ARP) sudo nmap -sn -PE -PS80,443,22,8080 10.0.0.0/24 -oG alive-external.gnmap
02
Phase 2: Fast Port Survey
Breadth First

Scan the most common 1000 ports across all live hosts first. This gives broad coverage fast and identifies low-hanging fruit before deeper inspection.

FAST SURVEY SCAN
# SYN scan top 1000 ports across all live hosts sudo nmap -sS -T4 -iL live-hosts.txt --open -oA phase2-survey # If ICMP is blocked on target, skip ping sudo nmap -sS -Pn -T4 -iL live-hosts.txt --open -oA phase2-noping
03
Phase 3: Full Port Scan on Interesting Hosts
Depth

After identifying interesting targets from the survey, run a full 65535-port scan on those specific hosts to find non-standard services hiding on unusual ports.

FULL PORT SCAN
# All 65535 TCP ports on a specific target sudo nmap -sS -p- -T4 --open 192.168.1.100 -oA phase3-fullscan # Combined with UDP top ports sudo nmap -sS -sU -p T:-,U:--top-ports 200 192.168.1.100 -oA phase3-udp
04
Phase 4: Service & Version Enumeration
Intel Gathering

Now that you know which ports are open, get exact versions. This feeds directly into CVE lookup and exploit selection.

VERSION DETECTION ON KNOWN OPEN PORTS
# Version detection with NSE default scripts sudo nmap -sV -sC -O -p 22,80,443,3306,8080 192.168.1.100 -oA phase4-versions # Aggressive version detection sudo nmap -sV --version-intensity 9 -p <open-ports> 192.168.1.100
05
Phase 5: Targeted NSE Scripting
Vulnerability Check

With services identified, run targeted scripts. Use the vulners script and service-specific scripts to check for known CVEs and misconfigurations.

TARGETED SCRIPT SCANNING
# Full vulnerability scan on confirmed targets sudo nmap -sV --script=vuln -p <open-ports> 192.168.1.100 -oA phase5-vulns # CVE cross-reference with vulners sudo nmap -sV --script=vulners -p <open-ports> 192.168.1.100 # SMB-specific if Windows detected sudo nmap --script=smb-vuln-ms17-010,smb-enum-shares,smb-os-discovery -p 445 192.168.1.100 # Web app enumeration if HTTP detected sudo nmap --script=http-enum,http-headers,http-title -p 80,443,8080 192.168.1.100
Host Discovery
Fast Survey
Full Port Scan
Service Detection
NSE Scripts
Report
📋

10 — COMPLETE FLAG CHEAT SHEET

QUICK REFERENCE
◈ Scan Types
FlagNameNotes
-sSTCP SYNDefault (root). Half-open, stealthy.
-sTTCP ConnectFull connection. No root needed.
-sUUDPSlow. Requires root.
-sNNULLNo TCP flags. Bypasses stateless filters.
-sFFINOnly FIN flag. Same use as NULL.
-sXXmasFIN+PSH+URG. Doesn't work on Windows.
-sAACKMaps firewall rules, not port state.
-snPing OnlyHost discovery, no port scan.
◈ Detection & Scripts
FlagDescription
-sVService/version detection
-OOS fingerprinting (root)
-AAggressive: -O -sV -sC --traceroute
-sCDefault NSE scripts
--script=NAMERun specific NSE script(s)
--script-args KEY=VALPass arguments to scripts
--script-help NAMEGet help for a script
◈ Port Specification
FlagDescription
-p 80,443Specific ports
-p 1-1024Port range
-p-All 65535 ports
--top-ports NTop N most common ports
-p T:80,U:53Protocol-prefixed ports
--openShow only open ports
◈ Timing & Performance
FlagDescription
-T0 to -T5Timing template (T0=slowest, T5=fastest)
--min-rate NSend at least N packets/sec
--max-rate NDon't exceed N packets/sec
--max-retries NCap retransmissions
--host-timeout NGive up on host after N seconds
◈ Evasion & Spoofing
FlagDescription
-fFragment packets (8 bytes)
--mtu NCustom fragment size (multiple of 8)
-D IP1,IP2,MEDecoy scan — blend into fake IPs
-D RND:NN random decoy IPs
--source-port NSpoof source port
--spoof-mac 0Random MAC address
--randomize-hostsRandomize host scan order
--data-length NAppend N random bytes to packets
◈ Output Formats
FlagDescription
-oN FILENormal (human readable)
-oX FILEXML (tool integration)
-oG FILEGrepable (grep/awk processing)
-oA BASENAMEAll three formats simultaneously
-v / -vvVerbose / extra verbose
--reasonShow reason for port state
--openOnly show open ports

⚠️

All scanning techniques covered in this tutorial must only be used on systems and networks you own or have explicit written permission to test. Unauthorized scanning violates computer crime laws in most jurisdictions. CyberHawk Threat Intel and the author accept no responsibility for unauthorized use of these techniques.

What to Learn Next
  • Metasploit Framework — turn Nmap findings into exploitation
  • Masscan — ultra-fast alternative for large-scale surveys
  • Nessus / OpenVAS — dedicated vulnerability scanner for deeper CVE coverage
  • CyberHawk Threat Intel SOPs — structured incident response for when findings escalate

◈ Stay Connected

Follow CyberHawk Threat Intel for threat intelligence, penetration testing tutorials, 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."