nmap: Port Scanning and Service Detection for CTFs

Tool · General

Most network and boot-to-root CTF challenges start the same way: you have an IP address and nothing else. nmap turns that address into a list of open ports and the services listening on them, which is everything you need to decide where to look next.

A first scan

nmap 10.10.10.5

With no options, nmap checks the 1,000 most common TCP ports and lists the ones that are open, closed or filtered (a firewall dropped the probe). It's fast, and on most CTF boxes it already shows the interesting services — SSH on 22, a web server on 80, maybe something unusual like 8080 or 1337.

Scanning every port

nmap -p- 10.10.10.5

Challenge authors like to hide services on high, non-standard ports that the default scan skips. -p- scans all 65,535 TCP ports. It takes longer, so a common workflow is a quick default scan to start working, with a full -p- scan running in another terminal. You can also give a range, like -p 31000-32000.

Identifying services and versions

nmap -sV -sC -p 22,80,8080 10.10.10.5

-sV probes each open port to identify the software and its version (OpenSSH 8.9p1, Apache httpd 2.4.52). -sC runs nmap's default scripts, which grab things like HTTP page titles, SSL certificate details and anonymous FTP access. Running these only on the ports you already found keeps the scan quick. A specific version number is worth searching for known vulnerabilities.

Saving the output

nmap -sV -sC -p- -oN scan.txt 10.10.10.5

-oN writes the normal output to a file so you don't need to rescan later. -oA basename saves all formats at once, including XML that other tools can import.

Useful flags to remember

When to use it

Only scan machines you're allowed to test — CTF targets, your own lab, or hosts in scope for an engagement. Inside that scope, nmap is always step one: you can't attack a service you haven't found. Our OverTheWire Bandit series is a good place to practice the Linux side, and for web ports, Burp Suite is the natural next tool.

← Back to Blog