Skip to content

Lesson 7 of 19 · 22m

Network Forensics: Reading Packets and Hunting Beacons

Turn Zeek logs, flow records, and TLS metadata into a C2 map — beacon regularity, JA3/SNI mismatches, and the DNS tells attackers can't hide.

The disk told you what ran; the network tells you who it talked to. Most organizations keep no full packet capture — pcap is expensive to store — so network forensics is usually three cheaper sources fused together: Zeek or firewall flow logs, DNS resolver logs, and whatever TLS metadata survived. Learn to read all three, because you'll rarely get the luxury of all of them.

The evidence hierarchy

  • Full pcap — everything, heavy, usually only captured reactively once you suspect something. tcpdump/dumpcap on a SPAN port or the host itself.
  • Zeek logs — the standard middle layer. Zeek turns traffic into structured logs (conn.log, dns.log, http.log, ssl.log) with durations, byte counts, and state — searchable for months, a fraction of pcap's size.
  • NetFlow / VPC Flow Logs — 5-tuples, packet/byte counts, no payload. In AWS, VPC Flow Logs are off by default and must be enabled per VPC — check that during triage, not after.
  • Resolver and proxy logs — DNS lookups and HTTP(S) requests. The cheapest, most underused scoping source in any org.

Hunting the beacon

C2 traffic hides in volume, not in port. The tells in conn.log or flow data:

  • Regularity: a process that phones home every 300 seconds ±2% is not a user browsing — compute mean and standard deviation of inter-connection intervals per destination.
  • Long-lived sessions: check duration — a 14-hour TCP session to a residential ASN is a channel, not a page load.
  • Asymmetry: small outbound, large inbound (or the reverse for exfil) is a session doing work, not fetching content.
  • Rare destinations: sort connections by destination frequency across the fleet; the IP that exactly one host talks to every five minutes is interesting by definition.
# tshark: DNS query counts from a pcap
tshark -r capture.pcap -Y dns -T fields -e dns.qry.name | sort | uniq -c | sort -rn | head -30

# Zeek conn.log: connections sorted by duration
awk -F'\t' '{print $5, $7, $9}' conn.log | sort -k3 -rn | head -20

TLS doesn't hide the interesting part

The payload is encrypted; the metadata isn't. The ClientHello still carries SNI in plaintext (unless ECH is deployed — rare in enterprise C2 today), and the TLS stack's own fingerprint betrays the client: JA3/JA4 hashes the cipher suites, extensions, and curves a client offers. A Python-based beacon presenting to a microsoft.com SNI produces a JA3 that no Edge browser ever sends — mismatched SNI and JA3 is a detection that survives full encryption. Certificate transparency logs (crt.sh) work the other direction: enumerate the attacker's certs for a domain and find the sibling infrastructure they stood up beside it.

DNS is the other leak. DGA domains produce NXDOMAIN bursts in dns.log; DNS-tunneling exfil produces absurdly long query names and TXT-record responses with high entropy. DNS over HTTPS closes this source, so the IR-era answer is: log or block known DoH endpoints at the proxy, or accept the blind spot explicitly.

Mind the quiet channels too: exfil over HTTP POST shows as upload-heavy sessions in http.log, ICMP tunneling shows as non-echo ICMP payloads, and QUIC rides UDP so a "TCP-only" filter in your flow review misses it. If your tooling only indexes TCP, you're auditing a fraction of the wire.

Two mechanical details pay rent. The uid field is Zeek's spine — the same value links a conn.log row to its dns.log query, http.log request, and ssl.log handshake, so pivoting is a grep, not a join. And ssl.log is where the TLS metadata this lesson leans on actually lives: server_name (the SNI), ja3/ja3s fingerprints, cert validation_status — while x509.log holds the full chain when a cert looks forged. On fingerprints: JA4 (FoxIO, 2023) is the GREASE-aware successor that also fingerprints QUIC — prefer it where your tooling supports it.

When you have nothing captured

Then capture now. During an active incident you stand up the telemetry you wish you'd had: a tcpdump ring buffer on the suspect host (tcpdump -i any -w /evidence/net.pcap -C 100 -W 10), Zeek on a tapped uplink, resolver query logging cranked up. Evidence collection during an incident isn't cheating; it's how real cases get made, and the attacker who survived your scoping will phone home again into a logged network.

Was this lesson helpful?

Sign in to rate

Keep reading

Related articles from the SudoSecurity blog.