tshark Cheat Sheet
CLI Wireshark for capture, display filters, and protocol field extraction on authorized traffic.
Overview
tshark analyzes live or saved PCAPs with display filters and field extraction—scriptable alternative to Wireshark GUI for authorized packet review and reporting.
Authorized testing only. Use only on systems, networks, and accounts you own or have explicit written permission to test. Unauthorized access is illegal.
Install
sudo apt install -y tsharksudo usermod -aG wireshark $USEREssential commands
Capture like tcpdump
sudo tshark -i eth0 -w capture.pcapRead pcap with summary
tshark -r capture.pcap -q -z io,stat,0Common workflows
Live capture with filter —
sudo tshark -i eth0 -f "host 10.10.10.5" -w target.pcapsudo tshark -i eth0 -Y "http.request" -T fields -e http.host -e http.request.uriExtract HTTP objects and credentials (cleartext) —
tshark -r capture.pcap -Y "http.request.method==POST" -T fields-e ip.src -e http.host -e http.request.uri -e urlencoded-form.keyKerberos / SMB (AD pentest) —
tshark -r capture.pcap -Y "kerberos.msg_type==30" -T fields -e kerberos.CNameStringtshark -r capture.pcap -Y "smb2.cmd==5" -T fields -e ip.src -e ip.dst -e smb2.filenameDNS exfil or lookups —
tshark -r capture.pcap -Y "dns" -T fields -e dns.qry.name | sort -uFollow TCP stream —
tshark -r capture.pcap -qz follow,tcp,ascii,0Export JSON for tooling —
tshark -r capture.pcap -T json > packets.jsonFlags reference
-i IF | Capture interface |
|---|---|
-r FILE | Input PCAP |
-w FILE | Output PCAP |
-f FILTER | Capture BPF filter |
-Y FILTER | Display filter |
-T fields | Field output |
-e FIELD | Field to print |
-T json | JSON output |
-q | Quiet (stats modes) |
-z | Statistics |
-c N | Packet count limit |
Tips
- Display filters (-Y) differ from capture filters (-f); use -f to reduce file size at capture time.
- tshark -G fields | grep -i kerberos lists extractable field names.
- For encrypted TLS, look for metadata (SNI, JA3) unless keys are available.
- Pair live capture with tcpdump when GUI-free remote SSH sessions only allow CLI.