Lesson 8 of 11
Packet Analysis with Wireshark
Wireshark is the industry-standard packet analyzer used by network engineers, security analysts, and penetration testers. It captures all network traffic passing through an interface, allowing deep inspection of every protocol, header, and payload.
Wireshark Core Concepts
- Packet capture: Wireshark puts your network interface into promiscuous mode - capturing all packets on the network segment, not just those addressed to your machine
- On a switched network, you only see traffic to/from your own machine unless using port mirroring (SPAN port) or ARP spoofing
- Pcap files: Captured traffic can be saved as .pcap files - the standard format for sharing captures for analysis and in CTF challenges
- Protocol dissection: Wireshark automatically identifies and decodes 3,000+ protocols - showing you HTTP headers, DNS queries, TLS certificates, etc. in human-readable form
- Color coding: Red = TCP errors, Black = abnormal packets, Blue = DNS/UDP, Green = TCP, Light blue = UDP
Essential Wireshark Display Filters
# Wireshark display filters - type in the filter bar
# Filter by protocol
http # HTTP traffic only
dns # All DNS queries/responses
tcp # All TCP traffic
tcp.port == 443 # HTTPS traffic
# Filter by IP address
ip.addr == 192.168.1.100 # Traffic to or from this IP
ip.dst == 10.0.0.1 # Traffic TO this IP
ip.src == 10.0.0.1 # Traffic FROM this IP
# Filter by port
tcp.port == 22 # SSH traffic
udp.port == 53 # DNS traffic
# Combine filters with logic operators
http and ip.addr == 192.168.1.100 # HTTP from specific IP
dns and ip.dst == 8.8.8.8 # DNS queries sent to Google
# Security-focused filters
tcp.flags.syn == 1 and tcp.flags.ack == 0 # SYN packets (port scans, SYN floods)
http.request.method == "POST" # POST requests (form submissions, login attempts)
ftp || telnet # Cleartext protocols (visible credentials!)
dns.qry.name contains "evil" # DNS queries containing suspicious stringsSecurity Analysis Scenarios
- Detecting cleartext credentials: Apply filter 'ftp or telnet or http.authbasic' - you will see usernames and passwords in plaintext. This demonstrates why these protocols must be replaced
- Identifying port scans: Large number of SYN packets from a single source to many destination ports (tcp.flags.syn==1 and tcp.flags.ack==0) with RST responses indicates a port scan
- ARP poisoning detection: Multiple ARP replies with the same IP mapped to different MACs - look for 'arp.duplicate-address-frame' or 'Who has' followed by unexpected replies
- DNS tunneling detection: Unusually long DNS query names (subdomains with 50+ character random strings), high volume of DNS queries, DNS TXT records with base64-encoded data
Command-Line Packet Capture (tcpdump)
# tcpdump - lightweight packet capture without GUI (ideal for servers)
# Capture all traffic on interface eth0
tcpdump -i eth0
# Capture traffic with readable timestamps and no DNS resolution (faster)
tcpdump -i eth0 -n -tttt
# Save capture to file for analysis in Wireshark
tcpdump -i eth0 -w /tmp/capture.pcap
# Capture only HTTP traffic
tcpdump -i eth0 port 80
# Capture traffic to/from specific host
tcpdump -i eth0 host 10.0.0.1
# Capture only TCP SYN packets (detect port scans)
tcpdump -i eth0 'tcp[tcpflags] & tcp-syn != 0'
# Capture DNS queries (detect DNS tunneling)
tcpdump -i eth0 port 53 -A # -A shows ASCII payloadCommon Mistakes
- Capturing without filters on high-traffic networks - produces enormous files quickly and makes analysis impossible; always apply a capture filter
- Not saving captures - during incident response, always save pcaps as evidence before analysis
- Forgetting that Wireshark cannot decrypt TLS traffic without the server's private key or pre-master secret logs - HTTPS traffic appears as TLSv1.3 Application Data
Tip
Tip
Practice Packet Analysis with Wireshark in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).
Practice Task
Note
Practice Task - (1) Write a working example of Packet Analysis with Wireshark from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Packet Analysis with Wireshark is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.
Key Takeaways
- Wireshark is the industry-standard packet analyzer used by network engineers, security analysts, and penetration testers.
- Packet capture: Wireshark puts your network interface into promiscuous mode - capturing all packets on the network segment, not just those addressed to your machine
- On a switched network, you only see traffic to/from your own machine unless using port mirroring (SPAN port) or ARP spoofing
- Pcap files: Captured traffic can be saved as .pcap files - the standard format for sharing captures for analysis and in CTF challenges
Finished this lesson?