Skip to content

hoanghai27/gwproxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GwProxy

Gateway proxy for Python 3

Build

python3 -m pip install --user --upgrade setuptools wheel
python3 setup.py sdist bdist_wheel

Install

Using setuptools

python3 setup.py install

Using pip

pip install https://gitlab.com/hoanghai27/gwproxy.git

Usage

Define your own session handler class:

from gwproxy.tcp import TcpSession


class SessionHandler(TcpSession):
    def __init__(self, client_sock, server_ip, server_port):
        TcpSession.__init__(self, client_sock, server_ip, server_port)
        print("New session %s:%d" %(server_ip, server_port))

    def on_client_send(self, sock, data):
        print('>>> %s' % data.hex())

    def on_server_send(self, sock, data):
        print('<<< %s' % data.hex())

    def on_client_close(self, sock):
        super().on_client_close(sock)
        print("[x] Client closed %s" % sock)

    def on_server_close(self, sock):
        super().on_server_close(sock)
        print("[x] Server closed %s" % sock)

Start gateway proxy with that handler:

from gwproxy.proxy import TcpGwProxy


proxy = TcpGwProxy('0.0.0.0', 5555, auto_fw=True)
proxy.start(SessionHandler)

In case of you want to modify tcp data, just set auto_fw=False and send it yourself on on_client_send() or on_server_send().

Good luck!

About

Man-in-the-middle proxy for TCP for Python 3

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published