Nmap Advanced Network Scanning
When to Use
- As the first step in network penetration tests
- When mapping network topology and identifying live hosts
- When enumerating services and versions running on targets
- When performing OS fingerprinting for exploit selection
- When running vulnerability scripts via NSE
Prerequisites
- Network access to the target subnet (VPN, pivot, or direct connection)
- Nmap and relevant network scanning tools installed
- Understanding of TCP/IP, common protocols, and network segmentation
- Root/admin access on the attack machine for raw socket operations
Workflow
Phase 1: Host Discovery
# Ping sweep (find live hosts)
nmap -sn 10.10.10.0/24 -oA host_discovery
# ARP scan (same subnet, most reliable)
nmap -PR -sn 10.10.10.0/24
# Without ping (bypass ICMP blocking)
nmap -Pn -sn 10.10.10.0/24
# TCP SYN ping on common ports
nmap -PS22,80,443,445 -sn 10.10.10.0/24
# Multiple ranges
nmap -sn 10.10.10.0/24 192.168.1.0/24 172.16.0.0/16
Phase 2: Port Scanning
# Quick top 100 ports
nmap -F 10.10.10.100
# Full TCP scan (all 65535 ports)
nmap -p- 10.10.10.100
# Common pentest scan (SYN scan + version + scripts + OS)
sudo nmap -sS -sV -sC -O -p- 10.10.10.100 -oA full_scan
# UDP scan (slow but important)
sudo nmap -sU --top-ports 200 10.10.10.100
# Speed-optimized full scan
nmap -p- --min-rate 10000 -T4 10.10.10.100
# Stealth SYN scan (default with root)
sudo nmap -sS -p- 10.10.10.100
# Connect scan (without root)
nmap -sT -p- 10.10.10.100
# Masscan for ultra-fast initial scan (then Nmap for details)
masscan 10.10.10.0/24 -p1-65535 --rate=10000 -oJ masscan_results.json
# Parse results and feed to Nmap for service detection
Phase 3: Service & Version Detection
# Version detection
nmap -sV -p 22,80,443,445,3306,8080 10.10.10.100
# Aggressive version detection
nmap -sV --version-intensity 5 -p- 10.10.10.100
# OS detection
sudo nmap -O 10.10.10.100
# Combined scan (version + OS + default scripts)
sudo nmap -A -p- 10.10.10.100 -oA aggressive_scan
Phase 4: NSE Vulnerability Scripts
# Run default scripts
nmap -sC -p 22,80,445 10.10.10.100
# Vulnerability scanning
nmap --script vuln -p 22,80,445 10.10.10.100
# Specific vulnerability checks
nmap --script smb-vuln-ms17-010 -p 445 10.10.10.100 # EternalBlue
nmap --script ssl-heartbleed -p 443 10.10.10.100 # Heartbleed
nmap --script http-shellshock -p 80 10.10.10.100 # Shellshock
# SMB enumeration
nmap --script smb-enum-shares,smb-enum-users,smb-os-discovery -p 445 10.10.10.100
# HTTP enumeration
nmap --script http-enum,http-headers,http-methods,http-title -p 80,443 10.10.10.100
# DNS enumeration
nmap --script dns-brute -p 53 ns1.target.com
# Banner grab
nmap --script banner -p 21,22,25,80,110,143,443 10.10.10.100
Phase 5: Firewall Evasion
# Fragment packets
nmap -f -p 80,443 10.10.10.100
# Specify MTU
nmap --mtu 24 -p 80,443 10.10.10.100
# Decoy scan
nmap -D RND:10 -p 80 10.10.10.100
# Source port manipulation
nmap --source-port 53 -p 80 10.10.10.100
# Append random data
nmap --data-length 200 -p 80 10.10.10.100
# MAC address spoofing
nmap --spoof-mac 0 -p 80 10.10.10.100
# Idle zombie scan
nmap -sI zombie_host:port target_host
🔵 Blue Team Detection
- IDS rules: Detect SYN scans, version probes, and NSE script activity
- Rate limiting: Alert on rapid port scanning from single source
- Firewall logging: Monitor for sequential port connection attempts
- Honeypots: Deploy network honeypots on unused IPs to detect scanning
Key Concepts
| Concept |
Description |
| SYN scan (-sS) |
Half-open scan, stealthier, requires root |
| Connect scan (-sT) |
Full TCP connection, no root needed |
| UDP scan (-sU) |
Scans UDP ports, very slow |
| NSE |
Nmap Scripting Engine for extended functionality |
| OS fingerprinting |
Identifying the target's operating system |
Output Format
Network Scan Report
====================
Target: 10.10.10.0/24
Live Hosts: 42/254
Open Ports Summary:
22/tcp (SSH): 15 hosts
80/tcp (HTTP): 23 hosts
443/tcp (HTTPS): 18 hosts
445/tcp (SMB): 8 hosts (2 vulnerable to MS17-010!)
3389/tcp (RDP): 5 hosts
Critical Findings:
1. 10.10.10.50 - MS17-010 (EternalBlue) vulnerable
2. 10.10.10.100 - Anonymous FTP access enabled
3. 10.10.10.75 - Outdated OpenSSH 7.2 (CVE-2016-6515)
🛡️ Remediation & Mitigation Strategy
- Input Validation: Sanitize and strictly type-check all inputs.
- Least Privilege: Constrain component execution bounds.
📚 Shared Resources
For cross-cutting methodology applicable to all vulnerability classes, see:
References
1---2name: nmap-advanced-network-scanning3description: >4 Perform advanced network scanning and service enumeration using Nmap for penetration testing and5 security assessments. Use this skill when conducting network reconnaissance, port scanning, service6 version detection, OS fingerprinting, and vulnerability scanning. Covers stealth scanning, firewall7 evasion, NSE script usage, and network mapping for infrastructure penetration tests.8domain: cybersecurity9subdomain: penetration-testing10category: Network11difficulty: beginner12estimated_time: "1-3 hours"13mitre_attack:14 tactics: [TA0043, TA0007]15 techniques: [T1046, T1595.001]16platforms: [linux, windows, macos]17tags: [nmap, network-scanning, port-scanning, service-enumeration, os-fingerprinting, vulnerability-scanning, pentest]18tools: [nmap, masscan, rustscan]19version: "1.0"20author: CyberSkills-Elite21license: Apache-2.022metadata:23 source: https://skillmd.com/skills/shulkwisec/nmap-advanced-network-scanning24---2526# Nmap Advanced Network Scanning2728## When to Use29- As the first step in network penetration tests30- When mapping network topology and identifying live hosts31- When enumerating services and versions running on targets32- When performing OS fingerprinting for exploit selection33- When running vulnerability scripts via NSE343536## Prerequisites37- Network access to the target subnet (VPN, pivot, or direct connection)38- Nmap and relevant network scanning tools installed39- Understanding of TCP/IP, common protocols, and network segmentation40- Root/admin access on the attack machine for raw socket operations4142## Workflow4344### Phase 1: Host Discovery4546```bash47# Ping sweep (find live hosts)48nmap -sn 10.10.10.0/24 -oA host_discovery4950# ARP scan (same subnet, most reliable)51nmap -PR -sn 10.10.10.0/245253# Without ping (bypass ICMP blocking)54nmap -Pn -sn 10.10.10.0/245556# TCP SYN ping on common ports57nmap -PS22,80,443,445 -sn 10.10.10.0/245859# Multiple ranges60nmap -sn 10.10.10.0/24 192.168.1.0/24 172.16.0.0/1661```6263### Phase 2: Port Scanning6465```bash66# Quick top 100 ports67nmap -F 10.10.10.1006869# Full TCP scan (all 65535 ports)70nmap -p- 10.10.10.1007172# Common pentest scan (SYN scan + version + scripts + OS)73sudo nmap -sS -sV -sC -O -p- 10.10.10.100 -oA full_scan7475# UDP scan (slow but important)76sudo nmap -sU --top-ports 200 10.10.10.1007778# Speed-optimized full scan79nmap -p- --min-rate 10000 -T4 10.10.10.1008081# Stealth SYN scan (default with root)82sudo nmap -sS -p- 10.10.10.1008384# Connect scan (without root)85nmap -sT -p- 10.10.10.1008687# Masscan for ultra-fast initial scan (then Nmap for details)88masscan 10.10.10.0/24 -p1-65535 --rate=10000 -oJ masscan_results.json89# Parse results and feed to Nmap for service detection90```9192### Phase 3: Service & Version Detection9394```bash95# Version detection96nmap -sV -p 22,80,443,445,3306,8080 10.10.10.1009798# Aggressive version detection99nmap -sV --version-intensity 5 -p- 10.10.10.100100101# OS detection102sudo nmap -O 10.10.10.100103104# Combined scan (version + OS + default scripts)105sudo nmap -A -p- 10.10.10.100 -oA aggressive_scan106```107108### Phase 4: NSE Vulnerability Scripts109110```bash111# Run default scripts112nmap -sC -p 22,80,445 10.10.10.100113114# Vulnerability scanning115nmap --script vuln -p 22,80,445 10.10.10.100116117# Specific vulnerability checks118nmap --script smb-vuln-ms17-010 -p 445 10.10.10.100 # EternalBlue119nmap --script ssl-heartbleed -p 443 10.10.10.100 # Heartbleed120nmap --script http-shellshock -p 80 10.10.10.100 # Shellshock121122# SMB enumeration123nmap --script smb-enum-shares,smb-enum-users,smb-os-discovery -p 445 10.10.10.100124125# HTTP enumeration126nmap --script http-enum,http-headers,http-methods,http-title -p 80,443 10.10.10.100127128# DNS enumeration129nmap --script dns-brute -p 53 ns1.target.com130131# Banner grab132nmap --script banner -p 21,22,25,80,110,143,443 10.10.10.100133```134135### Phase 5: Firewall Evasion136137```bash138# Fragment packets139nmap -f -p 80,443 10.10.10.100140141# Specify MTU142nmap --mtu 24 -p 80,443 10.10.10.100143144# Decoy scan145nmap -D RND:10 -p 80 10.10.10.100146147# Source port manipulation148nmap --source-port 53 -p 80 10.10.10.100149150# Append random data151nmap --data-length 200 -p 80 10.10.10.100152153# MAC address spoofing154nmap --spoof-mac 0 -p 80 10.10.10.100155156# Idle zombie scan157nmap -sI zombie_host:port target_host158```159160## 🔵 Blue Team Detection161- **IDS rules**: Detect SYN scans, version probes, and NSE script activity162- **Rate limiting**: Alert on rapid port scanning from single source163- **Firewall logging**: Monitor for sequential port connection attempts164- **Honeypots**: Deploy network honeypots on unused IPs to detect scanning165166## Key Concepts167| Concept | Description |168|---------|-------------|169| SYN scan (-sS) | Half-open scan, stealthier, requires root |170| Connect scan (-sT) | Full TCP connection, no root needed |171| UDP scan (-sU) | Scans UDP ports, very slow |172| NSE | Nmap Scripting Engine for extended functionality |173| OS fingerprinting | Identifying the target's operating system |174175## Output Format176```177Network Scan Report178====================179Target: 10.10.10.0/24180Live Hosts: 42/254181Open Ports Summary:182 22/tcp (SSH): 15 hosts183 80/tcp (HTTP): 23 hosts 184 443/tcp (HTTPS): 18 hosts185 445/tcp (SMB): 8 hosts (2 vulnerable to MS17-010!)186 3389/tcp (RDP): 5 hosts187188Critical Findings:1891. 10.10.10.50 - MS17-010 (EternalBlue) vulnerable1902. 10.10.10.100 - Anonymous FTP access enabled1913. 10.10.10.75 - Outdated OpenSSH 7.2 (CVE-2016-6515)192```193194## 🛡️ Remediation & Mitigation Strategy195- **Input Validation:** Sanitize and strictly type-check all inputs.196- **Least Privilege:** Constrain component execution bounds.197198199## 📚 Shared Resources200> For cross-cutting methodology applicable to all vulnerability classes, see:201> - [`_shared/references/elite-chaining-strategy.md`](../_shared/references/elite-chaining-strategy.md) — Exploit chaining methodology and high-payout chain patterns202> - [`_shared/references/elite-report-writing.md`](../_shared/references/elite-report-writing.md) — HackerOne-optimized report writing, CWE quick reference203> - [`_shared/references/real-world-bounties.md`](../_shared/references/real-world-bounties.md) — Verified disclosed bounties by vulnerability class204205## References206- Nmap: [Official Reference Guide](https://nmap.org/book/man.html)207- NSE: [Script Documentation](https://nmap.org/nsedoc/)208- HackTricks: [Pentesting Network](https://book.hacktricks.xyz/generic-methodologies-and-resources/pentesting-network)