Before all of this, if you are on a Windows machine, it might be a good idea to first migrate to another process like
explorer.exe to be sure that the meterpreter session runs with the admin’s privileges. Otherwise, you might still be using a process running with the privileges of a lower privileged user.
To do so, from your meterpreter session, run:migrate -N explorer.exeThen, run:
backgrounduse post/multi/manage/autorouteFor more information about the configuration of this module, see the official documentation: https://docs.metasploit.com/docs/using-metasploit/intermediate/pivoting-in-metasploit.html#autoroute
Once you have correctly configured the module, run:
runWe can verify that the route was correctly configured using:
routeAt this point, Metasploit modules should be able to use the pivot. To use the pivot with different tools:
use auxiliary/server/socks_proxyFor more information about the configuration of this module, see the official documentation: https://docs.metasploit.com/docs/using-metasploit/intermediate/pivoting-in-metasploit.html#socks-server-module-setup
From another terminal, we can configure proxychains-ng to pass through our proxy by adding:
socks5 127.0.0.1 1080at the end of the file, using:
sudo nano /etc/proxychains.confWe can now run any command through our pivot by using the command:
sudo proxychains4 $CMDNote that UDP traffic cannot pass through the proxy.