For a Certified Ethical Hacker (CEH), understanding and analyzing network traffic is critical across multiple phases of an engagement:
- Reconnaissance: Passively discovering hosts, services, and network topology by observing broadcast traffic (ARP, DHCP, NetBIOS) or baseline communications.
- Scanning Analysis: Observing network responses during active scans (e.g., Nmap) to understand firewall rules, IDS/IPS behavior, and target system responses.
- Exploitation Analysis: Monitoring traffic during exploit attempts to troubleshoot failures or confirm success (e.g., reverse shell callbacks).
- Post-Exploitation: Identifying Command & Control (C2) channels, detecting data exfiltration attempts, monitoring lateral movement.
- Security Auditing & Defense: Establishing baselines, detecting anomalies, identifying misconfigurations, verifying security control effectiveness (firewall rules, IDS signatures).
Kali Linux provides a rich arsenal of tools for these tasks, ranging from high-level dashboards to deep packet inspection.
I. Real-time Interface Statistics & High-Level Usage
These tools provide immediate visibility into traffic rates, top connections, and overall interface health, crucial for quick assessments and anomaly detection.
Displays bandwidth usage sorted by connection pairs (source/destination). Excellent for identifying "top talkers" and visualizing active flows.
sudo iftop -i eth0 -n -N -P -B
-i eth0: Specify interface.
-n: Don't resolve hostnames (essential for speed and seeing raw IPs).
-N: Show port numbers instead of service names.
-P: Show ports in the host display.
-B: Display bandwidth rates in Bytes per second (useful for comparison).
Press 'h' inside for help (e.g., 's'/'d' to hide source/destination).
A versatile ncurses-based monitor providing multiple views: general/detailed interface stats, TCP/UDP traffic by port, packet size distribution, and LAN station monitor (detects active hosts via broadcasts).
sudo iptraf-ngNavigate the menus. 'Detailed interface statistics' and 'TCP/UDP traffic monitor' are very useful. The LAN station monitor helps in passive reconnaissance.
CEH Use Case: Visualize traffic distribution by protocol/port (spotting unusual services), detect ARP spoofing attempts (via LAN monitor warnings), identify broadcast storms, monitor for specific flags (e.g., high SYN rate in TCP monitor).Simple console tools for visualizing real-time network traffic throughput as graphs. Good for understanding overall load.
# nload (Human-readable units)
nload -u H devices eth0
# bmon (Detailed stats for interface)
bmon -p eth0
# speedometer (Separate Rx/Tx graphs)
speedometer -r eth0 -t eth0Provides detailed packet/byte counters and crucially, error/drop counters for an interface. The modern `ifconfig` replacement for stats.
watch -n 1 -d 'ip -s link show eth0'
watch -n 1 -d: Refresh every second, highlight changes.
ip -s link show eth0: Show detailed stats for `eth0`. Look at RX/TX packets, bytes, errors, dropped.
II. Packet Capturing & Deep Dive Analysis
Capturing raw packets is essential for understanding exactly what's happening on the wire. These tools allow filtering, saving, and dissecting network traffic.
The fundamental command-line packet sniffer. Powerful filtering (BPF syntax) allows capturing precisely the traffic of interest.
# Capture first 100 packets, show link-layer headers, no name resolution
sudo tcpdump -i eth0 -c 100 -e -n
# Capture all TCP SYN packets (potential scan detection)
sudo tcpdump -i eth0 'tcp[tcpflags] & tcp-syn != 0 and tcp[tcpflags] & tcp-ack == 0' -n
# Capture traffic to/from a specific host and port, show ASCII payload
sudo tcpdump -i eth0 host 192.168.1.10 and port 80 -A -n
# Capture traffic, excluding SSH, and write to file
sudo tcpdump -i eth0 not port 22 -w capture_`date +%Y%m%d_%H%M%S`.pcap -n
# Read file and display packets matching a filter
tcpdump -r capture.pcap 'host 10.0.0.5' -nBPF (Berkeley Packet Filter) syntax is used directly on the command line for *capture* filtering. -w saves to file, -r reads from file. -A shows printable payload.
The command-line engine for Wireshark. Can capture like `tcpdump` but excels at reading capture files and applying Wireshark's powerful *display filters* and dissectors for detailed analysis in the terminal.
# Capture on eth0, resolve network/transport names
sudo tshark -i eth0 -n N nt
# Read capture file, apply Wireshark display filter for HTTP GET requests
tshark -r capture.pcap -Y "http.request.method == GET"
# Extract specific fields (IP source/dest, TCP stream index, HTTP Host header) for HTTP traffic
tshark -r capture.pcap -Y http -T fields -e ip.src -e ip.dst -e tcp.stream -e http.host
# Count DNS queries per source IP
tshark -r capture.pcap -Y "dns.flags.response == 0" -T fields -e ip.src | sort | uniq -c | sort -nrUses Wireshark display filters (-Y or -R), which are different and often more intuitive than BPF capture filters. -T fields combined with -e is extremely powerful for extracting specific data.
ssl.handshake.ja3), analyzing protocol fields not easily accessible with `tcpdump`, filtering based on expert knowledge dissectors.
The graphical standard for network protocol analysis. Provides intuitive visualization, powerful filtering, protocol dissection, session reconstruction, graphing, VoIP analysis, and much more.
# Launch Wireshark (may require sudo or specific group membership for live capture)
wiresharkSelect an interface to start live capture, or open a capture file (`.pcap`, `.pcapng`). Use the filter bar for display filters (e.g., ip.addr == 192.168.1.10, tcp.port == 80, http.request). Right-click packets -> Follow -> TCP Stream (or UDP/HTTP) to reconstruct sessions.
III. Correlating Network Activity with Local Processes
Identifying which process on your *own* Kali system (or a compromised host) is responsible for specific network traffic is crucial.
The modern replacement for `netstat`. Efficiently displays socket information, including listening ports and established connections, and can show the associated process.
# Show listening TCP and UDP sockets with process information, no name resolution
sudo ss -tulpn
# Show established TCP connections with process information
sudo ss -tpn state established
# Filter for connections involving a specific port (e.g., 4444 for a reverse shell)
sudo ss -tpn 'dport = :4444 or sport = :4444'
-t: TCP, -u: UDP, -l: Listening, -p: Show Process, -n: Numeric IPs/Ports.
Advanced interactive process viewers that can display network I/O rates per process, helping link high bandwidth usage seen in `iftop` back to a specific application.
htop
# Press F2 (Setup) -> Columns -> Add IO_READ_RATE / IO_WRITE_RATE
glances
# Network I/O often shown by defaultIV. Specialized Monitoring Scenarios
Sometimes specific network types require specialized tools.
Part of the aircrack-ng suite, essential for capturing 802.11 (Wi-Fi) management and data frames. Used for discovering wireless networks, connected clients, and capturing handshakes.
# Put interface in monitor mode first (e.g., sudo airmon-ng start wlan0)
sudo airodump-ng wlan0mon
# Target a specific network and capture to file
sudo airodump-ng --bssid AA:BB:CC:DD:EE:FF --channel 6 -w wifi_capture wlan0monV. CEH Focus: Identifying Suspicious Traffic Patterns
- Scanning Activity:
tcpdump/tshark/Wireshark:Look for bursts of TCP SYN packets to many ports/hosts from a single source (SYN Scan), packets with unusual flag combinations (FIN, URG, PSH - FIN/XMAS Scans), large numbers of ICMP Echo Requests (Ping Sweep).iftop/iptraf-ng:High connection rates from a single source to multiple destinations/ports.
- Command & Control (C2) Traffic:
iftop:Persistent connections to unusual external IPs/ports.tcpdump/tshark/Wireshark:Periodic, small "beacon" connections; traffic using non-standard protocols over common ports (e.g., DNS tunneling - excessive TXT queries, ICMP tunneling); analysis of TLS handshake metadata (JA3/JA3S) for known malware signatures; cleartext protocols like HTTP used for C2.ss:Identify the local process making the C2 connection.
- Data Exfiltration:
iftop/nload:Sustained high outbound bandwidth usage, especially to unexpected destinations.tcpdump/tshark/Wireshark:Large file transfers over protocols like FTP, HTTP, SMB; data hidden within other protocols (ICMP, DNS); large volumes of encrypted traffic to unusual destinations.
- Lateral Movement:
tcpdump/tshark/Wireshark:Attempts to connect to SMB/RPC ports (445, 135, 139), WinRM (5985, 5986), RDP (3389), SSH (22) between internal hosts; PsExec indicators; Kerberos ticket requests.iptraf-ng LAN Monitor:New or unexpected hosts appearing.
- Cleartext Credentials/Sensitive Data:
Wireshark/tcpdump -A:Filter for protocols like HTTP (POST requests), FTP, Telnet, POP3, IMAP, SNMP (v1/v2c community strings) and look for keywords like 'user', 'pass', 'login', 'password', 'community'.
- ARP Spoofing (MitM):
Wireshark/tcpdump:Look for frequent, unsolicited ARP replies, or ARP replies mapping a gateway/host IP to a different MAC address.iptraf-ng:Warnings about MAC address changes for a given IP.
Conclusion
Effective network traffic monitoring and analysis are indispensable skills for a Certified Ethical Hacker. Kali Linux offers a comprehensive suite of tools, from real-time dashboards like `iftop` and `iptraf-ng` for quick situational awareness, to powerful command-line sniffers like `tcpdump` and `tshark`, and the unparalleled graphical analysis capabilities of `Wireshark`. By mastering these tools and understanding how to apply them to detect scanning, C2 communication, exfiltration, and other malicious activities, ethical hackers can significantly enhance their ability to assess security posture, identify vulnerabilities, and simulate real-world attacks within authorized engagements.