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

FlagEffect
-rRecurse into directories
-sPrint matching strings
-p <n>Parallel scan threads
-gPrint 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.

Used in

§ home
~/knubertus/home/
1,1 Top