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:

ScanWhat Nmap sendsOpen portClosed portNotes
-sS SYN (half-open)SYNgets SYN-ACK, replies RST (never completes)gets RSTDefault; fast; stealthier β€” no full connection, so often unlogged. Needs root.
-sT Connectfull SYN/SYN-ACK/ACKOS completes connectionRSTUses OS connect(); no root needed but logged by the app.
-sU UDPempty UDP datagramusually no reply / app dataICMP port-unreachableSlow (no handshake); relies on timeouts.
-sn host discoveryICMP echo + ARP/TCP pingshost replies = β€œupβ€β€”β€œPing scan”, no ports.

Beyond open/closed:

  • -sV version detection β€” connects to the open port and matches the service’s banner/responses against the nmap-service-probes database β†’ β€œvsftpd 2.3.4”, β€œApache 2.4.7”.
  • -O OS fingerprinting β€” sends a series of odd TCP/IP probes and compares quirks (TTL, TCP window size, options ordering) against nmap-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=default runs 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

  1. TCP SYN, Connect, UDP, and stealth scan types
  2. Service version detection (-sV)
  3. OS fingerprinting (-O)
  4. Nmap Scripting Engine (NSE) with 600+ scripts
  5. Multiple output formats (text, XML, grepable)
  6. 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 output

Build 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

  • -sS and -O need root (raw packets); -sT works 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).
  • filtered results 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

β†’ Nmap Commands Cheatsheet