When an attacker targets your infrastructure, one of their first steps is a port scan. Tools like Nmap send carefully crafted packets to every port on your server and analyse the responses. In minutes, they have a complete inventory of every service your server exposes to the internet — web servers, SSH, databases, mail servers, and anything else listening on a port. Each open port is a potential entry point, and many organisations expose far more services than they realise.
What a Port Scan Reveals
A comprehensive Nmap scan provides more than just a list of open ports. It reveals:
- Service identification: Not just that port 8080 is open, but that it's running Apache Tomcat 9.0.65. Version numbers map directly to known CVEs.
- Operating system fingerprinting: TCP/IP stack behaviour differences between operating systems let Nmap identify whether the server runs Linux, Windows, or FreeBSD — and often the specific version.
- Script results: Nmap's scripting engine (NSE) can test for specific vulnerabilities, enumerate SSL/TLS configurations, extract HTTP headers, and identify web application technologies.
- Firewall detection: The pattern of filtered vs closed ports reveals firewall rules and helps attackers map the security boundary.
$ nmap -sV -sC target.com
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.9p1
80/tcp open http nginx 1.24.0
443/tcp open ssl/https nginx 1.24.0
3306/tcp open mysql MySQL 8.0.35
8080/tcp open http-proxy Apache Tomcat 9.0.65
9200/tcp open http Elasticsearch 7.17.0
This output tells an attacker there's an SSH server, a web server, a directly exposed database, a development application server, and a search engine — all accessible from the internet. The version numbers provide a direct path to exploitation.
The Problem of Unnecessary Services
Most production web servers need exactly two ports open to the internet: 80 (HTTP, for redirect to HTTPS) and 443 (HTTPS). Yet port scans routinely find:
- Database ports (3306, 5432, 27017): MySQL, PostgreSQL, and MongoDB should never be directly accessible from the internet. A directly exposed database is one weak password away from complete data theft.
- Development services (8080, 3000, 8443): Staging servers, development instances, and debug ports left accessible in production environments.
- Management interfaces (8443, 10000, 2082): cPanel, Webmin, and server management panels that provide root-level control through a web interface.
- Legacy services (21, 23, 25): FTP, Telnet, and unauthenticated SMTP that transmit credentials in plaintext and provide direct shell access if compromised.
Each unnecessary open port multiplies the attack surface without providing any value to legitimate users.
How Attackers Use Port Scan Data
Port scanning isn't the attack itself — it's the reconnaissance that informs the attack. The workflow follows a predictable pattern:
- Discovery: Scan the target's IP range to identify all open ports and services.
- Enumeration: Determine exact versions of each service using banner grabbing and fingerprinting.
- Vulnerability mapping: Cross-reference discovered versions against CVE databases to identify known exploits.
- Exploitation: Deploy exploits against the most promising targets — typically the service with the oldest unpatched version.
Automated attack tools combine these steps. Shodan and Censys continuously scan the entire internet, cataloguing every open port on every IP address. Your servers are already in their database. Attackers query these services to find targets with specific vulnerable versions, eliminating the scanning step entirely.
Attack Surface Reduction
The most effective defence is minimising what's exposed. For each open port, ask:
- Does this service need internet access? Databases, caches, and internal APIs should be accessible only from trusted private networks or through VPN/SSH tunnels.
- Is this service current? Outdated versions with known CVEs should be updated immediately or taken offline.
- Is this service necessary? Decommissioned services, forgotten development instances, and unused management panels should be shut down entirely.
- Is this service hardened? SSH should require key-based authentication. Management panels should be restricted to specific IP ranges. All services should have strong authentication.
Beyond Port Scanning: The Full Attack Surface
Ports are just one dimension of your attack surface. A complete assessment includes DNS records (dangling entries, missing email authentication), HTTP headers (missing security headers, information disclosure), TLS configuration (weak ciphers, expiring certificates), and web application behaviour (error messages, directory listings, exposed admin panels). Each dimension provides information that attackers combine to build a comprehensive attack plan.
ShieldReport maps your domain's external attack surface — from exposed services and server configuration to security headers and DNS records — identifying the unnecessary exposure that invites reconnaissance and the misconfigurations that attackers exploit after finding you.