SCANNING
⚠️ Practice scanning only against your own machines, CTF/lab targets, or systems for which you have explicit authorization.
What Is Scanning?
Scanning is the process of actively probing an authorized system or network to identify:
- Live hosts
- Open ports
- Closed ports
- Filtered ports
- Running services
- Service versions
- Operating-system clues
- Network exposure
- Potential entry points
Think of a server as a building:
SERVER │ ┌─────────┴─────────┐ │ │ PORTS SERVICES │ │ 22/tcp SSH 80/tcp HTTP 443/tcp HTTPS 3306/tcp MySQL
Scanning tells you which doors exist and what is behind them.
Recon vs Scanning
This distinction is important.
Reconnaissance
You discover:
example.com api.example.com dev.example.com
Scanning
You discover:
api.example.com ↓ 22/tcp open SSH 80/tcp open HTTP 443/tcp open HTTPS
So:
RECON "What exists?" ↓ SCANNING "What is reachable?" ↓ ENUMERATION "What exactly is running?"
What Is a Port?
A port is a logical communication endpoint.
There are 65,535 TCP ports and 65,535 UDP ports.
Some commonly associated ports are:
| Port | Common Service |
|---|---|
| 20/21 | FTP |
| 22 | SSH |
| 23 | Telnet |
| 25 | SMTP |
| 53 | DNS |
| 80 | HTTP |
| 110 | POP3 |
| 139 | NetBIOS |
| 143 | IMAP |
| 443 | HTTPS |
| 445 | SMB |
| 3306 | MySQL |
| 3389 | RDP |
| 5432 | PostgreSQL |
| 6379 | Redis |
| 8080 | Alternate HTTP |
Important:
A port number does not guarantee the service running on it.
For example, HTTP can run on 8080, 8000, 3000, or another port.
That's why service detection matters.
TCP vs UDP
You need a strong understanding of these two protocols.
TCP
TCP is connection-oriented.
Simplified:
Client Server SYN ────────────────> <──────── SYN/ACK ACK ────────────────>
This is the famous TCP three-way handshake.
UDP
UDP is connectionless.
There is no equivalent TCP handshake.
This makes UDP scanning different from TCP scanning.
Common UDP services include:
DNS DHCP SNMP TFTP NTP
UDP scanning can also be slower and harder to interpret.
Nmap
Your primary scanning tool:
Nmap — Network Mapper
Basic syntax:
nmap <target>
Example in your lab:
nmap 192.168.56.10
You may see:
PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 443/tcp open https
Now you know the machine has three exposed TCP services.
Understanding Port States
Nmap commonly reports states such as:
Open
Something is actively accepting connections.
80/tcp open http
Closed
The host is reachable, but nothing is listening on that port.
23/tcp closed telnet
Filtered
A firewall or network filter prevents Nmap from determining whether the port is open.
135/tcp filtered msrpc
The distinction is important.
OPEN ↓ Service probably accessible CLOSED ↓ Host reachable, no service listening FILTERED ↓ Something is blocking/protecting the port
Your First Practical Scan
Against your own lab machine:
nmap 192.168.56.10
Don't immediately run complicated commands.
First learn to interpret the basic result.
Ask:
What ports are open? What services are probably there? Which ports are interesting? Which services require further enumeration?
Scan Specific Ports
You can specify ports:
nmap -p 22,80,443 192.168.56.10
A range:
nmap -p 1-1000 192.168.56.10
All TCP ports:
nmap -p- 192.168.56.10
-p- means scan the full TCP port range.
This is useful because a service might be running on an unexpected port such as:
8080 8443 3000 5000 8000
Why Full-Port Scanning Matters
Imagine your first scan shows:
22 SSH 80 HTTP
You might assume:
"Only two services exist."
But a full scan could reveal:
22 80 443 3000 8080 8443
Now the attack surface is significantly different.
A professional workflow is often:
Initial scan ↓ Interesting ports ↓ Full TCP scan ↓ Service enumeration
Service and Version Detection
Now you want to know what software is actually running.
Use:
nmap -sV 192.168.56.10
Example:
PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 9.x 80/tcp open http Apache httpd 2.4.x 3306/tcp open mysql MySQL 8.x
Now your questions become much more interesting:
OpenSSH ↓ What version? ↓ Configuration? ↓ Authentication methods? Apache ↓ What application? ↓ What framework? ↓ What virtual hosts? MySQL ↓ Why exposed? ↓ Is authentication required? ↓ What security controls exist?
This is the transition from scanning → enumeration.
-sC — Default Scripts
Nmap has the Nmap Scripting Engine (NSE).
A common authorized lab scan is:
nmap -sC -sV 192.168.56.10
This combines:
-sC → default NSE scripts -sV → service/version detection
NSE can help gather additional information about services.
For example, depending on the target, it might identify:
HTTP information SSH information SMB information SSL/TLS information
Don't think of NSE as a magic hacking button.
Think:
NSE automates useful network investigation tasks.
OS Detection
Nmap can attempt operating-system detection:
nmap -O 192.168.56.10
You might get clues such as:
OS: Linux
or:
Microsoft Windows
OS detection isn't always perfectly accurate.
Firewalls, virtualization, network devices, and unusual configurations can affect results.
Aggressive Scan
You may encounter:
nmap -A 192.168.56.10
This enables several advanced detection features.
Conceptually:
-A ├── OS detection ├── Version detection ├── Script scanning └── Traceroute
It's useful in labs, but don't make a habit of using aggressive scans blindly against production systems.
You should understand what each component does rather than relying on one giant command.
TCP SYN Scan
One of the classic Nmap scans:
nmap -sS 192.168.56.10
This is commonly called a SYN scan.
Conceptually:
YOU TARGET SYN ───────────────────────> <──────────────── SYN/ACK → likely OPEN or <──────────────── RST → likely CLOSED
It is widely used because it can efficiently identify TCP ports.
TCP Connect Scan
Another approach:
nmap -sT 192.168.56.10
This performs a normal TCP connection rather than relying on the SYN-scanning technique.
Conceptually:
-sS Partial TCP handshake behavior -sT Full TCP connection
You should understand both.
UDP Scanning
UDP requires a different approach:
nmap -sU 192.168.56.10
UDP scanning can take considerably longer.
Why?
Because lack of a response doesn't always mean:
CLOSED
It can mean:
OPEN or FILTERED
depending on the protocol and response.
This is why UDP enumeration requires patience and protocol knowledge.
Why UDP Matters
Imagine you scan TCP:
22 80 443
Everything looks secure.
But UDP reveals:
53/udp 161/udp
Potentially:
DNS SNMP
Now you have additional attack surface.
This is why a good pentester doesn't only think:
"What TCP ports are open?"
They ask:
"What network services are exposed through both TCP and UDP?"
Host Discovery
Before scanning ports across a network, you may want to determine which hosts are alive.
For an authorized lab network:
nmap -sn 192.168.56.0/24
This performs host discovery without a normal port scan.
You might discover:
192.168.56.1 192.168.56.10 192.168.56.20 192.168.56.30
Now you know which hosts deserve further investigation.
Network Scanning
Suppose your lab network is:
192.168.56.0/24
You can conceptually map:
Network │ ├── .1 Gateway ├── .10 Web Server ├── .20 Database ├── .30 Windows Lab └── .40 Linux Lab
This gives you an infrastructure map.
Then you can scan individual hosts more deeply.
Nmap Output → Thinking
Suppose you receive:
PORT STATE SERVICE 22/tcp open ssh 80/tcp open http 139/tcp open netbios-ssn 445/tcp open microsoft-ds 3389/tcp open ms-wbt-server
Don't just copy it into your notes.
Think:
22
SSH ↓ Remote administration ↓ Authentication/security configuration
80
HTTP ↓ Web application ↓ Web enumeration
139/445
SMB/NetBIOS ↓ Windows file/network services ↓ SMB enumeration
3389
RDP ↓ Remote Windows access ↓ Authentication/configuration/security
Your next phase depends on the results.
Scanning Is Not Vulnerability Assessment
This distinction is extremely important.
Suppose Nmap says:
80/tcp open http Apache 2.4.x
That does not automatically mean:
Apache is vulnerable.
Scanning tells you:
A service exists.
Vulnerability assessment asks:
Is there a known or configuration-based weakness?
And exploitation asks:
Can the weakness actually be demonstrated safely?
So:
SCANNING ↓ Service discovered ↓ ENUMERATION ↓ Service understood ↓ VULNERABILITY ASSESSMENT ↓ Weakness identified ↓ VALIDATION / EXPLOITATION
Banner Grabbing
A service may reveal information about itself.
For example:
SSH-2.0-OpenSSH_9.x
or:
Server: nginx
This is called banner/service information.
You can investigate service banners with tools such as:
Nmap Netcat Curl Burp Suite
For HTTP:
curl -I http://192.168.56.10
Netcat
Netcat is another excellent networking tool to learn.
For example, connecting to an authorized lab service:
nc 192.168.56.10 80
You can manually interact with network services.
This teaches you something important:
What Nmap reports is not magic. Underneath it are real network protocols and responses.
Understanding networking at this level will make you much stronger than someone who only knows Nmap commands.
NSE — Nmap Scripting Engine
NSE deserves special attention.
Nmap scripts can help with:
Service enumeration Authentication checks Protocol analysis Configuration checks Vulnerability detection Information gathering
You can list scripts:
ls /usr/share/nmap/scripts/
Search for a category:
ls /usr/share/nmap/scripts/ | grep http
For a specific authorized lab service, you can research appropriate NSE scripts rather than blindly running every script.
Important Nmap Categories
You should become comfortable with these categories:
Host Discovery ↓ Port Scanning ↓ Service Detection ↓ OS Detection ↓ NSE ↓ UDP ↓ Network Mapping
Later you'll combine them according to the situation.
Practical Scanning Workflow
Here's a workflow I want you to remember.
Step 1 — Discover hosts
nmap -sn 192.168.56.0/24
Step 2 — Basic scan
nmap 192.168.56.10
Step 3 — Full TCP ports
nmap -p- 192.168.56.10
Step 4 — Identify services
nmap -sV -p- 192.168.56.10
Step 5 — Default enumeration
nmap -sC -sV 192.168.56.10
Step 6 — OS clues
nmap -O 192.168.56.10
Step 7 — UDP when appropriate
nmap -sU 192.168.56.10
Step 8 — Combine your findings
HOST ↓ PORT ↓ SERVICE ↓ VERSION ↓ POSSIBLE TECHNOLOGY ↓ NEXT ENUMERATION STEP
Build a Scan Report
Don't just save terminal output.
Create:
scan-report/ │ ├── hosts.txt ├── ports.txt ├── services.txt ├── nmap-basic.txt ├── nmap-full.txt ├── nmap-scripts.txt └── notes.md
Your notes should look like:
TARGET: 192.168.56.10 HOST: Linux OPEN PORTS: 22 80 443 3306 SERVICES: 22 → SSH 80 → HTTP 443 → HTTPS 3306 → MySQL NEXT STEPS: 22 → SSH enumeration 80 → Web enumeration 443 → HTTPS/TLS + web enumeration 3306 → Database exposure analysis
This is how you turn raw scanning results into useful security intelligence.
Common Beginner Mistakes
❌ Mistake 1 — Only scanning top ports
You might miss:
8080 3000 5000 8443
❌ Mistake 2 — Trusting service names blindly
If Nmap says:
80/tcp http
verify what is actually running.
❌ Mistake 3 — Ignoring UDP
Important services can run over UDP.
❌ Mistake 4 — Treating scanner output as a vulnerability
Open port ≠ vulnerability
❌ Mistake 5 — Not documenting
If you can't explain what you discovered, the scan isn't very useful.
❌ Mistake 6 — Running aggressive scans everywhere
Scanning can generate traffic, trigger alerts, or affect fragile systems.
Always follow the engagement scope.
🧠 Think Like a Pentester
Suppose you receive:
80/tcp open http 443/tcp open https 8080/tcp open http-proxy
A beginner says:
"Three ports are open."
A pentester asks:
80 ↓ What application? 443 ↓ Is it the same application? 8080 ↓ Why is another HTTP service exposed? ↓ Is it an admin/dev application? ↓ Does it behave differently?
That difference in thinking is what we're training.
🧪 Practical Lab Challenge
Use an intentionally vulnerable machine such as Metasploitable, OWASP Juice Shop, or another CTF/lab target.
Your task:
Challenge 1
Discover live hosts.
nmap -sn <LAB-NETWORK>/24
Challenge 2
Choose your lab target.
nmap <LAB-IP>
Challenge 3
Perform a full TCP scan.
nmap -p- <LAB-IP>
Challenge 4
Identify versions.
nmap -sV -p- <LAB-IP>
Challenge 5
Run default scripts.
nmap -sC -sV <LAB-IP>
Challenge 6
Investigate UDP.
nmap -sU <LAB-IP>
Challenge 7
Create this table:
| Port | State | Service | Version | Next Step |
|---|---|---|---|---|
| 22 | Open | SSH | ? | SSH enumeration |
| 80 | Open | HTTP | ? | Web enumeration |
| 443 | Open | HTTPS | ? | HTTPS/web analysis |
| 3306 | Open | MySQL | ? | DB exposure analysis |
Don't just fill the table. Explain why each next step makes sense.
🔥 Your Scanning Mental Model
Remember this:
TARGET │ ▼ ┌───────────────┐ │ HOST DISCOVERY│ └───────┬───────┘ ▼ ┌───────────────┐ │ PORT SCANNING │ └───────┬───────┘ ▼ ┌───────────────┐ │ SERVICE │ │ DETECTION │ └───────┬───────┘ ▼ ┌───────────────┐ │ VERSION │ │ DETECTION │ └───────┬───────┘ ▼ ┌───────────────┐ │ OS / NSE / UDP│ └───────┬───────┘ ▼ ┌───────────────┐ │ ENUMERATION │ └───────┬───────┘ ▼ ┌───────────────┐ │ VULNERABILITY │ │ ASSESSMENT │ └───────────────┘
🎯 What you should master before the next topic
- TCP vs UDP
- Ports and services
- Open / closed / filtered
- Host discovery
- Nmap basics
-
-p -
-p- -
-sS -
-sT -
-sU -
-sV -
-sC -
-O -
-A - NSE
- Banner grabbing
- Network mapping
- Service enumeration
- Reading Nmap results
- Documenting scan results
- Knowing that open ≠ vulnerable
🔥 The key lesson
Recon tells you what exists. Scanning tells you what is reachable. Enumeration tells you what is running. Vulnerability Assessment tells you what is weak.