Invoke SocksProxy : Socks Proxy & Reverse Socks Server Using Powershell

Invoke SocksProxy is a tool that 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:

Import-Module .\Invoke-SocksProxy.psm1
Invoke-SocksProxy -bindPort 1080

  • Increase the maximum number of threads from 200 to 400

Import-Module .\Invoke-SocksProxy.psm1
Invoke-SocksProxy -threads 400

Reverse

#On the remote host:
#Generate a private key and self signed cert

openssl 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 handler
python3 ReverseSocksProxyHandler.py 443 1080 ./cert.pem ./private.key

#On the local host:
Import-Module .\Invoke-SocksProxy.psm1
Invoke-ReverseSocksProxy -remotePort 443 -remoteHost 192.168.49.130

#Go through the system proxy:
Invoke-ReverseSocksProxy -remotePort 443 -remoteHost 192.168.49.130 -useSystemProxy

#Validate certificate
Invoke-ReverseSocksProxy -remotePort 443 -remoteHost 192.168.49.130 -certFingerprint ‘93061FDB30D69A435ACF96430744C5CC5473D44E’

#Give up after a number of failed connections to the handler:
Invoke-ReverseSocksProxy -remotePort 443 -remoteHost 192.168.49.130 -maxRetries 10

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

Credit for the System Proxy trick: 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.

R K

Recent Posts

Kali Linux 2024.4 Released, What’s New?

Kali Linux 2024.4, the final release of 2024, brings a wide range of updates and…

20 hours ago

Lifetime-Amsi-EtwPatch : Disabling PowerShell’s AMSI And ETW Protections

This Go program applies a lifetime patch to PowerShell to disable ETW (Event Tracing for…

20 hours ago

GPOHunter – Active Directory Group Policy Security Analyzer

GPOHunter is a comprehensive tool designed to analyze and identify security misconfigurations in Active Directory…

3 days ago

2024 MITRE ATT&CK Evaluation Results – Cynet Became a Leader With 100% Detection & Protection

Across small-to-medium enterprises (SMEs) and managed service providers (MSPs), the top priority for cybersecurity leaders…

5 days ago

SecHub : Streamlining Security Across Software Development Lifecycles

The free and open-source security platform SecHub, provides a central API to test software with…

1 week ago

Hawker : The Comprehensive OSINT Toolkit For Cybersecurity Professionals

Don't worry if there are any bugs in the tool, we will try to fix…

1 week ago