Tcpick is a sniffer able to understand wich status has the connection (SYN-SENT, SYN-RECEIVED and so on). To see the connection tracker in action on eth0 simply type:
# tcpick -i eth0 -C
`-C' means “enable colors”, and the output is very pretty.
You will see something like this:
23:07:42.672171 1 SYN-SENT 18.104.22.168:41599 > 22.214.171.124:http 23:07:42.822239 2 SYN-SENT 126.96.36.199:41600 > 188.8.131.52:5973 23:07:42.826634 3 SYN-SENT 184.108.40.206:41601 > 220.127.116.11:5555 23:07:42.854681 4 SYN-SENT 18.104.22.168:41602 > 22.214.171.124:56789 23:07:43.084242 1 SYN-RECEIVED 126.96.36.199:41599 > 188.8.131.52:http 23:07:43.087045 1 ESTABLISHED 184.108.40.206:41599 > 220.127.116.11:http 23:07:44.061311 5 SYN-SENT 18.104.22.168:41603 > 10.20.30.40:8888
It is very easy:
# tcpick -i eth0 -C -yP -h -a
`-yP' means “payload printable”, `-h' means “header” and `-a' means names resolution. Unprintable carachters are displayed as dots.
# tcpick -i eth0 -C -bCU -T1 "port 25"
`-bCU' means: display the rebuilded stream (`-b') only the client side (`C') and unprintable carachters will be displayed as hexcode (`U').
`T1' means: display only the first (1) connection.
“port 25” is the filter.
Yeah! It is very a simple job:
#tcpick -i eth0 -wR “port ftp-data”
When the file has been completely transmitted (connection displayed as “CLOSED”) check in the working directory: you will find some files named like this:
# ls *.tcpick client_22.214.171.124_126.96.36.199_34567.tcpick server_188.8.131.52_184.108.40.206_34567.tcpick
Bingo! If you do `$ file *.tcpick' you will find that one of the two is a a gzip archive or whatever you sniffed.
You must choose between client or server side, because you don't want both stream mixed in the standard output. It is a really simple job, just type:
# tcpick -i eth0 --pipe client "port 80" | gzip > http_response.gz
# tcpick -i eth0 --pipe server "port 25" | nc foobar.net 25
Now, use your imagination and let me know what crazy experiments have you done with tcpick ;^)