Skip to main content
Suspicious Network Traffic: Beaconing, Tunneling & Exfil
Lesson 6 of 12

Suspicious Network Traffic: Beaconing, Tunneling & Exfil

Learn how command-and-control beaconing, protocol tunneling, and covert exfiltration hide inside allowed network protocols, and how to hunt them with tshark and Zeek.

Advanced 26 min Networking
Authorised environments only — The techniques described here are used only in training labs and on systems you own or have written permission to test.

Learning objectives

  • Explain how C2 beaconing, protocol tunneling, and covert exfiltration abuse permitted egress protocols
  • Identify periodic check-in intervals and jitter patterns in Zeek connection and HTTP logs
  • Analyze DNS and ICMP packet captures with tshark and Zeek to spot encoded payloads and asymmetric flows
  • Apply egress controls, resolver enforcement, and flow baselining to disrupt unauthorized channels

Recommended first: Network Security Fundamentals & Protocol WeaknessesWireshark Deep Packet Inspection & Stream ReassemblyARP/DNS Spoofing, MITM & Denial-of-Service

#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_bytes and resp_bytes counts 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.
Inspecting Zeek conn.log for repeated outbound sessions
$ 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 188

Notice 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.

DNS tunneling through an internal recursive resolverDNS tunneling through an internal recursive resolverCompromised HostLocal ResolverAuthoritative C2 NSTXT aGVsbG8td29ybGQ.t1.example.testForward query for example.testTXT encoded response chunkRelayed TXT answerThe host never connects directly to the C2 IP

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, or SRV queries. Frequent TXT, NULL, CNAME, or MX lookups to a single apex domain stand out sharply.
  • High unique subdomain count: Thousands of distinct one-off queries to *.t1.example.test that never repeat indicate data transport rather than normal service discovery, often paired with low cache hit rates and occasional NXDOMAIN responses 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.

Checking DNS queries and ICMP packet lengths with tshark
$ 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.test

In 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.

  1. CaptureCollect PCAP or Zeek logs at egress
  2. FilterSeparate internal DNS, ICMP, and external TLS flows
  3. MeasureCheck interval jitter, label entropy, and byte ratios
  4. 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_bytes vs resp_bytes exposes 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_bytes over resp_bytes signals covert exfiltration, which defenders counter with egress controls, internal resolver logging, and metadata baselining.

Knowledge check

Sign in to take the test, complete lessons and save your progress. Log in

Practice: test your knowledge