Port Scanning and Network Reconnaissance
What you'll learn: How attackers use XSS vulnerabilities to turn a victim's browser into a scanner that probes internal networks from the inside.
The Core Idea
When an attacker successfully injects JavaScript via XSS, they gain code execution in the victim's browser context. This is powerful because the victim's browser likely sits inside a trusted network (corporate intranet, home network, etc.) that the attacker cannot reach directly from the outside. The attacker can inject JavaScript that makes the victim's browser send requests to internal IP addresses and services, effectively using the browser as a reconnaissance tool to map the network.
How It Works
The injected script can attempt to load resources from internal addresses (192.168.x.x, 10.x.x.x, 172.16.x.x) or localhost (127.0.0.1). By measuring response times or detecting error patterns, the attacker can determine:
- Which hosts are alive (by attempting connections)
- Which ports are open (based on how quickly requests fail or succeed)
- What services are running (by analyzing response behaviors)
For example, a fast connection failure might indicate a closed port, while a timeout suggests a filtered/firewalled port. A successful response reveals an open service.
The Danger
This turns XSS from a client-side annoyance into an internal network mapping tool. The attacker discovers:
- Internal IP ranges
- Web interfaces (routers, printers, admin panels)
- Development servers
- Database frontends
All from behind the firewall, using the victim's trusted position as a springboard for deeper attacks.
Key Takeaway:
XSS can transform a victim's browser into an internal network scanner, allowing attackers to map infrastructure and discover services hidden behind firewalls—all from the trusted perspective of an insider.