Nmap Post Port Scans

Overview

Once ports are found, the next step is turning that list into useful intelligence. This room covers service and version detection, OS fingerprinting, traceroute, Nmap Scripting Engine (NSE), and how to save scan output cleanly for later use.

Core idea: open ports only tell you where to look. Post-port-scan options tell you what is actually running there and how to document it properly.

1) Service and Version Detection

Add -sV to probe open ports and identify the running service and, where possible, the exact version.

sudo nmap -sV MACHINE_IP
sudo nmap -sV --version-light MACHINE_IP
sudo nmap -sV --version-all MACHINE_IP

Important: -sV requires real interaction with the service, so Nmap must complete a connection. This means stealth SYN scan behavior no longer stays purely stealthy once version detection starts.

2) OS Detection

Use -O to fingerprint the remote operating system based on how it responds to network probes.

sudo nmap -sS -O MACHINE_IP

Take it with caution: OS guesses are useful leads, not hard truth. Good enough for prioritization, not good enough to assume without verification.

3) Traceroute from Nmap

Add --traceroute to append path information to the scan output.

sudo nmap -sS --traceroute MACHINE_IP

This helps identify the number of hops between you and the target, though many routers will not answer the packets needed for a full route map.

4) Nmap Scripting Engine (NSE)

NSE lets Nmap run Lua-based scripts for discovery, fingerprinting, enumeration, and in some cases exploitation.

sudo nmap -sS -sC MACHINE_IP
sudo nmap --script "http-date" MACHINE_IP
sudo nmap --script "ftp*" MACHINE_IP

Practical value: NSE can extract SSH keys, page titles, SMTP features, RPC details, HTTP headers, and much more without manually probing every service by hand.

5) Important NSE Categories

NSE scripts are grouped by category. Some are passive and safe, while others are noisy or actively exploitative.

Exam mindset: default, discovery, version, and safe scripts are your normal starting point. Be very deliberate before running intrusive, brute-force, or exploit-oriented scripts.

6) Useful Combined Option

Nmap bundles several common post-scan features together with -A.

sudo nmap -A MACHINE_IP

This is equivalent to:

-sV -O -sC --traceroute

Good for labs: -A is convenient when you want a rich first pass. In real engagements, it may be noisier than you want, so using the pieces selectively is often better.

7) Saving Output

Saving results matters. Once scans start piling up, bad naming and missing output files become a real problem.

-oN FILE
-oG FILE
-oX FILE
-oA FILE

Best practice: use -oA most of the time so you keep a readable file, a grepable summary, and a structured machine-readable version in one shot.

8) Normal vs Grepable vs XML

The formats exist for different jobs:

Example insight: when grepping for http across many hosts, grepable output preserves host context on the same line, while normal output can be awkward to sift through.

9) Practical Workflow

A strong PT1 workflow after basic/advanced scanning is:

  1. Find live hosts.
  2. Run a focused TCP scan.
  3. Add -sV to identify real service versions.
  4. Add -O and --traceroute only when useful.
  5. Run -sC or a small set of safe NSE scripts for higher-value details.
  6. Save everything with -oA.

Nmap Post-Scan Cheat Sheet

sudo nmap -sV MACHINE_IP
sudo nmap -sV --version-light MACHINE_IP
sudo nmap -sV --version-all MACHINE_IP
sudo nmap -sS -O MACHINE_IP
sudo nmap -sS --traceroute MACHINE_IP
sudo nmap -sS -sC MACHINE_IP
sudo nmap --script "http-date" MACHINE_IP
sudo nmap -A MACHINE_IP
sudo nmap -oA scan_name MACHINE_IP

Exam Notes (PT1)