How Packet Capture Works
Understand network sniffing tools, promiscuous mode, and the principles of passive eavesdropping.
How Packet Capture Works is a free Cryptology Academy lesson on CoddyKit — lesson 2 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cryptology Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Promiscuous Mode on Network Interfaces
A network interface card normally discards packets not addressed to its MAC address. Promiscuous mode disables this filter, causing the NIC to pass all frames it receives to the operating system regardless of destination. With administrator privileges, any application can put the interface into promiscuous mode and receive all traffic visible on the network segment, not just traffic addressed to that machine.
libpcap: The Capture Foundation
libpcap is a portable C library that provides a standard API for packet capture on Unix-like systems. WinPcap and its successor Npcap provide the equivalent on Windows. Virtually every packet capture and network analysis tool, including Wireshark, tcpdump, and Snort, uses libpcap as the underlying capture engine. It handles the low-level interaction with the operating system and exposes a filter language for selecting specific packets.
Wireshark: The Packet Analyser
Wireshark is the most widely used graphical packet analysis tool. It captures live traffic or opens saved PCAP files and decodes hundreds of protocols, reassembling TCP streams and displaying decrypted content when keys are available. Colour-coded packet rows, display filters, stream following, and protocol statistics make it an essential tool for both network troubleshooting and security analysis.
tcpdump for Command-Line Capture
tcpdump is a command-line packet capture tool available on virtually all Unix systems. A simple command like tcpdump -i eth0 port 80 captures all HTTP traffic on the eth0 interface and prints each packet summary. The -w flag writes raw packets to a PCAP file for later analysis in Wireshark. tcpdump's BPF filter language allows precise selection of traffic by protocol, port, address, and flags.
ARP Poisoning to Intercept Switched Traffic
On modern switched networks, the switch forwards packets only to the correct destination port, so a promiscuous-mode NIC only sees broadcast traffic and traffic addressed to its own MAC. ARP poisoning overcomes this. The attacker sends gratuitous ARP replies telling the victim that the attacker's MAC is the gateway, and telling the gateway that the attacker's MAC is the victim. All traffic flows through the attacker's machine.
Man-in-the-Middle via ARP Spoofing
After ARP poisoning succeeds, the attacker's machine receives packets from both victim and gateway. To avoid disrupting communication, the attacker forwards packets between them while reading or modifying the content. Tools like arpspoof from the dsniff suite and Ettercap automate ARP poisoning and traffic forwarding. The attack works silently on the local network segment and is difficult for victims to detect without dedicated ARP monitoring.
Passive Sniffing on Hubs
Before switches became standard, networks used hubs that broadcast every packet to all ports. On a hub-based segment, promiscuous mode without any poisoning was sufficient to capture all traffic from all hosts. Hubs are rare today outside of old legacy environments and some industrial control networks. However, Wi-Fi networks behave like hubs for traffic within the same wireless channel, making passive capture straightforward in monitor mode.
Port Mirroring on Managed Switches
Network administrators use port mirroring (also called SPAN in Cisco terminology) to legitimately capture traffic for monitoring and troubleshooting. A managed switch is configured to copy all traffic passing through specified ports or VLANs to a dedicated mirror port connected to a monitoring device. This provides full traffic visibility without ARP poisoning and is the approved method for intrusion detection sensors and network taps.
Legal and Ethical Aspects of Packet Capture
Capturing network traffic you are not authorised to access violates laws in most jurisdictions, including the US Computer Fraud and Abuse Act and the UK Computer Misuse Act. Even within an organisation, capturing employee traffic may require consent and HR policy compliance. Penetration testers must have explicit written authorisation that covers packet capture. IT administrators typically require organisational policy approval to deploy network monitoring.
What Captured Packets Reveal
A packet capture of even a few minutes of network activity can reveal application versions from HTTP User-Agent headers, operating system fingerprints from TCP stack behaviour, internal hostnames from DNS queries, authentication credentials from legacy protocols, session cookies from HTTP traffic, and a map of all communicating systems and services. This reconnaissance value makes packet capture a primary attack tool.
Defending Against Packet Capture Attacks
The primary defence against packet capture is encrypting all network traffic so that captured packets contain only ciphertext. Dynamic ARP Inspection on managed switches validates ARP replies against a trusted DHCP binding table, preventing ARP poisoning. Port security limits which MAC addresses can appear on each switch port. Network segmentation limits the blast radius of any single compromised machine performing ARP attacks.
ARP Poisoning
What is the purpose of ARP poisoning in a packet capture attack on a switched network?
Packet Capture: Key Takeaways
Promiscuous mode lets a NIC receive all frames on the segment. libpcap is the foundation for all major capture tools. Wireshark and tcpdump are the primary analysis tools. ARP poisoning redirects switched traffic through an attacker machine for man-in-the-middle capture. Port mirroring provides legitimate monitoring without poisoning. Encryption is the primary defence; Dynamic ARP Inspection prevents the poisoning attack.
Frequently asked questions
Is the “How Packet Capture Works” lesson free?
Yes — the full text of “How Packet Capture Works” is free to read here on the web, and the Cryptology Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cryptology Academy course, upgrade to CoddyKit PRO.
What will I learn in “How Packet Capture Works”?
Understand network sniffing tools, promiscuous mode, and the principles of passive eavesdropping. You practise Cryptology Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start Cryptology Academy?
No prior experience is required. Cryptology Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 4, so you can start here or from the beginning and move at your own pace.
How long does the “How Packet Capture Works” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this Cryptology Academy lesson?
Yes. Every Cryptology Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Plaintext Protocols: What Attackers See
- How Packet Capture Works
- Encrypted Traffic Analysis
- DNS Security: DoH and DoT