|You may remember I had an awkward method to redirect a port (i.e. upon TCP connection to a port, forward it to another address and port) using [[netcat||http://www.rutschle.net/blog/archives/2007/03/29/T14_49_41/]].|
Yesterday I really needed a ‘tranparent proxy’: something that would allow me to look at the traffic going through a network connection, without doing anything else. You could use monitoring tools like tcpdump, but unfortunately you have to have administrative rights to run such tools, which isn’t always possible.
The other method is to go through a transparent proxy: connect to the proxy, which will dump all the data in a file while also forwarding to a different port. Note it’s almost exactly while netcat does.
Clearly I didn’t understand the netcat manual, so I wrote a little transparent proxy from scratch. Twice. Once in Perl and once in C.
Then today I realise that:
- netcat can dump the traffic going through it using option
- my hack is very awkward; to redirect a port all one needs to do is:
nc -l -p 5000 -c "nc smtp.free.fr 25"
which reads “listens for connections on port 5000, and when that happens connect the connection to another connection to smtp.free.fr, port 25. Now a telnet to localhost:5000 goes to smtp.free.fr:25.
And with just one more option, we get a transparent proxy:
nc -l -p 5000 -c "nc -o dump smtp.free.fr 25"
All that’s really missing in the dump is a dating field, which really has nothing to do with Meetic.