This project provides tools to convert Sigma rules (a generic format for SIEM detections) into Kusto Query Language (KQL) suitable for use with Microsoft Defender XDR (MDXDR). It leverages the sigma-py library and includes specific pipelines for MDXDR compatibility.
The converted rules can be generated in two formats:
- Individual KQL Files: Organized into directories based on the MITRE ATT&CK tactics and techniques tagged in the original Sigma rule.
- SQLite Database: A single
rules.dbfile containing rule metadata (ID, title, description, MITRE tags) and the corresponding KQL query.
- Converts Sigma rules (YAML format) to KQL.
- Uses the official
sigma-pylibrary andmicrosoft-xdr-pipeline. - Outputs KQL queries as individual
.kqlfiles. - Organizes
.kqlfiles based on MITRE ATT&CK tactics and techniques. - Alternatively, outputs rules and metadata into a structured SQLite database (
rules.db). - Includes the Sigma rules from this repository: https://github.com/SigmaHQ/sigma/tree/master. You might consider updating it before running the scripts.
- Use OPEAN AI to eventually figure out proper table when table mapping from microsoft-xdr-pipeline fails
- Python 3.x
- pip (Python package installer)
- Git (for cloning and potentially managing the Sigma submodule)
- Clone the repository:
git clone <repository-url> cd <repository-directory> alternatively you can use: git clone --recurse-submodules <your-repo-url> and there is no need to clone the submodule as described in step 2.
- Initialize/Update Sigma Submodule:
The
sigma/directory contains the Sigma rules. If it's a Git submodule, initialize and update it:(Ifgit submodule init git submodule update --remote
sigma/was just copied, this step might not be needed, but it's best practice for keeping rules up-to-date). - Install Dependencies:
Install the required Python packages listed in
requirements.txt:pip install -r requirements.txt
There are two main scripts provided:
-
Generate KQL Files: To convert Sigma rules and generate individual
.kqlfiles organized by MITRE ATT&CK tactics/techniques in theKQL/directory, run:python trySigmaConversion.py <optional: folder inside sigma where to fetch rules, default "rules">
This script will process all
.ymlfiles found within thesigma/<specified folder>/directory structure. -
Populate SQLite Database: To convert Sigma rules and populate the
rules.dbSQLite database with rule metadata and KQL queries, run:python trySigmaConvertloadDB.py
This script will create the
rules.dbfile if it doesn't exist and add/update rules based on their unique Sigma rule ID. Existing rules (based on ID) will be ignored.
KQL/Directory: Contains the generated.kqlfiles. The structure followsKQL/<Tactic>/<Technique>/<Rule_Title>.kql. Default foldersUntaggedandNoTechniqueare used if MITRE tags are missing.rules.dbFile: An SQLite database with the following table:- Table:
SigmaCommunity - Columns:
id(INTEGER, Primary Key): Auto-incrementing row ID.guid(TEXT, Unique): The original Sigma rule ID (from theidfield in the YAML).name(TEXT): The Sigma rule title.query(TEXT): The generated KQL query.description(TEXT): Formatted description including author, date, level, and original description.tactics(TEXT): Comma-separated list of MITRE ATT&CK tactics (e.g., "Initial Access,Execution").techniques(TEXT): Comma-separated list of MITRE ATT&CK techniques (e.g., "T1059.001,T1566.001").created_at(TEXT): Timestamp of when the record was inserted.
- Table: