Pivoting, Tunneling, and Port Forwarding
Lateral movement is a technique that adversaries use, after compromising an endpoint, to extend access to other hosts or applications in an organization.
Pivoting's primary use is to defeat segmentation (both physically and virtually) to access an isolated network. Tunneling, on the other hand, is a subset of pivoting. Tunneling encapsulates network traffic into another protocol and routes traffic through it.
Basic concepts
IP Addressing & NICs: Whether assigned dynamically or statically, the IP address is assigned to a Network Interface Controller (NIC). Commonly, the NIC is referred to as a Network Interface Card or Network Adapter. A computer can have multiple NICs (physical and virtual), meaning it can have multiple IP addresses assigned, allowing it to communicate on various networks.
Some adapters will have an IPv4 and an IPv6 address assigned in a dual-stack configuration allowing resources to be reached over IPv4 or IPv6.
We will see public IPs on devices that are directly facing the Internet, commonly hosted in DMZs.
Routing: Technically any computer can become a router and participate in routing. A router has a routing table that it uses to forward traffic based on the destination IP address. Sometimes we need to make a pivot host route traffic to another network. One way to do it is through the use of AutoRoute, which allows the attacker machine to have routes to target networks that are reachable through a pivot host.
Stand-alone appliances designated as routers typically will learn routes using a combination of static route creation, dynamic routing protocols, and directly connected interfaces. Any traffic destined for networks not present in the routing table will be sent to the default route, which can also be referred to as the default gateway or gateway of last resort.
Footprinting
Check for additional NICs:
Check out the routing table:
SSH
Port forwarding
| NIC | Attacker machine: kali | Attacked machine 2: Windows MS01 |
Attacked machine 3: Linux LINUX01 |
|---|---|---|---|
| 1 | 10.10.15.9/24 | 10.129.32.62/24 | |
| 2 | 172.16.1.5/24 | 172.16.1.15/24 | |
Logs you into MS01 (10.129.32.62). Sets up a port forwarding tunnel from your Kali machine (localhost:9999) to 172.16.1.15:22 via MS01. - The -L option sets up forwarding for traffic through MS01. Since MS01 has direct access to LINUX01, it transparently forwards the connection. |
Another example. We will use this tunneling as a way to access locally to a remote postgresql service:
1. In the attacking machine:
2. In another terminal in the attacking machine:
Forward multiple ports
Dynamic port forwarding
Dynamic port forwarding uses a single local port and dynamically assigns remote ports for each connection.
SSH command with the -D option: To use dynamic port forwarding with SSH, you can use the ssh command with the -D option, followed by the local port, the remote host and port, and the remote SSH server.
2. Setting up proxychains: Now we will require a tool that can route any tool's packets over the port 1234. We can do this using the tool proxychains, which is capable of redirecting TCP connections through TOR, SOCKS, and HTTP/HTTPS proxy servers.
nmaps + proxychains
Once you complete the previous steps 1 and 2, you can use nmap with proxychains:
Tip
One more important note to remember here is that we can only perform a full TCP connect scan over proxychains. The reason for this is that proxychains cannot understand partial packets.
RDP + proxychains
With proxychains you can use more services. For instance, xfreerdp:
Set the dynamic proxy using ssh portforwarding:
In the discovered networks range, scan ips. Use proxychain with nmap:
We have found $NewDiscoveredIp with open port 3389. We know the creds. So, with proxychain we can connect:
Metasploit + proxychains
Now, run metasploit:
SSH Reverse Port Forwarding
| NIC | Attacker machine: kali | Attacked machine 1: ubuntu META |
Attacked machine 2: Windows META2 |
|---|---|---|---|
| 1 | 192.64.166.2/24 | 192.64.166.3/24 | |
| 2 | 192.182.147.2/24 | 192.182.147.3/24 |

Goal: From the kali we will make a RDP connection with Meta_2, the windows machine.
For that we will use the Victim's machine 1 as a reverse port forwarding.
Obtain a reverse shell
Now we need to create a payload that is going to be triggered in the Victim's machine 2 (the windows one). First we create it in our kali:
Now we move this malicious file to the victim's machine 2:
Now, we start a listener in our kali:
Now we execute the payload from the Windows target.
We will receive the reverse shell.
Module portfwd in metasploit
Reverse port forwarding can also be accomplished using Meterpreter's portfwd module, where you might want to listen on a specific port on the compromised server and forward all incoming shells from the Ubuntu server to our attack host.
We will start a listener on a new port on our attack host for Windows and request the Ubuntu server to forward all requests received to the Ubuntu server on port 1234 to our listener on port 8081.
1. Configuring & Starting multi/handler
We can now create a reverse shell payload that will send a connection back to our Ubuntu server on 192.182.147.2:1234 when executed on our Windows host. Once our Ubuntu server receives this connection, it will forward that to attack host's ip:8081 that we configured.
Finally, if we execute our payload on the Windows host, we should be able to receive a shell from Windows pivoted via the Ubuntu server.
SSH Double pivoting - Port Fordward
| NIC | Attacker machine: kali | Attacked machine 1: ubuntu CONFLUENCE01 |
Attacked machine 2: Windows PGDATABASE01 |
Attacked machine 3: Windows |
|---|---|---|---|---|
| 1 | 192.168.45.187/23 | 192.168.187.63/23 | ||
| 2 | 10.4.187.63/24 | 10.4.187.215/24 | ||
| 3 | 172.16.187.110/24 | 172.16.187.217/24 |
![[double.png]]
From kali we achieve a reverse shell on Confluence01.
We also know the ssh user database_admin of PGDATABASE01, our pivoted machine number 2.
And now in the terminal of our first pivot Confluence01, we establish the following tunnel:
And now, from kali we can access the last service 172.16.187.217 using the tunnel that we set in port 4455 (assuming that we also know the password for that share):
And browse the share:
SSH Double pivoting - Dynamic Port Fordwarding
| NIC | Attacker machine: kali | Attacked machine 2: ubuntu CONFLUENCE01 |
Attacked machine 3: Windows PGDATABASE01 |
Attacked machine 5: Windows HRSHARES |
|---|---|---|---|---|
| 1 | 192.168.45.187/23 | 192.168.213.63/23 | ||
| 2 | 10.4.213.215/24 | 10.4.213.217/24 | ||
| 3 | 172.16.213.217/24 | 172.16.213.221/24 |
![[ssh-dinamic.png]]
From kali we achieve a reverse shell on Confluence01.
We also know the ssh user database_admin of PGDATABASE01, our pivoted machine number 2.
And now in the terminal of our first pivot Confluence01, we establish the following tunnel:
And now, from kali we can access the last service 172.16.213.217 using the tunnel that we set and enumerate all services in other internal IPs. But we need to enable proxychains.
So in kali:
It should display:
With Proxychains properly configured, we can use smbclient from our Kali machine to enumerate available shares on HRSHARES. Rather than connecting to the port on CONFLUENCE01, we'll write the smbclient command as though we have a direct connection to PGDATABASE01.
We may also use nmap and other services from kali.
SSH Remote Port Forwarding
| NIC | Attacker machine: kali | Attacked machine 2: ubuntu CONFLUENCE01 |
Attacked machine 3: Windows PGDATABASE01 |
Attacked machine 4: Windows HRSHARES |
|---|---|---|---|---|
| 1 | 192.168.45.187/23 | 192.168.213.63/23 | ||
| 2 | 10.4.213.63/24 | 10.4.213.215/24 | ||
| 3 | 172.16.213.215/24 | 172.16.213.217/24 |
![[ssh-reverse.png]]
The explanation: Outbound connections are more difficult to control than inbound connections. Most corporate networks will restrict inbound traffic but they will allow many types of common network traffic out (including SSH!). This is where SSH remote port forwarding can be extremely useful.
We can think of it like a reverse shell, but for port forwarding. While in local and dynamic port forwarding, the listening port is bound to the SSH client, in remote port forwarding, the listening port is bound to the SSH server. Instead of the packet forwarding being done by the SSH server, in remote port forwarding, packets are forwarded by the SSH client.
Start a Kali SSH server:
Initiate the reverse shell we had in Confluence01.
And now:
With the port forward active, we can now query port 2345 on the Kali loopback interface as though interacting directly with the PostgreSQL service on PGDATABASE01. From kali:
It will be redirected to the 10.4.213.215:5432
SSH Remote Dynamic Port Forwarding
With remote port forwarding, we were able to forward packets to one socket per SSH connection. However, just as we found with local port forwarding, this single-socket-per-connection limitation can slow us down. Remote dynamic port forwarding creates a dynamic port forward in the remote configuration.
| NIC | Attacker machine: kali | Attacked machine 2: ubuntu CONFLUENCE01 |
Attacked machine 3: Windows MULTISERVER03 |
Attacked machine 4: Windows PGDATABASE01 |
Attacked machine 5: Windows HRSHARES |
|---|---|---|---|---|---|
| 1 | 192.168.45.187/23 | 192.168.213.63/23 | |||
| 2 | 10.4.213.63/24 | 10.4.213.64/24 | 10.4.213.215/24 | ||
| 3 | 172.16.213.215/24 | 172.16.213.217/24 |
![[ssh-dinamic-forwarding2.png]]
Remote dynamic port forwarding has only been available since October 2017's OpenSSH 7.6.
The remote dynamic port forwarding command is relatively simple, although (slightly confusingly) it uses the same -R option as classic remote port forwarding. The difference is that when we want to create a remote dynamic port forward, we pass only one socket: the socket we want to listen on the SSH server. We don't even need to specify an IP address; if we just pass a port, it will be bound to the loopback interface of the SSH server by default.
Start a Kali SSH server:
Initiate the reverse shell we had in Confluence01.
And now:
Back on our Kali machine, we can check that port 9998 is bound by using ss.
The SOCKS proxy port has been bound on both the IPv4 and IPv6 loopback interfaces on our Kali machine.
We'll edit our Proxychains configuration file at /etc/proxychains4.conf on our Kali machine to reflect our new local SOCKS proxy port.
containing:
Now we can:
SSH Pivoting with Sshuttle
| NIC | Attacker machine: kali | Attacked machine 2: ubuntu | Attacked machine 3: Windows |
|---|---|---|---|
| 1 | 10.10.10.2/24 | 10.10.10.3/24 | |
| 2 | 10.10.20.2/24 | 10.10.20.3/24 |
Sshuttle is another tool written in Python which removes the need to configure proxychains. However, this tool only works for pivoting over SSH and does not provide other options for pivoting over TOR or HTTPS proxy servers.
Sshuttle can be extremely useful for automating the execution of iptables and adding pivot rules for the remote host. We can configure the Ubuntu server as a pivot point and route all of Nmap's network traffic with sshuttle:
1. Installing sshuttle
2. Running sshuttle
3. We can now use any tool directly without using proxychains.
Metasploit
Module portfwd in metasploit
Port forwarding can also be accomplished using Meterpreter's portfwd module. We can enable a listener on our attack host and request Meterpreter to forward all the packets received on this port via our Meterpreter session to a remote host on the 172.16.5.0/23 network
1. Create a payload for Ubuntu Pivot Host (our victim's machine 1):
2. Start a multi/handler, also known as a Generic Payload Handler.
3. Copy the backupjob binary file to the Ubuntu pivot host over SSH and execute it to gain a Meterpreter session.
4. Once the meterpreter Session is established, use Metasploit's post-exploitation portfwd module:
5. Connect to victim's machine2 from the attacker machine:
Module ping_sweep in metasploit
Module ping_sweep in metasploit allows us to perform a ping sweep from our meterpreter session to the new discovered subnet (reachable only from that session).
1. Create a payload for Ubuntu Pivot Host (our victim's machine 1):
2. Start a multi/handler, also known as a Generic Payload Handler.
3. Copy the backupjob binary file to the Ubuntu pivot host over SSH and execute it to gain a Meterpreter session.
4. Once the meterpreter Session is established, do the ping sweep with the module ping_sweep:
Module Autoroute in metasploit
Autoroute module allows you to set routes from a meterpreter session to a discovered subnet in the attacked machine. It allow us pivoting from one subnet to another.
1. Create a payload for Ubuntu Pivot Host (our victim's machine 1):
2. Start a multi/handler, also known as a Generic Payload Handler.
3. Copy the backupjob binary file to the Ubuntu pivot host over SSH and execute it to gain a Meterpreter session.
4. Once the meterpreter Session is established, send the session to the background with CTRL-z and in the same terminal use Metasploit's post-exploitation routing module socks_proxy to configure a local proxy on our attack host.
5. Add a Line to proxychains.conf if needed (in your kali machine).
6. Finally, we need to tell our socks_proxy module to route all the traffic via our Meterpreter session. Use the post/multi/manage/autoroute module from Metasploit to add routes for the 172.16.5.0 subnet and then route all our proxychains traffic.
7. Make sure that you will get back the communications with a reverse proxy:
8. Finally, use proxychains to route our Nmap traffic via our Meterpreter session.
Socat
Port forwarding: gaining a Reverse Shell
Socat is a bidirectional relay tool that can create pipe sockets between 2 independent network channels without needing to use SSH tunneling. It acts as a redirector that can listen on one host and port and forward that data to another IP address and port.
![[socat_01.png]]
From the CONFLUENCE01 pivoting machine:
where:
Now we CANNOT run nmap from our kali attacking machine commands on the second network interface in Confluence01 to enumerate services in PGDATABASE01:
BUT we can connect to that network interface by tunneling the communication via the socat:
Note the IP is the pivoting machine, and the target port used for tunneling.
Port forwarding: : gaining a Bind Shell
1. Create a bind shell with the windows payload using msfvenom from our attacker machine:
2. Start a socat bind shell listener, which listens on port 8080 and forwards packets to Windows server 8443. We do this from the attacked machine 1.
3. Configuring & Starting the Bind multi/handler. We do this from the attacked machine 1.
SSH for Windows: plink.exe
Plink, short for PuTTY Link, is a Windows command-line SSH tool that comes as a part of the PuTTY package when installed. Similar to SSH, Plink can also be used to create dynamic port forwards and SOCKS proxies
| NIC | Attacker machine: windows with putty | Attacked machine 2: ubuntu | Attacked machine 3: Windows |
|---|---|---|---|
| 1 | 10.10.10.2 | 10.10.10.3 | |
| 2 | 10.10.20.2 | 10.10.20.3 |
Another Windows-based tool called Proxifier can be used to start a SOCKS tunnel via the SSH session we created. Proxifier is a Windows tool that creates a tunneled network for desktop client applications and allows it to operate through a SOCKS or HTTPS proxy and allows for proxy chaining. It is possible to create a profile where we can provide the configuration for our SOCKS server started by Plink on port 9050.
After configuring the SOCKS server for 127.0.0.1 and port 9050, we can directly start mstsc.exe to start an RDP session with a Windows target that allows RDP connections.
Web Server Pivoting with Rpivot
Pivoting to access a web server on an internal network
Rpivot is a reverse SOCKS proxy tool written in Python for SOCKS tunneling. Rpivot binds a machine inside a corporate network to an external server and exposes the client's local port on the server-side.
| NIC | Attacker machine: kali | Attacked machine 1: ubuntu | Attacked machine 2: Windows |
|---|---|---|---|
| 1 | 10.10.10.2/24 | ||
| 2 | 10.10.50.2/24 | ||
| 3 | 172.10.20.2/24 | 172.10.20.3/24 |
And an External Network at 10.10.40.0
We will take the scenario above, where we have a web server on our internal network (172.10.20.135), and we want to access that using the rpivot proxy.
1. Install rpivot in kali attacker machine:
2. Run server.py with python2.7 from the kali attacker machine:
3. Transfer rpivot folder to the target, the attacked machine 1: ubuntu.
4. Run client.py from the pivot target (attacked machine 1: ubuntu):
5. Configure proxychains to pivot over our local server on 127.0.0.1:9050 on our attacker machine, which was initially started by the Python server.
6. Finally, we should be able to access the webserver on our server-side, which is hosted on the internal network of 172.16.5.0/23 at 172.16.5.135:80 using proxychains and Firefox.
Pivoting to access an external server (attack host) on the cloud
here could be scenarios when we cannot directly pivot to an external server (attack host) on the cloud. Some organizations have HTTP-proxy with NTLM authentication configured with the Domain Controller. In such cases, we can provide an additional NTLM authentication option to rpivot to authenticate via the NTLM proxy by providing a username and password. In these cases, we could use rpivot's client.py in the following way.
Client NTLM authentication example

1. Connect to a Web Server using HTTP-Proxy & NTLM Auth
Port Forwarding with Windows Netsh
Netsh is a Windows command-line tool that can help with the network configuration of a particular Windows system. Here are just some of the networking related tasks we can use Netsh for:
Finding routesViewing the firewall configurationAdding proxiesCreating port forwarding rules
We can use netsh.exe to forward all data received on a specific port (say 8080) to a remote host on a remote port.
This can be performed entering in the Windows machine (Windows-based pivot host) and using the below command.
Now we can connect to the 8080 port of the Windows machine (Windows-based pivot host) from our kali attacking machine using xfreerdp:
DNS tunneling
Dnscat2
Dnscat2 is a tunneling tool that uses DNS protocol to send data between two hosts. It uses an encrypted Command-&-Control (C&C or C2) channel and sends data inside TXT records within the DNS protocol.
There is a powershell version for the dnscat2 client: https://github.com/lukebaggett/dnscat2-powershell
dnscat2 comes in two parts: the client and the server.
- The client is designed to be run on a compromised machine. When you run the client, you typically specify a domain name. All requests will be sent to the local DNS server, which are then redirected to the authoritative DNS server for that domain (which you, presumably, have control of).
- The server is designed to be run on an authoritative DNS server.
dnscat2 strives to be different from other DNS tunneling protocols by being designed for a special purpose: command and control. It can tunnel any data, with no protocol attached. Which means it can upload and download files, it can run a shell, and it can do those things well. It can also potentially tunnel TCP, but that's only going to be added in the context of a pen-testing tool (that is, tunneling TCP into a network), not as a general purpose tunneling tool.
1. Install it in the attacker machine kali:
2. Start the dnscat2 server by executing the dnscat2 file.
After running the server, it will provide us the secret key, which we will have to provide to our dnscat2 client on the Windows host so that it can authenticate and encrypt the data that is sent to our external dnscat2 server:
3. Depending on if we are attacking a windows or a linux machine, we need to use a dnscat2 version for linux or for windows.
- Linux: the original dnscat2
- Windows: https://github.com/lukebaggett/dnscat2-powershell
In this case our attacked machine 1 is a windows machine so we will install dnscat 2 powershell version for clients.
Installation:
4. After dnscat2.ps1 is imported, we can use it to establish a tunnel with the server running on our attack host. We can send back a CMD shell session to our server.
5. In the server launched from the kali machine you will see:
6. Dnscat2 cheat sheet commands:
Chisel
Chisel pivot
Chisel is a TCP/UDP-based tunneling tool written in Go that uses HTTP to transport data that is secured using SSH. Chisel can create a client-server tunnel connection in a firewall restricted environment.
This can allow us to pivot from a reachable network segment to a different network segment. The traffic between the Chisel client and server is all HTTP-formatted. This means we can traverse the deep packet inspection solution regardless of the contents of each HTTP packet.
Scenario #1 from Offsec
| NIC | Attacker machine: kali | Compromised machine 1: ubuntu CONFLUENCE01 |
Attacked machine 2: Windows PGDATABASE01 |
|---|---|---|---|
| 1 | 192.168.45.231/23 | 192.168.227.63/23 | |
| 2 | 10.4.227.63/24 | 10.4.227.215/24 |
Check chisel releases to get the appropriate version (go version and chisel one):
Serve from kali the chisel client to the compromised pivoting machine 1 CONFLUENCE01:
Trigger the CVE vulnerability from CONFLUENCE01 to achieve the reverse shell:
In kali, start the chisel server:
And now initiate the reverse tunnel:
Check status of the SOCKs proxy with:
And... now we can use the tunnel. For that, we'll use Ncat, the Netcat alternative written by the maintainers of Nmap. We can install this on Kali with sudo apt install ncat.
And now, establish access to the SSH server, through the Chisel reverse SOCKS proxy, tunneling traffic through a reverse HTTP tunnel.
Scenario #2 from HTB
For that, we will use the compromised machine (Ubuntu) as our Chisel server, listing on port 1234:
| NIC | Attacker machine: kali | Compromised machine Ubuntu | Target: A webserver |
|---|---|---|---|
| 1 | 10.10.10.2/24 | 10.10.10.3/24 | |
| 2 | 172.16.5.10/23 | Webserver located at the network range 172.16.5.0/23 with a Domain Controller at 172.16.5.19 |
1. Install chisel:
2. Once the binary is built, we can use SCP to transfer it to the target pivot host.
3. Run the Chisel Server on the Pivot Host, the ubuntu Attacked machine:
The Chisel listener will listen for incoming connections on port 1234 using SOCKS5 (--socks5) and forward it to all the networks that are accessible from the pivot host. In our case, the pivot host has an interface on the 172.16.5.0/23 network, which will allow us to reach hosts on that network.
4. Connect to the chisel server
Results:
The Chisel client has created a TCP/UDP tunnel via HTTP secured using SSH between the Chisel server and the client and has started listening on port 1080.
5. Now we can modify our proxychains.conf file located at /etc/proxychains4.conf and add 1080 port at the end so we can use proxychains to pivot using the created tunnel between the 1080 port and the SSH tunnel.
6. Now if we use proxychains with RDP, we can connect to the DC on the internal network through the tunnel we have created to the Pivot host.
Chisel Reverse Pivot
In the previous example, we used the compromised machine (Ubuntu) as our Chisel server, listing on port 1234. Still, there may be scenarios where firewall rules restrict inbound connections to our compromised target. In such cases, we can use Chisel with the reverse option.
| NIC | Attacker machine: kali | Compromised machine Ubuntu | Target: A webserver |
|---|---|---|---|
| 1 | 10.10.10.2/24 | 10.10.10.3/24 | |
| 2 | 172.16.5.10/23 | Webserver located at the network range 172.16.5.0/23 with a Domain Controller at 172.16.5.19 |
1. Start the Chisel Server on our attacker machine or attacker host:
2. Then we connect from the Ubuntu (pivot host) to our attacker machine (or attack host), using the option R:socks
Results:
3. Now we can modify our proxychains.conf file located at /etc/proxychains4.conf and add 1080 port at the end so we can use proxychains to pivot using the created tunnel between the 1080 port and the SSH tunnel.
4. Now if we use proxychains with RDP, we can connect to the DC on the internal network through the tunnel we have created to the Pivot host.
ICMP tunneling with SOCKS
ICMP tunneling encapsulates your traffic within ICMP packets containing echo requests and responses.
Important: ICMP tunneling would only work when ping responses are permitted within a firewalled network.
We will use the ptunnel-ng tool to create a tunnel between our Ubuntu server and our attack host. Once a tunnel is created, we will be able to proxy our traffic through the ptunnel-ng client. We can start the ptunnel-ng server on the target pivot host.
1. Install ptunnel-ng in the attacker machine:
2. Start the ptunnel-ng Server on the Target Host
3. With the ptunnel-ng ICMP tunnel successfully established, we can attempt to connect to the target using SSH through local port 2222 (-p2222).
Now we can:
- OR Tunnel an SSH connection through an ICMP Tunnel
- OR use proxychains with nmap to scan targets on the internal network.
- OR use proxychains with RDP to connect to the machine in the other network range:
RDP and SOCKS Tunneling with SocksOverRDP
There are often times during an assessment when we may be limited to a Windows network and may not be able to use SSH for pivoting. We would have to use tools available for Windows operating systems in these cases. SocksOverRDP is an example of a tool that uses Dynamic Virtual Channels (DVC) from the Remote Desktop Service feature of Windows. DVC is responsible for tunneling packets over the RDP connection. Some examples of usage of this feature would be clipboard data transfer and audio sharing. However, this feature can also be used to tunnel arbitrary packets over the network. We can use SocksOverRDP to tunnel our custom packets and then proxy through it. We will use the tool Proxifier as our proxy server.
| NIC | Attacker machine: kali | Attacked machine 1: Windows | Attacked machine 2: Windows | Attacked machine 3: Windows |
|---|---|---|---|---|
| 1 | 10.10.10.2 | 10.10.10.3 | ||
| 2 | 172.16.5.150 | 172.16.5.19 | ||
| 3 | 172.16.6.150 | 172.16.6.155 |
Our goal will be reaching the attacked machine 3.
1. First, we download appropriate binaries to our kali attack host:
2. Attacking machine 1
Connect to the target using xfreerdp and transfer SocksOverRDPx64.zip to the Windows target machine. Once done, unzip it.
From the Windows machine 1, we will then need to load the SocksOverRDP.dll (located within the SocksOverRDP-x64 folder) using regsvr32.exe. Do it as Admin
3. Attacking machine 2
Now, from the machine 1, we can connect to machine 2 over RDP using mstsc.exe. Windows-R and enter mstsc.exe. Enter the machine 2 IP 172.16.5.19, username and password. When doing so, we should receive a prompt that the SocksOverRDP plugin is enabled. And we will have access to the machine 2 from the RDP connection done from machine 1.
4. Attacking machine 3
Now we need to transfer SocksOverRDPx64.zip or just the SocksOverRDP-Server.exe to machine 2, 172.16.5.19. You can just try to copy paste it.
When done, start SocksOverRDP-Server.exe with Admin privileges in machine 2.
When we go back to our foothold target (machine 1) and check with Netstat, we should see our SOCKS listener started on 127.0.0.1:1080.
Also, we transfer from our kali machine to the machine 1, the proxifier portable. Once done we configure it in machine 1 to forward all our packets to 127.0.0.1:1080. Use SOCKS5 as protocol.
With Proxifier configured and running, we can start mstsc.exe, and it will use Proxifier to pivot all our traffic via 127.0.0.1:1080, which will tunnel it over RDP to 172.16.5.19, which will then route it to 172.16.6.155 using SocksOverRDP-server.exe.
So, now Windows-R and mstsc.exe to connect to machine 3 with username and password. If there are some problems with the connection, play in RDP program with the tab EXPERIENCE.
Last update: 2026-02-15 Created: November 5, 2024 21:44:57