Reading width
Wide uses the full column for everything, text, diagrams, code, and exercises. Narrow keeps the standard reading width.
Text size
Scales the body text. Headings and code blocks keep their size.
In this section
Finding C2 Beacons in Network Traffic: Periodicity, Jitter, Sizes, Fronting and JA4
Introduction
A compromised host is useful to an attacker only while it can be reached, and most networks do not let the internet reach in. So the host reaches out: a program on it contacts a server the attacker controls, over and over, to report that it is alive and to collect instructions.
That repetition is the network's best chance of noticing, because the content is usually encrypted and the destination usually has no bad reputation yet.
The three green schedules are a product's fixed or lightly randomized timer. The two brick rows are one program: jittered, then moved to a new name when the first one stopped.
This lesson reads a window of the lab in which two workstations make scheduled connections. ws46 runs an updater, an endpoint agent and a sync client; ws45 runs a chat client and the time service, and something else. It measures every schedule, explains the ones a product accounts for, and builds a case against the one that is left, without relying on any reputation feed.
Module 8 teaches each step in depth.
Every Schedule in the Window
Measure first, explain secondA heartbeat is a schedule, and the first step is to find every schedule, not only the suspicious ones. The pack's periods.py takes timestamps per client and destination from Zeek's TLS log and reports how many sessions each pair made, the median interval between them, the middle half of the intervals and the spread, the middle half's width as a percentage of the median:
$ zeek-cut ts id.orig_h server_name < zeek-lan/ssl.log | python3 periods.py
n median middle half min max spread client destination
23 19.2 16.9-21.7 16.1 23.9 25% 10.20.30.45 api.cloud-metrics.example.org
6 21.5 18.9-22.2 16.9 22.8 16% 10.20.30.45 www.example.net
48 15.1 14.9-15.3 14.6 15.5 3% 10.20.30.46 edr.example.com
16 45.0 45.0-45.0 45.0 45.1 0% 10.20.30.46 cdn-sync.example.org
12 60.0 60.0-60.0 60.0 60.0 0% 10.20.30.46 updates.example.net
9 79.0 64.5-90.0 52.0 120.0 32% 10.20.30.46 www.example.net
Three traits separate a channel from the rest of a window's schedules, and the table above already holds the first:
What a heartbeat channel usually shows
Repeated sessions to one destination, fixed or jittered
The same request and reply sizes, session after session
No installed product that predicts the destination, interval and sizes
Six pairs repeat. A spread near 0% is a fixed timer: the same interval every time, to the tenth of a second. A larger spread means the interval varies, either because a person is involved, as with web browsing, or because the timer was built to vary, which is called jitter.
The time service runs over UDP, so it is not in the TLS log. The same script over the connection log finds it:
$ zeek-cut ts id.orig_h id.resp_h id.resp_p proto < zeek-lan/conn.log \
| awk '$5 == "udp" && $4 == 123' | cut -f1-3 | python3 periods.py
n median middle half min max spread client destination
12 64.0 64.0-64.0 64.0 64.0 0% 10.20.30.45 203.0.113.123:123/udp
The table so far is a description of the window, not a finding. Every operating system and most installed products make scheduled connections, and a quiet office workstation will show half a dozen of them.
Module 8 starts by reading what a channel looks like in each of Zeek's logs and Suricata's flow records, and its second lesson reads periodicity and jitter: how to measure them, and what they can and cannot show.
The order matters. A method that starts by searching for something suspicious finds whatever looks suspicious first, and on this window that would be the most regular timers, which are the most innocent.
Measuring everything first means the comparison that follows is between a schedule and the product that should own it, not between a schedule and an expectation of what malware looks like. It also produces something useful whatever the outcome: a list of every scheduled destination on two hosts, which is the baseline the next investigation on them will need.
The spread is the number to read first. It is the width of the middle half of the intervals divided by the median, so it ignores the occasional late or missed session and describes the timer itself.
Note the threshold periods.py applies: it reports a pair only after four sessions, and it merges events less than half a second apart. Both are choices. A channel that checks in once an hour would not appear in a twenty-minute window at all, and Module 8 reads how long a window has to be for a given interval to show.
Explaining the Ones You Can
A product that predicts destination, interval and sizeThe pack's hosts.txt includes notes from each installed product's documentation:
$ sed -n '/Vendor notes/,/Windows time/p' hosts.txt | tr -s ' ' | fold -s -w 80
Vendor notes, from each product's administration guide:
OfficeSuite 16 checks updates.example.net/v1/manifest.json every 60 s while a
session is open
SentinelPoint 7.2 heartbeat to edr.example.com/v1/heartbeat every 15 s,
randomized by up to 0.5 s
CloudSync 3.1 posts changed items to cdn-sync.example.org/v2/sync every 45 s;
size varies with changes
ChatDesk 5.3 one WebSocket to chat.example.net/ws, a ping every 30 s
Windows time SNTP to time.example.com every 64 s (the lab's setting)
Those notes are what turns a list of schedules into a set of explanations. Without them, the tempting move is the wrong one:
The reasonable mistake
Treating regularity as guilt
A detection flags every destination contacted at a steady interval. On this window it fires on the endpoint agent, the sync client and the updater first, because their timers are more regular than the channel's.
Instead: Measure every schedule, then explain it: a named product whose documentation predicts the destination, the interval and the sizes. What is left over after the explained ones are removed is the lead.
Each note predicts something the measurement can check. SentinelPoint's heartbeat to edr.example.com every 15 seconds, randomized by up to half a second: ws46's sessions to that name have a median of 15.1 seconds and a spread of 3%.
CloudSync's 45 seconds and OfficeSuite's 60 seconds match ws46's sessions to their names exactly, with a spread of 0%. The time service's 64 seconds matches ws45's NTP. ChatDesk's single WebSocket shows up as one TLS session to chat.example.net that lasted the whole window, which is why it has no interval at all.
That accounts for every schedule but two, both from ws45. ws45 to www.example.net could be a person browsing, and ws46's visits to the same name have the wide, irregular spread of browsing. ws45 to api.cloud-metrics.example.org has no product at all: no note mentions the name, and no installed program on ws45 has a timer near 19.2 seconds.
An explanation counts only if it predicts all three: the destination, the interval and the sizes. A product that contacts the right name on the wrong schedule, or the right schedule with the wrong sizes, is not an explanation.
Module 8's lesson on legitimate lookalikes works through each product in this window that way, and shows how an unlisted but legitimate agent can still look exactly like a channel until someone finds its documentation.
Writing the explanations down is part of the method. Each line names the product, the note that predicts it and the measurement that matches, so that a reviewer can check the elimination rather than trust it. An unexplained schedule left over after that process is a much stronger lead than one picked out by eye, because everything around it has been accounted for.
Sizes and Durations
The same exchange, every timeA channel that only reports in sends the same request and gets the same reply, session after session. The connection log for ws45's sessions to api.cloud-metrics.example.org, grouped by size:
$ zeek-cut id.resp_h orig_bytes resp_bytes < zeek-lan/conn.log \
| grep -e 203.0.113.110 -e 203.0.113.111 | cut -f2,3 | sort | uniq -c
10 1084 1441
5 1084 1442
8 1084 1443
Every one of the 23 sessions sent 1084 bytes of payload and received a reply within two bytes of the same size, and each was over in a few milliseconds. Nothing was uploaded, nothing was downloaded, and the server said the same thing every time: a check-in with nothing to report.
Size consistency cuts both ways. The updater and the endpoint agent on ws46 are just as consistent, because they too ask the same question on a timer.
The sync client is not: its upload sizes range from about 2 KB to over 36 KB, because it sends whatever has changed, as its documentation says. What makes the cloud-metrics sessions stand out is not that they are consistent but that they are consistent and owned by nothing.
Size also matters for what would come next. A channel that one day receives a 200 KB reply instead of its usual 1.4 KB has been given something, a command or a payload, and that change is visible in the connection log without any decryption.
Duration works the same way: a session that suddenly stays open for minutes is carrying something interactive. Module 8's lesson on duration and size reads both, and the TLS record structure that sets the floor on how small an encrypted exchange can be.
The chat client is the opposite shape: one session, open for over eleven minutes, with small messages in both directions. Long-lived connections are another way a channel can work, and one more reason not to read only for repetition. A channel built that way would appear in this window as one session, not twenty-three, and would be found by its duration and its owner rather than its interval.
When the Destination Changes
The same program, a new nameThe cloud-metrics sessions were spread across two addresses, 203.0.113.110 and .111, and then stopped. 109 seconds later, ws45 began a new schedule to www.example.net, a well-known site that ws46's user also browses. It has a similar jitter, and its sessions send 1085 bytes, one more than before.
The TLS log shows only the name in the handshake. The key log found on ws45, written by one program and covering only its connections, shows what was inside:
$ tshark -r lan.pcap -o tls.keylog_file:keys/ws45-beacon.keys \
-Y 'http.request && ip.src==10.20.30.45 && ip.dst==203.0.113.80' \
-T fields -e tcp.stream -e http.host -e http.request.uri | head -3
99 status.metrics-cdn.example.com /api/v2/metrics
102 status.metrics-cdn.example.com /api/v2/metrics
107 status.metrics-cdn.example.com /api/v2/metrics
The handshake of the first of those connections, stream 99, asked the server for a different name:
$ tshark -r lan.pcap -Y 'tcp.stream==99 && tls.handshake.type==1' \
-T fields -e tls.handshake.extensions_server_name
www.example.net
Set side by side, the two records describe one exchange in which the outside and the inside disagree:
The sensor sees the handshake's name. The front server picks its certificate from that name and routes the request by the Host header inside, which only the key log shows.
The request inside asked for another. A server that hosts several names on one address picks its certificate from the handshake's name and its content from the request's Host header, and nothing obliges the two to match.
The program connected to www.example.net in the open and asked, inside the encryption, for status.metrics-cdn.example.com. That is fronting: the visible destination is a site nobody would block, and the real one is hidden behind it.
The web server's log confirms it from the other side: six requests whose Host is status.metrics-cdn.example.com arriving on connections whose handshake named www.example.net. Without the key log the sensor would have seen only a new jittered schedule to a popular site, with the same sizes and the same fingerprint as the one that had just stopped.
That continuity, rather than the hidden name, is what ties the two together. A name can change in a minute; a program's timer, its exchange sizes and its TLS client are much harder to change without rewriting it. Module 8's lesson on destination changes follows the move in full, and what DNS shows of it.
Fronting also explains why the move happened at all. A channel whose destination has started to attract attention, or whose infrastructure has been taken down, needs somewhere else to go, and a popular shared front is the hardest kind of place to block.
For the investigator, the point is the continuity: when one schedule stops and another with the same shape starts on the same host, the second is a lead even if its destination is the most ordinary site on the internet.
What the Program Claims to Be
Conventions it gets wrongThe decrypted requests carry a Chrome user agent. The handshakes that carried them say something else:
$ tshark -r lan.pcap -Y 'tls.handshake.type==1' -T fields -e ip.src \
-e tls.handshake.ja4 -e tls.handshake.extensions_alpn_str | sort | uniq -c
30 10.20.30.45 t13d181100_85036bcba153_d41ae481755e
85 10.20.30.46 t13d3112h2_e8f1e7e78f70_b26ce05bbdd6 h2,http/1.1
The JA4 fingerprint summarizes each client hello. ws46's software sends a long list of ciphers and offers h2 and http/1.1 in its ALPN extension, the list of application protocols a client can speak. Everything ws45 sends, including the channel's connections, offers no ALPN at all.
Chrome offers h2 in its ALPN on every HTTPS connection it makes, as Module 8 shows, so a Chrome user agent on a connection with none was not sent by Chrome. Software that copies a browser's user agent is common, and many legitimate tools do it to avoid being turned away by servers; but it is also a claim the program made about itself that the handshake contradicts.
Note what the fingerprint does not do. ws45's chat client carries the same fingerprint as the channel, because both use Python's default TLS client, as Module 8's protocol misuse lesson shows.
A fingerprint describes a library, not a program, and it cannot on its own separate the channel from the chat client on the same host. It is evidence when it contradicts a claim, as here, and much weaker when it is used as a signature.
The ALPN check and the fingerprint need only a capture. The user agent needed the key log. Module 8's protocol misuse lesson checks the program against every convention it touches, from ports to DNS, and marks which checks a sensor alone can make.
The lesson for the case is the one about claims. A program tells the network several things about itself: its user agent, its protocols, its TLS client. Ordinary software tells the same story in every layer because it is built on libraries that agree with each other.
A mismatch between layers is not proof of malice, but it is evidence that the software is something other than it says, and that is worth a line in the case.
A Case Without Reputation
Observed, inferred and unknownNone of the names in this window is on any blocklist, and the lab's infrastructure has no reputation to look up. The case has to be built from behavior, and written so that a reader can tell what was seen from what was concluded. Every statement in it goes under one of three headings:
The case, by kind of statement
A jittered schedule, fixed sizes, a move to a fronted name, a browser claim from a client that is not a browser
An unlisted program on ws45 keeps a channel to infrastructure built to blend in
What the program is, and what the server sent it
The observed column is the strongest part of the case, because every item in it can be shown to someone else with the record that holds it. The inferred column is where judgment lives, and each inference should name the observations it rests on, so that a reader who disagrees can see exactly which step they reject.
The timeline adds one observation that the schedules alone could not. At 13:39:34, before the first cloud-metrics session, ws45 downloaded setup-helper.zip over plain HTTP. The order is evidence of timing only: the network cannot show that the download installed the program, and the case says so.
That structure is the module's practical outcome. A channel case built on reputation collapses when the feed is wrong or late; one built on a schedule that nothing owns, fixed exchanges, a move to a fronted name and a client that misrepresents itself survives a reputation check either way.
What it cannot answer is what the program is, which only the endpoint can; so the case ends with a precise request to the endpoint team, which host, which time, which download, rather than a conclusion they have to reverse-engineer.
The unknown column matters as much as the other two. It says what the network evidence cannot reach, and it is the list of questions the next team has to answer. A case without one has either overreached or stopped short of saying where its evidence ends.
Module 8's lesson on building the case lays the whole window out in time order and writes each statement with its source and its confidence.
What Module 8 Builds On It
Command-and-control investigation in depthModule 8 takes each step of this lesson as a lesson of its own, on the same window, then hands over Case 1: a download followed by recurring outbound connections, to be investigated without leaning on reputation. Its window holds legitimate schedules around the channel, and one of them, remote-support software, looks worse than the channel does, which is exactly the trap this lesson's elimination is built to avoid.
Module 8, in order
Each lesson in the list reads one dimension of the channel in full, and the order follows the one this lesson used. The lab is the same: the capture, the Zeek and Suricata logs, the resolver log, the web server's log, the product notes and the key log, with periods.py and a second script for sizes.
Nothing has to be captured again. Each lesson works on the same twenty minutes from a different angle, and the last one before the exercise assembles them into the case table this lesson sketched.
Case 1 asks for the same kind of case on a new window, with observed, inferred and unknown kept apart, and with each schedule that was explained away written down beside the product that explains it, so that a reviewer can follow the elimination. The answers are in the Phase 0 answer guide.
The habit to carry into it is the order of work this lesson followed. Measure every schedule; explain each one from a named product that predicts destination, interval and size; read what is left by its sizes, its destinations and the claims it makes; and write the case so that observed, inferred and unknown are never mixed.
Reputation can confirm such a case. It should never be the case. When a feed does list one of the names later, the case is stronger; when it never does, the case still stands on what the records show.
Practice
Which schedule has no owner? the lab workstationsThe prepared evidence below is the window's TLS schedules, measured by periods.py, beside the product notes for each workstation. Explain every schedule you can, find the one no product owns, and find where it went next. Each answer comes with its reasoning, so check it against the rows.
Work in the order this lesson did: match each row of the Schedules tab to a row of the Products tab by destination and interval, and strike it out only when both agree. Two rows from ws45 will be left.
One of them could be browsing; the other has no candidate at all. The third question asks which parts of the case would survive if the key log had never been found, which is the situation most investigations start in, so answer it from the sensor's records alone.
If you have a machine to hand, list the connections it makes over an hour with nothing open: most operating systems will show several scheduled destinations. Try to name the product that owns each one. The ones you cannot name are where an investigation would start.
Heartbeat channels are found by their schedules, but so is most legitimate software, so the method is to measure every schedule and explain each from a product that predicts its destination, interval and sizes. What is left is read by its sizes, its destination changes and the claims its connections make, and the case is written as observed, inferred and unknown, without depending on reputation.
The next lesson follows an intruder across the internal network and out of it with data.
Versions this lesson relies on: Wireshark and TShark 4.6.9; Zeek 9.0.1 (LTS); Suricata 8.0.8.