DEV Community

Billy
Billy

Posted on

A Practical Workflow for Finding and Fixing Internet-Exposed Services

Internet-facing services are easy to forget. A temporary admin panel, an old staging host, or a database bound to 0.0.0.0 can remain reachable long after the original deployment is finished.

This tutorial shows a small, repeatable workflow for finding exposed services on systems you own, validating what is actually reachable, and using ScanSearch as an external view of your organization’s internet footprint.

Only scan hosts and networks you are authorized to assess. Internet-wide search is useful for defensive asset discovery, but it does not grant permission to probe someone else’s infrastructure.

1. Start with a local inventory

Before looking at the public internet, establish what your server is supposed to expose. On a Linux host, list listening sockets with:

ss -tulpn
Enter fullscreen mode Exit fullscreen mode

For a containerized application, also check published ports:

docker ps --format 'table {{.Names}}\t{{.Ports}}'
Enter fullscreen mode Exit fullscreen mode

A typical result might reveal an application intended to be private but published publicly:

0.0.0.0:8080->8080/tcp
0.0.0.0:5432->5432/tcp
Enter fullscreen mode Exit fullscreen mode

The first could be a development dashboard. The second is a PostgreSQL database. Neither should automatically be reachable from the entire internet.

2. Scan your own external address

Local configuration is not the same as external exposure. Cloud security groups, load balancers, NAT rules, and host firewalls can all change the result.

From an authorized machine, use Nmap against the public IP or hostname:

nmap -Pn -sV --top-ports 1000 example.com
Enter fullscreen mode Exit fullscreen mode

Useful options here are:

  • -Pn: treat the host as online, even if ICMP is blocked
  • -sV: attempt service and version detection
  • --top-ports 1000: check commonly used ports without scanning every port

For a repeatable report, save XML output:

nmap -Pn -sV --top-ports 1000 -oX scan.xml example.com
Enter fullscreen mode Exit fullscreen mode

Do not treat a port number as proof of a vulnerability. Port 8080 only tells you that something answered there. You still need to identify the service, verify its configuration, and check whether exposure is intentional.

3. Turn scan output into a small report

Nmap’s XML format is convenient for automation. This Python script extracts open ports and detected service names:

#!/usr/bin/env python3
import sys
import xml.etree.ElementTree as ET

if len(sys.argv) != 2:
    raise SystemExit(f"usage: {sys.argv[0]} scan.xml")

root = ET.parse(sys.argv[1]).getroot()

for host in root.findall("host"):
    address = host.find("address")
    address_value = address.get("addr", "unknown") if address is not None else "unknown"

    for port in host.findall(".//port"):
        state = port.find("state")
        if state is None or state.get("state") != "open":
            continue

        service = port.find("service")
        name = service.get("name", "unknown") if service is not None else "unknown"
        product = service.get("product", "") if service is not None else ""
        version = service.get("version", "") if service is not None else ""

        details = " ".join(part for part in (product, version) if part)
        print(f"{address_value}:{port.get('portid')}/{port.get('protocol')} - {name} {details}")
Enter fullscreen mode Exit fullscreen mode

Run it with:

python3 report_ports.py scan.xml
Enter fullscreen mode Exit fullscreen mode

This gives you a clean starting point for ticketing: asset, port, protocol, service, and detected version.

4. Check HTTP services safely

For web services, collect response headers before opening the application in a browser:

curl -sS -D headers.txt -o /dev/null https://example.com
cat headers.txt
Enter fullscreen mode Exit fullscreen mode

You may find clues such as a server banner, missing security headers, an unexpected redirect, or an internal hostname in a response header. Headers are evidence, not a complete security assessment, so avoid drawing conclusions from one field.

A quick Python check for a few baseline headers:

import sys
import requests

url = sys.argv[1]
response = requests.get(url, timeout=10, allow_redirects=True)

expected = [
    "Content-Security-Policy",
    "Strict-Transport-Security",
    "X-Content-Type-Options",
]

print(f"final URL: {response.url}")
print(f"status: {response.status_code}")

for header in expected:
    print(f"{header}: {response.headers.get(header, '<missing>')}")
Enter fullscreen mode Exit fullscreen mode

Install the dependency once with python3 -m pip install requests, then run:

python3 check_headers.py https://example.com
Enter fullscreen mode Exit fullscreen mode

5. Use ScanSearch for external discovery

Local scans answer, “What can I see from this network?” An internet-wide search engine answers a different question: “What does the public internet appear to associate with this asset?”

Open ScanSearch and search for an organization-owned hostname, public IP address, or known service. Use the result to compare against your inventory:

  • Is an old hostname still visible?
  • Does a cloud address expose a port you did not expect?
  • Is a staging service presenting a recognizable banner?
  • Does the observed service match the version you believe is deployed?

Treat search results as a lead to validate, not as a final vulnerability report. Recheck important findings from an authorized network, then fix the cause: remove the public listener, restrict the firewall rule, require a VPN, update the service, or decommission the asset.

The practical loop is simple: inventory, scan, validate, remediate, and scan again. That cycle catches forgotten exposure much more reliably than relying on a one-time security review.

Top comments (0)