tcpdump to only print urls

Cripto picture Cripto · Jul 17, 2013 · Viewed 14.5k times · Source

Is there a way to do

tcpdump -i lo -A 

and have it print all urls, any connections made?

I have done:

sudo tcpdump -i lo -A | grep Host: 

which works great. But I was wondering if there are options to do the same in tcpdump

Finally, is there a way to do this in python without using a sys command or Popen/subprocess

Answer

Dennis Guse picture Dennis Guse · Jul 26, 2013

tcpdump cannot filter based upon the content of the packets (no deep packet inspection) as it only uses pcacp-filter. You could improve your performance by only dumping those packages for incoming TCP connections to your HTTP port.

tcpdump -i lo -A tcp port 80

TCPDUMP python: use Pcapy

Another option is to use tshark