YARA lets you describe malware by patterns - strings and byte sequences - and then scan files, memory or processes for matches. It's the workhorse of malware classification and IOC hunting.
Anatomy of a rule
rule Suspicious_Downloader {
meta:
author = "NexurAI"
description = "Example: certutil download cradle"
strings:
$a = "certutil" nocase
$b = "-urlcache" nocase
$c = { 68 74 74 70 3A 2F 2F } // "http://" in hex
condition:
$a and $b and $c
}
- strings - text (
$a = "..."), hex byte patterns ({ 4D 5A }= "MZ"), or regex. - condition - the boolean logic:
$a and $b,2 of them,all of ($s*), plus file properties (filesize,uint16(0) == 0x5A4Dfor PE files).
Where it's used
- Malware analysis - classify samples into families.
- Threat hunting - scan hosts/memory for known-bad patterns (Loki, THOR, Velociraptor all run YARA).
- Detection pipelines - flag files at the gateway or endpoint.
Write good rules
Anchor on stable, meaningful strings (unique code, C2 markers) - not generic ones that cause false positives. Combine several weak signals with N of them for balance, and always test against a clean corpus so precision stays high.
