Black Bytes » tshark http://www.blackbytes.info Sun, 15 Sep 2013 12:18:18 +0000 en-US hourly 1 http://wordpress.org/?v=3.5.2 Network forensics with tsharkhttp://www.blackbytes.info/2013/09/network-forensics-with-tshark/ http://www.blackbytes.info/2013/09/network-forensics-with-tshark/#comments Sun, 15 Sep 2013 12:18:18 +0000 admin http://www.blackbytes.info/?p=999 Let’s say we have a packet capture file (.pcap) and we want to get as much information out of it as possible, well one option could be wireshark and its command line version tshark, using the latter we will be able to manipulate and format the output using tools like sed, grep, awk…

Extracting host names

Since we are dealing with mostly http traffic we may be interested in the sites that have been visited, to obtain this information we can use the http.host field and then a bit of sorting and this will show us the top 10 sites.

tshark -T fields -e http.host -r tor.pcap > dns.txt
cat dns.txt | sort | uniq -c | sort -nr | head


top-sites

User agents

tshark -R 'http contains "User-Agent:"' -T fields -e http.user_agent -r tor2b.pcap | sort | uniq -c | sort -nr | less

user-agents

-R allows us to define display filters, in the same way we would in wireshark, you can find a list of useful display filters here.

Email address

Another interesting bit of data are email addresses, which we can extract by using a regexp on the raw data.

tshark -r tor.pcap -R "data-text-lines" -T fields -e text > alldata.txt

grep -Eio '\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b' alldata.txt | sort | uniq

email

Here are a few extra examples if you want to learn more and don’t forget to take a look at the official documentation.

]]>
http://www.blackbytes.info/2013/09/network-forensics-with-tshark/feed/ 0