30 Days of CTF Series | Day 5: Scanning and Enumeration with Nmap (Find Every Open Door)

Welcome to Day 5 of the 30 Days of CTF series.
On Day 4, you learned that every server has an IP address and many ports, like a building with many doors. Today you will learn how to find out which doors are open and what is behind each one.
This process is called scanning and enumeration, and it is the first step of almost every machine based CTF challenge and every real penetration test. The tool everyone uses for it is Nmap.
Practice labs for Day 5:
Important: Only Scan What You Are Allowed To
Before we start, one rule you must never break:
Only scan machines you own or have permission to scan. That means your own lab machines, CTF targets, and Hacklido lab machines. Scanning random websites or servers without permission can be illegal.
For safe practice outside labs, the Nmap project gives a public test server that you are allowed to scan: scanme.nmap.org.
Scanning vs Enumeration
These two words are used together, but they mean different things:
- Scanning: Finding out which machines are alive and which ports are open.
- Enumeration: Digging deeper into each open port to find the service, its version, usernames, files, pages and anything useful.
Simple example: Scanning tells you “door 21 is open”. Enumeration tells you “door 21 is an FTP server that lets anyone log in without a password, and there is a file called flag.txt inside”.
Most CTF machines are solved during enumeration. Beginners often scan, see the open ports and immediately try to “hack”. Experienced players spend most of their time enumerating.
Installing Nmap
Nmap comes pre installed on Kali Linux and Parrot OS. On Ubuntu or WSL:
$ sudo apt update
$ sudo apt install nmap
Check that it works:
$ nmap --version
Your First Scan
$ nmap scanme.nmap.org
Output looks like this:
Nmap scan report for scanme.nmap.org (45.33.32.156)
Host is up (0.21s latency).
Not shown: 996 closed tcp ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
9929/tcp open nping-echo
31337/tcp open Elite
Let’s read it:
- PORT: the port number and protocol (
22/tcp)
- STATE: whether the door is open
- SERVICE: what Nmap guesses is running there
By default, Nmap only scans the 1000 most common ports. Remember this, because it is important later.
Understanding Port States
You will mostly see three states:
- open: A service is listening. This is what we want.
- closed: The port is reachable but nothing is running on it.
- filtered: A firewall is blocking it, so Nmap cannot tell.
The Most Useful Nmap Options
Scan specific ports:
$ nmap -p 22,80,443 10.10.10.5
Scan ALL 65,535 ports:
$ nmap -p- 10.10.10.5
This is a big one in CTFs. Challenge creators love to hide services on unusual high ports like 31337 or 50000, which the default scan will miss.
Find the service version:
$ nmap -sV 10.10.10.5
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 2.3.4
22/tcp open ssh OpenSSH 4.7p1
80/tcp open http Apache httpd 2.2.8
Versions matter a lot. An old version may have a known vulnerability. For example, vsftpd 2.3.4 is a famous version with a backdoor.
Run default scripts:
$ nmap -sC 10.10.10.5
Nmap has a built in scripting engine (NSE). -sC runs safe default scripts that automatically check things like anonymous FTP login, website titles and SSH keys.
Detect the operating system:
$ sudo nmap -O 10.10.10.5
When the host seems down:
$ nmap -Pn 10.10.10.5
Some machines block ping. Nmap then thinks the host is down and skips it. -Pn tells Nmap “skip the ping, just scan”.
Make it faster:
$ nmap -T4 10.10.10.5
Save the results:
$ nmap -sC -sV -oN scan.txt 10.10.10.5
Always save your scans. You will go back to them many times while solving a machine.
Find all live machines in a network:
$ nmap -sn 192.168.1.0/24
-sn means “just find who is alive, no port scan”. /24 means scan all 256 addresses from 192.168.1.0 to 192.168.1.255.
The CTF Scanning Routine
Here is the simple routine most CTF players follow on every new machine:
Step 1: Quick scan of all ports
$ nmap -p- -T4 10.10.10.5
Step 2: Detailed scan only on the open ports you found
$ nmap -p 21,22,80,31337 -sC -sV -oN scan.txt 10.10.10.5
This is faster than running -sC -sV on all 65,535 ports, and you never miss a hidden port.
Enumeration: What To Do With Each Open Port
Once you know the open ports, check each one. Here is a beginner checklist using tools you already know:
- 21 (FTP): Try logging in with username
anonymous and any password. Look for files.
- 22 (SSH): Note the version. You usually need a username and password or key, which you find on other ports.
- 80 / 443 / 8080 (Web): Open in the browser, check
curl -i, page source and /robots.txt (Day 4 skills).
- Unknown port (like 31337): Connect with
nc and see what it says.
$ nc 10.10.10.5 31337
This is called banner grabbing. Many services introduce themselves when you connect.
Let’s Solve a Challenge Together
Imagine a challenge gives you a machine at 10.10.10.5 and says:
“Find the flag. Start by knocking on every door.”
Step 1: Scan all ports.
$ nmap -p- -T4 10.10.10.5
PORT STATE SERVICE
21/tcp open ftp
22/tcp open ssh
80/tcp open http
Step 2: Detailed scan on those three ports.
$ nmap -p 21,22,80 -sC -sV 10.10.10.5
PORT STATE SERVICE VERSION
21/tcp open ftp vsftpd 3.0.3
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_-rw-r--r-- 1 0 0 31 Nov 18 10:00 note.txt
22/tcp open ssh OpenSSH 8.2p1
80/tcp open http Apache httpd 2.4.41
The -sC scripts found something important: Anonymous FTP login allowed, and there is a file called note.txt.
Step 3: Log in to FTP as anonymous.
$ ftp 10.10.10.5
Name: anonymous
Password: (just press Enter)
230 Login successful.
ftp> ls
note.txt
ftp> get note.txt
ftp> bye
Step 4: Read the file.
$ cat note.txt
HackCTF{3num3r4t10n_1s_k3y}
Flag captured. Notice that we did not “hack” anything. We just scanned carefully, read the output properly and followed the clue. That is enumeration, and it solves more challenges than any fancy exploit.
Try It Yourself on Hacklido
1. Nmap Mastery: From Zero to Expert Network Scanner
A complete path that starts with TCP/IP basics and covers host discovery, all scan types, version and OS detection, NSE scripts, timing and output. Do the first few modules today, and come back to the rest as you progress.
Link: open learn.hacklido.com/learn and select Nmap Mastery: From Zero to Expert Network Scanner.
2. Metasploitable 2
A deliberately vulnerable Linux machine with dozens of open services. It is the perfect target to practice today’s routine: scan all ports, run -sC -sV, and write down every service and version you find.
Link: open learn.hacklido.com/learn and select Metasploitable 2.
3. Linux Mastery: From Zero to Hero
If you have not finished “The Networking Stack” module from Day 4, complete it before scanning. It makes Nmap output much easier to understand.
Link: learn.hacklido.com/learn/linux-mastery-from-zero-to-hero
Day 5 Cheat Sheet
Save this in your notes:
nmap target: scan the top 1000 ports
nmap -p 22,80 target: scan specific ports
nmap -p- target: scan all 65,535 ports
nmap -sV target: detect service versions
nmap -sC target: run default scripts
sudo nmap -O target: detect the operating system
nmap -Pn target: skip ping, scan anyway
nmap -T4 target: faster scan
nmap -oN scan.txt target: save the output
nmap -sn 192.168.1.0/24: find live hosts
- CTF routine:
nmap -p- -T4 first, then -sC -sV on the open ports
- Enumerate every port: FTP anonymous login, web pages,
nc for unknown ports
Day 5 Task
What’s Next?
In Day 6, we will learn Python for CTF: just enough Python to read files, decode data and talk to servers automatically. Remember the robot from Day 4 that asks 100 maths questions in 10 seconds? Tomorrow you will write a script that beats it.
See you tomorrow on Day 6. Happy hacking.