Port Forwarding

Port Forwarding Using SSH

$ ssh -L 1234:localhost:3306 Ubuntu@10.129.202.64

-L tells the ssh client to forward all requests sent to port 1234 to the localhost:3306 of the Ubuntu Server

Note: to confirm port forwarding, we can see that port 1234 is open on our machine

$ netstat -antp | grep 1234

(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
tcp        0      0 127.0.0.1:1234          0.0.0.0:*               LISTEN      4034/ssh            
tcp6       0      0 ::1:1234                :::*                    LISTEN      4034/ssh     

Forwading Multiple Ports

$ ssh -L 1234:localhost:3306 8080:localhost:80 ubuntu@10.129.202.64

Dynamic Port Forwading (SOCKS)

$ ssh -D 9050 ubuntu@10.129.202.64

-D tells ssh to do dynamic port forwarding on port 9050

Note: port 9050 must be on our proxychains.conf

Using NMAP with Proxy Chains

Note: Full TCP Connect scan can only be used because proxychains can't understand partial packets

Note: host-alive checks might also not work since Windows defender firewall blocks ICMP (ping) requests

Using msfconsole with Proxy Chains

Using xfreerdp with Proxy Chains


Port Forwarding Using Meterpreter

Assuming we already have a meterpreter session on our pivot host

Ping Sweep

Configuring MSF SOCKS Proxy

Check if Proxy Server is running

proxychains.conf

Creating Routes with auto route

Listing active routes

Testing Proxy and Routing Functionality


Using Meterpreter's portfwd module

The above command requests the Meterpreter session to start a listener on our attack host's local port (-l) 3300 and forward all the packets to the remote (-r) Windows server 172.16.5.19 on 3389 port (-p) via our Meterpreter session. Now, if we execute xfreerdp on our localhost:3300, we will be able to create a remote desktop session.

Last updated