Wireshark
Wireshark is the reference network protocol analyzer: it captures and dissects traffic packet by packet. It’s essential for network forensics, malware/C2 analysis, protocol debugging, and forensics CTF challenges (see Network forensics, Command & Control, Sniffing).
What it is
Section titled “What it is”Wireshark captures the traffic of an interface (or opens an existing .pcap/.pcapng) and breaks it down by layers (Ethernet, IP, TCP/UDP, HTTP, TLS…), showing every field of every packet. tshark is its command-line version, ideal for automating and filtering at scale.
What it is for
Section titled “What it is for”- Analyze network captures in forensics and incident response.
- Detect and understand malware traffic and C2 channels.
- Debug protocols and network problems.
- Solve forensics CTF challenges (extract files, credentials, flags).
Installation
Section titled “Installation”sudo apt install wireshark tshark # Kali/Parrot/Debian# allow capture without root (add your user to the group)sudo usermod -aG wireshark $USER# macOSbrew install --cask wiresharkBasic usage
Section titled “Basic usage”Two kinds of filter, don’t confuse them:
- Capture filters (BPF): decide what gets recorded (applied while capturing).
- Display filters: filter what’s already captured (Wireshark’s own syntax).
Most-used display filters:
ip.addr == 10.10.10.5— traffic to/from an IP.tcp.port == 443— by port.http.request.method == "POST"— POST requests.dns— DNS only.tcp.flags.syn == 1 && tcp.flags.ack == 0— connection starts (SYN).frame contains "password"— search a string in any packet.
Key action: right-click a packet > Follow > TCP Stream reconstructs the whole conversation (very useful for cleartext HTTP/FTP).
Advanced usage
Section titled “Advanced usage”Statistics (Statistics menu):
- Protocol Hierarchy: traffic breakdown by protocol.
- Conversations: who talks to whom and how much.
- Export Objects > HTTP: extract files transferred over HTTP.
tshark (CLI) for automation:
# capture on an interface with a capture filter (BPF) and savetshark -i eth0 -f "tcp port 80" -w capture.pcapng# read a pcap applying a display filter (-Y)tshark -r capture.pcapng -Y 'http.request' -T fields -e ip.src -e http.host -e http.request.uri# statistics of a pcaptshark -r capture.pcapng -q -z io,phs # protocol hierarchytshark -r capture.pcapng -q -z conv,tcp # TCP conversationsTLS decryption: if you have the session keys (the browser’s SSLKEYLOGFILE variable), load them in Preferences > Protocols > TLS > (Pre)-Master-Secret log filename to see the HTTP inside HTTPS in your own environment.
Tricks / workflow
Section titled “Tricks / workflow”flowchart TD
A[Open .pcap] --> B[Statistics: Protocol Hierarchy]
B --> C{Protocol of interest}
C -->|HTTP| D[Export Objects > HTTP]
C -->|Cleartext TCP| E[Follow TCP Stream]
C -->|DNS| F[dns filter: C2 domains]
E --> G[Credentials / files / flag]
D --> G
- Always start with Protocol Hierarchy and Conversations to get oriented in large captures.
- Use
frame containsortcp.stream eq Nto isolate a specific conversation. - For forensics CTF: Export Objects and Follow Stream often give the flag directly.
tshark -T fieldsproduces tabulated output that’s easy to process withgrep/awk.
Detection (Blue Team)
Section titled “Detection (Blue Team)”- Wireshark in listening mode is passive: it generates no traffic of its own and isn’t detectable over the network (unless it enables promiscuous mode on a port monitored by the switch).
- From the defensive angle, Wireshark/tshark are Blue Team tools: analyze PCAPs to identify C2, exfiltration (DNS tunneling, periodic beaconing), and insecure protocols.
- Signals to look for: connections at regular intervals (beacon), DNS spikes to odd domains, and credentials in cleartext protocols (FTP, HTTP, Telnet).
Checklist
Section titled “Checklist”- Capture obtained on an authorized network/environment.
- Initial review with Protocol Hierarchy and Conversations.
- Display filters applied to isolate what’s relevant.
- Follow Stream / Export Objects used to extract data.
- Findings (credentials/files) treated as sensitive data.