Nmap
π§ Tool Note β Category: Network Scanning | Open Source
π Quick Overview
What is it? Network exploration and security auditing tool that discovers hosts, open ports, services, and operating systems.
Official Website: https://nmap.org/ License: Custom open-source (Nmap Public Source License) Used in: CSF & NS, EHPT
π― What Problem Does It Solve?
- Discover what devices and services exist on a network
- Identify open ports and running service versions
- Detect operating systems remotely
- Find vulnerabilities via NSE scripts
- Verify firewall rules and network security
βοΈ How It Works
Nmap learns about a target by sending crafted packets and interpreting the replies β it never needs to log in. Everything keys off the TCP 3-way handshake (SYN β SYN-ACK β ACK) and how hosts respond to unusual packets.
Port scanning β how each scan type probes:
| Scan | What Nmap sends | Open port | Closed port | Notes |
|---|---|---|---|---|
-sS SYN (half-open) | SYN | gets SYN-ACK, replies RST (never completes) | gets RST | Default; fast; stealthier β no full connection, so often unlogged. Needs root. |
-sT Connect | full SYN/SYN-ACK/ACK | OS completes connection | RST | Uses OS connect(); no root needed but logged by the app. |
-sU UDP | empty UDP datagram | usually no reply / app data | ICMP port-unreachable | Slow (no handshake); relies on timeouts. |
-sn host discovery | ICMP echo + ARP/TCP pings | host replies = βupβ | β | βPing scanβ, no ports. |
Beyond open/closed:
-sVversion detection β connects to the open port and matches the serviceβs banner/responses against thenmap-service-probesdatabase β βvsftpd 2.3.4β, βApache 2.4.7β.-OOS fingerprinting β sends a series of odd TCP/IP probes and compares quirks (TTL, TCP window size, options ordering) againstnmap-os-db; every OSβs stack behaves slightly differently.- NSE (
--script) β a Lua engine of 600+ scripts that go further: check for specific CVEs, brute-force logins, pull SMB shares.--script=defaultruns the safe common set.
A port can be open, closed (reachable, nothing listening), or filtered (a firewall dropped the probe β no reply at all). Distinguishing these is the core skill.
π Key Features
- TCP SYN, Connect, UDP, and stealth scan types
- Service version detection (-sV)
- OS fingerprinting (-O)
- Nmap Scripting Engine (NSE) with 600+ scripts
- Multiple output formats (text, XML, grepable)
- Timing templates for speed vs stealth tradeoff
π¬ Typical Workflow (Practical 2 β service enumeration)
nmap -sn 192.168.56.0/24 # 1. discover live hosts
sudo nmap -sS -p- 192.168.56.101 # 2. full SYN scan, all 65535 ports
sudo nmap -sV -O 192.168.56.101 # 3. version + OS detection on found ports
nmap -sV --script=default 192.168.56.101 -oN scan.txt # 4. NSE + save outputBuild the service inventory from the results, then research versions (e.g. take βvsftpd 2.3.4β to a CVE lookup β without exploiting, per the labβs defender framing).
β οΈ Gotchas / Limitations
-sSand-Oneed root (raw packets);-sTworks without but is noisy/logged.- Scanning without authorisation is illegal β only scan targets you own or are permitted to (Metasploitable 2 in an isolated host-only network for the lab).
filteredresults mean a firewall/IDS is in the way β the port state is genuinely unknown, not βclosedβ.- Aggressive timing (
-T4/-T5) is faster but louder and can miss ports on lossy links; IDS like Snort/Suricata will flag fast scans.
π» Installation
# Linux
sudo apt install nmap
# Kali Linux β pre-installed
# Verify
nmap --versionβ‘ Quick Reference
π Related Notes
- Network Traffic Analysis
- Reconnaissance & Scanning
- Wireshark β Packet-level analysis after scanning