tshark is the command line tool behind wireshark. Very useful for extracting and analyzing TCP streams.


Tshark uses the -R flag to create filters. This is documented extensively on the wireshark website.

Convert local system requests into pseudo-JSON.

expressions. This assumes my active internet connection is from wlan0 and that my IP address on that interface is

sudo tshark -i wlan0 -R "ip.src ==" |
sed -r "s/^\s?+([0-9.]+)\s+([0-9.]+)\s+->\s+([0-9.]+)\s+([A-Z]+).*$/{'time':'\1','src':'\2','dst':'\3','proto':'\4'}/g"
[email protected]# ./grab_data.sh 
Capturing on wlan0

This is a total hack and could be massively improved with some better Regular expressions to search for the src and dst addresses as well as producing valid JSON.

Use tshark to print out header files

In this example we used grep to check for an arbitrary header (my_header)that I set in my app.

sudo tshark -i eth0 -d tcp.port==3000,http tcp port 3000 -V -R "http.response" | grep my_header -B 10 -A 10