41. Session Hijacking – Tokens, Cookies and Defence
41.5 Network Sniffing of Sessions – Host-Only Concepts
On a switched LAN, casual sniffing is harder than old hubs – but open Wi-Fi, misconfigured mirror ports, compromised routers, and MITM themes still teach why cleartext cookies die.
Lab-safe learning:
- Wireshark /
tcpdumpon host-only interface while your lab browser talks HTTP to your PHP VM - See
Cookie:headers in clear HTTP; contrast with TLS (payload encrypted) - Blue push: HTTPS + HSTS (
Strict-Transport-Security) so browsers refuse downgrade
# Kali host-only – capture ONLY your lab subnet traffic (example interface name varies)
# sudo tcpdump -i eth1 -n host 192.168.56.40 and port 80 -w /tmp/lab-http.pcap
# Then open pcap in Wireshark; filter: http.cookie || http.set_cookie
# Never capture on bridged café Wi-Fi hunting strangers
| Red team (attacker) does | Blue team (defender) detects / stops |
|---|---|
| Captures HTTP Cookie on open Wi-Fi / MITM lab | HTTPS + HSTS; Secure cookies; VPN on untrusted nets |
| SSL-strip / downgrade themes (awareness) | HSTS preload where appropriate; no HTTP links to auth |
| Compromises home router to sniff LAN | Router hardening; segment IoT; update firmware |
Ravindra Bagale's Tip
Students college Wi-Fi var Wireshark sodun "research" mhantat – legal + ethics red flag. Host-only lab VM traffic only. Interview: "I demonstrate cookie exposure on my lab HTTP app, then enforce HTTPS." Aata pudhe jaauya.
Lab
Start tcpdump/Wireshark on Kali toward 192.168.56.40:80 only. Login on weak HTTP PHP app. Confirm Cookie visible. Switch lab app to HTTPS (self-signed), re-login, confirm payload not readable as clear Cookie in same way. Screenshot ethics note in lab book.