This library implements a basic SOCKS5 server with Man-in-the-middle attack features.
- IPv4 and IPv6 support
- Address spoofing
- Authorization
- Connection through other proxy servers
- Message inspection and modification
- TLS interception
import sys
import socks5mitm
class Server(socks5mitm.SOCKS5Server):
def handle_auth(self, ctx):
return [socks5mitm.UsernamePassword("user", "12345")]
def handle_address(self, address, ctx):
print(f"REQUEST {address.host}:{address.port}")
return address
if __name__ == "__main__":
port = 9090 if len(sys.argv) != 2 else int(sys.argv[1])
print(f"Listening on 127.0.0.1:{port}")
Server().start("127.0.0.1", port)Take a look at the examples.
Ensure you have Python 3 installed. Install the library using the pip package manager:
pip install git+https://github.com/krasnikov05/socks5mitm.gitPlease follow the guidelines outlined below:
Before you start contributing, create and activate a virtual environment using the following command:
python3 -m venv .venv
source .venv/bin/activate # On Linux or macOS
.venv\Scripts\activate # On Windows
pip install '.[dev]'For maintaining code quality, use the following commands:
ruff check src
ruff format .
mypy src --strict
pytest