Network Sniffing in Ethical Hacking: Packet Capture & Analysis
Learn network sniffing concepts including packet capture, promiscuous mode, protocol analysis, and how to detect credentials in network traffic.
Prerequisites
- โข Understanding of networking protocols
- โข Basic Linux command line
What Is Network Sniffing?
Network sniffing is the process of capturing and analyzing data packets as they travel across a network. A packet sniffer intercepts network traffic at the data link layer, allowing examination of both packet headers and payload data.
In normal operation, a network interface card (NIC) only processes packets addressed to its own MAC address. In promiscuous mode, the NIC captures all packets on the network segment โ including those destined for other devices.
Sniffing is a legitimate network diagnostic tool used by administrators to troubleshoot connectivity issues, analyze performance problems, and monitor bandwidth usage. However, the same techniques can be abused to intercept sensitive data.
On switched networks, sniffing is more complex because switches forward traffic only to the intended destination port. Attackers must use additional techniques like ARP spoofing, MAC flooding, or port mirroring to intercept traffic on switched networks.
Active vs. Passive Sniffing
Passive sniffing involves capturing network traffic without injecting any packets. This works on hub-based networks where all traffic is broadcast to every port. Passive sniffing is undetectable because the sniffer only listens โ it never transmits.
Active sniffing involves injecting packets into the network to redirect traffic through the attacker's machine. Techniques include ARP spoofing (sending fake ARP messages), MAC flooding (overwhelming switch MAC tables), and DHCP spoofing (providing false network configuration).
Active sniffing is necessary on modern switched networks because switches isolate traffic between ports. By manipulating network protocols, an attacker can position themselves to intercept traffic that would otherwise be invisible to them.
The risk of detection is much higher with active sniffing because the injected packets can be noticed by network monitoring tools, intrusion detection systems, and alert administrators.
Protocols Vulnerable to Sniffing
Many common protocols transmit data in plaintext, making them vulnerable to sniffing attacks. HTTP sends web requests and responses (including form data and cookies) without encryption. Any data submitted over HTTP can be captured and read.
FTP transmits both credentials and file contents in plaintext. An attacker sniffing FTP traffic can capture usernames, passwords, and any transferred files. This is why SFTP and FTPS were developed as secure alternatives.
Telnet sends all communication, including login credentials, in plaintext. Similarly, older email protocols like POP3 and IMAP without TLS encryption expose email contents and authentication credentials to network sniffers.
DNS queries are typically unencrypted, revealing which websites users are visiting. SNMP v1 and v2 transmit community strings (essentially passwords) in plaintext. Even some database protocols transmit credentials without encryption if not properly configured.
Defending Against Sniffing Attacks
Encryption is the primary defense against sniffing. Use HTTPS instead of HTTP, SSH instead of Telnet, SFTP instead of FTP, and encrypted email protocols (IMAPS, POP3S, SMTPS). Encrypted traffic remains unreadable even if captured.
Implement network segmentation using VLANs to limit the scope of potential sniffing attacks. Critical systems should be on separate network segments with strict access controls between segments.
Deploy port security features on switches to limit the number of MAC addresses per port, preventing MAC flooding attacks. Enable Dynamic ARP Inspection (DAI) to prevent ARP spoofing. Use DHCP snooping to prevent rogue DHCP servers.
Use network monitoring tools to detect signs of sniffing attacks: unusual ARP traffic, duplicate IP addresses, network interfaces in promiscuous mode, and unexpected traffic patterns. IDS solutions like Snort can alert on many sniffing-related attack signatures.
Ready to Go Deeper?
This tutorial covers the basics. Join our instructor-led program for hands-on projects, certification prep, and placement assistance.