Lion Cipher Lab
Run a corpus-scale retrohunt with YARA-X — hunt a family across hundreds of files and measure precision, recall, and scan throughput
- Threat Intel Analyst
- Advanced
- ~90 min
- Free · no account required
Why it matters
Writing one good rule is table stakes; the job is running it against history. When a family is attributed, when a new IOC lands, when a rule finally generalizes, the question a threat-intel team actually asks is 'how many of these did we already have, and where?' — and answering it means a RETROHUNT: pointing the rule at a large historical corpus of files and finding every past sample. That is a different problem from the one the prerequisite lab solved. At corpus scale a rule that missed one variant in a 7-file test now misses hundreds of real samples (a recall problem you cannot see from a…
What you'll learn
- what a RETROHUNT actually is — scanning a large historical corpus with a rule to surface every past sample of a family — and why it is an operation, not a single scan
- installing and running YARA-X (`yr`), the Rust rewrite of YARA, and the CLI/behavioral differences from classic `yara` that will bite you: `--recursive` not `-r`, stricter regex parsing, the console module, and real per-rule profiling
- programmatically generating a large, reproducible, LABELLED test corpus with a shell loop — a 40-variant synthetic family, goodware lookalikes engineered to bait false positives, unrelated noise, and oversized blob files — so the retrohunt runs at realistic volume
- measuring a retrohunt with PRECISION = TP/(TP+FP) and RECALL = TP/(TP+FN), computed from the labels — the two numbers that actually describe a hunt, not a raw match count
- profiling RULE PERFORMANCE at scale: showing that an unbounded-regex, no-filesize-guard rule makes a corpus scan slow, that a tuned rule stays fast, and that at retrohunt volume a slow rule is a measurable operational cost
- the operational FALSE-POSITIVE TRIAGE loop: when the hunt lights up on goodware, confirm/deny each hit, tighten the rule around the durable trait (the code stub), and RE-MEASURE precision
- the named failure modes AT SCALE: rule too tight (low recall — misses variants), rule too loose (FP storm — unusable precision), no filesize/type guard (pathological scans), regex catastrophic backtracking, and treating one corpus's precision as production truth
- the judgment: retrohunt precision measured on YOUR corpus is OPTIMISTIC because production goodware is far more diverse, and on the Pyramid of Pain a string-family rule is cheap for the adversary to break — so a retrohunt is a hunting tool, not a durable control
Steps in this lab
- What a retrohunt is, and why YARA-X (not classic yara) for it
- Install the YARA-X `yr` CLI
- Generate a labelled corpus at realistic volume
- Write the generalizing rule and run the first retrohunt
- Measure the hunt: precision and recall
- Triage the false positives and tighten — then re-measure
- Profile the rule: throughput is a real cost at retrohunt scale
- The named failure modes — at scale this time
- Judgment: your precision is optimistic, and a retrohunt is not a control
- The way a pro runs a retrohunt — and what you built