Background user activity (life engine)
Background user activity (life engine)
When a lab enables background activity (user_activity_background: true in its configuration), simulated users work on its workstations while the attack runs: they open their mail, browse folders, write documents, run commands. The life engine of the user_activity service decides who does what, and when:
- each workstation gets a user, and each user has a profile: the hours and days they work, and the routine activities they pick from;
- users take part in workflows: ordered steps shared between roles (an office worker reports a problem, an administrator investigates, the office worker checks their files);
- a seed makes a run reproducible: the same seed, configuration and workstations replay, on each workstation, the same activities in the same order, with the same typing in each. Every workstation draws from its own generator, so how fast the others go changes nothing.
Where the configuration lives
Everything is in data/user_activity/ of the repository, baked into the user_activity image at /cyber-range-catalog/user_activity/. Changing it means releasing the user_activity component.
data/user_activity/
├── config/
│ ├── main.yaml # engine settings
│ ├── scenarios.yaml # every activity profiles and workflows may name
│ ├── users.yaml # the simulated users and their profile
│ ├── profiles/*.yaml # one file per profile
│ ├── workflows/*.yaml # one file per workflow
│ └── params/web.yaml # values drawn for web parameters
├── background_scenarios/ # the activities: <category>/<name>/scenario.py
└── common/common.py # helpers shared by the activitiesConfiguration files
scenarios.yaml
Names each activity and points at its directory under background_scenarios/. Profiles and workflows use these names.
scenarios:
windows_execute_command:
description: "Run a command in a Windows terminal"
path: operating_system/windows_execute_commandAn activity takes its parameters from the datas.json next to its scenario.py. generated_params lists parameters the engine draws at random each time instead (mail bodies, chat messages, documents, PowerShell commands…), from the files of data/user_activity/datasets/, baked into the image next to the configuration.
The documents those activities attach, open or edit are not in the image: when a lab has background activity, the scenario runner uploads datasets.zip to C:\Users\Public\Documents\Datasets on every Windows workstation with the client or admin role, before the engine starts.
requires lists CPEs the simulation must carry, each on at least one of its nodes, for the activity to be played at all: the server it talks to. The mail activities require an Exchange, so a topology without one plays no mail, neither in a routine nor in a workflow:
open_close_mail_client:
path: mail_client/open_close
requires: ['cpe:2.3:a:microsoft:exchange_server:2013-2019:*:*:*:*:*:*:*']The engine reads the CPEs of the simulation's nodes once, when it starts. Give the version, or a range such as 2013-2019: * does not match one.
node_requires lists CPEs the workstation playing the activity must carry itself, all of them. It is for activities whose screen captures exist on one image only: the desktop tour and the LibreOffice macros were captured on Windows 10 22H2 FR with LibreOffice 6.3.1.1 (and Acrobat Reader 2026 for the tour), so another Windows workstation with a text editor never gets them, in a routine or a workflow:
read_document_with_macro:
path: text_editor/read_document_with_macro
node_requires: ['cpe:2.3:o:microsoft:windows_10_22h2:-:*:*:fr:*:*:x64:*',
'cpe:2.3:a:libreoffice:libreoffice:6.3.1.1:*:*:en:*:*:*:*']params/web.yaml and the fake internet
web.yaml holds the sites, search keywords and video keywords the engine draws for an activity's url, link_name, keywords and video_keywords parameters. Its connected section points at the real internet, which a lab reaches through its proxy. Its disconnected section points at the fake internet, four servers on the lab's SwitchInternet with the internet role, each named by its link's domains, which DNSPublic serves (see data/topologies/ARCHITECTURE.md):
| Server (basebox) | Names | Activity that visits it |
|---|---|---|
AMOSSYS/linux/wordpress_fr | wordpress1.lan to wordpress3.lan | visit_favorite_web_sites: a site, then a few links |
AMOSSYS/linux/searxng_fr | searxng.lan, sites.lan | random_web_search: SearXNG over an index of sites.lan |
AMOSSYS/linux/peertube_fr | peertube.lan | watch_videos: a video found by its tags |
AMOSSYS/linux/humhub_fr | humhub.lan | browse_professional_network: logs in, scrolls, posts |
The engine uses disconnected as soon as one node of the lab has the internet role. Each of these activities requires its server's CPE and Windows 10 22H2 with Firefox 90, French or English: their screens were captured on the French image, but those of the sites' pages carry no language, the sites being French whatever the workstation. In any other lab or on any other workstation, they are never played.
A lab gets the four servers from its lab config, with fake_internet_sites: true: when it creates the lab, scenario_runner adds them to its topology, on SwitchInternet at free addresses below the platform's services, with the names above. The option is refused for BAS content, which has no DNSPublic, and for a topology that already has them: Flamanville v2's 2_clients_fake_internet profile declares them in its topology, as does generic/fake_internet, which has them and one workstation only (both in the CEL034 catalog, projects/cel034/, whose baseboxes the workstations use).
The sites serve HTTPS under certificates of the mantis authority (data/openssl/). In a lab with these servers and background activity, scenario_runner runs data/provisioning/deploy-CA on the Windows workstations the engine drives: it trusts that authority, lets Firefox use the system's roots, and makes Firefox ask for French pages first, since PeerTube and HumHub follow the browser's Accept-Language and the templates show them in French.
profiles/*.yaml
name: Office
description: "Office workers: documents, mail, files and the web"
node_roles: ['client'] # 'client' and/or 'admin'
active_days: ["mon-fri"] # day names or ranges
active_hours: ["09:00-12:30", "13:30-18:00"]
scenarios: # the routine, picked in turn at random
- name: windows_navigate_file_explorer
- name: write_txtAn entry's params fixes the value of one of the activity's generated_params instead of drawing it.
Outside its active days and hours a user stays idle. Hours are the user_activity service's local time: UTC unless its TZ is set. The shipped profiles are active at all hours, like the random activity the engine replaced, so a lab started at night or on a weekend still has background activity.
A profile is not tied to an operating system: a workstation only plays the activities its system and installed applications allow, so a Linux workstation skips the Windows activities of its profile.
users.yaml
users:
- name: jdupont
fullname: Jean Dupont
profile: ManagerEach user must be an account of the lab's AD basebox: its password is read from there. The shipped users are the acme.corp accounts of the windows_server_*_ad_acme.corp_* baseboxes. Users of the Administrator profile go to workstations with the admin role; the other profiles take turns on the remaining ones.
workflows/*.yaml
name: "IT support"
roles:
- role: Employee
profile: Office
- role: Admin
profile: Administrator
steps:
- scenario: open_close_mail_client
start: 1-3 # minutes from the workflow's start, or a "min-max" range
role: Employee
- scenario: windows_execute_command
start: 5-8
role: AdminA step starts once the previous one has finished and its start time has come. A step's params set the values of its activity's datas.json keys (txt, file_name, paths, urls, command…).
A role only goes to a user whose workstation can play all of that role's steps: its system and applications allow them, and the simulation has every node they require. A workflow no user can fill is not handed out, and the log says which step stops it. Users not taken by a workflow only play their routine.
Twenty-two workflows are shipped. Five need no mail and play on any Windows workstation: IT support by phone, Project kickoff, and one solo workflow per profile (Office daily notes, Manager weekly report, Administrator morning checks). IT support sends its mail from a desktop client, so it needs an Exchange and a workstation whose mail client can be driven.
The sixteen others come from ouranos_life. They use the Outlook web app through Firefox (web_mail_client, so an Exchange in the topology), the Gajim chat client (chat_client, with an XMPP server for its accounts), LibreOffice and Acrobat Reader 2026. Their screen captures were taken on Windows 10 22H2 FR, the workstations of Flamanville v2: elsewhere, the roles that use them are not handed out.
| Workflow | Profiles (roles) | Needs |
|---|---|---|
| Administrator solo work, Manager solo work, Office solo work | one of each | LibreOffice; PowerShell for the administrator |
| Access request, Quick admin request | Administrator, and Manager or Office | webmail; PowerShell for Access request |
| Project Meeting | Manager, Office | webmail, chat |
| Document review | Manager, Office | webmail, chat, LibreOffice |
| Internal com campaign | Administrator, Manager, Office | webmail, chat, LibreOffice |
| Project document edition and review | Administrator, Manager, Office | chat, LibreOffice macros |
| Technical documentation exchange | 2 Administrators | webmail, chat, LibreOffice |
| Manager collaboration | 2 Managers | webmail, chat, LibreOffice |
| Share document and discuss | 2 Office | webmail, chat, LibreOffice |
| Share link via email | 1 Manager, 2 Office | webmail, chat, LibreOffice |
| Update technical documentation | 2 Administrators, 1 Manager | chat, LibreOffice |
| IT Ticket request, Validate command | 4 roles: two Administrators or two Office | webmail, chat; PowerShell for IT Ticket request, LibreOffice for Validate command |
A workflow needing two users of one profile only goes to a topology with that many workstations of the profile: Flamanville v2's 2_clients (one Administrator, one Manager, one Office) never gets the last seven rows.
main.yaml
routine_scenarios_only:trueto play routines only, no workflow;priority_workflow: the name of a workflow to hand out first.
Adding an activity
- Create
background_scenarios/<category>/<name>/scenario.py. The category is an action pack category (operating_system,mail_client,web_browser,text_editor,pdf_reader,drawing_editor,web_mail_client). Inoperating_system, start the name withwindows_orlinux_. - Put its parameters' default values in
datas.jsonnext to it, and callopen_session_if_necessary(player)(fromcommon) first if it needs a session. - Declare it in
scenarios.yaml, then name it in a profile or a workflow.
Driving it from the Python API
The scenario runner starts the engine for labs with background activity. With an AD, it first lets the engine give each client and admin workstation one of its users, writes that user's credentials to the node and opens the session under them. An admin workstation therefore runs the session of one of the engine's administrators, not the domain admin's: a kill chain must read the node's username (or work with whoever is logged on) rather than assume the domain admin. A Linux workstation carries user@domain, the name its session runs under. The runner starts the engine with the lab config's seed, and the engine uses its default one (42) when the lab config has none. To replay a lab, or to vary it, set it in the YAML given to --lab_config, as a string:
user_activity_background: true
seed: "7"The same calls, by hand:
from cr_api_client import user_activity_api
user_activity_api.user_activity_background_start(seed="7")
# Optional: give each workstation the user the configuration chooses, and make
# the workstation's credentials that user's. Do it before sessions are opened.
user_activity_api.user_activity_assign_users_to_nodes(
["CLIENT1", "CLIENT2", "ADMIN1"], id_simulation=1
)
user_activity_api.user_activity_background_add_client_nodes(id_simulation=1)
# ...
user_activity_api.user_activity_background_stop()Without user_activity_assign_users_to_nodes, the workstations keep the credentials they already have; the engine only decides which profile each one plays. Each played activity's report is under /cyber-range-catalog/simulations_resources/<simulation>/output/life_reports/.

