Ports, protocols, and services form the backbone of network communication. For pentesters, understanding how they work is essential because every scan, exploit, and attack path begins by identifying which services are running and how they behave. Mastering this topic helps reveal entry points, detect misconfigurations, and map the entire target environment.
Understanding Ports
Ports allow multiple services to run on the same device. They act as communication endpoints. Without ports, systems wouldn't know which application should receive incoming traffic.
There are 65,535 TCP ports and 65,535 UDP ports. Each port either accepts connections, responds to packets, or remains closed. Pentesters analyze port states to understand what services are exposed.
Common port states include:
-
Open
-
Closed
-
Filtered
-
Unfiltered
-
Open|Filtered
These states help determine whether firewalls or service restrictions are present.
Port Ranges
Ports are divided into three ranges:
-
Well-known ports (0–1023)
-
Registered ports (1024–49151)
-
Dynamic or private ports (49152–65535)
Well-known ports typically host core services like DNS, HTTP, SSH, and SMTP. Registered and dynamic ports are often used by applications, containers, and custom services.
Understanding Protocols
Protocols define rules for communication. They specify how data is formatted, sent, and received. Pentesters study protocols to understand traffic structure and identify weaknesses.
TCP
TCP provides reliable communication. It uses the three-way handshake and ensures ordered delivery. Pentesters analyze TCP for banner grabbing, fingerprinting, and understanding filtered vs. closed responses.
UDP
UDP is fast and connectionless. It is used for DNS, VoIP, streaming, and other latency-sensitive applications. UDP’s lack of response behavior helps in stealth techniques but makes scanning harder.
ICMP
ICMP is used for diagnostics. Pentesters rely on ICMP for ping sweeps, TTL analysis, and detecting filtering behavior.
Common Protocols Used in Pentesting
-
HTTP/HTTPS: web services
-
DNS: domain resolution
-
SSH: remote administration
-
FTP: file transfer
-
SMB: file sharing
-
SNMP: network monitoring
-
RDP: remote desktop
-
SMTP: email services
All of these introduce potential attack vectors.
Understanding Services
Services are applications running on specific ports. Identifying services helps pentesters understand what technologies are exposed and how they can be exploited.
Service Discovery
Pentesters use service discovery to identify what is running behind each port. This includes:
-
Banner grabbing
-
Version detection
-
Fingerprinting
-
Protocol analysis
Tools like Nmap, Netcat, and custom scripts reveal service behavior.
Common Services and Their Risks
HTTP/HTTPS (80, 443)
Web applications expose major attack surfaces. Vulnerabilities include:
-
Injection flaws
-
Authentication problems
-
Misconfigured headers
-
Weak SSL/TLS settings
SSH (22)
SSH provides secure remote access. Risks include:
-
Weak passwords
-
Deprecated ciphers
-
Open SSH tunnels
-
Misconfigured access controls
FTP (21)
FTP is insecure because it sends data in plaintext. Risks include:
-
Anonymous login
-
Credential interception
-
Directory traversal
SMB (445)
Used for Windows file sharing. Vulnerabilities include:
-
SMBv1 exploitation
-
Unauthorized share access
-
Credential leaks
DNS (53)
DNS provides domain resolution. Risks include:
-
Zone transfers
-
Cache poisoning
-
Amplification attacks
SNMP (161)
Used for monitoring. Risks include:
-
Default community strings
-
Information disclosure
RDP (3389)
Provides remote GUI access. Risks include:
-
Weak passwords
-
Misconfigured network access
-
Known vulnerabilities
Pentesters examine each service for outdated versions, exposed features, weak authentication, and misconfigurations.
How Pentesters Analyze Ports and Services
Pentesters follow a structured process:
1. Scanning
Initial scanning identifies open ports. Tools like Nmap map the attack surface using TCP and UDP scans.
2. Enumeration
Enumeration reveals detailed service information. This includes:
-
Version numbers
-
Protocol details
-
Supported features
-
Authentication methods
3. Vulnerability Mapping
Once services are identified, pentesters compare them against:
-
Known exploits
-
CVEs
-
Misconfiguration checklists
-
Protocol weaknesses
4. Exploitation Attempts
After confirming a vulnerability, controlled exploitation validates impact.
Why Ports, Protocols, and Services Matter
Every attack begins with discovering what services exist. Understanding ports and protocols lets pentesters:
-
Map reachable systems
-
Identify high-risk services
-
Detect firewall rules
-
Recognize outdated protocols
-
Build accurate attack paths
Strong knowledge of this topic leads to faster discovery, cleaner reports, and more successful testing.
Intel Dump
-
Ports identify services; protocols define communication rules; services run on ports
-
TCP, UDP, and ICMP form the core protocol set
-
Common services include HTTP, SSH, DNS, SMB, FTP, SMTP, SNMP, RDP
-
Pentesters scan, enumerate, map vulnerabilities, and attempt exploitation
-
Understanding services helps identify misconfigurations and high-risk systems