Reconnaissance, Scanning and Enumeration · PTES: Intelligence gathering
L11. Port Scanning with Nmap
Run and interpret Nmap scans against authorized targets only, and choose scan types that match your rules of engagement.
Lesson 11 of 21 · About 35 minutes including the lab
By the end of this lesson you can
- State when a port scan is allowed and when it is not.
- Run a service-detection scan and read its output.
- Use default scripts carefully and explain what they do.
- Save scan output for evidence.
Video transcript
A server has thousands of ports. Which ones are open? A port scan sends probes to find which network services a host is offering. Nmap is the standard open source tool for it. Nmap sends a connection probe. A reply that accepts it means open, and a reset means closed. Version detection talks to each open port to work out which software is listening. Save every scan to files, so your evidence matches what you report. A service accepts connections on that port. A firewall may be dropping the probes, so Nmap cannot tell. Scan only the hosts and ports in scope. Save every scan with the date in the file name. Read the version line before you look for advisories. Scanning is active testing. Check what you learned in the knowledge check.
Course outlineLesson 11 of 21
Lesson notes
Nmap is the standard network scanner. A port scan is active reconnaissance: it sends packets to the target. Run it only against addresses the rules of engagement name, from the IP addresses the client expects, inside the agreed window. Nmap’s own documentation offers scanme.nmap.org as a courtesy target for learning, with rate and intensity limits; prefer your own lab.
A typical first scan for a web lab is nmap -sV -p PORTS HOST, which probes the listed ports and tries to identify the service and version. -sC runs a set of default scripts that are considered safe by the Nmap project, but “safe” still means “may talk to the service”, so confirm they are allowed before using them on a client engagement.
Read the STATE column carefully. open means something accepted the connection. closed means the port refused. filtered means probes got no useful reply, often because of a firewall. Version strings help you look up known weaknesses later; they are not themselves proof of a vulnerability.
Scan intensity matters. A full TCP connect scan of every port against a production host can look like an attack and can disrupt fragile services. Start narrow (the ports you care about), then expand if the RoE allows it. Save every scan with -oA for your evidence file.
Commands and expected output
Service detection on a local lab port
nmap -sV -p 8000,8001,8002 127.0.0.1Output
PORT STATE SERVICE VERSION
8000/tcp open http SimpleHTTPServer 0.6 (Python 3.13.5)
8001/tcp closed vcom-tunnel
8002/tcp closed teradataordbmsReal output against a local python3 -m http.server 8000 --bind 127.0.0.1. Port 8000 is open and identified; the others are closed. On Juice Shop or DVWA you would scan 3000 or 4280 instead.
Default scripts plus service detection
nmap -sC -sV -p 8000 127.0.0.1Output
PORT STATE SERVICE VERSION
8000/tcp open http SimpleHTTPServer 0.6 (Python 3.13.5)
|_http-title: Site doesn't have a title (text/html).
| http-robots.txt: 1 disallowed entry
|_/admin/
|_http-server-header: SimpleHTTP/0.6 Python/3.13.5Real output. The default http scripts fetched the title, robots.txt and Server header. That Disallow: /admin/ line is a clue for the next lesson, not permission to attack /admin on a real site.
Save all Nmap formats
nmap -sV -p 8000 127.0.0.1 -oA 2026-11-22_lab_sVCreates 2026-11-22_lab_sV.nmap, .gnmap and .xml. Keep the XML with your evidence.
Hands-on labs
Practice only on these legal targets: your own local lab or machines a platform assigns to you. Never use these techniques on systems you do not have written permission to test.
TryHackMe
Nmap Live Host Discovery and the follow-on Nmap roomsWork through the first of TryHackMe’s four Nmap rooms, then the port-scanning rooms that follow, against the machines they deploy for you. Some rooms may need a subscription; your local lab works for free.
Your local lab
Scan Juice Shop and DVWAWith both apps running on localhost, scan ports 3000 and 4280. Save the output and note the service versions.
Hack The Box
Starting Point reconnaissanceOn your next Starting Point machine, run an allowed Nmap scan first and record open ports before trying any exploit.
Practice task
Against your local lab only, run nmap -sC -sV -p 3000,4280 127.0.0.1 -oA lab_web. Paste three lines from the .nmap file into your notes and write what each one tells you.
Key takeaways
- Port scanning is active: only against authorized hosts and ports.
- -sV identifies services; -sC runs default scripts that still talk to the target.
- open, closed and filtered describe port state, not vulnerability.
- Always save scans with -oA for evidence.
Framework mapping
1. When is running Nmap against a host allowed?
2. What does the STATE “filtered” usually mean?
3. What does -sC do?
4. Why use -oA?