When performing internal penetration testing, gaining a foothold is just the beginning. The next step is pivoting — finding a way to explore deeper into restricted networks. Two powerful techniques for this are SOCKS proxying and port forwarding. Both serve different purposes, and knowing when to use each is key.

  1. What is a SOCKS Proxy?
  2. Setting Up SOCKS Proxy with Metasploit
  3. Configuring ProxyChains
  4. Scanning and Enumeration
  5. Tools That Work with ProxyChains
  6. What is Port Forwarding?
  7. Side-by-Side Comparison
  8. When to Use What
  9. Pro Tips
  10. Final Thoughts

A SOCKS proxy works at the transport layer and forwards any TCP traffic through a pivot host. It allows your tools (e.g., Nmap, CrackMapExec, Hydra) to operate as if they were on the internal network.

It’s like creating a VPN through your compromised host, allowing dynamic and flexible access.

sessions -i 1
run autoroute -s 10.10.10.0/24
use auxiliary/server/socks_proxy
set SRVPORT 1080
run

This sets up a SOCKS proxy on port 1080, routing through your Meterpreter session.

Edit /etc/proxychains.conf and add:

socks5 127.0.0.1 1080

Use proxychains to route tools through the SOCKS tunnel:

proxychains nmap -sT -Pn -n -p- 10.10.10.0/24
proxychains nmap -sT -Pn -n -p 80,135,445,3389 10.10.10.10
proxychains nmap -sT -Pn -sV 10.10.10.10
ToolPurpose
crackmapexecEnumerate SMB, WinRM
xfreerdpRDP access via proxy
hydraBrute-force services
smbclientAccess Windows shares
nmapInternal scanning
impacket toolsRemote execution (e.g., wmiexec.py)
msfconsoleRoute modules via SOCKS proxy
proxychains crackmapexec smb 10.10.10.20 -u user -p pass
proxychains hydra -l admin -P rockyou.txt rdp://10.10.10.20
proxychains xfreerdp /u:user /p:pass /v:10.10.10.20

Port forwarding allows you to forward a single port from your attacker machine to a specific port on an internal target.

ssh -L 3389:10.10.10.20:3389 user@pivot
portfwd add -l 4444 -p 3389 -r 10.10.10.20

This forwards local port 4444 to RDP on the target.

  • GUI apps like RDP, VNC, or web access
  • Single-port scenarios
  • One tunnel per port
  • Tedious for large-scale recon
  • Static (no dynamic routing)
FeatureSOCKS ProxyPort Forwarding
Setup EffortOne-time setupPer-host, per-port
Multi-host Recon✅ Yes❌ No
Supports Tools (Nmap, CME)✅ Yes❌ Limited
Ideal for GUI Apps⚠️ Okay✅ Excellent
Traffic ScopeAll TCP trafficSingle port/service
UDP Support❌ No⚠️ Some workarounds
Proxychains Compatible✅ Yes❌ Not needed
SituationUse This
Need to access RDP/Web GUI/VNC?Port Forwarding
Need to scan internal subnets?SOCKS Proxy
Want to brute-force credentials at scale?SOCKS Proxy
Using Metasploit + Meterpreter?Either
Quick access to a single internal port?Port Forwarding
Pivoting across complex networks?SOCKS Proxy
  • Combine SOCKS for recon with port forwarding for GUI access
  • Use proxychains-ng for better DNS and multiple proxies
  • Use tools like ligolo or chisel for stealthy SOCKS over HTTPS
  • Test tunnels with proxychains curl <target>

If you’re scanning and enumerating: use a SOCKS proxy.
If you’re clicking and typing into a GUI app: use port forwarding.

Port forwarding is surgical.
SOCKS proxy is operational warfare.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top