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
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())
Metadata
Release files for pysocks5server 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pysocks5server-0.1.2.tar.gz | 8.0 kB | Without provenance | Details for pysocks5server-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pysocks5server-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for pysocks5server-0.1.2-py3-none-any.whl |
Total release size: 18.6 kB
Release files / pysocks5server-0.1.2.tar.gz
| Download URL | pysocks5server-0.1.2.tar.gz |
|---|---|
| Size | 8.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e368d06d8cc69282c2654a31e2e14cb7a4990f0b9b2503a6c906024fca9f55b0
|
|
BLAKE2b-256 checksum How to use checksums |
2f8bb40819897a8191b416acd695ad41999fe788d4bcddb1d3fc24c6aef667bf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.13.7 Linux/6.14.9-200.fc41.x86_64
|
Release files / pysocks5server-0.1.2-py3-none-any.whl
| Download URL | pysocks5server-0.1.2-py3-none-any.whl |
|---|---|
| Size | 10.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9fa357c2b0ca93a37254520ea2f322db438a44186d87c2d25df37a70ae67d62e
|
|
BLAKE2b-256 checksum How to use checksums |
949f93bcc329fb00f645bbe6085d0d2c39cc0fb3fe99db6e6f04ca5b7d809e09
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.3 CPython/3.13.7 Linux/6.14.9-200.fc41.x86_64
|
Security for pysocks5server 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.