Cyber Services / All lessons / CEH — Ethical Hacking / Network Sniffing & Analysis Tools

Network Sniffing & Analysis Tools

Module 52 of 130 · 8 min read · Free to read

MODULES ↓ Command blocks have a COPY button

Complete Professional Guide to Network Traffic Analysis and Security Testing

Introduction to Network Sniffing

Network sniffing is the process of capturing and analyzing network traffic to monitor, troubleshoot, or analyze network communications. In security contexts, it's used for penetration testing, network forensics, and detecting malicious activities.

Security Applications: Network sniffing helps identify unencrypted credentials, detect network intrusions, analyze malware communications, and test network security controls.

Legal Notice: Only use these tools on networks you own or have explicit permission to test. Unauthorized network monitoring may violate laws and regulations.

ARP Spoofing

Technique for intercepting network traffic by sending falsified ARP messages

Man-in-the-Middle
Layer 2 Attack

DNS Chef

DNS proxy for penetration testers to fake DNS responses

DNS Spoofing
Proxy

dsniff

Collection of tools for network auditing and penetration testing

Password Sniffing
Network Audit

netsniff-ng

High-performance Linux network sniffing toolkit

High Performance
Linux

Scapy

Powerful Python-based interactive packet manipulation tool

Packet Crafting
Python

tcpdump

Command-line packet analyzer for capturing network traffic

CLI
Universal

Wireshark

World's most popular network protocol analyzer with GUI

GUI
Comprehensive

ARP Spoofing with arpspoof

ARP spoofing is a technique where an attacker sends falsified ARP (Address Resolution Protocol) messages to associate their MAC address with the IP address of another host, causing traffic to be intercepted.

Installation

Kali Linux Installation
sudo apt update && sudo apt install dsniff

Basic ARP Spoofing Attack

1

Enable IP Forwarding

Enable IP forwarding to allow traffic to pass through your machine:

Command
echo 1 > /proc/sys/net/ipv4/ip_forward
2

ARP Poison the Target

Send ARP replies to the target claiming to be the gateway:

Command
arpspoof -i eth0 -t 192.168.1.100 192.168.1.1
3

ARP Poison the Gateway

Send ARP replies to the gateway claiming to be the target:

Command
arpspoof -i eth0 -t 192.168.1.1 192.168.1.100

Key Switches and Options

Switch Description Example
-i interface Network interface to use -i eth0
-t target Target IP to poison -t 192.168.1.100
-r Poison both hosts (target and gateway) -r

Pro Tip: Combine arpspoof with other tools like Wireshark or dsniff to capture and analyze the intercepted traffic. Always test in controlled environments.

DNS Spoofing with DNS Chef

DNS Chef is a highly configurable DNS proxy for penetration testers that allows you to fake DNS responses and redirect traffic to controlled servers.

Installation

Kali Linux Installation
sudo apt update && sudo apt install dnschef

Basic DNS Spoofing Setup

1

Start DNS Chef

Launch DNS Chef with fake IP mappings:

Command
dnschef --interface 192.168.1.10 --fakeip 192.168.1.10 --fakedomains google.com,facebook.com
2

Advanced Configuration

Use a configuration file for complex setups:

Command
dnschef --interface 192.168.1.10 --file dns_records.conf
3

DNS Proxy Mode

Act as a proxy while spoofing specific domains:

Command
dnschef --interface 0.0.0.0 --fakeip 192.168.1.10 --fakedomains target.com --nameservers 8.8.8.8

Key Switches and Options

Switch Description Example
--interface ip IP address to listen on --interface 192.168.1.10
--fakeip ip IP address for fake responses --fakeip 192.168.1.10
--fakedomains domains Comma-separated list of domains to fake --fakedomains google.com
--file file Configuration file with DNS records --file config.txt
--nameservers ips Real DNS servers for non-faked domains --nameservers 8.8.8.8

Pro Tip: Combine DNS Chef with ARP spoofing to redirect DNS queries from targets to your DNS Chef instance for effective phishing or traffic interception.

Network Auditing with dsniff

dsniff is a collection of tools for network auditing and penetration testing, including password sniffers, network traffic analyzers, and various network manipulation utilities.

Installation

Kali Linux Installation
sudo apt update && sudo apt install dsniff

Key dsniff Tools and Examples

1

Password Sniffing with dsniff

Capture passwords from various protocols:

Command
dsniff -i eth0
2

File Reconnaissance with filesnarf

Capture and reconstruct files from NFS traffic:

Command
filesnarf -i eth0
3

Mail Sniffing with mailsnarf

Capture and reconstruct email messages:

Command
mailsnarf -i eth0
4

Web Traffic Analysis with urlsnarf

Capture and log HTTP requests:

Command
urlsnarf -i eth0

Advanced dsniff Usage

Tool Description Example
dsniff Password sniffer for various protocols dsniff -c -i eth0
arpspoof ARP cache poisoning tool arpspoof -i eth0 192.168.1.1
dnsspoof Forge DNS replies dnsspoof -i eth0
macof Flood switch with MAC addresses macof -i eth0
tcpkill Kill TCP connections tcpkill -9 host 192.168.1.100

Important: Many dsniff tools are considered intrusive and should only be used in controlled environments with proper authorization.

High-Performance Sniffing with netsniff-ng

netsniff-ng is a high-performance Linux networking toolkit that includes powerful packet capture and analysis capabilities with zero-copy mechanisms for maximum efficiency.

Installation

Kali Linux Installation
sudo apt update && sudo apt install netsniff-ng

Basic Packet Capture

1

Capture Packets to File

Capture network traffic and save to pcap file:

Command
netsniff-ng -i eth0 -o capture.pcap
2

Live Packet Analysis

Display live packet capture with detailed output:

Command
netsniff-ng -i eth0 -s -H
3

Packet Replay

Replay captured packets from pcap file:

Command
netsniff-ng -i eth0 -I capture.pcap

Key Switches and Options

Switch Description Example
-i interface Network interface to use -i eth0
-o file Output pcap file -o capture.pcap
-I file Input pcap file for replay -I capture.pcap
-s Print packet output to stdout -s
-H Enable human-readable output -H
-n count Number of packets to capture -n 1000

Performance Tip: netsniff-ng uses zero-copy mechanisms, making it significantly faster than traditional packet capture tools for high-traffic networks.

Packet Crafting with Scapy

Scapy is a powerful Python-based interactive packet manipulation program that can forge or decode packets, send them on the wire, capture them, and match requests and replies.

Installation

Kali Linux Installation
sudo apt update && sudo apt install python3-scapy

Basic Scapy Usage

1

Start Scapy Interactive Shell

Launch the Scapy interactive environment:

Command
scapy
2

Create and Send Packets

Basic packet creation and transmission:

Python Code
from scapy.all import *
# Create IP packet
ip = IP(dst="192.168.1.1")
# Create ICMP packet
icmp = ICMP()
# Send packet
send(ip/icmp)
3

Packet Sniffing

Capture and analyze network packets:

Python Code
from scapy.all import *
# Sniff 10 packets
packets = sniff(count=10)
# Display packet summary
packets.summary()
# Save to pcap file
wrpcap("captured.pcap", packets)

Advanced Scapy Examples

Function Description Example
ARP Ping Discover hosts using ARP arping("192.168.1.0/24")
Port Scanning TCP SYN port scan sr1(IP(dst="target")/TCP(dport=80,flags="S"))
DNS Spoofing Send fake DNS responses send(IP()/UDP()/DNS(...))
Packet Forging Create custom packets Ether()/IP()/TCP()/Raw("data")

Pro Tip: Scapy's flexibility makes it ideal for custom packet manipulation, protocol testing, and developing network security tools. Use it for tasks that standard tools can't handle.

Command-Line Analysis with tcpdump

tcpdump is a powerful command-line packet analyzer that allows you to capture and display TCP/IP and other packets being transmitted or received over a network.

Installation

Kali Linux Installation
sudo apt update && sudo apt install tcpdump

Basic Packet Capture

1

Capture on Specific Interface

Capture packets on a network interface:

Command
tcpdump -i eth0
2

Save Capture to File

Capture and save packets to a pcap file:

Command
tcpdump -i eth0 -w capture.pcap
3

Read from Capture File

Read and analyze packets from a pcap file:

Command
tcpdump -r capture.pcap

Advanced Filtering Examples

Filter Type Description Example
Host Filter Capture traffic to/from specific host tcpdump host 192.168.1.100
Port Filter Capture specific port traffic tcpdump port 80
Network Filter Capture network range tcpdump net 192.168.1.0/24
Protocol Filter Capture specific protocol tcpdump icmp
Packet Size Capture packets of specific size tcpdump greater 1000

Pro Tip: Combine tcpdump with other command-line tools like grep, awk, and sed for powerful traffic analysis pipelines. Use BPF (Berkeley Packet Filter) syntax for complex filtering.

Comprehensive Analysis with Wireshark

Wireshark is the world's foremost and widely-used network protocol analyzer that lets you see what's happening on your network at a microscopic level with a rich GUI interface.

Installation

Kali Linux Installation
sudo apt update && sudo apt install wireshark

Basic Wireshark Usage

1

Start Capture

Launch Wireshark and select interface:

Command
wireshark

Then select network interface and click "Start"

2

Apply Display Filters

Use display filters to focus on specific traffic:

Common Filters
http
tcp.port == 443
ip.addr == 192.168.1.100
dns
tcp.flags.syn == 1 and tcp.flags.ack == 0
3

Follow TCP Stream

Reconstruct complete TCP conversations:

Right-click TCP packet → Follow → TCP Stream

Advanced Wireshark Features

Feature Description Access Method
IO Graphs Visualize traffic patterns over time Statistics → I/O Graph
Conversations View traffic between hosts Statistics → Conversations
Protocol Hierarchy See protocol distribution Statistics → Protocol Hierarchy
Export Objects Extract files from traffic File → Export Objects → HTTP
Expert Info View warnings and errors Analyze → Expert Info

Pro Tip: Use Wireshark's powerful filtering and statistical tools for deep packet analysis. Combine with tshark (command-line version) for scripting and automation.

Practical Lab Setup

Setting up a controlled environment for practicing network sniffing techniques is essential for effective learning and ethical testing.

Recommended Lab Configuration

1

Virtual Environment

Use virtualization software like VirtualBox or VMware:

  • Kali Linux (Attacker Machine)
  • Windows 10/11 (Target Machine)
  • Metasploitable (Vulnerable Server)
2

Network Configuration

Set up internal network (NAT Network or Host-only):

VirtualBox Network Setup
VirtualBox → Preferences → Network → NAT Networks
Create NAT Network: 192.168.100.0/24
3

Testing Scenarios

Practice with these realistic scenarios:

  • ARP spoofing between target and gateway
  • DNS spoofing for phishing simulation
  • HTTP password capture
  • VoIP call interception
  • Wireless network analysis

Ethical Practice: Always obtain proper authorization before testing. Use dedicated lab environments isolated from production networks. Document all activities and findings.

Modules (130) ← CEH — Ethical Hacking