Notes
How capture works
Everything you send is cut into packets, each with source and destination addresses and a payload. Normally a network card keeps only the packets addressed to it and ignores the rest. In promiscuous mode it keeps everything it can see, and on Wi-Fi, monitor mode captures raw radio frames from the air. A sniffer is simply a program that records those packets. It sends nothing, which is why sniffing is so hard to detect.
- data is cut into packets, each with addresses and a payload
- normally a card keeps only packets addressed to it
- promiscuous mode: keep everything it can see
- monitor mode (Wi-Fi): capture radio frames from the air
- a sniffer just records them
Two tools
There are two tools to know. tcpdump runs in a terminal and is on almost every server, so it is what you use during an incident. Wireshark is the graphical one, with colour, decoding of hundreds of protocols, and powerful search. The usual workflow combines them: capture with tcpdump into a file, here on the loopback interface for traffic to a local lab server, then open that file in Wireshark to study it.
# list interfaces tcpdump -D # capture web traffic to a file sudo tcpdump -i lo -w lab.pcap \ port 8080 # read it back, show payload tcpdump -r lab.pcap -A | less # or open lab.pcap in Wireshark
HTTP: plain text
Log in to your lab copy of ShopRung over plain HTTP and look at the capture. There it is: the request line, the headers, and the body with the email and password in readable text. In Wireshark, right-click any packet and choose follow HTTP stream to see the whole conversation, including the session cookie the server sends back. Anyone on the path who captured this now has the password, and the cookie that proves you are logged in.
POST /api/login HTTP/1.1
Host: localhost:8080
Content-Type: application/json
{"email":"test@lab.test",
"password":"lab-pass-123"}
Wireshark: right-click a packet,
Follow > HTTP Stream HTTPS: ciphertext
Now repeat the login over HTTPS. The capture shows a TLS handshake, the client hello, the server hello and the certificate, and after that only records labelled application data. No path, no headers, no password, no cookie. The sniffer still captured every byte, and can read none of them. This single comparison is the best argument you will ever see for encrypting everything, and it takes five minutes to run.
- TLS handshake: Client Hello, Server Hello, certificate
- then "Application Data": encrypted records
- no path, no headers, no password, no cookie
- the sniffer captures every byte and can read none of it
What still leaks
TLS hides the content, but not everything. An observer still sees the addresses of both sides, the DNS lookup that came first unless DNS is encrypted too, the server name sent in the handshake, and the timing and size of every message. That is metadata: who talked to whom, when and how much. It matters for privacy, and defenders use exactly this metadata to spot malware calling home, even when they cannot read the payload.
- IP addresses of both sides
- the DNS lookup, unless DNS is also encrypted
- the server name in the handshake (SNI)
- timing and sizes of messages
- this is metadata: who talked to whom, when, how much
Filters
A real capture has thousands of packets, so filters matter. In Wireshark you can show only HTTP posts, only traffic to one address, only one port, only DNS, or only TLS client hellos. A filter for packets with the SYN flag and no ACK shows new connection attempts, which is how a port scan looks. And searching frames for a word like password quickly proves whether anything sensitive is crossing in plain text.
http.request.method == "POST" ip.addr == 10.0.0.5 tcp.port == 443 dns tls.handshake.type == 1 tcp.flags.syn == 1 && tcp.flags.ack == 0 frame contains "password"
The defender side
Defenders use the same skill constantly. To prove that an internal service sends secrets in plain text, which gets it fixed faster than any policy document. To investigate an incident and see what left the network and where it went. To find malware by the regular rhythm of its calls home. To check that TLS versions are modern. And to keep capture files as evidence. Network captures do not lie and do not forget.
- prove a service sends secrets in plain text, then fix it
- investigate an incident: what left the network, to where
- find malware beaconing by its regular timing
- check that TLS versions and ciphers are modern
- keep pcaps as evidence
Rules
One rule before you practise. Capturing traffic on your own machine and your own lab network is fine. Capturing on a network you do not own or operate, a cafe, a college, an office, without written permission is interception, and it is illegal in most countries. Even at work, a capture contains other people's data, so follow the monitoring policy, capture the minimum you need, and store the file as sensitive.
- your own machine and your own lab: fine
- a network you do not own or run: needs written permission
- captures hold other people's data: handle as sensitive
- at work: follow the monitoring policy, capture the minimum
Common mistakes
Mistakes. Assuming nobody is listening on the network. Leaving internal tools on plain HTTP because they are internal. Still running old plain-text protocols like FTP, Telnet, and unencrypted mail and directory traffic. Capturing with no filter and drowning in packets. Sharing a capture file that contains real passwords and cookies. And the one that ends careers: sniffing a network you do not own.
- "nobody is listening"
- HTTP for internal tools
- old protocols: FTP, Telnet, plain SMTP and LDAP
- capturing with no filter and drowning in packets
- sharing pcaps with secrets
- sniffing networks you do not own
Say it like this
In the interview: over plain HTTP an attacker on the same network sees everything, including paths, headers, passwords and session cookies. Over TLS they see only metadata: addresses, DNS lookups, the server name, sizes and timing. So I encrypt all traffic, including internal traffic, retire plain-text protocols, and I use packet captures myself to verify that nothing sensitive crosses the network unencrypted.
- "Over plain HTTP, everything: paths, headers, passwords and session cookies. Over TLS only metadata: IP addresses, DNS
- lookups, the server name, sizes
- and timing. So I encrypt all traffic, internal too, and use
- captures to verify it."