Skip to main content

PySocks5Server

Simple socks5 proxy server written in python.

Installation

Requirements:

  • Python 3.10+
pip install pysocks5server

Usage

Usage: python -m socks5server [-h] [--host HOST] [--port PORT] [--no-auth] [--users [USERS ...]]

options:
  -h, --help           show this help message and exit
  --host HOST
  --port PORT
  --no-auth            Allow connections without authentication.
  --users [USERS ...]  List of users. Example: "--users user1:password1 user2:password2"

TODO

  • TCP/IP port binding
  • UDP port association
  • Socks4/socks4a support?

Code examples

Run server without authentication

from asyncio import get_event_loop
from socks5server import SocksServer

server = SocksServer("0.0.0.0", 1080, True)

if __name__ == '__main__':
    get_event_loop().run_until_complete(server.serve())

Run server with callbacks

from asyncio import get_event_loop
from socks5server import SocksServer, Socks5Client, DataDirection

server = SocksServer("0.0.0.0", 1080, True)

@server.on_client_connected
async def client_connected(client: Socks5Client):
    print(f"Client connected: {client}")
    
    
@server.on_client_disconnected
async def client_disconnected(client: Socks5Client):
    print(f"Client disconnected: {client}")
    
    
@server.on_data
async def data_received(client: Socks5Client, direction: DataDirection, data: bytes):
    print(f"{direction} | {data}")

    
if __name__ == '__main__':
    get_event_loop().run_until_complete(server.serve())

Run server with password authentication

from asyncio import get_event_loop
from socks5server import SocksServer, PasswordAuthentication

server = SocksServer("0.0.0.0", 1080)
users = {"test_login1": "test_password1", "login": "password"}
server.register_authentication(0x02, PasswordAuthentication(users))  # 0x02 is password authentication type

if __name__ == '__main__':
    get_event_loop().run_until_complete(server.serve())

Run server with custom authentication

All Authentication methods

import asyncio
from asyncio import get_event_loop
from socks5server import SocksServer, AuthenticationBase


class ChallengeHandshakeAuthentication(AuthenticationBase):
    async def authenticate(self, reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> bool:
        ... # Implement authentication process
    
        return True


server = SocksServer("0.0.0.0", 1080)

# 0x03 is type of Challenge–Handshake Authentication Protocol
server.register_authentication(0x03, ChallengeHandshakeAuthentication())

if __name__ == '__main__':
    get_event_loop().run_until_complete(server.serve())

Download files

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

Source Distribution

pysocks5server-0.1.2.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

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

pysocks5server-0.1.2-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file pysocks5server-0.1.2.tar.gz.

File metadata

  • Download URL: pysocks5server-0.1.2.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.13.7 Linux/6.14.9-200.fc41.x86_64

File hashes

Hashes for pysocks5server-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e368d06d8cc69282c2654a31e2e14cb7a4990f0b9b2503a6c906024fca9f55b0
MD5 cfab174aa39a7f2208c373519b5e6433
BLAKE2b-256 2f8bb40819897a8191b416acd695ad41999fe788d4bcddb1d3fc24c6aef667bf

See more details on using hashes here.

File details

Details for the file pysocks5server-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: pysocks5server-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.13.7 Linux/6.14.9-200.fc41.x86_64

File hashes

Hashes for pysocks5server-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9fa357c2b0ca93a37254520ea2f322db438a44186d87c2d25df37a70ae67d62e
MD5 0f0481050f911b8cabdff6be233d8cea
BLAKE2b-256 949f93bcc329fb00f645bbe6085d0d2c39cc0fb3fe99db6e6f04ca5b7d809e09

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

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