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
- HTTP proxy support
- Message inspection and modification
- TLS interception
import sys
import socks5mitm
class Server(socks5mitm.SOCKS5Server):
def handle_auth(self, ctx):
yield 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.git
Please 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
Enable Git hooks by running the following command:
git config --local core.hooksPath .githooks/
If you need to disable the pre-commit hook for a specific commit, use the following command:
NO_PRECOMMIT=1 git commit -m "Your commit message here"