Catching exposed remote access with nmap, cron and diff
Daily external scanning built from free tools, with every open port traced to an owner. A newly exposed device was secured within 12 hours.
Challenge
At a UK telecoms provider, I judged that the biggest unmanaged risk was unknown devices, and remote access in particular. There was no budget for a commercial attack surface product, and no list of what the company exposed to the internet.
Approach
- Scope from authoritative data. I took every address range announced under the company's AS number. I removed customer ranges and anything the company did not own. Route announcements prove those ranges are reachable from the internet, so the scope was a fact, not an assumption.
- Scan on a schedule. I ran nmap from my own infrastructure twice a day, against ranges the company owned. I started with SSH and Telnet, then added RDP.
- Detect change. Each scan was compared with a baseline of known good results using
diff. Cron ran the job and themailcommand sent the result every day. Every change needed an explanation. - Build the baseline by finding owners. An open port is only acceptable if someone can say why it is open. For each one I traced the owner and the reason, and checked whether the device was exposed directly or sat behind a firewall or load balancer. This took the most effort, and it was the most useful part.
Outcome
A device became publicly exposed. The daily report caught it, and it was secured within 12 hours. The work also gave the company its first documented view of what it exposed to the internet, which turned later reviews from guesswork into a comparison with a known position. The results also made the case for further investment in scanning tools, because they showed which risks the company faced.