
Pywssocks
Pywssocks is a SOCKS proxy implementation over WebSocket protocol.
Overview
This tool allows you to securely expose SOCKS proxy services under Web Application Firewall (WAF) protection (forward socks), or enable clients to connect and serve as SOCKS proxy servers when they don't have public network access (reverse socks).

For golang version, please check zetxtech/wssocks.
Features
- Both client and server modes, supporting command-line usage or library integration.
- Forward and reverse proxy capabilities.
- Round-robin load balancing for reverse proxy.
- SOCKS proxy authentication support.
- IPv6 over SOCKS5 support.
- UDP over SOCKS5 support.
Potential Applications
- Distributed HTTP backend.
- Bypassing CAPTCHA using client-side proxies.
- Secure intranet penetration, using CDN network.
Usage
As a tool
Forward Proxy:
pywssocks server -t example_token
pywssocks client -t example_token -u ws://localhost:8765 -p 1080
Reverse Proxy:
pywssocks server -t example_token -p 1080 -r
pywssocks client -t example_token -u ws://localhost:8765 -r
As a library
Forward Proxy:
import asyncio
from pywssocks import WSSocksServer, WSSocksClient
server = WSSocksServer(
ws_host="0.0.0.0",
ws_port=8765,
)
token = server.add_forward_token()
print(f"Token: {token}")
asyncio.run(server.start())
client = WSSocksClient(
token="<token>",
ws_url="ws://localhost:8765",
socks_host="127.0.0.1",
socks_port=1080,
)
asyncio.run(client.start())
Reverse Proxy:
import asyncio
from pywssocks import WSSocksServer, WSSocksClient
server = WSSocksServer(
ws_host="0.0.0.0",
ws_port=8765,
socks_host="127.0.0.1",
socks_port_pool=range(1024, 10240),
)
token, port = server.add_reverse_token()
print(f"Token: {token}\nPort: {port}")
asyncio.run(server.start())
client = WSSocksClient(
token="<token>",
ws_url="ws://localhost:8765",
reverse=True,
)
asyncio.run(client.start())
Installation
Pywssocks requires python >= 3.8
, and can be installed by:
pip install pywssocks
Pywssocks is also available via docker:
docker run --rm -it jackzzs/pywssocks --help
Documentation
Visit the documentation: https://pywssocks.zetx.tech
License
Pywssocks is open source under the MIT license.