simple TCP proxies#
By connecting a client and server’s input and output together, it is possible to create a simple TCP proxy.
Create a named pipe by using the mkfifo command:
mkfifo backpipe
Create a server on port 8000 and feed it’s output into a connection to the destination host on port 80 while using the backpipe to feed the host connection’s output back to the server’s input stream:
pync -l 8000 < backpipe | pync host.example.com 80 > backpipe
1import pync
2
3
4def main():
5 server = pync.Netcat(port=8000,
6 l=True,
7 stdin=pync.PIPE,
8 stdout=pync.PIPE,
9 )
10 server.start_process(daemon=True)
11
12 client = pync.Netcat('host.example.com', 80,
13 stdin=server.stdout,
14 stdout=server.stdin,
15 )
16 client.run()
17
18
19if __name__ == '__main__':
20 main()