Communitygithub.com

Sigmaによる検知ルールの構築

Sigmaルール形式を使用して、ベンダーに依存しない検知ルールを構築します。

Sigmaによる検知ルールの構築 とは?

このスキルは、SOCエンジニアや脅威ハンターが、複数のSIEMプラットフォーム間で移植可能なベンダー非依存の検知ルールをSigma形式で作成するためのガイドです。SigmaはYAMLベースの汎用的な検知ルール記述形式であり、pySigmaライブラリを使用してSplunk SPL、Elasticsearch Lucene、Microsoft Sentinel KQLなどの様々なSIEMクエリに変換できます。ワークフローは、脅威インテリジェンスから検知ロジックを定義し、ルール構文の検証、ターゲットSIEMへの変換、MITRE ATT&CKマッピング、テスト、本番展開、CI/CD統合までの全工程をカバーします。このスキルは、検知ルールの標準化、マルチSIEM環境への移行、Threat Intelの迅速な運用化、および検知-as-aコード(Detection-as-Code)の実践に特に役立ちます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/building-detection-rules-with-sigma

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

Sigmaによる検知ルールの構築 は何をしますか?

使用すべき場面

以下の場合にこのスキルを使用してください:

  • SOCエンジニアが複数のSIEMプラットフォームで移植可能な検知ルールを作成する必要がある場合
  • 脅威インテリジェンスレポートが新たな検知カバレッジを必要とするTTPを説明している場合
  • 既存のベンダー固有ルールを共有可能な形式に標準化する必要がある場合
  • チームがCI/CDパイプラインにおける検知-as-aコードの標準としてSigmaを採用する場合

使用すべきでない場合: リアルタイムストリーミング検知(Sigmaはバッチ/スケジュール検索向け)や、ターゲットSIEMがSigmaで表現できないネイティブ検知機能(例:Splunk RBAリスクスコアリング)を持つ場合。

前提条件

  • Python 3.8+とpySigma、および適切なバックエンド(pySigma-backend-splunk、pySigma-backend-elasticsearch、pySigma-backend-microsoft365defender)
  • Sigmaルールリポジトリのクローン: git clone https://github.com/SigmaHQ/sigma.git
  • テクニックマッピングのためのMITRE ATT&CKフレームワークの知識
  • ターゲットSIEMのログソースフィールドマッピングの理解

ワークフロー

ステップ 1: 脅威インテリジェンスから検知ロジックを定義する

脅威レポートまたはATT&CKテクニックから始めます。例:Mimikatz資格情報ダンピング(T1003.001 — LSASSメモリ)の検知:

title: Mimikatz Credential Dumping via LSASS Access
id: 0d894093-71bc-43c3-8d63-bf520e73a7c5
status: stable
level: high
description: Detects process accessing lsass.exe memory, indicative of credential dumping tools like Mimikatz
references:
    - https://attack.mitre.org/techniques/T1003/001/
    - https://github.com/gentilkiwi/mimikatz
author: mahipal
date: 2024/03/15
modified: 2024/03/15
tags:
    - attack.credential_access
    - attack.t1003.001
logsource:
    category: process_access
    product: windows
detection:
    selection:
        TargetImage|endswith: '\lsass.exe'
        GrantedAccess|contains:
            - '0x1010'
            - '0x1038'
            - '0x1fffff'
            - '0x40'
    filter_main_svchost:
        SourceImage|endswith: '\svchost.exe'
    filter_main_csrss:
        SourceImage|endswith: '\csrss.exe'
    filter_main_wininit:
        SourceImage|endswith: '\wininit.exe'
    condition: selection and not 1 of filter_main_*
falsepositives:
    - Legitimate security tools accessing LSASS
    - Windows Defender scanning
    - CrowdStrike Falcon sensor

ステップ 2: Sigmaルールの構文を検証する

sigma checkを使用してルールを検証します:

# pySigmaとバリデータをインストール
pip install pySigma pySigma-validators-sigmaHQ

# ルールを検証
sigma check rule.yml

または、Pythonで検証:

from sigma.rule import SigmaRule
from sigma.validators.core import SigmaValidator

rule = SigmaRule.from_yaml(open("rule.yml").read())
validator = SigmaValidator()
issues = validator.validate_rule(rule)
for issue in issues:
    print(f"{issue.severity}: {issue.message}")

ステップ 3: ターゲットSIEMクエリに変換する

Splunk SPLに変換:

from sigma.rule import SigmaRule
from sigma.backends.splunk import SplunkBackend
from sigma.pipelines.splunk import splunk_windows_pipeline

pipeline = splunk_windows_pipeline()
backend = SplunkBackend(pipeline)

rule = SigmaRule.from_yaml(open("rule.yml").read())
splunk_query = backend.convert_rule(rule)
print(splunk_query[0])

出力:

TargetImage="*\\lsass.exe" (GrantedAccess="*0x1010*" OR GrantedAccess="*0x1038*"
OR GrantedAccess="*0x1fffff*" OR GrantedAccess="*0x40*")
NOT (SourceImage="*\\svchost.exe") NOT (SourceImage="*\\csrss.exe")
NOT (SourceImage="*\\wininit.exe")

Elasticクエリ(Lucene)に変換:

from sigma.backends.elasticsearch import LuceneBackend
from sigma.pipelines.elasticsearch import ecs_windows_pipeline

pipeline = ecs_windows_pipeline()
backend = LuceneBackend(pipeline)
elastic_query = backend.convert_rule(rule)
print(elastic_query[0])

Microsoft Sentinel KQLに変換:

from sigma.backends.microsoft365defender import Microsoft365DefenderBackend

backend = Microsoft365DefenderBackend()
kql_query = backend.convert_rule(rule)
print(kql_query[0])

ステップ 4: MITRE ATT&CKにマッピングし、カバレッジメタデータを追加する

すべてのルールにATT&CKテクニックIDをtagsフィールドでタグ付けします:

tags:
    - attack.credential_access        # 戦術
    - attack.t1003.001                # サブテクニック
    - attack.t1003                    # 親テクニック

ATT&CKナビゲーターを使用して検知カバレッジを追跡します:

import json

# SigmaルールからATT&CKナビゲーターレイヤーを生成
layer = {
    "name": "SOC検知カバレッジ",
    "versions": {"attack": "14", "navigator": "4.9", "layer": "4.5"},
    "domain": "enterprise-attack",
    "techniques": []
}

# テクニックタグについてSigmaルールディレクトリを解析
import os
from sigma.rule import SigmaRule

for root, dirs, files in os.walk("sigma/rules/windows/"):
    for f in files:
        if f.endswith(".yml"):
            rule = SigmaRule.from_yaml(open(os.path.join(root, f)).read())
            for tag in rule.tags:
                if str(tag).startswith("attack.t"):
                    technique_id = str(tag).replace("attack.", "").upper()
                    layer["techniques"].append({
                        "techniqueID": technique_id,
                        "color": "#31a354",
                        "score": 1
                    })

with open("coverage_layer.json", "w") as f:
    json.dump(layer, f, indent=2)

ステップ 5: サンプルデータに対してルールをテストする

テストデータを作成し、ルールが期待されるイベントをキャッチすることを検証します:

# sigmaテストフレームワークを使用
sigma test rule.yml --target splunk --pipeline splunk_windows

# または、サンプルデータを使用してSplunkで手動テスト
# 既知のMimikatzシグネチャを持つSysmon process_accessログをアップロード

アラートを発生させない保存検索で、7日間の本番データに対して偽陽性率を検証します。

ステップ 6: 本番SIEMにデプロイする

変換されたクエリをスケジュール検索または相関ルールとしてデプロイします:

Splunk ES相関検索:

| tstats summariesonly=true count from datamodel=Endpoint.Processes
  where Processes.process_name="*\\lsass.exe"
  by Processes.src, Processes.user, Processes.process_name, Processes.parent_process_name
| `drop_dm_object_name(Processes)`
| where count > 0

Elastic Securityルール(TOML形式):

[rule]
name = "LSASSメモリアクセス - 資格情報ダンピング"
description = "LSASSプロセスメモリへの不審なアクセスを検出します"
risk_score = 73
severity = "high"
type = "eql"
query = '''
process where event.action == "access" and
  process.name == "lsass.exe" and
  not process.executable : ("*\\svchost.exe", "*\\csrss.exe")
'''

[rule.threat]
framework = "MITRE ATT&CK"
[[rule.threat.technique]]
id = "T1003"
name = "OS資格情報ダンピング"

ステップ 7: バージョン管理とCI/CD統合

自動テスト付きでGitにルールを保存します:

# .github/workflows/sigma-ci.yml
name: SigmaルールCI
on: [push, pull_request]
jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      - run: pip install pySigma pySigma-validators-sigmaHQ
      - run: sigma check rules/
      - run: sigma convert -t splunk -p splunk_windows rules/ > /dev/null

主要な概念

用語定義
Sigmaベンダー非依存の検知ルール形式(YAMLベース)。バックエンドを介してSIEM固有のクエリにコンパイルされます
pySigmaレガシーなsigmacに代わるPythonライブラリ。ルール変換、検証、パイプラインレンダリングを行います
バックエンドSigma検知ロジックをターゲットプラットフォームのクエリ言語(SPL、KQL、Lucene)に変換するpySigmaプラグイン
パイプライン汎用的なSigmaフィールド名をSIEM固有のフィールド名に変換するフィールドマッピング設定
ログソースターゲットデータのカテゴリ(process_creation、network_connection)と製品(windows、linux)を定義するSigmaルールセクション
検知-as-a-CodeCI/CDテストと自動デプロイによってバージョン管理下で検知ルールを管理するプラクティス

ツールとシステム

  • SigmaHQ: GitHub上の公式Sigmaルールリポジトリ。コミュニティメンテナンスによる3,000以上の検知ルールを収録
  • pySigma: モジュール式バックエンドとパイプラインを備えたPythonベースのSigmaルール処理フレームワーク
  • ATT&CKナビゲーター: ATT&CKテクニックにマッピングされた検知カバレッジを可視化するMITREツール
  • Uncoder.IO: クイックトランスレーションのために30以上のSIEMプラットフォームをサポートするWebベースのSigmaルールコンバーター

一般的なシナリオ

  • 新しいCVE検知: エクスプロイト指標(例:WebログにおけるLog4Shell JNDIルックアップパターン)に対するSigmaルールを作成
  • ハンティングルールのプロモーション: アドホックなSplunkハンティングクエリを、継続的な自動検知のためのSigmaルールに変換
  • マルチSIEM移行: 500以上のSplunk相関検索をSigmaに変換し、Elastic Securityに移行
  • パープルチームの成果: レッドチームの調査結果をSigmaルールに変換し、即座に防御カバレッジを展開
  • 脅威インテリジェンスの運用化: IOCベースの脅威レポートを行動ベースのSigmaルールに変換

出力形式

SIGMAルールデプロイメントレポート
━━━━━━━━━━━━━━━━━━━━━━━━━━━
ルールID:     0d894093-71bc-43c3-8d63-bf520e73a7c5
タイトル:       Mimikatz LSASSアクセス経由の資格情報ダンピング
ATT&CK:        T1003.001 - LSASSメモリ
深刻度:        高
ステータス:     本番環境にデプロイ済み

変換:
  Splunk SPL:    成功 — 保存検索「sigma_lsass_access」を作成
  Elastic EQL:   成功 — 検知ルールID elastic-0d894093を有効化
  Sentinel KQL:  成功 — ARMテンプレートを介してAnalyticsルールをデプロイ

テスト:
  真陽性:          4/4のテストケースに一致
  偽陽性:          7日間のバックテストで2件(svchostエッジケース — フィルター追加)
  パフォーマンス:    50Mイベント/日の環境で平均実行時間3.2秒

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

関連スキル