Skip to main content

17. Building Reversing Signatures with YARA Rules

YARA is a tool for declaratively matching patterns in binaries and memory dumps. During reversing, it is useful for quickly tagging which version a function belongs to or which family a sample comes from.

Key points

  • Mix byte sequences and wildcards in strings to reduce noise.
  • Add context conditions such as filesize, pe.is_pe, and uint16(0)==0x5A4D in condition.
  • To distinguish versions, combine a short shared pattern with one or two unique patterns.

Minimal rule example

rule fast_tag {
strings:
$s1 = "XOR_KEY" ascii
$b1 = { 55 48 89 E5 ?? ?? 5D }
condition:
uint16(0)==0x5A4D and 1 of ($s*) and $b1
}

Practical tip

Split rules into many small units, log their false-positive rates, and tune them. This sharply accelerates both CTF and incident-response work.