Developing YARA Rules
1. Basic YARA Rule for UPX-packed Executables
Perform String Analysis:
strings svchost.exeSample YARA Rule:
rule UPX_packed_executable {
meta:
description = "Detects UPX-packed executables"
strings:
$string_1 = "UPX0"
$string_2 = "UPX1"
$string_3 = "UPX2"
condition:
all of them
}2. Generating a YARA Rule with yarGen
Command:
python3 yarGen.py -m /home/htb-student/temp -o htb_sample.yarResult:
cat htb_sample.yar3. Manual YARA Rule Development Examples
Example 1: ZoxPNG RAT Used by APT17
String Analysis:
Calculate Imphash:
APT17 YARA Rule:
Example 2: Neuron Used by Turla
Reverse Engineering with monodis:
Neuron Service YARA Rule:
Example 3: Stonedrill Used in Shamoon 2.0 Attacks
Entropy Analysis:
Stonedrill YARA Rule:
Resources for YARA Rule Development
Official Documentation: YARA Documentation
Kaspersky Guide: Effective YARA Rule Development
Last updated