FTP Bounce Attack Exploitation
A confirmed FTP bounce (covered in FTP Bounce Attack Check) turns the FTP server into a scanning proxy. The server initiates connections on your behalf to third-party hosts, allowing you to reach internal systems that have no direct route to your machine. All connections originate from the FTP server's IP, so firewall rules blocking your source address do not apply.
Scan Internal Hosts via FTP Bounce with nmap
nmap has native support for FTP bounce scanning:
Replace INTERNAL_TARGET_IP with an internal host identified through ARP, routing tables, or other enumeration. nmap uses the FTP server's PORT command capability to open data connections to each port on the internal target and determines open vs closed from the response.
With a specific port range:
Authenticated bounce if anonymous is not permitted:
Manual PORT Command Abuse
The PORT command format encodes the destination IP and port as six comma-separated decimal values. The IP 10.10.20.5 on port 80 encodes as 10,10,20,5,0,80 because the port is split into p1 * 256 + p2, so 80 = 0 * 256 + 80.
Connect to the FTP server:
PORT 10,10,20,5,0,80 LIST
Responses:
150 Opening data connectionfollowed by a listing or data means port 80 on10.10.20.5is open and the server connected425 Failed to establish connectionmeans the connection attempt was made but the port is closed or filtered500 Illegal PORT commandmeans the server blocked the third-party PORT attempt
Iterate through ports by repeating the PORT and LIST commands with different port values. This is slow manually — use nmap's -b option for any real scanning.
Port Encoding Reference
For port scanning via bounce, compute the two port encoding values:
p1 = port // 256
p2 = port % 256
Examples:
Port 22:
0,22Port 80:
0,80Port 443:
1,187Port 445:
1,189Port 3389:
13,69Port 8080:
31,144
Full PORT command for 10.10.20.5 port 445: PORT 10,10,20,5,1,189
What Bounce Scanning Reveals
The bounce scan maps what services are accessible from the FTP server's network position, not from yours. Hosts and ports that show open through the bounce but are unreachable directly from your machine indicate the FTP server has additional network access. Use this to identify database servers, internal web applications, management interfaces, and other services on segments you cannot reach directly.
Once internal services are identified, set up tunnelling through the FTP server or another pivot to interact with them. SSH port forwarding and proxychains options are covered in the Linux lateral movement pages.
References
-
Nmap Book: FTP Bounce Scannmap.org/book/scan-methods-ftp-bounce-scan.html (opens in new tab)
Official nmap documentation for the -b FTP bounce scanning method
-
ftp-bounce NSE Scriptnmap.org/nsedoc/scripts/ftp-bounce.html (opens in new tab)
Detection script that also documents the bounce condition and PORT encoding
Was this helpful?
Your feedback helps improve this page.