A comprehensive guide to packet capture and analysis for ethical hacking
Wireshark is a powerful network protocol analyzer that allows security professionals to capture and interactively browse the traffic running on a computer network. This tutorial explores how to sniff packets in real-time and analyze the captured data.
Note: For ethical hacking purposes, always ensure you have proper authorization before capturing network traffic. Unauthorized packet sniffing may violate privacy laws and regulations.
Before starting packet capture, you need to be in the "man in the middle" position to effectively capture relevant traffic. This typically means being on the same network segment as your target or using techniques like ARP spoofing to route traffic through your machine.
Choose the correct network interface (e.g., eth0) that is generating traffic from your target machine.
Set capture filters and output options to control what traffic is captured and where it's stored.
Start the packet capture process and generate traffic on the target system for analysis.
Wireshark can capture traffic on multiple network interfaces simultaneously:
Wireshark allows you to save captured packets for later analysis:
Important: When dealing with HTTPS traffic, it will appear encrypted unless you've successfully implemented SSL/TLS downgrading techniques like HSTS caplet manipulation. For educational purposes, focus on HTTP traffic which is readable by default.
Once you've captured packets, you'll need to understand how to navigate the Wireshark interface:
| No. | Time | Source | Destination | Protocol | Length | Info |
|---|---|---|---|---|---|---|
| 1 | 0.000000 | 10.20.14.206 | 8.8.8.8 | DNS | 83 | Standard query 0x1234 A google.ie |
| 2 | 0.045892 | 8.8.8.8 | 10.20.14.206 | DNS | 99 | Standard query response 0x1234 A 142.250.74.110 |
| 3 | 0.048733 | 10.20.14.206 | 142.250.74.110 | TCP | 74 | 52846 → 80 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 |
| 4 | 0.085923 | 142.250.74.110 | 10.20.14.206 | TCP | 74 | 80 → 52846 [SYN, ACK] Seq=0 Ack=1 Win=65535 Len=0 MSS=1460 |
| 5 | 0.086012 | 10.20.14.206 | 142.250.74.110 | TCP | 66 | 52846 → 80 [ACK] Seq=1 Ack=1 Win=64240 Len=0 |
| 6 | 0.086453 | 10.20.14.206 | 142.250.74.110 | HTTP | 518 | GET /search?q=zSecurity HTTP/1.1 |
| 7 | 0.134629 | 142.250.74.110 | 10.20.14.206 | TCP | 54 | [TCP Previous segment not captured] [TCP Out-Of-Order] |
Wireshark uses colors to help you quickly identify different types of packets:
When capturing HTTP traffic (especially after HTTPS downgrading), you can observe detailed information about web requests:
Example HTTP Traffic Analysis: