Views
No views yet
process, file, and network events against configurable JSON rules mapped to MITRE ATT&CK techniques.┌─────────────────────────────────────────────────────────────────┐
│ RuleEngine │
│ ┌──────────────┐ ┌───────────────────┐ ┌──────────────────┐ │
│ │ Rule Loader │ │ Condition Evaluator│ │ Time Window │ │
│ │ (JSON→Rule) │ │ (recursive tree) │ │ Tracker (sliding│ │
│ └──────┬───────┘ └────────┬──────────┘ │ deque per key) │ │
│ │ │ └──────────────────┘ │
│ ┌──────┴───────────────────┴──────────────────────────────┐ │
│ │ Blacklist Manager (O(1) sets) │ │
│ │ process_names │ ips │ file_hashes │ │
│ └─────────────────────────────────────────────────────────┘ │
│ │
│ Event ──→ evaluate() ──→ Verdict {risk_score, rules, block} │
└─────────────────────────────────────────────────────────────────┘| File | Description |
|---|---|
rule_engine.py | Core engine — all classes and evaluation logic |
rules.json | 15 MITRE ATT&CK-mapped detection rules + blacklists |
sample_test.py | 29 test scenarios with realistic attack simulations |
1from rule_engine import RuleEngine, make_event
2import json
3
4# Load rules and blacklists
5config = json.load(open("rules.json"))
6engine = RuleEngine.from_config("rules.json", blacklists=config["blacklists"])
7
8# Evaluate an event
9event = make_event("process", {
10 "process_name": "mimikatz.exe",
11 "command_line": "mimikatz.exe sekurlsa::logonpasswords",
12 "parent_process": "cmd.exe",
13})
14
15verdict = engine.evaluate(event)
16print(f"Risk: {verdict.risk_score}/100")
17print(f"Block: {verdict.force_block}")
18print(f"Rules: {[r.rule_id for r in verdict.triggered_rules]}")
19# Risk: 100.0/100
20# Block: True
21# Rules: ['RULE-001', 'RULE-015']1python sample_test.py
2# 29/29 tests passed ✓| Rule | MITRE | Event Type | Weight | Block | Description |
|---|---|---|---|---|---|
| RULE-001 | T1003 | process | 1.00 | ✅ | Credential dumping tool (blacklisted process) |
| RULE-002 | T1059.001 | process | 0.80 | PowerShell encoded command | |
| RULE-003 | T1003.001 | process | 0.95 | ✅ | LSASS memory access from non-system process |
| RULE-004 | T1071.001 | network | 1.00 | ✅ | Connection to blacklisted C2 IP |
| RULE-005 | T1071.004 | network | 0.60 | DNS to suspicious TLD / DGA domain | |
| RULE-006 | T1105 | file | 1.00 | ✅ | Blacklisted file hash on disk |
| RULE-007 | T1486 | file | 0.90 | ✅ | Ransomware file-creation burst (rate-based) |
| RULE-008 | T1053.005 | process | 0.70 | Scheduled task creation (persistence) | |
| RULE-009 | T1547.001 | file | 0.75 | Registry Run key modification | |
| RULE-010 | T1059.003 | network | 0.85 | Reverse shell indicator (shell→high port) | |
| RULE-011 | T1055.001 | process | 0.90 | Process injection (CreateRemoteThread) | |
| RULE-012 | T1048.001 | network | 0.70 | Large outbound data transfer (exfiltration) | |
| RULE-013 | T1070.001 | process | 0.85 | Event log clearing (anti-forensics) | |
| RULE-014 | T1547.001 | file | 0.70 | File dropped in startup folder | |
| RULE-015 | T1021.002 | process | 0.80 | PsExec-style lateral movement |
equals · not_equals · contains · not_contains · starts_with · ends_with · regex · in_list · greater_than · less_than · existsand · or · notblacklist_process · blacklist_ip · blacklist_hashrate_threshold — triggers when event count exceeds threshold within windowparent_process · command_line_contains1{
2 "risk_score": 100.0,
3 "triggered_rules": [
4 {
5 "rule_id": "RULE-001",
6 "description": "Credential dumping tool detected",
7 "mitre_technique": "T1003",
8 "weight": 1.0,
9 "force_block": true,
10 "explanation": "Process 'mimikatz.exe' is blacklisted"
11 }
12 ],
13 "force_block": true,
14 "explanations": ["[RULE-001] Credential dumping tool detected: Process 'mimikatz.exe' is blacklisted"],
15 "event_type": "process",
16 "timestamp": 1745487396.955
17}engine.reload_rules() swaps rules without restartConditionEvaluator