---
title: "9. windows netsh"
date: 2024-08-28
draft: false
---

[Netsh](https://docs.microsoft.com/en-us/windows-server/networking/technologies/netsh/netsh-contexts) 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 routes`
- `Viewing the firewall configuration`
- `Adding proxies`
- `Creating port forwarding rules`

Let's take an example of the below scenario where our compromised host is a Windows 10-based IT admin's workstation (`10.129.15.150`,`172.16.5.25`). Keep in mind that it is possible on an engagement that we may gain access to an employee's workstation through methods such as social engineering and phishing. This would allow us to pivot further from within the network the workstation is in.

![](/img/Pasted image 20240825120927.png|700)

using `netsh` to forward all data received on a specific port (say 8080) to a remote host on a remote port. 
```bash
netsh.exe interface portproxy add v4tov4 listenport=8080 listenaddress=10.129.15.150 connectport=3389 connectaddress=172.16.5.25
```
verification: 
```bash
 netsh.exe interface portproxy show v4tov4
```

After we configure this on the windows based pivot host, we can try to connect to the 8080 port of this host from our attack host using xfreerdp. Once request is sent from attack  host, windows host will route traffic according to proxy settings we configured with `netsh` 

---
practical application 


![](/img/Pasted image 20240825122226.png)
change 10.129.15.150 to 10.129.42.198 

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

The section was wrong - `172.16.5.25` is the wrong private IP for the RDP service, so our xfreerdp session wasn't able to be established. 

Looking at `arp` table we can confirm the actual private IP we need to specify with `netsh` 
![](/img/Pasted image 20240825122633.png)
![](/img/Pasted image 20240825122646.png)

xfreerdp works after setting this up correctly 


deleting netsh.exe listeners: 
```bash
PS C:\Windows\system32> netsh interface portproxy delete v4tov4 listenaddress=176.16.5.35 listenport=9191

PS C:\Windows\system32> netsh interface portproxy delete v4tov4 listenaddress=176.16.5.35 listenport=9292
```
