When I want to figure out how a certain protocol works (let's say in this case, the HTTP protocol on port 80), I open two terminal windows:
nc -l 80
nc google.com 80
I then fire up the program I want to "man-in-the-middle", in this case FireFox, and go to http://localhost:80
.
When the terminal on the left side sends a message, I copy and paste the data into the terminal on the right side. When the terminal on the right side sends a message, I do the same for the left terminal.
In addition to being manual and tedious, this process has two downsides:
- If I'm not fast enough, the connection may time-out.
- Copying and pasting does not handle binary data very well.
Can I automate this process? Can I have one port automatically forward data to another port, or even another machine, in a way that allows me to inspect and debug the data going back and forth?
socat
options like-v
,-x
,-r <file>
and-R <file>
. – Ingo Karkat Dec 18 '23 at 08:20