GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Metercedes/detection-engineering-lab: Sigma detections for Windows, Linux and authentication telemetry, with an offline evaluator that proves each rule fires on its technique and stays silent on a benign baseline.

BranchesTags
Open more actions menu

Latest commit

 

History

5 Commits
5 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
detections
detections
 
 
docs
docs
 
 
elastic
elastic
 
 
scripts
scripts
 
 
sigmatch
sigmatch
 
 
telemetry
telemetry
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pyproject.toml
pyproject.toml
 
 

Repository files navigation

detection-engineering-lab

15 Sigma detections for Windows, Linux and Windows authentication telemetry, with an offline evaluator that proves each one fires on the technique it targets and stays silent on a benign baseline. Rules export to Elastic Security detection rules, and a Docker Compose stack is included for running them against a live Elasticsearch and Kibana.

The point of the repository is the validation loop. A detection that has never been tested against telemetry is a guess, so every rule here ships with the events it is supposed to match, the events it must not match, and a test that enforces both.

$ sigmatch hunt telemetry/true_positive/powershell_encoded_command.jsonl
[         high] 2026-03-02T09:15:00Z  Office Application Spawning a Script Interpreter
                  powershell.exe -nop -w hidden -enc SUVYKE5ldy1PYmplY3QgTmV0LldlYkNsaWVudCk=
[         high] 2026-03-02T09:15:00Z  PowerShell Encoded Command Execution
                  powershell.exe -nop -w hidden -enc SUVYKE5ldy1PYmplY3QgTmV0LldlYkNsaWVudCk=

Two rules fire on that first event, which is correct: the process was started by winword.exe, so it is both an encoded PowerShell command and an Office application spawning an interpreter.

Running it

Python 3.11 or newer. No external services needed for the tests.

python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"

pytest                      # 139 tests
sigmatch validate           # rules parse and carry required metadata
sigmatch coverage           # ATT&CK coverage table
sigmatch hunt telemetry/true_positive/reverse_shell_invocation.jsonl

Regenerating the corpus, the Elastic rules and the catalogue is deterministic:

python scripts/generate_telemetry.py
python scripts/export_elastic_rules.py
python scripts/generate_docs.py

What is detected

Full catalogue with queries, investigation steps and false positives: docs/DETECTIONS.md.

Tactic Detections
Initial Access Office application spawning a script interpreter
Execution Encoded PowerShell, PowerShell download cradle, curl piped to shell, reverse shell
Persistence Scheduled task, Run key with a script payload, cron entry with a network payload
Privilege Escalation sudo used to launch a shell or interpreter
Defense Evasion rundll32 and regsvr32 proxy execution
Credential Access LSASS access and dumping, failed-logon burst, password spraying
Lateral Movement Service creation matching remote execution tooling

Coverage is 18 ATT&CK techniques across 8 tactics.

How the evaluator works

sigmatch implements the part of the Sigma specification these rules use, so a rule can be tested without deploying it anywhere and without a converter in the loop.

  • Field modifiers: contains, startswith, endswith, re, cidr, all, base64, base64offset, windash, and the numeric comparisons.
  • Search semantics: keys within a map are ANDed, a list of maps is ORed, and a list of values for one key is ORed unless |all is present.
  • Conditions: a recursive-descent parser over and, or, not, parentheses, and the 1 of, all of, any of quantifiers including them and wildcard identifiers.
  • Correlations: event_count and value_count over a sliding window with group-by, because "ten failures in five minutes" cannot be expressed as a single-event rule.

base64offset is the piece worth explaining. Base64 encodes three input bytes into four output characters, so where a substring begins relative to that grouping changes its encoding entirely. The modifier generates the three possible encodings and trims the characters at each end that are contaminated by the surrounding bytes. tests/test_engine.py asserts that for every alignment of a needle inside a larger plaintext, at least one generated candidate really is a substring of the encoded stream.

Windows for correlations slide rather than tumble. A tumbling window lets an attacker place five failures on each side of a boundary and stay under a threshold of ten in both.

Telemetry

telemetry/ holds NDJSON in Elastic Common Schema shape, generated by scripts/generate_telemetry.py from a fixed base timestamp so regeneration produces no diff.

Nothing in it is captured from a real host. The fields are modelled on what Elastic Agent produces with Sysmon and the Windows Security channel, which is enough to exercise the rules without publishing anyone's logs. All addresses are from the documentation ranges reserved by RFC 5737.

The benign baseline is the important half: ordinary PowerShell reporting scripts, a legitimate Invoke-WebRequest download, Defender opening LSASS, a vendor service installation, a vendor Run key, an installer-created scheduled task, sudo systemctl restart, and a handful of isolated failed logons. A rule that matches any of these fails its test.

Deploying to Elastic

cp elastic/.env.example elastic/.env    # fill in, the file is gitignored
./scripts/setup_lab.sh

That starts Elasticsearch and Kibana, exports the rules, and installs them through the detection engine API. Credentials are read from the environment; nothing authenticating is committed.

Ten rules translate to KQL. Three use regular expressions, which KQL has no operator for, so they are emitted with language: lucene instead. The converter raises instead of silently producing a query that means something different from the rule.

This part has not been re-run recently. The Compose stack and the Kibana deployment script came from an Elastic 9.4.2 lab that was working when it was built, but the machine this repository was last developed on has no Docker, so the tests and everything else in this README were verified and the live deployment path was not. Treat it as documented but unverified.

Layout

detections/          Sigma rules, grouped by telemetry source
telemetry/           Synthetic ECS corpus: true positives and a benign baseline
sigmatch/            Rule model, field matching, condition parser, correlations, Elastic export
tests/               Engine unit tests and per-rule validation
elastic/             Compose stack, standalone Agent input, exported rules
scripts/             Corpus, export, docs and deployment scripts
docs/DETECTIONS.md   Generated catalogue

Limitations

  • The evaluator covers the Sigma subset these rules use. Field-reference comparisons, expand, and the temporal correlation types are not implemented and raise rather than misbehave.
  • Rules are validated against synthetic telemetry. That proves the logic is right and that the rule is not trivially broad; it does not predict the false-positive rate on a real estate.
  • The benign baseline is 21 events. It is a regression guard against obviously broad rules, not a substitute for tuning against production volume.
  • Correlation evaluation is in-memory and loads the whole corpus, which is fine for a lab-sized file and not how a SIEM would do it.

About

Sigma detections for Windows, Linux and authentication telemetry, with an offline evaluator that proves each rule fires on its technique and stays silent on a benign baseline.

Topics

cybersecuritydetection-as-codedetection-engineeringelastic-securitymitre-attackpythonsecurity-operationssiemsigmasocsysmonthreat-detection

Resources

Readme
MIT license
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.