الفرق الزرقاء — الدفاعخبير110mL78
هندسة الكشف وSIEM — Sigma و KQL و Splunk
كتابة قواعد الكشف، تخفيض الإيجابيات الكاذبة، تغطية ATT&CK
#SIEM#Sigma#KQL#Splunk#Detection
ما الذي يميز detection engineer عن SOC analyst؟
تشبيه — شرح مبسط
المحلل (analyst) هو الحارس الذي يستجيب للإنذارات. مهندس الكشف هو الذي يصمم نظام الإنذارات نفسه: يقرر متى يطن الجرس، ومتى يصمت، وأي فناء يحتاج كاميرا أكثر. السؤال الأهم لمهندس الكشف ليس "هل المهاجم هنا؟" بل "لو دخل، هل سأراه؟"
Detection Engineering = كتابة قواعد كشف، اختبارها، قياس تغطيتها على ATT&CK، وضبطها لتقليل false positives دون فقدان true positives. هذا هو فرق الـ blue team الناضج عن SOC رد الفعل.
دورة حياة قاعدة كشف
01
Hypothesis
"المهاجم يفرّغ LSASS عبر comsvcs.dll" — افتراض محدد، مرتبط بـ ATT&CK technique (T1003.001).
02
Data source
ما اللوغ الذي سيكشف هذا؟ Sysmon Event ID 10 (Process Access). تأكد أنه فعلاً مفعل ويتدفق إلى الـ SIEM.
03
Detection logic
صياغة باستعلام SIEM. ابدأ بسيطاً، شدّد حسب الـ noise.
04
Validation
اختبر مع Atomic Red Team أو CALDERA. قاعدة لا تطلق على هجوم حقيقي = قاعدة ميتة.
05
Tuning
راقب FP rate لمدة أسبوع. إذا فاق 5/يوم، شدّد فلتر السياق.
06
Documentation
سجل الـ ATT&CK ID، assumption، known FPs، playbook للاستجابة. القاعدة بدون runbook لا قيمة لها.
Sigma — معيار قواعد الكشف
Sigma هو YAML format محايد عن SIEM. اكتب القاعدة مرة، ترجمها إلى Splunk SPL أو KQL أو Elasticsearch عبر sigmac.
yaml
title: LSASS Memory Dump via comsvcs.dll
id: a8e2d456-1234-5678-9abc-def012345678
status: stable
description: Detects MiniDump of LSASS using rundll32 and comsvcs.dll
references:
- https://attack.mitre.org/techniques/T1003/001/
author: Detection Eng Team
date: 2026/01/15
tags:
- attack.credential_access
- attack.t1003.001
logsource:
product: windows
service: sysmon
detection:
selection_proc:
EventID: 10
TargetImage|endswith: '\lsass.exe'
selection_caller:
SourceImage|endswith: '\rundll32.exe'
CallTrace|contains: 'comsvcs.dll'
condition: selection_proc and selection_caller
falsepositives:
- Microsoft tools that legitimately call MiniDumpWriteDump (rare)
level: highKQL — Microsoft Defender / Sentinel
kusto
// Same hypothesis in KQL against DeviceProcessEvents
DeviceProcessEvents
| where Timestamp > ago(7d)
| where FileName == "rundll32.exe"
| where ProcessCommandLine has_all ("comsvcs.dll", "MiniDump")
| where ProcessCommandLine has "lsass" or ProcessCommandLine matches regex @"\b\d{3,5}\b"
| project Timestamp, DeviceName, AccountName, ProcessCommandLine, InitiatingProcessFileName
| sort by Timestamp desc
// Pivot: who logged on to that host before the dump?
DeviceLogonEvents
| where DeviceName == "WS-EXEC-04"
| where Timestamp between ((ago(2h)) .. (now()))
| project Timestamp, AccountName, LogonType, RemoteIPSplunk SPL
spl
index=sysmon EventCode=10 TargetImage="*\\lsass.exe"
| where match(SourceImage,"rundll32\.exe")
| where match(CallTrace,"comsvcs\.dll")
| stats count by host, SourceImage, GrantedAccess, _time
| where count > 0
// Hunting variant: any process that accessed LSASS with high rights
index=sysmon EventCode=10 TargetImage="*lsass.exe" GrantedAccess IN (0x1010, 0x1410, 0x1438)
| stats values(SourceImage) as accessors, count by host
| where count > 5تقليل False Positives
ثلاث تقنيات أساسية:
السياق Process Lineage
هل rundll32 أُطلق من cmd مرتبط بـ session تفاعلي؟ هذا أكثر إثارة للقلق من خدمة تشغّل rundll32.
Allow-list معروف
EDR vendor قد يحقن أداة legitimate تقرأ LSASS. ضعها في الـ allow list مع توقيع الناشر.
Threshold و time-window
لو تكنولوجيا تقوم بدفعة admin، ستطلق 50 alert في دقيقة. اجمعها في incident واحد.
قياس التغطية — ATT&CK Navigator
لوّن مصفوفة ATT&CK بحسب ما تكشفه قواعدك. النتيجة = خريطة "ما تراه" مقابل "ما يفعله المهاجم". فجوة تكشف الأولوية التالية.
$ # تصدير coverage matrix إلى ATT&CK Navigator JSON
$ python attack-navigator-export.py --rules /detections/*.yml -o coverage.json
Coverage report:
TA0001 Initial Access: 17/22 techniques (77%)
TA0003 Persistence: 14/19 techniques (73%)
TA0006 Credential Access: 9/16 techniques (56%) <-- weak
TA0011 Command & Control: 11/16 techniques (68%)
مبادئ مهندس الكشف
- True Positive Rate > Coverage: قاعدة واحدة تعمل أفضل من 100 قاعدة بـ 95% FP
- Detect by behavior, not by IoC: signature لـ hash يموت في يوم؛ سلوك LSASS access يبقى
- Test كل قاعدة: Atomic Red Team أو CALDERA يومياً
- Versioning: قواعدك في git، code review، تاريخ تعديل
- كل alert = runbook: ماذا يفعل المحلل في أول 5 دقائق؟
مصادر
- Sigma Project — github.com/SigmaHQ/sigma
- Atomic Red Team — Red Canary
- The DFIR Report — حالات حقيقية + queries
- SpecterOps — Detection Engineering Methodology
- Florian Roth blog — Sigma و detection engineering