What this miniature lab demonstrates
Compare an expected backup service operation with a suspicious privileged action. The detector should not treat every event from a known host as automatically safe.
Set up a harmless offline test
Requires Python 3. Run only on your own computer in a text console. No packages, accounts, network connections, malware, production logs or cloud credentials are required. Copy the example into a file or download the runnable script. The script includes assertions that fail if the expected behaviour changes.
# Offline detection decision model; no systems or services are contacted.
events = [
{"id": "B1", "account": "svc_backup", "operation": "backup", "hour": 2},
{"id": "B2", "account": "unknown_admin", "operation": "grant_role", "hour": 2},
{"id": "B3", "account": "svc_backup", "operation": "grant_role", "hour": 2},
{"id": "B4", "account": "svc_backup", "operation": "backup", "hour": 17},
]
def decide(e):
if e["account"] == "svc_backup" and e["operation"] == "backup" and e["hour"] == 2:
return "expected"
return "investigate"
result = [(e["id"], decide(e)) for e in events]
assert result == [("B1", "expected"), ("B2", "investigate"),
("B3", "investigate"), ("B4", "investigate")]
for event_id, label in result:
print(event_id, label)
Output from the bundled script
The following text was generated by running this exact script in an offline Python environment during package validation. It is not a product or attacker simulation result.
B1 expected
B2 investigate
B3 investigate
B4 investigate
Interpretation and limits
The small decision function evaluates a principal, operation and scheduled context. It is a policy modelling exercise, not a SIEM plugin, exploit simulation or empirical measure of attack coverage.
Questions to discuss
Which identity, action and time must agree before the event is classified as expected? How would an approved change window alter the logic?
To practise further, open the red blue learning track and download a three-case CSV from any individual guide. Those records are fictional and deliberately contain an ambiguous case for analysis.
Primary sources
Scope: An illustrative educational model tested for deterministic output; no real-world security effectiveness or deployed vulnerability assessment is claimed. If a command, API or framework changes, follow the current official documentation and obtain approval before changes to real systems.