Skip to content

This library implements a basic SOCKS5 server with Man-in-the-middle attack features.

License

Notifications You must be signed in to change notification settings

Krasnikov05/socks5mitm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

socks5mitm

This library implements a basic SOCKS5 server with Man-in-the-middle attack features.

Features

  • IPv4 and IPv6 support
  • Address spoofing
  • Authorization
  • Connection through other proxy servers
  • HTTP proxy support
  • Message inspection and modification
  • TLS interception

Examples

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.

Installation

Ensure you have Python 3 installed. Install the library using the pip package manager:

pip install git+https://github.com/krasnikov05/socks5mitm.git

Contribution

Please follow the guidelines outlined below:

Setting up a Virtual Environment

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]'

Tools

For maintaining code quality, use the following commands:

ruff check src
ruff format .
mypy src --strict
pytest

Git Hooks

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"