Skip to main content

TCP proxy

Benifits of Tcp proxy we can forward the traffic from host to host as well as useful when assessing network based software.
So in this code we will continually read from local ,process and send to remote ,read from remote ,process and send to local until there is no more data detected.
##
we will firstly take the command line arguements and then fire up a server loop that listens that listens for connections.
once any connection request comes in ,we hand it off to 'proxy_handler' ,which does all the sending and recieving of bits to either side of the data stream.
##
we will make sure that we should not be initiating a connection to the remote side and request data before going into our main loop.
Then we will use the 'recieve_from' function which we reuse for both side of the communication ,it simply takes in a connected socket object and performs a recieve.
Then we will dump the contents of packets so that we can inspect it for anything interesting .then we pass the output to our 'response_handler' function and in this function we can modify the packet contents ,perform fuzzing tasks ,test for authentication issues etc. Then finally we will send our recieved buffer to our local client. ##
This hexdumping function will simply output the packet details with both their hexadecimal values and ASCII-printable characters ,which is quite useful for understanding unknown protocols ,finding user credentails in plaintext protocols etc. ##
This method is used both for recieving local and remote data.and we simply pass in socket object to be used