Post

SOC Lab 3: Sigma Rules

SOC Lab 3: Sigma Rules

Toolchain: sigma-cli 3.x, pySigma backends Environment: Python 3 (venv) on Linux Series: Part 1 ran Snort 3 as a passive IDS, Part 2 pushed the same rules inline. This part stops writing packet signatures and writes detection content for logs instead. Part 4 moves to the artifact itself with YARA.

Parts 1 and 2 shared a constraint we never questioned: a signature is bound to its engine. The rule that alerts in Snort stays in Snort; port it to Splunk and you rewrite it by hand [2]. Sigma breaks that coupling. It is a generic, open signature format for log events [1]: describe what happened once, in YAML, then convert the same rule into native queries for Splunk, Elasticsearch, QRadar, Sentinel, whatever the shop runs.

1
2
3
4
5
6
7
8
9
            one Sigma rule  (YAML)
                     │
                     ▼
         sigma convert  +  pipeline
                     │
    ┌────────────────┼────────────────┐
    ▼                ▼                ▼
 Splunk SPL    ES / Lucene / EQL    anything with
   (fields)     (fields → ECS)      a pySigma backend

This post stands up sigma-cli, authors three rules by hand (recon, credential-dumping tooling, encoded PowerShell) and converts them to Splunk SPL and Elasticsearch Lucene, the two backends that map onto the stacks this blog has built. Every output below is from a real run against the actual rule files shown. No SIEM is harmed; the point is the content, not the platform.

Roadmap

Eleven stages, in the order they were run. Each one ends with the evidence it produced, so you can tell whether yours worked before moving on.

  1. Reproduce the Lab. A venv with sigma-cli and the two backends, plus four rule files written in one copy-paste session.
  2. Why Sigma. The coupling problem Parts 1 and 2 never questioned, and the one-rule-many-dialects model that breaks it.
  3. Toolchain and Backends. sigma list targets and sigma list pipelines: the difference between a backend, which picks the query language, and a pipeline, which picks the field names.
  4. Rule Anatomy. The first rule read line by line, and the mapping from Snort’s header/options/sid onto Sigma’s logsource/detection/id.
  5. The logsource Block. category, product and service, and why the pipeline is what resolves them to real fields.
  6. The detection Block. Map keys as AND, list values as OR, and the condition grammar that combines them.
  7. Value Modifiers. contains, startswith, re, cidr, base64offset and the rest, and how they chain left to right.
  8. First Conversion. The first rule turned into Splunk SPL and Elasticsearch Lucene, and the field remaps the pipeline performs on the way.
  9. Filters and Coverage. A filter_* selection added to carve out the benign case, and what that costs in coverage.
  10. Tool Fingerprints with OR Logic. A credential-dumping rule keyed on sekurlsa::, lsadump:: and the rest, converted to both dialects.
  11. base64offset: Encoded PowerShell. Why one encoded string needs three base64 variants, and the modifier order that makes it work.

Then two closing sections: The Public Library, which clones SigmaHQ and batch-converts 1,184 process_creation rules to SPL, and In Production, which covers what Sigma does not do (it does not alert) and what a pipeline actually assumes about your logs.

Reproduce the Lab

To follow along, build the same environment. The whole setup is Python in a venv plus four rule files, so it is one copy-paste session:

1
2
3
4
python3 -m venv ./sigma-lab
source ./sigma-lab/bin/activate
pip install sigma-cli pySigma-backend-splunk pySigma-backend-elasticsearch
mkdir -p ./sigma-lab/rules && cd ~/sigma-lab
1
2
3
4
5
6
./sigma-lab/          the venv doubles as the project root
└── rules
    ├── soclab_whoami_recon.yml
    ├── soclab_whoami_recon_filtered.yml
    ├── soclab_cred_dump_toolkit.yml
    └── soclab_encoded_powershell.yml

Write the four rules. The first two are shown in full below; here they are laid down so your outputs match:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
cat > rules/soclab_whoami_recon.yml <<'EOF'
title: SOC-LAB Command-Line Recon via Whoami
id: 1d8dcfc9-a054-49e9-bfa9-aeb39090f97e
status: experimental
description: Detects whoami.exe run with the /priv or /groups switches, the classic
    Windows post-exploitation step of mapping the current user's privileges and
    group membership.
references:
    - https://attack.mitre.org/techniques/T1033/
author: Nassim (k1tch0p)
date: 2026/09/07
tags:
    - attack.discovery
    - attack.t1033
logsource:
    category: process_creation
    product: windows
detection:
    selection_img:
        - Image|endswith: '\whoami.exe'
        - OriginalFileName: 'whoami.exe'
    selection_flags:
        CommandLine|contains:
            - '/priv'
            - '/groups'
    condition: all of selection_*
falsepositives:
    - Legitimate administration and troubleshooting
level: medium
EOF

cat > rules/soclab_whoami_recon_filtered.yml <<'EOF'
title: SOC-LAB Command-Line Recon via Whoami, Filtered
id: 6e9c1403-0cd5-4f60-b6c9-e30c57529865
status: experimental
description: Detects whoami.exe with /priv or /groups, minus the benign case where
    the parent process is explorer.exe (a user double-clicking a batch job).
references:
    - https://attack.mitre.org/techniques/T1033/
author: Nassim (k1tch0p)
date: 2026/09/07
tags:
    - attack.discovery
    - attack.t1033
logsource:
    category: process_creation
    product: windows
detection:
    selection_img:
        - Image|endswith: '\whoami.exe'
        - OriginalFileName: 'whoami.exe'
    selection_flags:
        CommandLine|contains:
            - '/priv'
            - '/groups'
    filter_benign:
        ParentImage|endswith: '\explorer.exe'
    condition: all of selection_* and not filter_benign
falsepositives:
    - Legitimate administration and troubleshooting
level: medium
EOF

cat > rules/soclab_cred_dump_toolkit.yml <<'EOF'
title: SOC-LAB Credential Dumping Toolkit Arguments
id: 91c21465-e172-4960-969d-a66781f0a8f9
status: experimental
description: Detects command lines carrying the classic module keywords of credential-dumping
    tools such as mimikatz (sekurlsa::, lsadump::, kerberos::). A strong post-compromise
    indicator that normally only shows up in tooling.
references:
    - https://attack.mitre.org/techniques/T1003/
author: Nassim (k1tch0p)
date: 2026/09/07
tags:
    - attack.credential-access
    - attack.t1003.001
logsource:
    category: process_creation
    product: windows
detection:
    selection_module:
        CommandLine|contains:
            - 'sekurlsa::'
            - 'lsadump::'
            - 'kerberos::'
            - 'dpapi::'
            - 'crypto::'
    selection_tool:
        - Image|endswith: '\mimikatz.exe'
        - OriginalFileName: 'mimikatz.exe'
    condition: 1 of selection_*
falsepositives:
    - Unlikely
level: high
EOF

cat > rules/soclab_encoded_powershell.yml <<'EOF'
title: SOC-LAB Encoded PowerShell Command Lines
id: 63e1e6c7-7e65-4e16-9b42-79f834ff0d85
status: experimental
description: Detects PowerShell command lines that base64-encode the classic download
    and execute markers IEX, FromBase64String or DownloadString.
references:
    - https://attack.mitre.org/techniques/T1059.001/
author: Nassim (k1tch0p)
date: 2026/09/07
tags:
    - attack.execution
    - attack.t1059.001
logsource:
    category: process_creation
    product: windows
detection:
    selection_img:
        - Image|endswith: '\WindowsPowerShell\v1.0\powershell.exe'
        - Image|endswith: '\powershell.exe'
        - OriginalFileName: 'PowerShell.EXE'
    selection_payload:
        CommandLine|base64offset|contains:
            - 'IEX'
            - 'FromBase64String'
            - 'DownloadString'
    condition: all of selection_*
falsepositives:
    - Legitimate administration scripts that build encoded commands
level: high
EOF

Versions move. If sigma version reports a newer release than 3.1.0 below, conversion formatting can shift slightly; the logic the post walks through does not change.

Why Sigma

Detection content has a portability problem. A SOC runs tools that all consume detections, and each speaks a different dialect: Snort has its own grammar, Splunk reads SPL, Elasticsearch reads Lucene/EQL/ESQL. The same analytical idea, “a process spawned whoami.exe with recon flags”, gets re-expressed per platform, drifting from the original each time and doubling the maintenance of every hunt.

Sigma is a vendor-neutral signature language that sits above those dialects. You express the idea once, in YAML any analyst can read, and the converter produces the per-SIEM query. Two design decisions make this work [1][3]:

  • Sigma is content, not an engine. It defines what to look for and has no runtime. The query still executes inside your SIEM, so your collection pipeline does not change; Sigma just gives you portable, reviewable logic on top of it.
  • The conversion is layered. sigma-cli (the command line) drives pySigma (the conversion library). The library loads two plugin kinds: backends, which express a query in one SIEM language, and pipelines, which adapt a rule’s generic logsource and field names to a concrete deployment [4]. That split is why one rule becomes correct Splunk and correct Elasticsearch without hand-editing.

The ecosystem is more than the tooling. The SigmaHQ/sigma repository is an open library of community rules, 3,000+ detections covering Windows process creation, Sysmon, DNS, web, cloud and Linux logs, that share the format and convert with the same command you run here [1].

Toolchain and Backends

Sigma is a Python project, so it lives in a venv with the CLI and the backends we intend to convert to:

1
2
3
➜  sigma-lab python3 -m venv ~/sigma-lab
➜  sigma-lab source ~/sigma-lab/bin/activate
(sigma-lab) ➜  sigma-lab pip install sigma-cli pySigma-backend-splunk pySigma-backend-elasticsearch
1
2
(sigma-lab) ➜  sigma-lab sigma version      
3.1.0 (online pypi.org: 3.1.0)

sigma list targets shows which query languages the installed backends can emit:

1
2
3
4
5
6
7
8
9
10
11
(sigma-lab) ➜  sigma-lab sigma list targets
+-------------+----------------------------------------+------------------------------+---------------+
| Identifier  | Target Query Language                  | Processing Pipeline Required | Plugin        |
+-------------+----------------------------------------+------------------------------+---------------+
| lucene      | Elasticsearch Lucene                   | Yes                          | elasticsearch |
| eql         | Elasticsearch EQL                      | Yes                          | elasticsearch |
| esql        | ES|QL backend                          | Yes                          | elasticsearch |
| elastalert  | Elasticsearch Elastalert               | Yes                          | elasticsearch |
| splunk      | Splunk SPL & tstats data model queries | Yes                          | splunk        |
| splunk_spl2 | Splunk SPL2 queries                    | Yes                          | splunk        |
+-------------+----------------------------------------+------------------------------+---------------+

Every target wants a pipeline, and sigma list pipelines shows why they matter: each maps the rule’s generic logsource onto one concrete log schema:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
(sigma-lab) ➜  sigma-lab sigma list pipelines
+----------------------------+----------+--------------------------------------------------------------+----------------------------------------+---------------+
| Identifier                 | Priority | Processing Pipeline                                          | Backends                               | Plugin        |
+----------------------------+----------+--------------------------------------------------------------+----------------------------------------+---------------+
| ecs_windows                | 20       | Elastic Common Schema (ECS) Windows log mappings from        | elasticsearch, eql, lucene, opensearch | elasticsearch |
|                            |          | Winlogbeat from version 7                                    |                                        |               |
| ecs_windows_old            | 20       | Elastic Common Schema (ECS) Windows log mappings from        | elasticsearch, eql, lucene, opensearch | elasticsearch |
|                            |          | Winlogbeat up to version 6                                   |                                        |               |
| ecs_zeek_beats             | 20       | Elastic Common Schema (ECS) for Zeek using filebeat >= 7.6.1 | elasticsearch, eql, lucene, opensearch | elasticsearch |
| ecs_zeek_corelight         | 20       | Elastic Common Schema (ECS) mapping from Corelight           | elasticsearch, eql, lucene, opensearch | elasticsearch |
| ecs_kubernetes             | 30       | Elastic Common Schema (ECS) Kubernetes audit log mappings    | elasticsearch, eql, lucene             | elasticsearch |
| ecs_macos_esf              | 30       | Elastic Common Schema (ECS) macOS Endpoint Security          | elasticsearch, eql, lucene, opensearch | elasticsearch |
|                            |          | Framework (ESF) mappings                                     |                                        |               |
| splunk_windows             | 20       | Splunk Windows log source conditions                         | splunk, splunk_spl2                    | splunk        |
| splunk_sysmon_acceleration | 25       | Splunk Windows Sysmon search acceleration keywords           | splunk, splunk_spl2                    | splunk        |
| splunk_cim                 | 20       | Splunk CIM Data Model Mapping                                | splunk, splunk_spl2                    | splunk        |
+----------------------------+----------+--------------------------------------------------------------+----------------------------------------+---------------+

The mental model for the rest of the post: a backend picks the query language, a pipeline picks the field names. You author the rule once; the pipeline is what makes it speak process.command_line (ECS) on one stack and CommandLine on another.

For a no-install look at a single rule, SigConverter exposes the same sigma-cli backends behind a web form [11]: pick a target and a pipeline, paste a rule, and it hands back the generated query plus the equivalent sigma convert command, so the site and the CLI stay in lockstep. It is open source (Apache-2.0) and self-hostable, which matters once your rule content stops being public library and starts being proprietary: host your own instance rather than paste that into a third-party site. The rest of this post stays on the CLI, because that is what a real pipeline runs.

Rule Anatomy

Sigma rules are YAML with a fixed skeleton: metadata on top, then the two halves that matter, logsource (where the rule points) and detection (what it matches) [5]. Our first rule is a Windows process-launch detection for whoami.exe used as recon:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# rules/soclab_whoami_recon.yml
title: SOC-LAB Command-Line Recon via Whoami
id: 1d8dcfc9-a054-49e9-bfa9-aeb39090f97e
status: experimental
description: Detects whoami.exe run with the /priv or /groups switches, the classic
    Windows post-exploitation step of mapping the current user's privileges and
    group membership.
references:
    - https://attack.mitre.org/techniques/T1033/
author: Nassim (k1tch0p)
date: 2026/09/07
tags:
    - attack.discovery
    - attack.t1033
logsource:
    category: process_creation
    product: windows
detection:
    selection_img:
        - Image|endswith: '\whoami.exe'
        - OriginalFileName: 'whoami.exe'
    selection_flags:
        CommandLine|contains:
            - '/priv'
            - '/groups'
    condition: all of selection_*
falsepositives:
    - Legitimate administration and troubleshooting
level: medium

If Part 1 taught you Snort, the shape is familiar with the ends swapped. Snort splits a rule into a header (what traffic) and options (what evidence); Sigma splits it into logsource (which log stream) and detection (what evidence). And where Snort keys a signature on a numeric sid, Sigma uses a random UUIDv4 id that travels with the rule wherever it is copied or converted [5].

1
2
3
4
5
 Snort rule                      Sigma rule
 ----------------                ------------------------------
 header  action/proto/net    ->  logsource  category/product   (WHERE)
 options payload evidence    ->  detection  selection_*+condition (WHAT)
 sid / msg / rev             ->  id / title / level / status / tags

The metadata encodes analyst judgment, not syntax, so it is worth reading before the detection:

  • status marks how much to trust a rule: experimental (noisy, unproven), test (mostly stable), stable (production), deprecated/unsupported (retired). A library rule you import blind is experimental for a reason.
  • level is the severity the SOC applies: informational, low, medium, high, critical.
  • tags namespace detections so you can slice a fleet by tactic. The attack.* prefix maps to MITRE ATT&CK: attack.t1033 is System Owner/User Discovery, the technique whoami /priv serves [6].

The format also has conventions the parser does not enforce: lowercase keys, single quotes around strings, filenames like soclab_whoami_recon.yml (lowercase, underscores, .yml) [5].

The logsource Block

logsource is mandatory and answers the question the whole rule depends on: which log events is this meant to run against? It has three selectors [5]:

keymeaningexample
categorylogical group of log filesprocess_creation, dns_query, firewall
productproduct / platform that emits themwindows, linux, apache
servicea specific subset of a productsecurity (Windows Security log), sshd

They compose freely. category: process_creation + product: windows is deliberately abstract: it does not say Sysmon EventID 1 or Security 4688 or an EDR’s process-launch event, because the rule should not care. That abstraction is the trick: the pipeline later decides which concrete event type each backend means, so one rule covers Sysmon, native audit and EDR alike instead of forking into three copies [5].

You will meet a handful of combinations constantly in the public library:

1
2
3
4
5
product: windows   category: process_creation   process launches (Sysmon 1 / 4688 / EDR)
product: windows   category: dns_query          DNS queries (Sysmon 22)
product: windows   category: network_connection outbound sockets (Sysmon 3)
product: linux     category: process_creation   process launches (auditd / EDR)
category: webserver                              web access / reverse-proxy logs

The detection Block

detection holds search identifiers (named YAML blobs, each one predicate) and a condition that combines them with boolean algebra. The semantics are simple but non-negotiable; get these four straight and you can read any rule in the library [5]:

1
2
3
4
map   {field: value}                 -> all keys in the map are AND'd
list  under a field                  -> the list values are OR'd
list  of plain strings (no field)    -> keyword search over the whole event, OR'd
each  selection must be true         -> then `condition` decides how they combine

Run that over selection_img and selection_flags and the rule reads exactly as intended:

1
2
3
4
5
6
selection_img:      # list of two maps -> OR:
    - Image|endswith: '\whoami.exe'            #   image ends in \whoami.exe
    - OriginalFileName: 'whoami.exe'           #   OR original name is whoami.exe
selection_flags:    # map, CommandLine is a list -> field AND (priv OR groups):
    CommandLine|contains: ['/priv', '/groups'] #   CommandLine contains /priv OR /groups
condition: all of selection_*

condition is the only field that combines identifiers. The practical subset of its grammar [5]:

1
2
3
4
5
6
selection                            one identifier by name
all of them                          AND of every identifier
1 of them                            OR  of every identifier
all of selection_* / 1 of selection_*   same, restricted to identifiers matching a pattern
selection and not filter             negation
( ... )                              grouping

Two idioms dominate community rules. all of selection_* and not filter_* requires every evidence predicate, then carves out known-benign cases. 1 of selection_* fires on any member of a family, the shape of tool-fingerprint rules. Identifiers that start with an underscore (_example) are excluded from all/1 of them by convention, so rules can carry pre-filter definitions without making them required evidence.

Value Modifiers

A bare field: value is an exact, case-insensitive match, useless for command lines, where you need “contains” and “ends with”. That is what value modifiers are for: they hang off the field name with a pipe and refine how a value is interpreted. They chain, applied left to right (field|contains|all: ...) [7]:

modifiereffect
contains*value*, match anywhere
startswith / endswithanchor at the start / end
allflip a value list from OR to AND
casedforce case-sensitive
retreat value as PCRE
cidrvalue is a network range
windashaccept -///– flag spellings
base64offsetmatch plaintext inside base64
utf16le / widevalue in UTF-16-LE bytes

Our first rule uses two of them: CommandLine|contains for the flag tokens and Image|endswith to anchor on the image path. Note the backslash in '\whoami.exe': Sigma only treats * and ? as wildcards, so a single backslash needs no escaping unless a wildcard follows it. Write \whoami.exe, not \\whoami.exe [7]. One modifier gotcha awaits in the base64 section, and it is a two-line fix once seen.

First Conversion

Write the rule to disk, and here is the first thing sigma-cli does: it parses and validates before any conversion, so a structurally broken rule never reaches the SIEM as a malformed query. Delete the logsource block and conversion dies at the gate:

1
sigma convert rules/soclab_whoami_recon.yml -t lucene -p ecs_windows
1
2
3
4
Parsing Sigma rules
Errors found in Sigma rules:
* Sigma rule must have a log source in rules/soclab_whoami_recon.yml
Error: Errors found in Sigma rules. Please check the output above.

That is the Sigma equivalent of snort -T from Part 1: fail fast, on the authoring side, where the fix is cheap. Rule intact, convert to Splunk. -t splunk selects the backend, -p splunk_windows selects the pipeline that understands Windows Event Log field conventions:

1
2
3
4
(sigma-lab) ➜  sigma-lab sigma convert rules/soclab_whoami_recon.yml -t splunk -p splunk_windows

Parsing Sigma rules  [####################################]  100%
Image="*\\whoami.exe" OR OriginalFileName="whoami.exe" CommandLine IN ("*/priv*", "*/groups*")

Deployable SPL for a shop whose Splunk indexes Windows Event Log fields under their native names. Note what the converter preserved: the two selection_img alternatives collapsed into one OR, the CommandLine list collapsed into an IN (...) set, and the effective grouping came out as (Image=… OR OriginalFileName=…) AND (CommandLine IN (...)), because Splunk’s search command evaluates OR before the implicit AND, and this query has exactly one implicit-AND boundary [8]. Structure survived the language change.

Now the same rule for the stack this blog actually runs. Point it at the Elasticsearch family with the ECS pipeline:

1
2
3
4
(sigma-lab) ➜  sigma-lab sigma convert rules/soclab_whoami_recon.yml -t lucene -p ecs_windows

Parsing Sigma rules  [####################################]  100%
(process.executable.caseless:*\\whoami.exe OR process.pe.original_file_name:whoami.exe) AND (process.command_line:(*\/priv* OR *\/groups*))

Compare the two outputs and the pipeline’s job is visible at a glance: ECS remapped Image to process.executable, OriginalFileName to process.pe.original_file_name, CommandLine to process.command_line, so the query matches an Elastic index normalized to ECS, the schema Part 1’s Logstash pipeline was building toward [9]. Same detection idea, different field dialect.

One honesty note that belongs in any Sigma walkthrough: a converted query is a starting point, not a guarantee. Operator precedence and wildcard semantics differ subtly per language, and a pipeline only maps the field names it knows. Paste the output into your SIEM, run it against a known event, and eyeball the grouping before you schedule an alert. SigConverter automates that eyeball pass for a single rule with the same target-and-pipeline model, and its query is meant to match the CLI’s [11]. The value of Sigma is that you tune one rule, not four copies of it.

Filters and Coverage

Our rule fires on any whoami /priv, including the legitimate troubleshooting that makes up most of the noise. Detection engineering’s reflex is a filter, a benign baseline to subtract. Author a variant that ignores whoami.exe whose parent is Explorer, the signature of a user double-clicking a batch job:

1
2
3
4
5
6
7
8
9
10
11
# rules/soclab_whoami_recon_filtered.yml  (detection excerpt)
    selection_img:            # unchanged from the base rule
        - Image|endswith: '\whoami.exe'
        - OriginalFileName: 'whoami.exe'
    selection_flags:
        CommandLine|contains:
            - '/priv'
            - '/groups'
    filter_benign:
        ParentImage|endswith: '\explorer.exe'
    condition: all of selection_* and not filter_benign
1
2
3
4
(sigma-lab) ➜  sigma-lab sigma convert rules/soclab_whoami_recon_filtered.yml -t lucene -p ecs_windows

Parsing Sigma rules  [####################################]  100%
((process.executable.caseless:*\\whoami.exe OR process.pe.original_file_name:whoami.exe) AND (process.command_line:(*\/priv* OR *\/groups*))) AND (NOT process.parent.executable.caseless:*\\explorer.exe)

and not filter_benign became a trailing AND (NOT ...): the same grouping, one predicate subtracted. The Splunk side reads just as cleanly:

1
Image="*\\whoami.exe" OR OriginalFileName="whoami.exe" CommandLine IN ("*/priv*", "*/groups*") NOT ParentImage="*\\explorer.exe"

But filters deserve the same distrust as the broad-versus-specific trade-off from Part 1: every filter you add to kill false positives also carves a hole in your coverage. The Explorer filter is reasonable until an attacker drops a .bat on a shared drive and the user double-clicks it. Then whoami /priv runs under Explorer, and your filter just made the detection silent. Name filters filter_*, keep them next to their selection_*, and review them as often as the selections themselves. A silently over-filtered rule is indistinguishable from a deleted one.

Tool Fingerprints with OR Logic

A recon whoami is one predicate. Credential-dumping tooling is better caught with any-of semantics: a mimikatz run can look like a renamed binary, a module call on the command line, or both. No single predicate is dependable, so OR a family of them. 1 of selection_* expresses exactly that:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# rules/soclab_cred_dump_toolkit.yml
title: SOC-LAB Credential Dumping Toolkit Arguments
id: 91c21465-e172-4960-969d-a66781f0a8f9
status: experimental
description: Detects command lines carrying the classic module keywords of credential-dumping
    tools such as mimikatz (sekurlsa::, lsadump::, kerberos::). A strong post-compromise
    indicator that normally only shows up in tooling.
references:
    - https://attack.mitre.org/techniques/T1003/
author: Nassim (k1tch0p)
date: 2026/09/07
tags:
    - attack.credential-access
    - attack.t1003.001
logsource:
    category: process_creation
    product: windows
detection:
    selection_module:
        CommandLine|contains:
            - 'sekurlsa::'
            - 'lsadump::'
            - 'kerberos::'
            - 'dpapi::'
            - 'crypto::'
    selection_tool:
        - Image|endswith: '\mimikatz.exe'
        - OriginalFileName: 'mimikatz.exe'
    condition: 1 of selection_*
falsepositives:
    - Unlikely
level: high

1 of selection_* means: fire if the command line carries a dumping-module keyword or the image/name is mimikatz. Either strand alone is enough. Watch the same logic land in both dialects:

1
2
3
4
(sigma-lab) ➜  sigma-lab sigma convert rules/soclab_cred_dump_toolkit.yml -t splunk -p splunk_windows

Parsing Sigma rules  [####################################]  100%
CommandLine IN ("*sekurlsa::*", "*lsadump::*", "*kerberos::*", "*dpapi::*", "*crypto::*") OR Image="*\\mimikatz.exe" OR OriginalFileName="mimikatz.exe"
1
2
3
4
(sigma-lab) ➜  sigma-lab sigma convert rules/soclab_cred_dump_toolkit.yml -t lucene -p ecs_windows

Parsing Sigma rules  [####################################]  100%
(process.command_line:(*sekurlsa\:\:* OR *lsadump\:\:* OR *kerberos\:\:* OR *dpapi\:\:* OR *crypto\:\:*)) OR (process.executable.caseless:*\\mimikatz.exe OR process.pe.original_file_name:mimikatz.exe)

The two outputs are structurally identical under the dialects, which is the entire thesis of the format. We did not have to write this rule to prove it; the community already did. The same conversion, applied verbatim to a real library rule cloned in the library section:

1
sigma convert .../proc_creation_win_hktl_mimikatz_command_line.yml -t splunk -p splunk_windows
1
CommandLine IN ("*DumpCreds*", "*mimikatz*") OR CommandLine IN ("*::aadcookie*", "*::detours*", "*::memssp*", "*::mflt*", ...) OR CommandLine IN ("*rpc::*", "*token::*", "*crypto::*", "*dpapi::*", ...)

Community content flows through the same pipeline as our own rules, because it is the same language.

base64offset: Encoded PowerShell

The rules so far match plaintext. Attackers read threat intel too, and the cheap evasion for -enc-style PowerShell is to base64 the payload: the event’s CommandLine holds gibberish, so CommandLine|contains: 'IEX' matches nothing. The fix is the base64offset modifier, which answers: “if this plaintext keyword sat somewhere inside a base64 stream, what would its encoded bytes look like?”

Base64 encodes 3 bytes into 4 characters. If the keyword starts exactly on a 3-byte boundary you see its own clean block: base64('IEX') is SUVY. But inside a longer payload the keyword can start one or two bytes off that boundary, and then its letters straddle two blocks and look different. Three possible alignments, three observable substrings:

1
2
3
keyword start is   byte offset ≡ 0 (mod 3)   ->  base64 contains 'SUVY'
                    byte offset ≡ 1 (mod 3)   ->  base64 contains 'lFW'
                    byte offset ≡ 2 (mod 3)   ->  base64 contains 'JRV'

base64offset emits all three variants, so the rule matches the keyword at any alignment inside an encoded payload [7]:

1
2
3
4
5
6
7
8
9
10
11
# rules/soclab_encoded_powershell.yml  (detection excerpt)
    selection_img:
        - Image|endswith: '\WindowsPowerShell\v1.0\powershell.exe'
        - Image|endswith: '\powershell.exe'
        - OriginalFileName: 'PowerShell.EXE'
    selection_payload:
        CommandLine|base64offset|contains:
            - 'IEX'
            - 'FromBase64String'
            - 'DownloadString'
    condition: all of selection_*

Here is the modifier-order gotcha flagged in the modifiers section. Write the chain backwards (contains|base64offset) and conversion dies, because contains wraps the keyword in * wildcards first, and you cannot base64-encode a wildcard:

1
2
3
4
(sigma-lab) ➜  sigma-lab sigma convert rules/soclab_encoded_powershell.yml -t splunk -p splunk_windows
Errors found in Sigma rules:
* Base64 encoding of strings with wildcards is not allowed in rules/soclab_encoded_powershell.yml
Error: Errors found in Sigma rules. Please check the output above.

The rule chain is base64offset|contains: encode first, then wrap. Fixed, conversion shows exactly what the modifier bought: three keywords became nine base64 tokens, three per keyword for the three alignments.

1
2
3
(sigma-lab) ➜  sigma-lab sigma convert rules/soclab_encoded_powershell.yml -t splunk -p splunk_windows
Parsing Sigma rules  [####################################]  100%
Image="*\\WindowsPowerShell\\v1.0\\powershell.exe" OR Image="*\\powershell.exe" OR OriginalFileName="PowerShell.EXE" CommandLine="*SUVY*" OR CommandLine="*lFW*" OR CommandLine="*JRV*" OR CommandLine="*RnJvbUJhc2U2NFN0cmluZ*" OR CommandLine="*Zyb21CYXNlNjRTdHJpbm*" OR CommandLine="*Gcm9tQmFzZTY0U3RyaW5n*" OR CommandLine="*RG93bmxvYWRTdHJpbm*" OR CommandLine="*Rvd25sb2FkU3RyaW5n*" OR CommandLine="*Eb3dubG9hZFN0cmluZ*"

The output is one long SPL term list: the three-image selection stays put, and behind it sit nine CommandLine tokens, the IEX, FromBase64String and DownloadString triples, three encodings each. Worth saying plainly: the rule now fights base64 exactly once, at conversion time, instead of at every search.

The analyst who reads this rule knows the cost too: the compact, readable IEX became nine opaque substrings, and a rule that prints cleanly is easier to maintain than one that does not. base64offset is reserved for detections where the encoding is the adversary’s point. It buys coverage at the price of readability, and it is worth both only in that trade.

The Public Library

The format is nothing without the corpus behind it. The SigmaHQ/sigma repository is the shared detection library, and it converts with the same commands we have been running all along:

1
git clone --depth 1 https://github.com/SigmaHQ/sigma.git

The layout is a taxonomy in itself: rules are filed by platform, then by log type.

1
2
3
4
5
6
7
8
9
rules/
├── windows/  (2410)   ├── process_creation/  (1185)  <- our playground
│                      ├── dns_query/
│                      ├── network_connection/
│                      ├── registry/
│                      └── ...
├── linux/    (210)    ├── cloud/  (225)
├── macos/    (69)     ├── web/    (45)
└── ...                └── ...

The file names double as documentation: proc_creation_win_whoami_groups_discovery.yml tells you platform, log type and detection intent before you open it. Inside, the conventions match what we wrote by hand (selection_* predicates, filter_* carve-outs, UUID ids, attack.* tags), which is the quiet payoff of authoring in the house style: library rules and your rules read identically.

The same command that converts one file converts the whole tree. The 1,185 process_creation rules become Splunk SPL in about seven seconds:

1
sigma convert -t splunk -p splunk_windows -s -od converted rules/windows/process_creation
1
2
Parsing Sigma rules
Wrote 1184 file(s) to converted

One rule in the set uses a construct the Splunk backend cannot express; -s skips unsupported rules instead of aborting the batch. That number is the real product: 1,184 working detections, in your query dialect, minutes after a clone.

The discipline that applies to our three rules applies harder at library scale. A cloned rule is only as good as its logsource matching what you actually collect and index; a Sysmon-dependent rule is dead weight on a fleet that only ships Security 4688. Start with status: stable and high level, run them where the data exists, and treat experimental as the label it is.

In Production

Three things to internalize before wiring Sigma into a real pipeline.

Sigma does not alert; your stack does. The output of sigma convert is a query that must be scheduled, run and routed inside your SIEM. Porting detection logic between SIEMs is the win; the detection platform is still on you. Keep the rule in version control, convert at deploy time, and never let the committed query and the committed rule drift: the rule is the source of truth, the query is derived.

A pipeline is an assumption about your logs. We converted with ecs_windows and got ECS field names because we assumed the Elastic index was ECS-normalized, like Part 1’s. If your index keeps raw Windows field names, that pipeline silently produces queries that match nothing. Verify the mapping against a real event before trusting a converted batch, and check the pipeline list: splunk_cim, for example, expects CIM data models and rejects rule types it cannot express.

The format has grown past single events. Sigma now ships correlation rules that link several rules or events (a count of failed logons crossing a threshold, or two detections firing on the same host inside a window) and filters, the same idea as our filter_benign, factored out so many rules share one exclusion [5][10]. Same language family, higher-level hunts, still portable.

Wrap-up

Part 1 wrote signatures the wire could trip; Part 2 made them enforce; this one stopped writing for one engine at all. Three rules, two SIEM dialects, zero rewrites:

1
2
3
soclab_whoami_recon.yml        ─┐
soclab_cred_dump_toolkit.yml   ─┼─►  Splunk SPL   +   Elasticsearch Lucene
soclab_encoded_powershell.yml  ─┘        (native fields)      (fields → ECS)

The workflow that produced them is the skill worth keeping: author the idea in YAML, let the parser fail fast, convert with a pipeline that names your fields, then eyeball the grouping in your own SIEM. Do that and a detection is no longer rewritten per platform; it is owned once and shipped everywhere. Part 4 keeps the same philosophy one layer down, reading the bytes of the artifact itself with YARA.


References

  1. Sigma, the Generic Signature Format for Log Events. The SigmaHQ/sigma repository holds the format’s rationale and the public rule library used in this post.
  2. SOC Lab 1, Snort 3 as an IDS and SOC Lab 2, Snort 3 as an IPS: the packet-detection baseline this post extends.
  3. sigma-cli: the command-line interface driving pySigma (targets, pipelines, conversion).
  4. pySigma: the Python conversion library and its backend/pipeline plugin model.
  5. Sigma Rules Specification: rule structure, logsource, detection semantics, condition grammar, status/level.
  6. MITRE ATT&CK: tactic/technique taxonomy used in rule tags (T1033 System Owner/User Discovery, T1003 OS Credential Dumping, T1059 Command and Scripting Interpreter).
  7. Sigma Value Modifiers Appendix: contains, endswith, all, base64offset and the encoding modifiers.
  8. Splunk Search Manual: Boolean expressions with logical operators: operator precedence in the search command (OR before implicit AND).
  9. Elastic Common Schema (ECS) Reference: the field schema the ecs_windows pipeline targets (process.executable, process.command_line, …).
  10. Sigma Correlation Rules Specification: multi-event correlation rule types (count thresholds, temporal joins across rules).
  11. SigConverter: a free, browser-based Sigma rule converter driving the same sigma-cli/pySigma backends used in this post; open source (github.com/magicsword-io/sigconverter.io, Apache-2.0) and self-hostable.

Tags

#Sigma #SigmaRules #DetectionEngineering #pySigma #sigma-cli #Splunk #Elasticsearch #SOC #BlueTeam

This post is licensed under CC BY 4.0 by the author.