Skip to main content

A forward and reverse socks over websocket server and client implementation in Python.

Project description

GitHub Actions Workflow Status Codecov Python Version PyPI - Version Docker Pulls License

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).

Main Diagram

For golang version, please check linksocks/linksocks.

Note: LinkSocks is implemented in Go and also ships with a thin Python binding. Pywssocks, however, is written entirely in pure Python (no C extensions) and remains minimally compatible with the latest linksocks protocol and feature set.

Features

  1. Both client and server modes, supporting command-line usage or library integration.
  2. Forward and reverse proxy capabilities.
  3. Round-robin load balancing for reverse proxy.
  4. SOCKS proxy authentication support.
  5. IPv6 over SOCKS5 support.
  6. UDP over SOCKS5 support.

Potential Applications

  1. Distributed HTTP backend.
  2. Bypassing CAPTCHA using client-side proxies.
  3. Secure intranet penetration, using CDN network.

Usage

As a tool

Forward Proxy:

# Server (WebSockets at port 8765, as network connector)
pywssocks server -t example_token

# Client (SOCKS5 at port 1080)
pywssocks client -t example_token -u ws://localhost:8765 -p 1080

Reverse Proxy:

# Server (WebSockets at port 8765, SOCKS at port 1080)
pywssocks server -t example_token -p 1080 -r

# Client (as network connector)
pywssocks client -t example_token -u ws://localhost:8765 -r

As a library

Forward Proxy:

import asyncio
from pywssocks import WSSocksServer, WSSocksClient

# Server
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
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
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
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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywssocks-1.4.7.tar.gz (40.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pywssocks-1.4.7-py3-none-any.whl (43.2 kB view details)

Uploaded Python 3

File details

Details for the file pywssocks-1.4.7.tar.gz.

File metadata

  • Download URL: pywssocks-1.4.7.tar.gz
  • Upload date:
  • Size: 40.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pywssocks-1.4.7.tar.gz
Algorithm Hash digest
SHA256 01f238a41aa69a69b94330d71d97985c72d388f6ec10465726beb7687c7aeed7
MD5 39997dfce795e665e6fce4d7851dfebd
BLAKE2b-256 39f039764d2f26a792adde08b47163c80dcb044dab066474080188b4c34de67b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywssocks-1.4.7.tar.gz:

Publisher: pypi.yml on linksocks/pywssocks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pywssocks-1.4.7-py3-none-any.whl.

File metadata

  • Download URL: pywssocks-1.4.7-py3-none-any.whl
  • Upload date:
  • Size: 43.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pywssocks-1.4.7-py3-none-any.whl
Algorithm Hash digest
SHA256 e5eeec03e9e050c23e5f3c6dd69463ce1c5bfdbc539da5b925db3dbc8b413641
MD5 16f9c63a5a2073f8bc048d726f98ad88
BLAKE2b-256 1d59cf3a5a797ef0a3ece4e82dc32ac081c08c0879e42aa5dd14ffa187ea7073

See more details on using hashes here.

Provenance

The following attestation bundles were made for pywssocks-1.4.7-py3-none-any.whl:

Publisher: pypi.yml on linksocks/pywssocks

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page