Skip to content
Documentation

Running scenarios

This page is published from the scenarios repository. Edit on GitHub View source

A scenario needs a running agent to be worth anything: on its own it only produces activity. There are two ways to run one, by hand on a test machine or through the rig, which does the bookkeeping and judges the result. Both need a disposable machine.

Through the rig

The rig is the intended way to run the catalog. It expects the four checkouts side by side:

mkdir synthaea && cd synthaea
for r in agent rules scenarios rig; do git clone https://github.com/synthaea-lab/$r.git; done
cd rig
python3 rig.py up debian12
python3 rig.py build debian12 --ort-compat   # Debian 12 needs the ONNX Runtime compatibility build
python3 rig.py run debian12                  # every `default` scenario
python3 rig.py run debian12 lineage argv     # just these, opt-in ones included
python3 rig.py report debian12

The rig's README covers host setup, the machine list and reports. What it does per Linux scenario, from runner/run-scenarios.sh:

  1. Checks the scenario's needs (commands, active LSMs) and min_kernel from runner/scenarios.conf. A missing need is a SKIP with the reason, not a failure.

  2. Builds a content directory from the rules checkout plus any YARA file the catalog row names (response-marker.yar for response).

  3. Starts a fresh agent: agent run --standalone --content-dir <run>/content --alerts <run>/alerts.ndjson --events <run>/events.jsonl plus the row's agent_flags, and waits up to 90 seconds for the Linux sensor to log that it is listening.

  4. Runs bash scenarios/<name>.sh from the run directory, under sudo when the row says root yes, with a 300-second timeout and this environment:

    VariableValue
    EVENTSThe agent's event log for this run
    ALERTSThe agent's alert log for this run
    AGENT_PIDThe agent's pid
    the row's envFor example EXPECT=observe for response and ransomware-reflex, TAG=lab for prevalence-lineage
  5. Waits the row's settle seconds (default 3), then until the alert file has not grown for two seconds (at most 20 more), copies it, and only then stops the agent.

  6. Judges the copy against the sidecar (sidecar-format.md) and the script's exit code.

One agent per scenario: a late alert or rule state from one scenario cannot leak into the next.

ResultMeaning
PASSEvery expected technique fired within [min_count, min_count + tolerance] and nothing else fired
UNEXPECTEDThe expectations are met, but other techniques fired too
FAILAn expected technique fired too few or too many times
ERRORThe agent did not start, or the script exited non-zero with the counts otherwise met
SKIPThe guest lacks a need; the reason is shown

RESPONSE-ESCALATE, a follow-up record the agent adds on top of detections, is listed but not judged unless a sidecar expects it. rig.py run exits 1 when a scenario fails or errors; UNEXPECTED does not fail the run, but each one is either a false positive or a sidecar to update.

To inspect the catalog and the expectations without a VM, from the rig checkout:

bash runner/run-scenarios.sh --scenarios ../scenarios/scenarios --list
bash runner/run-scenarios.sh --scenarios ../scenarios/scenarios --check

--check fails when a scenarios/*.sh has no catalog row, a cataloged scenario has no script or no readable sidecar, or a row names a YARA file that does not exist. A new scenario therefore needs a pull request in the rig as well (writing-scenarios.md).

On Windows guests the rig uses runner/run-scenarios.ps1 and runner/scenarios-windows.conf, whose expect column stands in for the missing sidecars.

By hand

On a Linux test machine with the agent built from synthaea-lab/agent and a configuration at /etc/synthaea/agent.toml (see the agent's configuration guide), and the checkouts side by side:

# Terminal A, in the agent checkout. --content-dir is the directory that holds rules/.
sudo ./target/release/agent run --standalone --content-dir .. \
    --alerts /tmp/alerts.ndjson --events /tmp/events.jsonl

# Terminal B, in this repository.
./scenarios/beacon.sh

Then compare /tmp/alerts.ndjson with scenarios/beacon.yaml. Count lines per technique:

grep -o '"technique":"[^"]*"' /tmp/alerts.ndjson | sort | uniq -c

Start the agent before the scenario and wait until it logs that the sensor is listening: bind-shell.sh, for one, alerts on listeners the agent did not see at startup, and every scenario is lost if the sensor attaches after it ran. Leave the agent running for a few seconds after the scenario ends; correlation rules and the access-log poll decide after the fact.

Each script's header comment gives its exact usage, the agent flags it needs and the alert text to expect. The catalog summarizes the requirements. In short:

RequirementScenarios
Run the scenario as rootlog-clear, pid-reuse, signal, web-webshell-php
An agent flagdns-exfil (--enable-dns-capture); response (--enable-kill --enable-quarantine for EXPECT=enforce); ransomware-reflex (--enable-kill for EXPECT=enforce)
An agent.toml entrymysql-failed-login, web-webshell, web-webshell-php, web-custom-logformat ([[logs.sources]]); ransomware-reflex ([deception] canary_dirs)
Extra contentresponse (response-marker.yar under <content-dir>/rules/yara/)
A real servicemysql-failed-login (MariaDB or MySQL), web-* (nginx or Apache, PHP-FPM for web-webshell-php)
Kernel or libctimestomp-linux (BPF LSM active, kernel 6.3 or later), dns-exfil (glibc)
A control planeprevalence-lineage (two enrolled hosts, not --standalone)

signal.sh reads the agent's files itself: run it from the directory where the agent writes events.jsonl and alerts.ndjson, or set EVENTS and ALERTS, and set AGENT_PID if the process is not named agent or synthaea-agent.

On Windows, run the agent from an elevated prompt and the scenario with Windows PowerShell 5.1:

powershell -ExecutionPolicy Bypass -File scenarios\encoded-powershell.ps1

windows-scenarios.md describes the self-checking -AgentExe runs, which start and stop their own agent.

Exit codes

The Linux scripts share one convention, implemented in lib/common.sh:

CodeMeaningPrinted
0The scenario ran, and its self-check passed where it has oneThe script's own summary
1The scenario ran and its self-check failedFAIL: ... lines on stderr
2A precondition is not met (not root, a tool, service or setting missing); nothing was attemptedERROR: precondition not met: ... on stderr

The distinction lets a runner tell "this host is not set up for the scenario" from "the scenario ran and something is wrong". Two exceptions: signal.sh prints its own PASS and FAIL lines on stdout, and a self-checking scenario started without EXPECT stops with Bash's own parameter null or not set error and code 1 (an invalid EXPECT value exits 2).

The Windows scripts run with $ErrorActionPreference = "Stop", so any failure, a precondition included, is a terminating error and exit code 1.

Environment variables

Variables a scenario reads, all optional unless noted:

VariableScenariosMeaning
EXPECTresponse, ransomware-reflex (required)enforce or observe: how the agent was started
CANARY_DIRransomware-reflex (required)The directory listed in [deception] canary_dirs, not under /tmp, /var/tmp or /dev/shm
COUNT, MAX_ENCRYPTED, PAUSEransomware-reflexFiles to create (300), the most renames allowed before the kill (60), seconds between renames (0.04)
PORT, CONNECTIONS, PAYLOADresponseListener port (4444), connections one second apart (30), payload path (/tmp/synthaea-response-payload.bin)
TAGprevalence-lineage (required)Names the directory the fake web server runs from
FAKE_COMMweb-webshellThe parent's name: nginx (default), apache2, httpd, php-fpm8.4, ...
WEB_ROOTweb-webshell-phpThe document root the PHP file is dropped under (/var/www/html)
EVENTS, ALERTS, AGENT_PIDsignalThe agent's files and pid
TMPDIRransomware-reflexWhere the encryptor's script file is written

Positional arguments select modes or targets: pid-reuse.sh [recycled|real], ransomware-rename-burst.sh [single|loop], signal.sh [live|kill|verify-kill], dns-exfil.sh [PARENT_DOMAIN], mysql-failed-login.sh [USER], and a base URL for the web-* scenarios.