Cheat sheet

Network filters

Two syntaxes not to mix up: BPF filters at capture time (tcpdump, and Wireshark at start-up); Wireshark and tshark display filters filter when reading. The analysis approach is in Network Traffic Analysis.

CJCADefence

BPF and Wireshark side by side

I want…BPF (capture)Wireshark (display)
One hosthost 10.0.0.5ip.addr == 10.0.0.5
One sourcesrc host 10.0.0.5ip.src == 10.0.0.5
A networknet 10.0.0.0/24ip.addr == 10.0.0.0/24
A portport 443tcp.port == 443
Destination portdst port 445tcp.dstport == 445
A protocolicmp, udp, arpicmp, dns, http
Excludenot port 22!(tcp.port == 22)
Combinehost A and port 80ip.addr == A && tcp.port == 80
SYN only'tcp[tcpflags] == tcp-syn'tcp.flags.syn == 1 && tcp.flags.ack == 0

Useful display filters for analysis

FilterShows
http.request.method == "POST"Form and data submissions
http.authorizationHTTP Basic authentication (base64 credentials)
ftp || telnetCleartext protocols
dns.qry.name contains "x"DNS queries containing a word
dns.qry.type == 16DNS TXT queries
tls.handshake.extensions_server_nameDomain names visited over HTTPS (SNI)
smb2Modern SMB traffic
kerberosKerberos exchanges
arp.duplicate-address-detectedOne IP announced by two MAC addresses
tcp.analysis.flagsTCP retransmissions and anomalies
frame contains "admin"Packets containing a string

tcpdump options

OptionEffect
-iListening interface (-D to list them)
-nnResolves neither hostnames nor ports
-w / -rWrite to / read from a pcap file
-A / -XContent as ASCII / as hex and ASCII
-cStop after N packets
-s 0Capture whole packets
-v / -vvMore detail

tshark

# Display filter and selected fields
tshark -r capture.pcap -Y 'http.request' -T fields -e ip.src -e http.host -e http.request.uri
# TCP conversation statistics
tshark -r capture.pcap -qz conv,tcp
# Protocol hierarchy
tshark -r capture.pcap -qz io,phs