YARA / Sigma Rules

YARA and Sigma are two critical detection engineering tools used in SOC operations.
They help analysts detect malware, attacker behaviors, and suspicious activity across endpoints, networks, cloud platforms, and log sources.
Both rule types convert analyst knowledge into machine-readable detections that improve SIEM, EDR, threat hunting, and incident response.

This chapter explains YARA and Sigma in full-depth, practical SOC style, including structure, patterns, workflow, tuning, use cases, and real examples.


Understanding YARA

YARA is a pattern-matching engine used to identify malware based on static or behavioral characteristics.
SOC, IR, and malware analysis teams use YARA to:

  • Detect malware families

  • Identify malicious files

  • Scan memory for fileless malware

  • Classify similar malware variants

  • Support forensics investigations

  • Improve detection during IR

  • Validate suspicious binaries

YARA rules operate on:

  • File content

  • Memory buffers

  • Strings (plain, hex, regex)

  • Byte patterns

  • PE file metadata

  • Import tables

  • Entropy and sections


YARA Rule Structure (Practical Breakdown)

A YARA rule contains four main parts:

Rule Header

Name of the rule:

rule CobaltStrike_Beacon { 

Meta Section

Description and author information:

meta:
    description = "Detects Cobalt Strike beacon"
    author = "SOC Analyst"

Strings Section

Patterns YARA looks for:

strings:
    $url = "beacon" nocase
    $str1 = "MZ" 
    $hex1 = { 2E 63 6F 62 61 6C 74 } 

Condition Section

Logic when rule should trigger:

condition:
    all of them

YARA applies these conditions to files and memory dumps.


Practical YARA Examples

Detecting a Known Malware String

strings:
    $a = "xmrig" nocase
condition:
    $a

Used to detect crypto miners.

Detecting a Malware PE Header Pattern

strings:
    $mz = "MZ"
    $cs = { 90 90 90 E8 ?? ?? ?? ?? }
condition:
    $mz and $cs

Used to identify suspicious executable padding.

Detecting Cobalt Strike Beacon

strings:
    $c2 = "http-get-client" nocase
    $sig = { 2F 62 65 61 63 6F 6E }
condition:
    any of ($c2, $sig)

When SOC Uses YARA

YARA is used in scenarios like:

  • Scanning suspicious attachments

  • Memory analysis for fileless malware

  • Detecting persistence DLLs

  • Identifying shellcode patterns

  • Confirming malware families during IR

EDR platforms like CrowdStrike and SentinelOne use YARA internally.


Understanding Sigma

Sigma is a generic rule format for SIEM detection.
It is called the “YAML-based SIEM detection language.”

Sigma rules define:

  • Log source

  • Suspicious patterns

  • Fields to match

  • Detection conditions

  • Severity

  • MITRE ATT&CK mapping

Then Sigma converts automatically into:

  • Splunk queries

  • Elastic queries

  • QRadar rules

  • Sentinel KQL

  • Chronicle rules

This makes Sigma universal across SIEM platforms.


Sigma Rule Structure (Practical Breakdown)

A Sigma rule has these components:

Title

title: Suspicious Encoded PowerShell

Log Source

logsource:
  category: process_creation
  product: windows

Detection Section

detection:
  selection:
    Image|endswith: 'powershell.exe'
    CommandLine|contains: '-enc'
  condition: selection

Fields & Metadata

level: high
tags:
  - attack.execution
  - attack.t1059.001

Sigma rules focus on log analysis, not file scanning.


Practical Sigma Examples

Detect Encoded PowerShell Execution

detection:
  selection:
    Image|endswith: 'powershell.exe'
    CommandLine|contains: '-enc'
  condition: selection

Detect LSASS Access (Credential Theft Indicator)

logsource:
  category: process_access
  product: windows

detection:
  selection:
    TargetImage|endswith: '\lsass.exe'
    GrantedAccess: '0x10'
  condition: selection

Detect Suspicious Service Creation

logsource:
  category: process_creation
  product: windows

detection:
  selection:
    CommandLine|contains: 'sc.exe create'
  condition: selection

How SOC Uses Sigma Rules

Sigma is used for:

  • SIEM rule creation

  • Hunting queries

  • Alert development

  • MITRE ATT&CK mapping

  • Reducing false positives

  • Detecting known patterns

  • Building playbooks

Sigma rules allow the SOC to deploy standardized detections across different SIEM platforms.


YARA vs Sigma (SOC Comparison)

YARA

  • Detects malware in files and memory

  • Used by malware analysts, DFIR, IR teams

  • Pattern-based file scanning

Sigma

  • Detects attacker behavior in logs

  • Used by SOC, detection engineers, hunters

  • SIEM query standardization

Both are essential for SOC maturity.


Detection Engineering With YARA & Sigma

Detection engineers use YARA/Sigma together:

Example Scenario — Suspicious PowerShell Infection

  1. Malware sample analyzed using YARA

    • Drops payload

    • Connects to C2

  2. Indicators extracted

  3. Sigma rule created to detect same behavior in logs

  4. SIEM rule deployed

  5. EDR behavior blocked

Detection lifecycle becomes continuous.


Advanced SOC Techniques

1. Pivoting From YARA → Sigma

Malware identified → behavior patterns extracted → Sigma rules created.

2. Mapping Sigma Rules to MITRE ATT&CK

Example:

attack.execution → T1059.001
attack.credential_access → T1003

3. Memory Hunting With YARA

Detect obfuscated implants in LSASS, svchost, explorer.

4. Sandbox Behavior → Sigma Rule

Sandbox reveals:

powershell -enc
curl malicious_url
registry persistence

All converted into Sigma.


Analyst Workflow When Using YARA / Sigma

  1. Receive suspicious sample/log

  2. Extract strings, behaviors, patterns

  3. Build YARA rule for malware detection

  4. Build Sigma rule for log-based detection

  5. Convert Sigma into SIEM queries

  6. Test and tune rules

  7. Deploy into production

  8. Monitor false positives

  9. Improve rule accuracy

  10. Document detection coverage

This workflow strengthens SOC detection capabilities.


Intel Dump

  • YARA detects malware in files and memory using string, hex, and pattern matches.

  • Sigma detects attacker behavior in logs and converts into SIEM queries.

  • YARA is used in malware analysis, DFIR, memory scanning, and sample classification.

  • Sigma is used in SIEM correlation, alerting, threat hunting, and ATT&CK mapping.

  • Both tools support detection engineering and significantly enhance SOC capabilities.

  • YARA identifies malware artifacts; Sigma identifies malicious behavior.

HOME LEARN COMMUNITY DASHBOARD