pentesting, updated
YARA
Pattern-matching engine for identifying and classifying malware by writing rules that describe its traits.
What it’s for
Scan files or running processes against rules that describe known malware families, exploit shellcode, or custom indicators of compromise.
Install
apt install yara
# curated rule sets: git clone https://github.com/Yara-Rules/rules
Common commands
yara rule.yar suspect.exe # run one rule file against one target
yara -r rules/ /mnt/evidence/ # recurse through a directory with a rule folder
yara -s rule.yar suspect.exe # print the matched strings, not just the rule name
yara -p 4 -r rules/ /mnt/evidence/ # use 4 threads for a large evidence set
Minimal rule to start from:
rule suspicious_strings {
strings:
$a = "powershell -enc" nocase
$b = { 4D 5A 90 00 } // MZ header
condition:
$a or $b
}
Useful flags
| Flag | Effect |
|---|---|
-r | Recurse into directories |
-s | Print matching strings |
-p <n> | Parallel scan threads |
-g | Print rule tags |
Notes
Rule quality decides everything — a vague string match produces noise; prefer maintained sets (Yara-Rules, Neo23x0/signature-base) over writing your own from scratch.