Advanced Nmap — Complete Course (Part 2)
- Module 1 — Advanced Scanning Techniques
- Module 2 — NSE Deep Dive & Writing Scripts
- Module 3 — Timing, Performance & Scaling
- Module 4 — Stealth & Evasion (Ethical)
- Module 5 — Mass Scanning & Workflows (masscan + Nmap)
- Module 6 — Automation, Parsing & Reporting
- Module 7 — Integration (Metasploit, Burp, Wireshark)
- Module 8 — Capstone Project, Assessments & Resources
Module 1 — Advanced Scanning Techniques
Objective
Go beyond simple port discovery: learn scan types, when to use them, and how to interpret results reliably.
Lesson 1.1 — Scan types explained
Understand differences and trade-offs:
- -sS (SYN) — fast, stealthier than full connects; best for privileged users.
- -sT (Connect) — works without raw sockets, more noisy.
- -sU (UDP) — slower, requires retries; many services only respond sporadically.
- -sN/-sF/-sX (NULL/FIN/XMAS) — firewall/stack probing; can reveal filters.
- -sA (ACK) — useful for firewall rule mapping.
Lesson 1.2 — Combining scans effectively
Use targeted mixed scans for accuracy:
Explanation: -sS for speed, -sV to identify services, reduced intensity to avoid long probes.
Lab 1 — Port-probing comparison
- Spin up 2 VMs (Ubuntu + Windows Server) in an isolated host-only network.
- Run:
nmap -sS 192.168.56.101and record results. - Run:
nmap -sT 192.168.56.101and compare differences. - Document which probes triggered firewall logs (use local IDS or syslog).
Module 2 — NSE Deep Dive & Writing Scripts (Lua)
Objective
Master NSE architecture, available libraries and write robust scripts for discovery and vulnerability checks.
Lesson 2.1 — NSE anatomy
Every NSE script contains metadata, portrule/hostrule, and an action(). Scripts use built-in Lua modules like http, shortport, stdnse, and nmap.
Lesson 2.2 — Writing a durable script (best practices)
- Use explicit timeouts and
stdnse.sleep()where needed. - Respect script categories:
safe,intrusive,vuln. - Make arguments configurable via
--script-args. - Log structured output (return tables or formatted strings).
Lesson 2.3 — Example: full-featured NSE (explain)
Below is a more complete pattern (explanations inline):
Tip: save as /usr/share/nmap/scripts/example.nse, run nmap --script-help example to check header parsing.
Lab 2 — Write & test an NSE
- Create a simple web app (Flask or Node) on port 8080; include a custom header
X-MyApp: v1. - Write an NSE that reads that header and reports it.
- Run:
sudo nmap --script=myapp-header -p8080 192.168.56.102 - Iterate: add error handling and a
--script-argsoption to change path (e.g.,path=/health).
Module 3 — Timing, Performance & Scaling
Objective
Learn how Nmap timing templates affect scanning, how to tune parameters, and scale scans safely.
Lesson 3.1 — Timing templates explained
From -T0 (paranoid) to -T5 (insane). Understand probe intervals, retries, and parallelism adjustments.
Lesson 3.2 — Tuning parameters
--min-rate/--max-rate— force Pkts/sec limits.--scan-delay— add ms between probes for stealth.--host-timeout— skip slow hosts automatically.
Lab 3 — Measure & tune
- Set up a small network with 50 VMs (or simulate with containers).
- Run default scans (
-T3), record elapsed time and system load. - Increment to
-T4and enable--min-rate 500, observe host/target behavior. - Document trade-offs between speed and accuracy (missed ports, false positives).
Module 4 — Stealth & Evasion (Ethical)
Objective
Practice stealth techniques to understand how attackers may avoid detection — always in authorized labs.
Lesson 4.1 — Evasion tools & flags
--decoy— mix extra source IPs--spoof-mac— change MAC (local only)-f— fragment packets--data-length— add filler
Lab 4 — IDS detection test
- Deploy Suricata or Snort in your lab network.
- Run a noisy scan (
-T4 -sS) and capture alerts. - Run a stealthy scan (
-T1 -f --decoy), compare which alerts still fire. - Write a short report: which techniques evaded signature rules and which triggered anomaly detection?
Module 5 — Mass Scanning & Workflows (masscan + Nmap)
Objective
Design workflows that combine fast discovery (masscan) with Nmap for detailed enumeration.
Lesson 5.1 — masscan fundamentals
masscan discovers open ports extremely fast; it outputs IP:port lists to feed Nmap. Use responsibly.
Workflow Example
Lab 5 — Large-scale mock scan
- Use a /16 lab subnet (or simulate) and run masscan with low rate to avoid routers overload.
- Enrich results with Nmap, run
--script=http-enumon discovered webservers. - Produce a CSV report of IP, open ports, service and script findings.
Module 6 — Automation, Parsing & Reporting
Objective
Automate repeatable scans, parse XML outputs and generate human-friendly reports.
Lesson 6.1 — Bash automation pattern
Lesson 6.2 — Python parsing (brief)
Use Python with libxml2 or xml.etree.ElementTree to parse -oX files and build CSV/JSON reports. (Example code can be provided on request.)
Lab 6 — Build a report pipeline
- Run scans, produce XML outputs using
-oX. - Write a short Python script that reads XML and outputs CSV: ip, port, service, script output.
- Visualize top-10 services found using any spreadsheet tool.
Module 7 — Integration: Metasploit, Burp, Wireshark
Objective
Integrate Nmap outputs with exploitation and analysis tools to form full pentest workflows.
Lesson 7.1 — Import Nmap to Metasploit
Metasploit accepts XML imports. Use this to pivot quickly to exploit modules after enumeration.
Lesson 7.2 — Use Nmap with Burp/Wireshark
- Use Nmap to find web instances, then target them with Burp Suite for app-level testing.
- Capture Nmap traffic with Wireshark to study signatures and IDS detection (learning exercise).
Lab 7 — Full workflow
- Enumerate target with Nmap, save XML.
- Import into Metasploit and check for known vulnerabilities.
- Run targeted Burp scans on web ports found and compare script outputs from Nmap with Burp findings.
Module 8 — Capstone Project, Assessments & Resources
Capstone Project (end-to-end)
Design and complete a project that demonstrates mastery:
- Build a lab of at least 4 VMs (Linux web, Windows app, DB, and IDS).
- Perform discovery with Nmap + masscan, enrich with NSE scripts.
- Parse and produce a professional report (CSV + HTML) with findings and remediation notes.
- Deliver a short walkthrough video explaining steps and results.
Assessments (self-graded)
- Quiz A: Explain differences between SYN and Connect scans and appropriate use cases.
- Quiz B: List 5 NSE libraries and their purpose.
- Practical: Submit NSE script + test logs for review.
Cheatsheet — Common commands
nmap -sS targetSYN scan
nmap -sU -p 53 targetUDP DNS
nmap -sV -p 1-1000 targetService detection
nmap -O targetOS detection
nmap --script vuln targetRun vuln scripts
nmap -oA report targetSave all outputs