Skip to content

wagga40/pySigma-backend-sqlite

Repository files navigation

Tests Coverage Badge Status

This repository is no longer the main one, it has been forked and is now included in the SigmaHQ organisation.

Follow this link

pySigma SQLite Backend

This is the SQLite backend for pySigma. It provides the package sigma.backends.sqlite with the sqliteBackend class.

This backend also aims to be compatible with Zircolite which uses pure SQLite queries to perform SIGMA-based detection on EVTX, Auditd, Sysmon for linux, XML or JSONL/NDJSON Logs.

It supports the following output formats:

  • default: plain SQLite queries
  • zircolite : SQLite queries in JSON format for Zircolite

This backend is currently maintained by:

Known issues/limitations

  • Full text search support will need some work and is not a priority since it needs virtual tables on SQLite side
  • In a future update, changing table name will be handled by a backend option
  • Aggregation is not supported since it is deprecated by the sigma specification and there are nearly no rule using it in the official repository

Quick Start

Example script (default output) with sysmon pipeline

Add pipelines

poetry add pysigma-pipeline-sysmon
poetry add pysigma-pipeline-windows

Convert a rule

from sigma.collection import SigmaCollection
from sigma.backends.sqlite import sqlite
from sigma.pipelines.sysmon import sysmon_pipeline
from sigma.pipelines.windows import windows_logsource_pipeline

from sigma.processing.resolver import ProcessingPipelineResolver

# Create the pipeline resolver
piperesolver = ProcessingPipelineResolver()
# Add pipelines
piperesolver.add_pipeline_class(sysmon_pipeline()) # Syssmon  
piperesolver.add_pipeline_class(windows_logsource_pipeline()) # Windows
# Create a combined pipeline
combined_pipeline = piperesolver.resolve(piperesolver.pipelines)
# Instantiate backend using the combined pipeline
sqlite_backend = sqlite.sqliteBackend(combined_pipeline)

rule = SigmaCollection.from_yaml(
r"""
    title: Test
    status: test
    logsource:
        category: test_category
        product: test_product
    detection:
        sel:
            fieldA: valueA
            fieldB: valueB
        condition: sel
""")

print(sqlite_backend.convert(rule)[0])

Running

poetry run python3 example.py

About

pySigma SQlite backend

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages