YARA rule builder
Pick strings and write a condition that matches five builds of one loader and none of five clean files, including an antivirus signature database.
What you’re looking at
Pick strings and write a condition that matches five builds of one loader and none of five clean files, including an antivirus signature database.
Your goal: Build a rule that matches all five loader builds and none of the five clean files.
- Candidate strings
- the strings on the left, each with a switch and a note on what it is. Switched-on strings go into the rule.
- condition
- the text box under the strings. The buttons insert words like and, 2 of, and the MZ header check.
- Sample set
- the table on the right. One row per file with whether it is a Windows executable (MZ), its size, which strings it contains, and whether the rule matched.
- Walkthrough
- the numbered path beside the workbench (below it on a phone). Each step says what to do and what you should see. Hints open one at a time.
Words you will meet
- YARA
- a rule language for finding patterns in files
Start with step 1 in the walkthrough. Every step says what to do and what you should see. The whole thing takes about 2 min to talk through.
Briefing
Incident response pulled five builds of the same loader from three hosts. You also have five clean files from those hosts that a good rule must leave alone, including an antivirus signature database.
Choose which candidate strings go into the rule, write the condition, and scan the set. The rule is ready when it matches every loader and nothing else. Samples are modelled by the strings they contain; no binaries are involved.
Candidate strings
- Mutex name the loader creates
- Config block marker “QX7CFG”
- Drop path for the second stage
- User agent used for check-in
- Shell command prefix
- Windows system library name
5 of 5 loaders matched · 4 false positives · 0 missed
rule QX7_Loader
{
meta:
description = "QX7 loader family, lab sample set"
author = "HackBlue lab"
strings:
$mutex = "Global\\qx7-sync" ascii wide
$cfg = { 51 58 37 43 46 47 ?? 01 }
$ua = "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" ascii
$k32 = "kernel32.dll" ascii nocase
condition:
any of them
}| File | MZ | Size | Contains | Match | Truth |
|---|---|---|---|---|---|
loader_a.exe | yes | 210 KB | $mutex $cfg $path $ua $cmd $k32 | match | loader |
loader_b.exe | yes | 198 KB | $mutex $cfg $path $ua $k32 | match | loader |
loader_c.dll | yes | 240 KB | $mutex $cfg $ua $cmd $k32 | match | loader |
loader_d.exePacked build, mutex name is generated at run time | yes | 205 KB | $cfg $path $ua $k32 | match | loader |
loader_e.exeNewest build, config marker changed | yes | 221 KB | $mutex $path $ua $k32 | match | loader |
setup.exeSigned installer for a PDF reader | yes | 3.1 MB | $cmd $k32 $ua | match | clean (false positive) |
browser_helper.exe | yes | 1.2 MB | $ua $k32 | match | clean (false positive) |
notepad.exe | yes | 200 KB | $k32 | match | clean (false positive) |
av-defs.binAntivirus signature database that lists these indicators | no | 8.4 MB | $mutex $cfg $path | match | clean (false positive) |
cleanup.ps1Admin script | no | 4 KB | $cmd | no match | clean |
The whole walkthrough
Every step in order, written to be read aloud: 291 words, about 2 min. It gives away every answer, so try the steps first.