---
title: "13. RDP Socks tunneling with SocksOverRDP"
date: 2024-08-27
draft: false
---

Situation: 
- Limited to windows network
- Not able to use SSH for pivoting. 
- Need to use tools available to Windows for this situation 

SocksOverRDP is an example of one such tool. 
https://github.com/nccgroup/SocksOverRDP

Uses DVC `Dynamic Virtual Channels` from RDP service feature in windows. 
- Responsible for tunneling packets over an RDP connection
- EX: 
	- Clipboard data
	- Audio sharing
- Feature can be used to tunnel arbitrary packets over a network. 
- SocksOverRDP uses this feature to tunnel custom packets and proxy through it. 

We use the tool `proxifier` as our proxy server.
 https://www.proxifier.com/

Binaries:
https://github.com/nccgroup/SocksOverRDP/releases
https://www.proxifier.com/download/#win-tab

We can then connect to the target using xfreerdp and copy the `SocksOverRDPx64.zip` file to the target. From the Windows target, we will then need to load the SocksOverRDP.dll using regsvr32.exe.

```bash
C:\Users\htb-student\Desktop\SocksOverRDP-x64> regsvr32.exe SocksOverRDP-Plugin.dll
```

just search for RDP in search to open rdp client. 

Now we can connect to 172.16.5.19 over RDP using `mstsc.exe`, and we should receive a prompt that the SocksOverRDP plugin is enabled, and it will listen on 127.0.0.1:1080. We can use the credentials `victor:pass@123` to connect to 172.16.5.19.
![](/img/Pasted image 20240827194902.png)

We need to transfer `SocksOverRDPx64.zip` or just `SocksOverRDP-Server.exe` to `172.16.5.19` then we can start `SocksOverRDP-Server.exe` with admin privileges 
`.\SocksOverRDP-Server.exe` 

When we go back to foothold target and check with netstat we will see SOCKS listener started on `127.0.0.1:1080`

```bash
netstat -antb | findstr 1080
```

After listener is started, transfer `Proxifier` to Win10 target (on `10.129.x.x` network) and configure it to forward all packets to `127.0.0.1:1080` 
- Proxifier will route traffic thru given host and port. 
- With proxifier configured/running, we 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` and route it to `172.16.6.155` using `SocksOverRDP-server.exe`

![](/img/Pasted image 20240827195820.png)


![](/img/Pasted image 20240826173431.png)

```bash
When interacting with our RDP sessions on an engagement, we may find ourselves contending with slow performance in a given session, especially if we are managing multiple RDP sessions simultaneously. If this is the case, we can access the Experience tab in mstsc.exe and set Performance to Modem.
```
