Skip to content

Instantly share code, notes, and snippets.

@nathanborror
Last active March 19, 2016 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nathanborror/f1cd5354eb46d9253e0b to your computer and use it in GitHub Desktop.
Save nathanborror/f1cd5354eb46d9253e0b to your computer and use it in GitHub Desktop.

tshark

Capturing traffic

Capture some traffic and save in ‘pcap’ format:

$ tshark -w capture.pcap

Reading captured data

Get data out of the capture and remove all newlines and commas:

$ tshark -r capture.pcap -T fields -e data | tr -d '\n' | tr -d ',' > tempfile

Decode data:

#!/usr/bin/python

import sys

out = open(sys.argv[1], "r").read()
sys.stdout.write(out.decode("hex"))

Convert tempfile:

$ python convert.py tempfile > converted

Reading raw packets

$ tshark -r capture.pcap -T pdml > tempfile.xml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment