# Invoke-SocksProxy | Socks Proxy, And Reverse Socks Server Using Powershell

**URL:** <https://onehack.st/t/invoke-socksproxy-socks-proxy-and-reverse-socks-server-using-powershell/176222>\
**Category:** Tools & Scripts\
**Tags:** privacy, networking\
**Created:** [March 22, 2021, 10:53am UTC](https://onehack.st/t/invoke-socksproxy-socks-proxy-and-reverse-socks-server-using-powershell/176222 "2021-03-22T10:53:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BlueHacker](https://onehack.st/user_avatar/onehack.st/bluehacker/32/174721_2.png) [@BlueHacker](https://onehack.st/u/BlueHacker)\
**Post date:** [March 22, 2021, 10:53am UTC](https://onehack.st/t/invoke-socksproxy-socks-proxy-and-reverse-socks-server-using-powershell/176222/1 "2021-03-22T10:53:35Z")

</div>

![image](https://onehack.st/uploads/default/original/3X/4/c/4c08b1d159fe1beea1c0a4ca3e78d4b78b25eb44.jpeg)

Creates a local or “reverse” Socks proxy using powershell.

The local proxy is a simple Socks 4/5 proxy.

The reverse proxy creates a tcp tunnel by initiating outbond SSL connections that can go through the system’s proxy. The tunnel can then be used as a socks proxy on the remote host to pivot into the local host’s network.

**Examples**

**Local**

Create a Socks 4/5 proxy on port 1080:

```auto
Import-Module .Invoke-SocksProxy.psm1Invoke-SocksProxy -bindPort 1080

```

Increase the maximum number of threads from 200 to 400

```auto
Import-Module .Invoke-SocksProxy.psm1Invoke-SocksProxy -threads 400

```

**Reverse**

Create a “reverse” Socks 4/5 proxy on port 1080 of a remote host:

```auto
# On the remote host: # Generate a private key and self signed certopenssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout private.key -out cert.pem# Get the certificate fingerprint to verify it:openssl x509 -in cert.pem -noout -sha1 -fingerprint | cut -d "=" -f 2 | tr -d ":"# Start the handlerpython ReverseSocksProxyHandler.py 443 1080 ./cert.pem ./private.key# On the local host:Import-Module .Invoke-SocksProxy.psm1Invoke-ReverseSocksProxy -remotePort 443 -remoteHost 192.168.49.130 # Go through the system proxy:Invoke-ReverseSocksProxy -remotePort 443 -remoteHost 192.168.49.130 -useSystemProxy# Validate certificateInvoke-ReverseSocksProxy -remotePort 443 -remoteHost 192.168.49.130 -certFingerprint '93061FDB30D69A435ACF96430744C5CC5473D44E'# Give up after a number of fail ed connections to the handler:Invoke-ReverseSocksProxy -remotePort 443 -remoteHost 192.168.49.130 -maxRetries 10

```

Credit for the System Proxy trick: [https://github.com/Arno0x/PowerShellScripts/blob/master/proxyTunnel.ps1](https://github.com/Arno0x/PowerShellScripts/blob/master/proxyTunnel.ps1)

**Limitations**

- This is only a subset of the Socks 4 and 5 protocols: It does not support authentication, It does not support UDP or bind requests.
- When the Socks Proxy runs out of available threads, new connections cannot be established until a thread is freed.
- New features will be implemented in the future. PR are welcome.

**Disclaimer**

This project is intended for security researchers and penetration testers and should only be used with the approval of system owners.

## GitHub:

> **[GitHub - p3nt4/Invoke-SocksProxy: Socks proxy, and reverse socks server using...](https://github.com/p3nt4/Invoke-SocksProxy)**
>
> Socks proxy, and reverse socks server using powershell.
