Beaconing and suspected C2 detection
A beacon is a connection that repeats on a regular schedule, like a program that calls its server every few minutes.
Malware often does this to reach its command and control (C2) server. Many normal programs do it too, for example update checks.
The
beacon_detectormodule finds these repeating connections by looking at their timing, bytes, packets and duration.It can also say when a repeating connection looks like the malware C2 examples it was trained on.
Contents
What is reported
Evidence |
Threat level |
Meaning |
|---|---|---|
|
info |
The connections repeat on a regular schedule. Normal programs can cause this. No malware example is needed to find it. |
|
low |
The connections repeat, at least 80% of them were answered, and they also look like the malware C2 examples. |
The score in
SUSPECTED_C2_CHANNELsays how much the traffic looks like the C2 examples. It is not the chance that the computer is infected.Neither evidence proves malware on its own. Use it together with threat intelligence and other evidence.
Both evidence types are marked as DAMP in the default configuration.
They go through the usual evidence, whitelist and alert steps of Slips.
The module never blocks anything itself. Slips can still block a host when enough evidence adds up, if blocking is enabled.
The web interface shows each evidence under its source host, with
beacon_detectoras the module.
Each evidence describes:
the repeat interval in seconds, and the same value as a frequency in Hz.
the number of connections and the time they cover.
how many of the gaps follow the schedule, and how much they vary.
how many gaps had missed connections.
the usual (median) bytes sent and received, and the usual connection duration.
up to 32 flow UIDs that link to the original flows.
For repeating packets inside one long connection, see packet timing.
Enable it
In config/slips.yaml:
beacon_detector:
enabled: true
model_file: modules/beacon_detector/c2_pattern_model.json
c2_score_threshold: 0.5
modules:
disable:
- template
- rnn_cc_detection
The default configuration enables this module and disables the old RNN module.
Your own older configuration files keep whatever modules they enable or disable.
A
beaconing:section from an older config file is still read when the same option is not inbeacon_detector:. Rename it when you can.To only find repeating connections, without the C2 check, set
model_file: ''.Restart Slips after changing these settings.
How long until the first evidence:
There is no training period, and no traffic is assumed to be clean.
With the defaults, a connection history needs 12 connections that cover at least 30 seconds before it is checked.
Slow beacons take longer. A one minute test can’t show a connection that happens once per hour.
What is measured
A connection history is all the connections with the same source IP, destination IP, destination port and protocol.
The source port is ignored, because clients change it on every connection.
Only TCP and UDP connections to a single host are used.
ICMP, multicast, broadcast (when the subnet is known) and broken records are skipped.
Each flow is counted once, from the side of the source host.
Different destination IPs are different connection histories. The module doesn’t assume that two IPs of the same CDN are the same service.
For the latest connections in a history, Slips tries three ways of finding a schedule:
The time from the start of one connection to the start of the next.
The time from the end of one connection to the start of the next. This fits programs that sleep for a fixed time after they get an answer.
The time between groups of connections that are close together. This fits programs that send several requests each time.
How a schedule is accepted, with the default settings:
Slips tries several possible intervals taken from the gaps it saw.
At least 80% of the gaps must be within 25% of the interval.
A gap of two or three intervals is accepted as missed connections, but at least half of the gaps must be one interval long.
Gaps of zero seconds don’t count as a schedule.
Any interval between
min_period_secondsandmax_period_secondsis checked. No specific interval is treated as malicious.Connections that overlap are noted as overlapping. They are not treated as a negative sleep time.
The C2 check
The check is a small model: 32 decision trees, each at most three questions deep.
It uses:
how much the intervals, sizes, packet counts and durations vary, and their usual values.
how many connections were answered, how many were missed and how many overlapped.
It does not use IP addresses, ports, domains, capture names or stratoletters.
The model is a JSON file. Slips needs no TensorFlow or scikit-learn to use it, and loads no pickle file.
The model that comes with Slips was trained on TCP only. Repeating UDP connections are still reported as
PERIODIC_CONNECTION, but can’t be reported asSUSPECTED_C2_CHANNEL.
Limitations
Slips works on finished Zeek flows, so a connection is only seen after Zeek writes it.
One long connection is one flow. Messages that repeat inside it can’t be seen here. The optional packet timing collector looks at those.
C2 with fully random timing can be missed.
A weak schedule mixed with other traffic to the same destination can be missed. Slips looks for the main interval of a connection history, not for every hidden frequency.
A slow beacon needs
retention_hoursto cover enough connections. See the settings.
How it keeps memory and CPU low
The limits below are fixed in modules/beacon_detector/detection_settings_reader.py. They are not options of config/slips.yaml.
Limit |
Value |
Meaning |
|---|---|---|
|
4096 |
Connection histories that have fewer than |
|
2048 |
Connection histories that reached |
|
128 |
The latest connections kept for each checked connection history. |
Short histories and checked histories have separate limits, so one-time connections and scans can’t push out the connection histories that matter.
When a limit is reached, the connection history that was quiet the longest is dropped. If it comes back it has to collect connections again.
The same flow UID is not counted twice.
Flows that arrive out of order are put in the right place by their start time.
Messages about the limits:
Beaconing short history capacity: ...is information only. New, short connection histories were dropped.Beaconing history capacity: ...is a warning. Checked connection histories were dropped, so some beacons may be missed.Each message shows how many connection histories were dropped since the previous message. It is only printed when there are new drops.
An older Slips version printed
Beaconing channel capacity reached: 410 older windows evicted. That number was the total since the module started, and the message was repeated even when nothing new was dropped.
Saved state
On an interface, or with a growing Zeek directory, the module saves its connection histories in
<permanent_dir>/beacon_detector/channels.sqlite(permanent_diris set inslips.yaml, defaultpermanent). When reading a file or PCAP, it saves them in<output>/beacon_detector/channels.sqliteinstead.Only one Slips run can use the file in the permanent directory at a time. A second live run prints a warning, starts empty and saves its histories in its own
<output>/beacon_detector/channels.sqlite.Only connection histories that changed are saved, every 30 seconds, and not once per flow.
If the database is busy, the changes are kept and saved on a later try.
Old records are removed after
retention_hours, and the number of saved connection histories is limited.No new Redis keys are used and old flows are never read again from the database.
When reading a file, the module starts empty.
On an interface, or with a growing Zeek directory, the module loads the recent state saved in the permanent directory. It also remembers what it already reported.
Files saved by an older version of the module can still be loaded.
How often evidence is repeated
A new schedule sets one evidence.
If the schedule goes on, the next evidence is set at around 100 connections, then 1,000, then 10,000 and so on.
The number of connections can be a bit higher, because Slips waits for the next successful check.
This replaces one evidence per hour for a schedule that didn’t change.
Each evidence has the total number of connections and the total time so far. The timing and size numbers are from the latest connections only.
PERIODIC_CONNECTIONandSUSPECTED_C2_CHANNELare counted separately. A connection history that starts to look like C2 is reported right away.A new evidence can also be set right away when:
the interval becomes at least two times longer or shorter.
the way the schedule was found changes, between the three ways listed above.
When a schedule is lost and then found again, the same schedule is reported again only after
alert_cooldown_seconds.When a connection history is quiet for longer than both
alert_cooldown_secondsand four intervals, its old connections are dropped and it starts again.
How often a connection history is checked:
A connection history with no schedule yet is checked after every 4 new connections, and at most once every 5 seconds.
Once a schedule is found, it is checked after every 32 new connections, and at most once every 60 seconds.
When a check fails, the faster checking comes back.
The C2 check only runs after a successful schedule check.
Who started the connection
For TCP flows with a Zeek history, the handshake must show who the client is.
A flow that Slips first saw in the middle of a connection is skipped. Otherwise the client’s temporary port could be taken for a service.
Flows that Zeek flipped are still used when their history supports the final direction.
The same private IP in different networks
On an interface, a connection history also includes the interface, the gateway MAC, the subnet and the MAC of the client when it is known.
So
192.168.1.5on a phone hotspot and192.168.1.5on a Wi-Fi network are different computers for the module.Flows that arrive late use the network that was active at the time of the flow.
When the gateway is not known, the connection histories are only valid for the current run. They are not joined with the ones from before a restart.
Settings
Every option is also explained next to it in config/slips.yaml.
Option |
Default |
Range |
What it does |
|---|---|---|---|
|
|
|
Turns the module on or off. Restart Slips to apply. |
|
|
6-512 |
Connections needed before a connection history is checked. More means fewer chance matches, but slow beacons take longer to find. |
|
|
0-31536000 |
Seconds the connections must cover. This stops a short burst from looking like a beacon. Lower it for short tests. |
|
|
0.001-86400 |
Shortest repeat interval to look for. A smaller value also matches fast loops of normal programs. |
|
|
0.001-604800 |
Longest repeat interval to look for. |
|
|
0.01-0.45 |
How far a gap can be from the interval. |
|
|
0.6-1 |
Part of the gaps that must follow the schedule. |
|
|
1-8760 |
Hours that connections and quiet connection histories are kept. It can’t be shorter than |
|
|
1-2592000 |
Seconds before a schedule that was lost and found again is reported again. See how often evidence is repeated. |
|
|
a path, or |
The model used for the C2 check. Empty turns the C2 check off and keeps |
|
|
0.5-1 |
Lowest score for |
The options under beacon_detector.packet_timing are explained in packet timing.
Test results, 25 October 2026
How the model was trained:
Each capture was put, as a whole, in the training, validation or test group before the model was chosen. No capture is split between groups.
Training captures:
Hancitor 2020-01-21, Hancitor 2021-02-09 and Qakbot 2021-02-12, using only their known C2 servers.
CTU-Normal-38 as normal traffic.
Validation captures: SystemBC 2021-02-01 and CTU-Normal-39.
Only the flows to the known C2 servers were labeled as C2. Other flows of the malware captures were left without a label.
A few tree depths were compared on the validation captures, and the simplest model was the best.
Capture |
Flows |
Repeating histories |
Suspected C2 histories |
Used for, and result |
|---|---|---|---|---|
Hancitor 2020-01-21 |
60 |
2 |
2 |
Training |
Hancitor 2021-02-09 |
711 |
2 |
2 |
Training |
Qakbot 2021-02-12 |
1,105 |
3 |
1 |
Training. The TLS C2 server was missed |
SystemBC 2021-02-01 |
517 |
2 |
2 |
Validation |
CTU-Normal-38 |
72,307 |
40 |
0 |
Normal traffic, training |
CTU-Normal-39 |
114,520 |
50 |
0 |
Normal traffic, validation |
Qakbot 2021-05-18 |
605 |
1 |
0 |
Test. Its Cobalt Strike C2 server was missed |
Syprix spyware capture 1 |
125 |
0 |
0 |
Extra check. The connections don’t repeat enough |
NuclearEk02 |
395 |
1 |
0 |
Extra check. Repeating connections found, not reported as C2 |
|
299 |
1 |
0 |
Test. Repeating connections found |
|
263 |
1 |
0 |
Test. Repeating connections found |
Cherry’s saved live flows |
235,931 |
64 |
1 |
Traffic assumed to be normal. One false |
What these results mean:
❌ The model is mostly tuned to these Hancitor and Cobalt Strike examples. It was not tested on many malware families.
❌ The C2 server of the test capture (Qakbot 2021-05-18) was missed.
❌ One HTTP connection history in normal live traffic was reported as suspected C2, because its numbers look like the training examples.
These misses and the false evidence are kept here on purpose. The model was not changed to hide them.
The two simulations are not real malware.
This is why
SUSPECTED_C2_CHANNELhas a low threat level. More labeled examples, including normal programs that poll over TCP, are needed before raising it.Don’t use the score alone to decide that a computer is infected.
CPU and memory:
What was measured |
Result |
|---|---|
Reading and checking the 114,520 flows of CTU-Normal-39 |
About 7.5 CPU seconds in total |
Reading and checking the 235,931 saved live flows |
About 17.6 CPU seconds in total, including reading JSON and SQLite, without the C2 check |
Memory with 2,048 connection histories of 128 connections each |
About 84 MiB, 86 MiB at the highest, on top of Python itself |
Saving that full state |
0.44 CPU seconds, 0.53 seconds in total, 12.2 MiB file |
These are totals for a whole capture, not a CPU percentage.
A Raspberry Pi, and long runs at the limits, were not measured yet.
Where the captures come from:
The captures are not in the repository.
modules/beacon_detector/c2_pattern_model.jsonlists the hashes of the training files, the C2 servers used and the validation numbers.
Train or test your own model
Run the commands from the root of the repository.
Turn each PCAP into Zeek logs, each in its own directory:
mkdir -p output/beacon_detector/sample nice -n 15 zeek -C -r path/to/sample.pcap LogAscii::use_json=T \ 'Log::default_logdir=output/beacon_detector/sample'
Write a JSON file that lists the captures:
[ {"name":"normal-training","path":"path/to/normal/conn.log","split":"train","label":"benign"}, {"name":"c2-training","path":"path/to/malicious/conn.log","split":"train","label":"malicious-capture","c2_endpoints":["203.0.113.10:443/tcp"]} ]
pathis a JSON or TSVconn.log, or aflows.sqlitesaved by Slips.splitistrain,validationortest. Put a whole capture in one of them.labelis one of:benign: normal captures used for training or validation.malicious-capture: malware captures. List each C2 server you checked inc2_endpoints, asIP:port/protocol. A flow is not C2 just because it is in a malware capture.benign-assumed: live traffic that you think is normal. It is used for checking, not for training.simulation: simulated beacons. They are used for checking, not for training.
groupis optional. Give the samegroupto captures that come from the same recording or session.The two entries above are not enough to train. You need normal and C2 captures in both
trainandvalidation.Keep the test captures out of training and validation.
Extract the numbers, train, then test:
python -m modules.beacon_detector.tools.capture_replay_evaluator manifest.json --output output/beacon_detector/features.json python -m modules.beacon_detector.tools.c2_model_trainer output/beacon_detector/features.json --output output/beacon_detector/candidate.json python -m modules.beacon_detector.tools.capture_replay_evaluator test-manifest.json --model output/beacon_detector/candidate.json \ --output output/beacon_detector/test-results.json
Check the false evidence, the missed C2 servers and the CPU and memory use. Only then set
model_fileto the new model.
Good to know:
The trainer stops if the same capture, or the same
group, is in more than one split.Each connection history gets a weight, so one very long capture doesn’t decide the whole model.
Training needs scikit-learn and NumPy. Running Slips doesn’t.
Packet timing: repeating packets inside one TCP connection
Some malware opens one TCP connection, keeps it open for hours and sends a small message on a regular schedule.
Zeek writes one line in
conn.logfor the whole connection, so the beaconing detection of connections can’t see these messages.The packet timing collector records the time and size of the packets inside a connection, so Slips can find the schedule.
It never stores the content of the packets.
Packet timing evidence
Evidence |
Threat level |
Confidence |
Meaning |
|---|---|---|---|
|
info |
0.60 |
Packets repeat on a regular schedule inside one connection. It adds nothing to the score of the host. |
|
medium |
0.85 |
Small messages of the same size repeat very regularly, on a port where TLS is expected, and Zeek sees no TLS or any other known protocol. |
SUSPICIOUS_PACKET_HEARTBEAT is set only when all of these are true:
the packets carry application data and come from the client.
the TCP handshake shows who the client is.
both sides sent application data in the connection.
the destination port is in
expected_tls_ports.Zeek recognized no application protocol.
the usual message is at most 128 bytes, and at least 90% of the messages have the same size.
at least 95% of the gaps follow the schedule, and they vary by at most 5%.
It adds 0.5 × 0.85 = 0.425 to the score of the host that started the connection, with the default threat level.
What can only be PERIODIC_PACKETS:
connections where Zeek recognized TLS, HTTP or another protocol.
pure ACKs and TCP keepalives. They are only collected when
include_acksis on.
What is never counted:
retransmitted data.
packets larger than 512 bytes, and packets less than 1 second after the previous one. These clear what was collected so far for that direction and kind of packet, so a burst is not turned into a fake schedule.
a TCP keepalive can look the same as a retransmitted one byte packet. Neither is used for
SUSPICIOUS_PACKET_HEARTBEAT.
What the evidence means:
SUSPICIOUS_PACKET_HEARTBEATdescribes a suspicious behaviour. It doesn’t name a malware family.A normal program with its own protocol on port 443 can cause it too.
For traffic you checked and trust, add a whitelist rule for this evidence type and that source or destination.
Don’t whitelist port 443 for everything, and don’t treat every
PERIODIC_PACKETSas malicious.The C2 model of the
beacon_detectormodule is not used on packets. It was trained on connections.
What each evidence has:
who sent and who received the packets, and the UID of the connection.
the repeat interval, how many gaps follow it and how much they vary.
the usual size of the messages.
the times and sizes of the packets it is based on. No content.
When it is set:
The evidence can be set while the connection is still open. The
conn.logline of the connection only comes when Zeek closes it.If an info evidence was set and the stronger one applies later, the stronger one is set right away.
After the stronger one was set, the info one is not set again for the same connection, direction and kind of packet.
If the schedule goes on, the next evidence is set at around 100 packets, then 1,000 and so on.
Enable and run
Packet timing is on in the default config/slips.yaml. In the configuration file you pass with -c:
beacon_detector:
enabled: true
packet_timing:
enabled: true
The Zeek collector is loaded when
beacon_detectoris enabled, is not inmodules.disable, andpacket_timing.enabledis notfalse.If your configuration file has no
packet_timingsection, the default is used, which is enabled.Set
beacon_detector.packet_timing.enabled: falseto turn it off.Enabling another evidence type or opening a web page doesn’t turn it on.
Restart Slips after changing these options.
Old outputs:
Packet times are written by Zeek to a new
packet_timing.log.An output made before this can’t get them back with
--view. Run Slips on the PCAP again.A Zeek directory can be given to Slips directly when it already has this log.
Things to check:
Keep
parameters.tcp_inactivity_timeoutlonger than the gap you expect between messages.Slips sets it to 60 minutes by default.
With Zeek’s own default of 5 minutes, messages that are 300.7 seconds apart would be split into separate connections.
Measure the cost on your own traffic before using it all the time on a busy network.
Packet timing parameters
All options are under beacon_detector.packet_timing in config/slips.yaml. Restart Slips to apply them.
Option |
Default |
What it does |
|---|---|---|
|
|
Loads the Zeek collector and checks what it collects. Turn it off to save the CPU used per packet. |
|
|
Also collects pure ACKs and TCP keepalive probes. They can only set info evidence. Leave it off to get less noise. |
|
|
Ports where TLS is expected. Regular small messages with no known protocol on these ports set |
|
|
Threat level of |
The values below are fixed in modules/beacon_detector/detection_settings_reader.py. They are not options of config/slips.yaml.
Fixed value |
Meaning |
|---|---|
12 packets |
Packets needed before a schedule is checked. |
64 packets |
The latest packets kept for each connection, direction and kind of packet. |
every 8 packets |
How often Zeek sends an update after the first 12 packets. |
2048 connections |
Connections followed at the same time. |
30 seconds |
Packets in the first 30 seconds of a connection are skipped. |
1 second |
Shortest gap between two packets. |
60 seconds |
Time the packets must cover. |
512 bytes |
Largest packet that is collected. |
90% and 10% |
For |
95% and 5% |
The same two values for |
128 bytes and 90% |
For |
0.85 and 0.6 |
Confidence of |
Zeek explains the cost and the meaning of the sequence numbers of its
tcp_packet event.
How packet timing keeps memory and CPU low
In Zeek (zeek-scripts/packet-timing.zeek):
The work per TCP packet is small and always the same size.
Each connection has at most six lists: two directions times three kinds of packet (data, ACK, keepalive). Each list keeps the latest 64 packets.
Zeek sends a summary after 12 packets, then after every 8 more, and when the connection closes if something new was not sent yet.
When a connection closes, its memory is freed. A connection that is quiet for one hour is forgotten.
When 2048 connections are followed, new ones are not added and a warning is logged.
In Slips:
Slips gets the summaries through the
new_packet_timingchannel. It doesn’t get one message per packet.The profiler only reads, stores and passes on the summaries.
The
beacon_detectormodule looks for the schedule, using the same method as for connections.What was already reported is remembered for a limited number of connections.
The collector starts empty every time Zeek starts. Saved summaries can be viewed later, but normal flows can’t replace packet times that were not collected.
Looking at packet timing in the web interface
The Packet timing tab:
shows the gap between each packet and the one before it, in seconds or milliseconds, next to the size of the packet.
the first packet has no gap.
hover over a packet number to see its full timestamp. The original timestamps are also in the JSON that can be expanded.
the summary shows the direction, the application protocol, the number of packets shown, the median gap and the range of the gaps.
the number of packets shown can be lower than the total number counted in a long connection.
these are only the collected data, ACK or keepalive packets of one direction. They are not all the TCP packets.
packets that are broken or out of order are not sorted or removed. The web interface says that their gaps can’t be computed.
The Why this was flagged panel, shown when the saved numbers of the evidence are available:
shows the repeat interval, the percentage of gaps that match it and how much the timing varies.
More detection details adds how many messages have the same size, the median size, and whether the schedule is between packets or between groups of packets.
a gap matches when it is one interval long, or an allowed whole number of intervals.
how much the timing varies is not the same as the confidence of the evidence.
the panel shows what was recorded when the evidence was set. It doesn’t use the current configuration and doesn’t detect again in the browser.
Example: training-capture-022
What the capture has:
A known DarkVNC server:
10.0.2.15 → 37.48.125.108:443.The client sends an 8 byte message about every 300.5–300.8 seconds.
One TCP connection has 85 of these messages over about seven hours.
They are real application data. They are not retransmitted packets and not TCP keepalives.
The server sends application data at the start, but Zeek recognizes no TLS or other protocol on port 443.
What Slips finds with the default settings:
The first long connection reaches 12 messages about 1 hour and 1.5 minutes into the capture. The interval is about 300.503 seconds.
SUSPICIOUS_PACKET_HEARTBEATis set for it. Slips doesn’t use the IP of the server or the nameDARKVNCfor this.Short connections with only a few messages don’t have enough packets to be checked.
Results on the full capture (613,753 packets):
17 summaries came from Zeek.
✅ Three medium
SUSPICIOUS_PACKET_HEARTBEATevidence were set, all for the known DarkVNC server.✅ One
PERIODIC_PACKETSevidence was set. No other server got aSUSPICIOUS_PACKET_HEARTBEAT.This is the result for one capture. It is not a false positive rate.
Cost on this capture, with the same Zeek scripts and TCP timeout:
Run |
Zeek CPU time |
|---|---|
Without packet timing |
2.586 seconds |
With packet timing |
3.218 seconds |
That is about 0.632 seconds more, or 24%. The total time on the clock changed from run to run because of caching.
When packet timing is off, the Zeek script is not loaded, so there is no extra cost.
Python doesn’t handle every packet. It only checks the summaries.
About the PCAP file:
The original PCAP ends with a cut packet. The test used a copy with only the complete packets. The original file was not changed.
This has nothing to do with the detection.
Running this capture with less noise
The first run of this capture also had many evidence from other models that were not about the DarkVNC server:
Module |
Evidence |
|---|---|
|
447 |
|
12 |
|
108 |
These need a review before those models are used to score this capture.
Lowering the alert threshold for everything would make this noise worse.
For a cleaner test of this capture:
Add these three modules to
modules.disableand enable packet timing.Keep
beacon_detectorand the detectors of each protocol enabled.This is only for this test. It doesn’t change the defaults of Slips.
Use a free web port and a new output directory.
nice -n 15 .venv-macos/bin/python slips.py -m -w \
-c output/packet-rhythm-development/conservative-pcap-022.yaml \
-f output/packet-rhythm-development/readable-capture.pcap \
-o output/pcap-case-22-packet-timing --web-port 55022
conservative-pcap-022.yamlis a copy of the PCAP analysis configuration with the changes above.readable-capture.pcapis the copy of the capture without the cut last packet.