A transparent TCP proxy for intercepting, logging, and modifying traffic between a client and a remote host. Useful for analyzing undocumented network protocols during security assessments.
- Bidirectional TCP forwarding with hex dump logging of every packet
- Pluggable
request_handler/response_handlerfunctions for traffic modification (fuzzing, injection, tampering) - Threaded, supports multiple concurrent client connections
receive_firstmode for server-initiated protocols (e.g. FTP, SSH banners)
./tcp-proxy.py [localhost] [localport] [remotehost] [remoteport] [receive_first]
# Example
./tcp-proxy.py 127.0.0.1 9000 10.12.132.1 9000 Truereceive_first — True if the remote service sends data first, False if the client initiates.
Each accepted connection is handled in its own thread. proxy_handler opens a socket to the remote host and relays data both ways: reading, hex-dumping, and passing each buffer through the request/response handlers before forwarding. The session ends when either side stops sending data.
Python 3.x, standard library only.
Intended for authorized security testing on systems you own or have explicit permission to test.