Sigma Cheatsheet
# Install via pip
pip install sigma-cli
# Install with all dependencies
pip install sigma-cli[all]
# Install development version
pip install git+https://github.com/SigmaHQ/sigma.git
# Verify installation
sigma --version
```_
**Installieren aus Quelle:**
```bash
# Clone repository
git clone https://github.com/SigmaHQ/sigma.git
cd sigma
# Install in development mode
pip install -e .
# Install with optional dependencies
pip install -e .[test,dev]
```_
### Docker Installation
**Docker Setup:**
```bash
# Pull Sigma Docker image
docker pull sigmahq/sigma
# Run Sigma in container
docker run --rm -v $(pwd):/data sigmahq/sigma convert -t splunk /data/rules/
# Create alias for convenience
alias sigma='docker run --rm -v $(pwd):/data sigmahq/sigma'
```_
## Sigma Regelstruktur
### Grundregelformat
** Standard Sigma Regel:**
```yaml
title: Suspicious PowerShell Execution
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects suspicious PowerShell command execution
author: Security Team
date: 2023/01/15
modified: 2023/01/20
tags:
- attack.execution
- attack.t1059.001
logsource:
category: process_creation
product: windows
detection:
selection:
Image|endswith: '\powershell.exe'
CommandLine|contains:
- '-EncodedCommand'
- '-WindowStyle Hidden'
- 'DownloadString'
condition: selection
falsepositives:
- Legitimate administrative scripts
level: medium
```_
### Artikel Komponenten
** Datenfelder:**
```yaml
# Required fields
title: "Rule Title"
id: "unique-uuid-here"
| status: experimental | test | stable |
description: "Detailed description"
# Optional metadata
author: "Author Name"
date: 2023/01/15
modified: 2023/01/20
references:
- https: //attack.mitre.org/techniques/T1059/001/
tags:
- attack.execution
- attack.t1059.001
| level: low | medium | high | critical |
```_
**Log Source Definition:**
```yaml
logsource:
category: process_creation
product: windows
service: sysmon
definition: "Sysmon Event ID 1"
```_
**Detection Logic:**
```yaml
detection:
selection1:
EventID: 1
Image|endswith: '\cmd.exe'
selection2:
CommandLine|contains:
- 'whoami'
- 'net user'
condition: selection1 and selection2
```_
## Nachweismuster
### Auswahl Muster
**Basic Auswahl:**
```yaml
detection:
selection:
EventID: 4624
LogonType: 3
TargetUserName: 'administrator'
condition: selection
```_
**Multiple Selections:**
```yaml
detection:
sel_process:
Image|endswith: '\powershell.exe'
sel_command:
CommandLine|contains:
- 'Invoke-Expression'
- 'IEX'
condition: sel_process and sel_command
```_
**Keyword Lists:**
```yaml
detection:
keywords:
- 'mimikatz'
- 'sekurlsa'
- 'kerberos'
condition: keywords
```_
### Feldmodifikatoren
**String Modifier:**
```yaml
detection:
selection:
# Contains substring
CommandLine|contains: 'malware'
# Starts with
Image|startswith: 'C:\Temp\'
# Ends with
FileName|endswith: '.exe'
# Case insensitive
| ProcessName | contains | all: |
- 'cmd'
- 'powershell'
# Regular expression
| CommandLine | re: '.*\.(exe | bat | cmd) |
**Numeric Modifiers: **
```yaml
Nachweis:
Auswahl:
# Less than
ProzessId|lt: 1000
# Greater than
Dateigröße|gt: 1048576
# Greater than or equal
EventID|gte: 4624
# Less than or equal
Logo Typ:lte: 10
__CODE_BLOCK_11_yaml
Nachweis:
sel_suspicious_process:
Image|endswith:
- '\powershell.exe '
- '\cmd.exe '
sel_suspicious_args:
CommandLine|contains:
- '-EncodeedCommand '
- 'DownloadString '
sel_network:
Bestimmung Hafen:
- 80
- 443
Zustand: sel_suspicious_process and sel_suspicious_args and sel_network
**Aggregation Conditions:**
Nachweis:
Auswahl:
EventID: 4625
Ziel Benutzername: '*'
Zustand: select|count(TargetUserName) by SourceNetworkAddress > 10.
**Time-based Conditions:**
Nachweis:
Auswahl:
EventID: 4624
LogonTyp: 3
| Zustand: select | count() by TargetUserName > 5 | timeframe 5m |
## Rule Categories
### Process Creation Rules
**Suspicious Process Execution:**
Titel: Verdächtiges Verfahren in Temp Directory
Logsource:
Kategorie: Process_creation
Produkt: Fenster
Nachweis:
Auswahl:
Image|startswith:
- C:\Temp\ '
- 'C:\Benutzer\\AppData\Local\Temp\ '
Image|endswith: '.exe'
Zustand: Auswahl
Ebene: mittel
**Command Line Analysis:**
Titel: Encoded Power Shell Command
Logsource:
Kategorie: Process_creation
Produkt: Fenster
Nachweis:
Auswahl:
Image|endswith: '\powershell.exe '
CommandLine|contains: '-EncodedCommand '
Zustand: Auswahl
Niveau: hoch
### Network Connection Rules
**Suspicious Outbound Connections:**
Titel: Verbindung zu Suspicious Domain
Logsource:
Kategorie: Network_connection
Produkt: Fenster
Nachweis:
Auswahl:
Initiiert: '
ReisezielHostname|endsmit:
- '.tk'
- '.ml '
- '.ga. '
Zustand: Auswahl
Ebene: mittel
### File System Rules
**Suspicious File Creation:**
Titel: Ausführbar in Startup Folder
Logsource:
Kategorie: Datei_event
Produkt: Fenster
Nachweis:
Auswahl:
TargetFilename|contains: '\Startup\ '
TargetFilename|endswith: '.exe'
Zustand: Auswahl
Niveau: hoch
### Registry Rules
**Registry Persistence:**
Titel: Registry Run Key Modification
Logsource:
Kategorie: Registrierung_event
Produkt: Fenster
Nachweis:
Auswahl:
Ziel Gegenstand:
- '\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\ '
- '\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce\ '
Zustand: Auswahl
Ebene: mittel
## Conversion and Deployment
### Convert Rules to SIEM Formats
**Splunk Conversion:**
# Einfache Regel umrechnen
sigma konvertieren -t splunk rule.yml
# Mehrere Regeln umrechnen
sigma Convert -t splunk rules/*.yml
# Konvertieren mit benutzerdefinierten config
sigma Convert -t splunk -c splunk-windows.yml rule.yml
# Ausgabe in Datei
sigma konvertieren -t splunk rule.yml -o splunk_query.txt
**Elastic/ECS Conversion:**
# Elasticsearch umrechnen Abfrage DSL
sigma konvertieren -t elastischesearch rule.yml
# In ECS Format umrechnen
sigma konvertieren -t elastischesearch -c ecs-cloudtrail.yml rule.yml
# nach Kibana umrechnen
sigma konvertieren -t kibana rule.yml
**QRadar Conversion:**
# QRadar AQL umrechnen
sigma konvertieren -t qradar rule.yml
# Umrechnen mit Feld Mapping
sigma konvertieren -t qradar -c qradar-fields.yml rule.yml
**Microsoft Sentinel Conversion:**
# nach KQL umrechnen
sigma konvertieren -t microsoft365defender rule.yml
# nach Azure Sentinel umrechnen
sigma konvertieren -t azure-sentinel rule.yml
### Backend Configurations
**Custom Backend Config:**
# splunk-custom.yml
Titel: Custom Splunk Konfiguration
Bestellung: 20
Backends:
- Speck
Logsources:
Fenster:
Kategorie: Process_creation
Bedingungen:
EventID: 1
Umschreiben:
Produkt: Fenster
Service: sysmon
Feldmappen:
Bild: Process_name
CommandLine: Process_command_line
ProcessId: Prozess_id
**Field Mapping:**
# Feldmapping.yml
Titel: Custom Field Mapping
Feldmappen:
# Windows Security Events
EventID: Event_id
Ziel Benutzername: user_name
QuelleNetwork Anschrift: src_ip
ReisezielPort: dest_port
# Sysmon Events
Bild: Process_path
CommandLine: Kommandozeile
ProcessId: Pid
Elternarbeit Id: S.
## Rule Development
### Testing Rules
**Rule Validation:**
# Syntax der gültigen Regel
sigma check rule.yml
# Validierung mehrerer Regeln
sigma check rules/*.yml
# Check mit spezifischem Backend
sigma check -t splunk rule. Yml
# Verbose Validierung
sigma check -v rule.yml
**Rule Testing:**
# Testkonvertierung
sigma konvertieren -t splunk rule.yml --trocken
# Test mit Probendaten
sigma test rule.yml --data Sample_logs.json
# Debug-Regellogik
sigma konvertieren -t splunk rule.yml - Debug.
### Rule Optimization
**Performance Optimization:**
# Verwenden Sie bestimmte Feldspiele anstelle von Wildcards
Nachweis:
Auswahl:
# Good - specific match
EventID: 4624
LogonTyp: 3
# Avoid - too broad
# EventData|contains: 'logon'
Zustand: Auswahl
__CODE_BLOCK_28_yaml
Nachweis:
Auswahl:
Image|endswith: '\powershell.exe '
CommandLine|contains: 'DownloadString '
Filter:
Benutzername: 'SYSTEM'
ParentImage|endswith: '\services.exe '
Zustand: Auswahl und nicht Filter
## Rule Management
### Rule Collections
**Organize Rules by Category:**
Vorschriften/
ĂŒ â â â â â â ¢ Fenster /
Ψ ο â â â prozess_kreation/
Ψ ĂŒ â â âTMa network_connection/
¶ â âTMa âTMa file_event/
Ψ ψ └ -- Registrierung_event/
ĂŒ â â â ¢ â linuxâ
Ψ ο â â â prozess_kreation/
Ψ └ -- Netzwerk_Verbindung/
└, englisch
ĂŒ â â âTMa aws/
- azure/
└, englisch
**Rule Metadata Management:**
# Verwenden Sie konsistentes Etikettieren
tags:
- angriff.execution
- Angriff.t1059.001
- Erkennung.emerging_threats
- Plattform.Fenster
- data_source.process_monitoring
### Version Control
**Git Workflow:**
# Erstellen Sie Funktionszweig für neue Regel
git checkout -b feature/new-detection-rule
# Regeldatei hinzufügen
git add rules/windows/process_creation/suspicious_powershell.yml
# Commit mit beschreibender Botschaft
git commit -m "Erkennung für verdächtige PowerShell-Ausführung hinzufügen"
# Schieben und erstellen Sie Zuganforderung
git push origin feature/new-detection-rule
**Rule Review Process:**
# Gültig vor der Verpflichtung
Sigma Check Regeln/Fenster/Prozess_Erstellung/*.yml
# Prüfkonvertierung zum Ziel SIEM
sigma Convert -t splunk rules/windows/process_creation/new_rule.yml
# Überprüfen Sie die Duplikate
grep -r "title:" Regeln/grgrep "Suspicious PowerShell"
__CODE_BLOCK_33_yaml
Name: Sigma Regel Validierung
auf: [Push, pull_request]
Arbeitsplätze:
Gültigkeit:
run-on: ubuntu-latest
Schritte:
- Verwendung: Aktionen/Checkout@v2
- Name: Setup Python
Verwendung: Aktionen/Setup-python@v2
mit:
python-version: 3,9
- Name: Sigma installieren
run: pip install sigma-cli
- Name: Gültige Regeln
Ausführung:
finden Sie Regeln / -name "*.yml" -exec sigma check \{\} \;
- Name: Test Conversions
Ausführung:
sigma Convert -t splunk rules/windows/process_creation/*.yml
sigma konvertieren -t elastischsearch Regeln/linux/process_creation/*.yml
### SIEM Integration
**Splunk Integration:**
#!/bin/bash
# deploy-to-splunk.sh
RULES_DIR="Regeln/Fenster"
SPLUNK_CONFIG="configs/splunk-windows.yml"
OUTPUT_DIR="splunk_searchs"
# Regeln nach Splunk umrechnen
für Regel in $RULES_DIR/*.yml; tun
rule_name=$(Basisname "$rule" .yml)
sigma konvertieren -t splunk -c $SPLUNK_CONFIG "$rule" > "$OUTPUT_DIR/$\{rule_name\}.spl"
erledigt
# Splunk über REST API bereitstellen
für die Suche in $OUTPUT_DIR/*.spl; tun
search_name=$(basename "$search" .spl)
curl -k -u admin:password \
-d "name=$search_name" \
-d "search=$(cat $search)" \
https://splunk:8089/services/saved/searches
erledigt
**Elasticsearch Integration:**
Einfuhr
Importieren von Yaml
Elastische Forschung Import Elastische Forschung
von sigma.cli.convert import convert_rule
def deploy_sigma_rules_to_elasticsearch():
""Deploy Sigma Regeln als Elasticsearch Watcher Warnungen""
Es = Elastische Forschung(['localhost:9200'])
Regeln_dir = 'Rules/linux '
für rule_file in os.listdir(rules_dir):
wenn rule_file.endswith('.yml'):
rule_path = os.path.join(rules_dir, rule_file)
# Convert Sigma rule to Elasticsearch query
es_query = Convert_rule(rule_path, 'elasticsearch')
# Create Watcher alert
mit offen(rule_path, 'r') als f:
Regel_Daten = yaml.safe_load(f)
*Beobachter_config = \{
"Trigger":
"Schedule": "5m"
\},
"Eingang":
"Suche":
"Request": \{
"search_type": "query_then_fetch",
"Indizes":
"Körper":
"query": es_query
{\cHFFFF}
{\cHFFFF}
{\cHFFFF}
\},
"Bedingung":
"Vergleich":
"ctx.payload.hits.total": \{"gt": 0\}
{\cHFFFF}
\},
"Aktionen":
"log_alert":
"Login": \{
"text": f"Sigma-Regel ausgelöst: \{rule_data['title']\}"
{\cHFFFF}
{\cHFFFF}
{\cHFFFF}
{\cHFFFF}
# Deploy to Elasticsearch
rule_id = rule_data['id']
es.watcher.put_watch(id=rule_id, body=watcher_config)
## Advanced Features
### Aggregation Rules
**Count-based Detection:**
Titel: Multiple Failed Logons
Logsource:
Kategorie: Authentifizierung
Produkt: Fenster
Nachweis:
Auswahl:
EventID: 4625
Ziel Benutzername: '*'
Zustand: select|count(TargetUserName) by SourceNetworkAddress > 5.
Zeitrahmen: 5m
Ebene: mittel
**Statistical Analysis:**
Titel: Unusual Process Execution Volume
Logsource:
Kategorie: Process_creation
Produkt: Fenster
Nachweis:
Auswahl:
Image|endswith: '\powershell.exe '
Zustand: Auswahl:count() von Computer > avg(count() * 3
Zeitrahmen: 1h
Ebene: mittel
### Correlation Rules
**Multi-stage Attack Detection:**
Titel: Credential Dumping Gefolgt von Lateral Movement
Logsource:
Kategorie: Process_creation
Produkt: Fenster
Nachweis:
Stufe1:
Imagesendswith: '\mimikatz.exe '
CommandLine|contains: 'sekurlsa::logonpasswords '
Phase2:
Image|endswith: '\psexec.exe '
CommandLine|contains: '\\\\\*'
Zustand: Stufe1 gefolgt von Stufe2
Zeitrahmen: 30m
Niveau: hoch
### Custom Functions
**Custom Detection Logic:**
Titel: Entropiebasierter Verdacht auf Streicherkennung
Logsource:
Kategorie: Process_creation
Produkt: Fenster
Nachweis:
Auswahl:
CommandLine: '*'
Zustand: Auswahltropentropie(CommandLine) > 6.5
Ebene: mittel
## Troubleshooting
### Common Issues
**Rule Validation Errors:**
# Überprüfen Sie die YAML-Syntax
python -c "import yaml; yaml.safe_load(open('rule.yml'))"
# Gültige Sigma-Regelstruktur
sigma check rule.yml -V
# Feldmappings prüfen
sigma konvertieren -t splunk rule.yml - Debug.
**Conversion Problems:**
# Liste verfügbare Backends
Sigma Liste Backends
# Check Backend Konfiguration
sigma list modifiers -t splunk
# Test mit minimaler Regel
sigma konvertieren -t splunk -e 'Erkennung: \{Auswahl: \{EventID: 1\}, Zust.: Auswahl\} '
**Performance Issues:**
# Umrechnung von Profilregel
Zeit sigma konvertieren -t splunk rules/*.yml
# Regelkomplexität prüfen
grep -c "Bedingung:" rule.yml
grep -c "|" rule.yml # Count Modifiers
# Regelstruktur optimieren
sigma konvertieren -t splunk rule.yml --optimieren
### Debugging
**Debug Mode:**
# Debug-Logging aktivieren
sigma konvertieren -t splunk rule.yml - Debug.
# Verbose Ausgang
sigma konvertieren -t splunk rule.yml -V
# Trockenlaufmodus
sigma konvertieren -t splunk rule.yml --trocken
**Rule Analysis:**
# Regelabdeckung analysieren
sigma analysieren Regeln/ --
# Überprüfen Sie die Duplikate
sigma analysiert Regeln/-dupliziert
# Leistungsanalyse
sigma analysiert Regeln/-performance
This comprehensive Sigma cheatsheet covers rule development, conversion, deployment, and advanced features for effective threat detection across multiple SIEM platforms.
# Base64 encoded
| CommandLine | base64offset | contains: 'powershell' |
**Numerische Modifikatoren:**
Advanced Conditions
Complex Logic:
### Erweiterte Bedingungen
**Komplexe Logik:**
Aggregation Conditions:
**Aggregationsbedingungen:**
Time-based Conditions:
**Zeitbasierte Bedingungen:**
Rule Categories
Process Creation Rules
Suspicious Process Execution:
## Artikel Kategorien
### Prozess Erstellungsregeln
**Auffällige Prozessausführung:**
Command Line Analysis:
**Command Line Analyse:**
Network Connection Rules
Suspicious Outbound Connections:
### Netzanschlussregeln
**Verschiedene Outbound-Verbindungen:**
File System Rules
Suspicious File Creation:
### Dateisystemregeln
**Auffällige Datei-Erstellung:**
Registry Rules
Registry Persistence:
### Registrierungsbedingungen
**Registry Persistence:**
Conversion and Deployment
Convert Rules to SIEM Formats
Splunk Conversion:
## Umstellung und Bereitstellung
### Regeln in SIEM Formate umrechnen
**Splunk Umrechnung:**
Elastic/ECS Conversion:
**Elastik/ECS Umrechnung:**
QRadar Conversion:
**QRadar Umrechnung:**
Microsoft Sentinel Conversion:
**Microsoft Sentinel Umrechnung:**
Backend Configurations
Custom Backend Config:
### Backend Konfigurationen
**Custom Backend Config:**
Field Mapping:
**Field Mapping:**
Rule Development
Testing Rules
Rule Validation:
## Artikel Entwicklung
### Prüfregeln
**Regelvalidierung: **
Rule Testing:
**Regeltest:**
Rule Optimization
Performance Optimization:
### Regeloptimierung
**Leistungsoptimierung:**
Reduce False Positives:
**Reduzieren Falsche Positive:**
Rule Management
Rule Collections
Organize Rules by Category:
## Regelverwaltung
### Artikelsammlungen
**Organisieren Sie Regeln nach Kategorie:**
Rule Metadata Management:
**Rule Metadatenmanagement:**
Version Control
Git Workflow:
### Versionskontrolle
**Git Workflow:**
Rule Review Process:
**Review-Prozess:**
Integration Examples
CI/CD Pipeline
GitHub Actions Workflow:
## Integrationsbeispiele
### CI/CD Pipeline
**GitHub Aktionen Workflow:**
SIEM Integration
Splunk Integration:
### SIEM Integration
**Splunk Integration:**
Elasticsearch Integration:
**Elastische Forschungsintegration:**
Advanced Features
Aggregation Rules
Count-based Detection:
## Erweiterte Funktionen
### Aggregationsregeln
**Count-basierte Erkennung:**
Statistical Analysis:
**Statistische Analyse:**
Correlation Rules
Multi-stage Attack Detection:
### Korrelationsregeln
** Mehrstufige Angriffserkennung:**
Custom Functions
Custom Detection Logic:
### Benutzerdefinierte Funktionen
**Custom Detection Logic:**
Troubleshooting
Common Issues
Rule Validation Errors:
## Fehlerbehebung
### Gemeinsame Themen
**Regelvalidierungsfehler:**
Conversion Problems:
**Conversion Probleme:**
Performance Issues:
**Leistungsfragen:**
Debugging
Debug Mode:
### Debugging
**Debug Mode:**
Rule Analysis:
**Regelanalyse:**