#Why this matters
Firewalls and intrusion prevention systems typically block unsolicited inbound connections, so modern adversaries rely on outbound channels that blend into routine enterprise traffic. Under the Command and Control and Exfiltration tactics of MITRE ATT&CK, compromised endpoints reach out over HTTPS, DNS, or ICMP because perimeter policies routinely permit those protocols for browsing, name resolution, and diagnostics.
For a network defender or digital forensics analyst, payload encryption often hides the message body. Even when TLS obscures application content, packet timing, query structure, byte symmetry, and connection metadata expose abnormal behavior. Learning to read those signals in tshark and Zeek lets you spot active intrusions before sensitive data leaves the environment.
#Command-and-control beaconing and jitter
Instead of holding an interactive shell open for hours, an implant normally sleeps, wakes up, sends a small outbound check-in, collects any queued instructions, and returns to sleep. This heartbeat pattern is beaconing. Because the host initiates each TCP or UDP session from inside the network, stateful firewalls allow the traffic out.
Naive beacons use a fixed interval such as 60 seconds, producing identical gaps between timestamps (ts) in Zeek's conn.log. To evade simple interval matching, operators add jitter, a percentage of random variation around the base sleep timer. With a 60-second interval and 20 percent jitter, check-ins arrive anywhere between 48 and 72 seconds apart.
Even with jitter, beacons leave clear statistical fingerprints across hours of telemetry:
- Clustered inter-arrival times: Plotting the time deltas between connections from the same source IP to the same destination IP and port shows a tight distribution compared to human browsing, which comes in irregular bursts.
- Uniform session sizes: Empty "no task" check-ins repeat nearly identical
orig_bytesandresp_bytescounts across dozens of connections. - Unusual timing windows: Check-ins continue steadily at 03:00 local time when no user is logged in, or from headless servers that should only contact internal services.
$ zeek-cut -d ts id.orig_h id.resp_h id.resp_p duration orig_bytes resp_bytes < conn.log | grep "192.0.2.44"
2026-11-18T02:01:12+0000 10.10.10.25 192.0.2.44 443 0.14 412 188
2026-11-18T02:02:19+0000 10.10.10.25 192.0.2.44 443 0.15 412 188
2026-11-18T02:03:11+0000 10.10.10.25 192.0.2.44 443 0.13 412 188
2026-11-18T02:04:17+0000 10.10.10.25 192.0.2.44 443 0.14 412 188Notice the gaps: 67s, 52s, and 66s around a 60-second mean, paired with identical 412 and 188 byte counts. Human web browsing varies in duration, target hosts, and response sizes; a uniform loop like this warrants immediate endpoint triage.
#Protocol tunneling over DNS and ICMP
When strict proxies block direct outbound HTTP or raw TCP to unknown hosts, attackers look for protocols that still traverse the perimeter. Protocol tunneling wraps command traffic or stolen bytes inside protocol fields meant for routing or name lookup.
#DNS tunneling
Every endpoint needs name resolution, and internal recursive resolvers forward unknown domain queries outward to authoritative servers. In a DNS tunnel, the compromised host encodes data as subdomain labels under an attacker-controlled domain and sends queries through the normal local resolver.
Because the internal resolver relays the traffic, firewall logs only show port 53 to your own DNS server. Hunting DNS tunnels therefore focuses on dns.log or packet captures:
- Long, high-entropy subdomains: Standard hostnames use short dictionary words (
mail.lab.local). Tunneled queries pack hex, base32, or base64 strings into labels up to 63 characters long, raising Shannon entropy and digit ratios. - Rare query types: Normal clients send
A,AAAA,PTR, orSRVqueries. FrequentTXT,NULL,CNAME, orMXlookups to a single apex domain stand out sharply. - High unique subdomain count: Thousands of distinct one-off queries to
*.t1.example.testthat never repeat indicate data transport rather than normal service discovery, often paired with low cache hit rates and occasionalNXDOMAINresponses when sessions desynchronize.
#ICMP tunneling
ICMP echo requests (type 8) and replies (type 0) carry an optional data payload for diagnostics. Standard utilities send small, fixed patterns: Linux ping defaults to 56 data bytes (64 bytes including the ICMP header, 84 bytes total IP packet), and Windows sends 32 data bytes of repeating alphabet characters.
In an ICMP tunnel, both echo requests and echo replies carry variable-length, high-entropy payloads exceeding normal diagnostic sizes, or the reply payload differs completely from the request payload. Under RFC 792, a normal echo responder mirrors the request data unchanged; mismatched request and reply contents are an immediate red flag.
$ tshark -r lab_capture.pcap -Y "dns.flags.response == 0" -T fields -e frame.time_relative -e ip.src -e dns.qry.type -e dns.qry.name | head -n 4
0.120411 10.10.10.25 16 4a6f6230312d686f7374.t1.example.test
0.341008 10.10.10.25 16 737973696e666f2d6f6b.t1.example.test
0.562190 10.10.10.25 1 www.lab.local
0.790442 10.10.10.25 16 646174612d6368756e6b.t1.example.testIn tshark, dns.qry.type value 16 represents TXT records, and the hexadecimal subdomain labels decode directly to ASCII strings (Job01-host, sysinfo-ok, data-chunk).
#Detecting covert exfiltration and flow anomalies
Exfiltration aims to move files out without triggering volume alerts. Attackers either burst data quickly over a permitted cloud storage API or trickle chunks slowly over days through a tunnel. Comparing flow metadata catches both patterns.
| Traffic pattern | Key protocol clues | Primary Zeek / tshark signal |
|---|---|---|
| HTTP/TLS beaconing | Fixed sleep plus jitter, consistent packet sizes | Tight delta distribution in conn.log, repeated orig_bytes |
| DNS tunneling | High-entropy labels, unusual record types (TXT, NULL) |
High unique query count per apex domain in dns.log |
| ICMP tunneling | Oversized payloads, mismatched request/reply data | ip.len well above 84 bytes, differing icmp data payloads |
| Bulk or slow exfiltration | Heavy outbound asymmetry over non-upload services | High producer-consumer ratio (orig_bytes >> resp_bytes) |
Normal web sessions are consumer-heavy: a client sends a short request and downloads megabytes of pages or media (resp_bytes exceeds orig_bytes). When a workstation uploads an archive over an unexpected channel, the producer-consumer ratio flips. Tracking orig_bytes / (orig_bytes + resp_bytes) across long-lived or repeated flows highlights hosts pushing far more data out than they pull in.
- CaptureCollect PCAP or Zeek logs at egress
- FilterSeparate internal DNS, ICMP, and external TLS flows
- MeasureCheck interval jitter, label entropy, and byte ratios
- DecideVerify host process or isolate suspicious endpoint
#Defending and common mistakes
Effective defence treats egress traffic with the same skepticism as inbound traffic:
- Enforce strict egress filtering: Allow outbound DNS only from approved internal resolvers, block unnecessary outbound ICMP echo traffic at the perimeter, and restrict direct outbound HTTP/HTTPS from servers that have no business browsing the internet.
- Log internal resolver traffic: Capture DNS queries at the recursive resolver rather than only at the firewall, otherwise every internal client hides behind the resolver's IP address.
- Monitor TLS and flow metadata: Even without TLS decryption, logging SNI hostnames, certificate anomalies, JA3/JA4 fingerprints, and
orig_bytesvsresp_bytesexposes beaconing and asymmetric uploads. - Baseline normal behavior: Know which hosts run backups or log shippers so genuine administrative transfers do not trigger false alarms while real exfiltration slips past.
Common mistakes in practice include monitoring only firewall-allowed ports instead of protocol anomalies inside permitted ports, setting static volume thresholds that miss slow trickle exfiltration, and ignoring NXDOMAIN spikes that often accompany broken or rate-limited DNS tunnels.
#Summary
- Adversaries hide C2 beaconing, protocol tunneling, and exfiltration inside allowed outbound protocols such as HTTPS, DNS, and ICMP.
- Beaconing reveals itself through clustered inter-arrival intervals (even with jitter) and repetitive byte counts in Zeek's
conn.log. - DNS and ICMP tunnels stand out via high-entropy subdomains, rare record types (
TXT,NULL), oversized echo payloads, and request-reply mismatches. - Asymmetric
orig_bytesoverresp_bytessignals covert exfiltration, which defenders counter with egress controls, internal resolver logging, and metadata baselining.