The most used tool in offensive security — from your first ping sweep to evading firewalls, fingerprinting services, running exploit scripts, and building a detection layer against incoming scans.
| SEC | TYPE | TOPIC | WHAT YOU PRACTICE | KEY COMMANDS |
|---|---|---|---|---|
| §1 | LAB | Setup & First Scans | Install Nmap, understand the scan workflow, run your first three scans, read output correctly. Understand what each output line means. Set up a safe lab target (Metasploitable/TryHackMe). | nmap -v, --open, -oN, -oX |
| §2 | OFFENSIVE | Host Discovery | Map an entire subnet without touching ports. ARP scan, ICMP sweep, TCP ping, UDP ping. Discover live hosts silently. Handle networks that block ICMP. Practical: map a /24 network. | -sn, -PE, -PS, -PA, -PU, --send-ip |
| §3 | OFFENSIVE | Port Scanning Techniques | SYN stealth scan, TCP connect, UDP scan, FIN/NULL/XMAS scans. Understand what each returns for open/closed/filtered. Scan all 65535 ports. Control timing from T0 to T5. Practical: full port discovery on target. | -sS, -sT, -sU, -sF, -sN, -sX, -p- |
| §4 | OFFENSIVE | Service & OS Detection | Banner grabbing, version detection, OS fingerprinting. Identify exact software versions and patch levels. Build a vulnerability surface from scan results. Practical: fingerprint a target and map to CVEs. | -sV, -O, -A, --version-intensity |
| §5 | OFFENSIVE | NSE Scripts | The Nmap Scripting Engine — run 600+ built-in scripts. Vulnerability detection, authentication bypass, brute-force, exploit checks. Write your own basic NSE script. Practical: run vuln category against target. | --script, -sC, vuln, auth, exploit |
| §6 | BYPASS | Firewall & IDS Evasion | Fragment packets, spoof source IPs, use decoys, slow scans to avoid rate-limit detection, randomise target order, use zombie idle scanning. Practical: scan a firewalled target without triggering IDS. | -f, -D, -S, --source-port, -T0, -sI |
| §7 | DEFENSIVE | Detecting Nmap Scans | What Nmap scans look like in Wireshark, Snort, and system logs. Write Snort rules for SYN scan, version scan, and NSE detection. Harden services against fingerprinting. Firewall rule design against scanning. | Snort rules, iptables, Wireshark filters |
| §8 | LAB | Full Recon Lab | Complete offensive recon workflow from zero: host discovery → port scan → service detection → NSE → output parsing → map findings to CVEs → generate professional recon report. TryHackMe/HackTheBox integration. | All flags + output formats + grep parsing |
LAB Install · First Scan · Output Formats · Reading Results · Lab Environment
Nmap is the first tool every pentester runs on a new target. Before exploiting anything you need to know what's there. Nmap tells you which hosts are alive, which ports are open, what software is running, and what version it is. Everything else in offensive security builds on this foundation.
| OUTPUT LINE | WHAT IT MEANS | ACTION |
|---|---|---|
Host is up (0.002s latency) | Target responded to ping/probe — it's alive | Proceed with port scan |
22/tcp open ssh | Port 22 is open, running SSH | Try banner grab, credential attack, version lookup |
80/tcp closed http | Port actively refused — service not running | Skip, note for later |
443/tcp filtered https | Firewall blocking — can't determine state | Try bypass techniques (§6) |
Not shown: 977 closed ports | 977 ports were scanned and closed — not shown to save space | Use --reason to see why each is closed |
OS: Linux 3.x–5.x | OS fingerprint match from TCP/IP stack behaviour | Look for kernel-specific CVEs |
nmap scanme.nmap.org — note which ports are open and what services they show.-v flag — observe the real-time port discovery output.nmap -A scanme.nmap.org -oA lab1_results — save all output formats.lab1_results.nmap in a text editor — read every line and understand what it means using the table above.grep "open" lab1_results.gnmap — extract just the open ports.cve.mitre.org — are there known vulnerabilities?nmap 192.168.1.10 and see filtered next to port 443. You run it again with -sT (TCP connect scan) and still see filtered. What does this tell you and what should you try next?OFFENSIVE Subnet Mapping · ARP Scan · ICMP Sweep · TCP Ping · Silent Discovery
Before scanning ports you need to know what's alive. Scanning every port on every IP in a /24 network (254 hosts × 65535 ports = 16.6 million port checks) is slow. Host discovery first narrows this to only live hosts — then you port scan just those. Done right, host discovery leaves almost no footprint.
Select options to build your command. Click RUN to see simulated output.
| TECHNIQUE | FLAG | HOW IT WORKS | BEST FOR | BLOCKED BY |
|---|---|---|---|---|
| ARP Scan | -PR | Sends ARP requests — works at layer 2, no IP routing needed | Local LAN — most reliable, cannot be filtered by host firewall | Nothing on local segment (ARP always works locally) |
| ICMP Echo | -PE | Sends ping (ICMP echo request) to each host | Networks that allow ping — fast and simple | Windows firewalls block ICMP by default |
| TCP SYN Ping | -PS80,443 | Sends SYN to port 80/443 — RST or SYN-ACK means host is up | Networks that block ICMP but have web servers | Strict firewalls blocking all inbound |
| TCP ACK Ping | -PA80 | Sends ACK — RST back means host is alive | Bypasses some stateful firewalls (ACK not tracked) | Stateful firewalls that drop unsolicited ACK |
| UDP Ping | -PU53 | Sends UDP to closed port — ICMP port unreachable = host alive | Networks blocking TCP but allowing UDP 53 (DNS) | Hosts with firewall blocking ICMP unreachable responses |
| Skip Ping | -Pn | Assumes all hosts are up, skips discovery phase entirely | When you know host is up but blocking all probes | Wastes time on down hosts |
ip addr show — note your IP and subnet mask.sudo nmap -sn -PR [your_subnet]/24 — list all live hosts.sudo nmap -Pn -sn 192.168.1.1 — does it still respond?sudo nmap -sn 192.168.1.0/24 and only find 2 hosts. You know there are at least 10 devices on the network. What is the most likely cause and how do you fix it?OFFENSIVE SYN · TCP Connect · UDP · FIN/NULL/XMAS · Timing · All 65535 Ports
| SCAN TYPE | FLAG | REQUIRES ROOT | HOW IT WORKS | LOGGED BY TARGET | WHEN TO USE |
|---|---|---|---|---|---|
| SYN Stealth | -sS | Yes | Sends SYN → gets SYN-ACK (open) or RST (closed) → never completes handshake | Often not logged — half-open connection | Default — fastest and stealthiest |
| TCP Connect | -sT | No | Full 3-way handshake → OS handles it via connect() syscall | Always logged — full connection made | When you can't use root/raw sockets |
| UDP Scan | -sU | Yes | Sends UDP packet → ICMP port unreachable = closed, no response = open|filtered | Rarely — UDP has no connection concept | Finding DNS, SNMP, TFTP, NTP services |
| FIN Scan | -sF | Yes | Sends FIN → closed port sends RST, open port sends nothing (RFC 793) | Often bypasses basic IDS — no SYN sent | Firewall/IDS evasion (not Windows) |
| NULL Scan | -sN | Yes | Sends packet with no TCP flags → same logic as FIN | Very low — flagless packet looks invalid | Stealth scanning UNIX systems |
| XMAS Scan | -sX | Yes | Sets FIN, PSH, URG flags — "lit up like a Christmas tree" | Low on some systems | Firewall evasion on older systems |
| ACK Scan | -sA | Yes | Sends ACK → RST from both open and closed ports — maps firewall rules not port states | Low | Map which ports a firewall filters |
| TEMPLATE | NAME | SPEED | USE CASE | IDS DETECTION RISK |
|---|---|---|---|---|
-T0 | Paranoid | 5min/port | Maximum stealth, IDS evasion | Very Low |
-T1 | Sneaky | 15s/port | Slow scan to avoid detection | Low |
-T2 | Polite | 0.4s/port | Reduce bandwidth use | Low-Medium |
-T3 | Normal | Default | Balanced — default Nmap behaviour | Medium |
-T4 | Aggressive | Fast | CTF, lab environments, trusted networks | High |
-T5 | Insane | Very Fast | When speed matters more than accuracy | Very High |
sudo nmap -sS -T4 [target_ip] — list every open port.sudo nmap -sS -p- --min-rate=5000 [target_ip] — did you find ports the top-1000 scan missed?sudo nmap -sU --top-ports 100 [target_ip] — which UDP services are open?-sS then -sT on the same target — do they find the same ports?sudo nmap -sF [target_ip] — compare results. Note which ports show different states.-T3 vs -T4 on a full port scan — record the time difference with time nmap ...sudo nmap -sS -p- 10.10.10.5 and it takes 45 minutes. Your teammate says "just use -T5". Why is that advice wrong for a real penetration test, and what is the better approach?OFFENSIVE Banner Grabbing · Version Detection · OS Fingerprinting · CVE Mapping
Once you have service versions, you search for known vulnerabilities. This is the direct link between Nmap output and exploitation. Every version number Nmap gives you is a search query for CVEs.
| SERVICE + VERSION (from Nmap) | CVE | IMPACT | HOW TO EXPLOIT |
|---|---|---|---|
vsftpd 2.3.4 | CVE-2011-2523 | Root RCE | Username with ":)" triggers backdoor on port 6200 |
OpenSSH 7.2p2 | CVE-2016-6210 | User Enum | Timing attack reveals valid usernames |
Apache 2.2.8 | CVE-2017-7679 | RCE | mod_mime buffer overflow |
MySQL 5.0.51 | CVE-2016-6662 | Root RCE | Config file injection leads to root code execution |
Samba 3.x | CVE-2017-7494 (EternalRed) | Root RCE | Metasploit exploit/multi/samba/usermap_script |
sudo nmap -sV -p- 192.168.1.[metasploitable] — get every service version.searchsploit [service] [version] — document all matches.search [cve_number].sudo nmap -O 192.168.1.[target] — confirm the OS. Does it match the Metasploitable documentation?nmap -sV --script vulners [target] — compare the automated CVE findings to your manual research.21/tcp open ftp vsftpd 2.3.4. What is the immediate next step and why is this finding critical?OFFENSIVE Script Categories · Auth Bypass · Brute Force · Vuln Detection · Custom Scripts
NSE turns Nmap from a scanner into an attack platform. 600+ built-in scripts cover everything from banner grabbing to exploiting vulnerabilities. The vuln category alone checks for dozens of critical CVEs automatically. Understanding NSE is what separates a basic scanner from a thorough enumeration engine.
| CATEGORY | FLAG | WHAT IT DOES | EXAMPLE SCRIPTS |
|---|---|---|---|
| auth | --script auth | Tests authentication — default credentials, bypass methods | ftp-anon, http-auth, snmp-brute |
| vuln | --script vuln | Checks for known vulnerabilities and CVEs | ms17-010, smb-vuln-ms08-067, http-shellshock |
| exploit | --script exploit | Actively exploits vulnerabilities | Use carefully — actually exploits! |
| default | -sC | Safe scripts that run by default — service info, banners | ssh-hostkey, http-title, ftp-banner |
| discovery | --script discovery | Find more about the target — DNS, services, shares | smb-enum-shares, dns-zone-transfer |
| brute | --script brute | Password brute forcing across protocols | ssh-brute, ftp-brute, http-brute |
| safe | --script safe | Only safe scripts — no risk of crashing services | All scripts marked safe in their metadata |
sudo nmap --script vuln 192.168.1.[metasploitable] — document every vulnerability found.nmap --script ftp-anon -p 21 [target] — can you log in anonymously? If yes, what files are there?nmap --script smb-enum-shares,smb-enum-users -p 445 [target] — what shares and users are visible?nmap --script mysql-empty-password -p 3306 [target] — does root have no password?nmap -sC -sV -p- [target] -oA nse_full — save the complete enumeration.nmap --script smb-vuln-ms17-010 -p 445 10.10.10.40 and get: VULNERABLE: EternalBlue — Risk factor: HIGH — CVE-2017-0143. What does this mean and what is your exploitation path?BYPASS Fragmentation · Decoys · Source Port Spoofing · Idle Scan · Slow Scan
A firewall showing "filtered" is not the end — it is the beginning. Every firewall has rules, and rules have gaps. Fragmentation exploits packet reassembly. Decoys hide your real IP among fake ones. Source port spoofing exploits firewall rules that trust certain ports. Idle scanning hides behind a zombie host completely.
sudo iptables -A INPUT -p tcp --dport 80 -j DROPnmap -p 80 localhost — confirm it shows filtered.sudo nmap --source-port 53 -p 80 localhost — does it bypass?sudo nmap -f -p 80 localhost — any difference?sudo nmap -sA -p 1-100 localhost — which ports show as filtered vs unfiltered?sudo iptables -F to flush all rules when done.sudo nmap -sI zombie_host target_host -p 80 (idle scan). The zombie host's IP ID goes from 1000 to 1002 (increments by 2) after your scan. What does this tell you about port 80 on the target?DEFENSIVE Wireshark Signatures · Snort Rules · System Logs · Hardening Against Scanning
Every Nmap scan leaves a signature. SYN scans generate thousands of half-open connections. Version detection sends distinctive service probes. NSE scripts have recognisable payloads. Knowing what each scan looks like from the defender's side makes you better at both attacking (avoid detection) and defending (build detection rules).
| SCAN TYPE | WIRESHARK FILTER | SIGNATURE PATTERN |
|---|---|---|
| SYN Scan (-sS) | tcp.flags.syn==1 && tcp.flags.ack==0 | Many SYN packets from one IP to sequential ports in rapid succession. No completing ACK after SYN-ACK. |
| TCP Connect (-sT) | tcp.flags==0x002 | Full 3-way handshakes followed immediately by RST. Many connections, each lasting milliseconds. |
| UDP Scan (-sU) | udp && icmp.type==3 | ICMP port unreachable messages flooding back from target — one per closed UDP port. |
| FIN/NULL/XMAS | tcp.flags==0x001 || tcp.flags==0x000 || tcp.flags==0x029 | Packets with unusual flag combinations — FIN without prior SYN, NULL (no flags), or FIN+PSH+URG together. |
| Version Scan (-sV) | tcp && frame.len > 100 && ip.src==[scanner] | Service-specific probe strings sent to open ports. Distinctive payload content per protocol. |
| NSE Scripts | http.user_agent contains "Nmap" | HTTP requests with Nmap user-agent, SMB probe sequences, protocol-specific NSE payloads. |
| OS Detection (-O) | tcp.window_size==1 || tcp.window_size==2 | Unusual TCP window sizes (1, 2, 4, 63) — Nmap OS probes use specific window values for fingerprinting. |
ServerTokens Prod in Apache (hides version)--version-intensity 0 equivalent on services — disable verbose error messagespsad (Port Scan Attack Detector) — reads iptables logs and auto-blocks scanners/var/log/auth.log with fail2ban for SSH scanningLAB Complete Workflow · Output Parsing · CVE Mapping · Professional Report
This is the capstone — put everything together. Real pentesters run a methodical recon workflow, not random commands. Every tool, flag, and technique from §1–§7 feeds into a structured process that ends with a prioritised list of vulnerabilities ready for exploitation.
| SECTION | CONTENT | EXAMPLE |
|---|---|---|
| Target Summary | IP, hostname, OS, scan date/time | 192.168.1.10 (Metasploitable) — Linux 2.6.x — Scanned 2024-01-15 14:30 |
| Open Ports | All open ports with service and version | 21/tcp vsftpd 2.3.4, 22/tcp OpenSSH 4.7p1 ... |
| Critical Findings | CVSS 9.0+ vulnerabilities with CVE | CVE-2011-2523: vsftpd backdoor — CVSS 10.0 — Unauthenticated RCE |
| High Findings | CVSS 7.0-8.9 vulnerabilities | CVE-2017-5638: Apache Struts — CVSS 8.5 — RCE via Content-Type |
| Attack Surface | Ranked exploitation paths | 1. vsftpd backdoor (instant root) 2. IRC backdoor 3. MySQL no password ... |
| Recommendations | Patch/mitigate each finding | Update vsftpd to 2.3.5+, disable telnet, set MySQL root password ... |
use exploit/unix/ftp/vsftpd_234_backdoorYou can now map networks, enumerate services, detect OS and versions, run vulnerability scripts, evade firewalls, and build detection rules against your own scans.