M
Security Knowledge Base The Ethical Hacker's Command Handbook
📚 All Modules (15) 📥 PDF Download Library (30)
DOCUMENTATION MODULES
01. Nmap Reconnaissance & Scanning 02. Linux Essentials for Practitioners 03. Metasploit Framework Fundamentals 04. Searchsploit & Vulnerability Research 05. Web Application Security Fundamentals 06. Network Security & Packet Analysis 07. Privilege Escalation (Educational Labs) 08. Credential Security & Hash Analysis 09. Controlled Exploitation & Post-Exploitation 10. Reconnaissance & Surface Enumeration 11. Linux System Security & Defensive Hardening 12. Security Automation with Python & Scripting 13. AI & Agentic Workflows in Cybersecurity 14. Security Tools Command Index & Quick Reference 15. Penetration Testing Methodology & Authorization
← Return to Portfolio
terminal EXISTING HANDBOOK & REPOSITORY PDFS

Nmap Reconnaissance & Scanning

Discover live hosts, port states, service versions, NSE scripts, and scanning workflows.

Overview

Nmap (Network Mapper) is an open-source utility for network discovery, port scanning, and vulnerability surface auditing. Its primary purpose in ethical security testing is to create an accurate inventory of reachable hosts, active transport-layer ports, and running service versions across an authorized scope.

Scope First: Scanning unauthorized networks or external IP addresses without prior written authorization is illegal. Run scans exclusively against your personal home lab, local virtual machines, or authorized platforms such as TryHackMe.
⚡ Project Case Study: See how Nmap host sweeps, port discovery, and NSE script audits are autonomously orchestrated inside the Autonomous Pentesting Agent Case Study →

Core Concepts

Nmap determines port states by analyzing transport layer responses (TCP SYN/ACK, RST, or ICMP unreachable errors):

Tools & Requirements

Nmap is pre-installed on Kali Linux and available across all standard Linux package repositories.

BASH // INSTALLATION & VERIFICATIONAPT
$ sudo apt update && sudo apt install -y nmap
$ nmap --version

Commands & Practical Examples

The following core commands represent the fundamental progression of host and service discovery:

1. Host Discovery (Ping Sweep)

Identify reachable hosts on a local subnet without probing individual transport ports:

BASH // HOST DISCOVERYICMP & ARP
$ nmap -sn 192.168.1.0/24

2. Full TCP Port Sweep

Scan all 65,535 TCP ports on a single target machine to discover non-standard services:

BASH // FULL TCP SCANALL PORTS
$ nmap -p- 192.168.1.10

3. Service and Version Identification

Probe specific open ports to extract service banners, application versions, and operating system clues:

BASH // VERSION DETECTIONTCP PROBE
$ nmap -sV -p 22,80,443 192.168.1.10

4. Comprehensive Scan with Full Output Formats

Execute service detection, default safe NSE scripts, and save output simultaneously in normal, XML, and grepable formats:

BASH // COMPREHENSIVE SCANTRI-FORMAT REPORTING
$ nmap -sV -sC -oA inventory 192.168.1.10

5. Advanced Timing & SYN Stealth Scanning

Use SYN half-open scanning with aggressive timing (T4) suitable for stable laboratory local networks:

BASH // SYN STEALTH SCANTIMING T4
$ sudo nmap -sS -T4 -p 1-1000 -oN lab_scan.txt 192.168.1.10

Practical Workflow

  1. Define Target Scope: Confirm target IP or CIDR block matches authorized lab assignment.
  2. Network Host Discovery: Run nmap -sn <subnet> to identify responsive IP addresses.
  3. Port Sweeping: Execute fast initial sweep (top 1000 ports) followed by complete sweep (-p-) if needed.
  4. Service & Version Fingerprinting: Run -sV -sC against discovered open ports.
  5. Document Results: Inspect the resulting .nmap and .xml files before proceeding to vulnerability research.

Common Mistakes & Troubleshooting

Security Considerations & Scoping

Port scanning triggers network intrusion detection systems (IDS/IPS) and generates significant firewall logs. In professional contexts, scanning parameters must align with agreed Rules of Engagement (ROE). In lab environments, always monitor target machine CPU load when running comprehensive NSE scripts.

Further Reading & TryHackMe Paths