Developing YARA Rules

1. Basic YARA Rule for UPX-packed Executables

Perform String Analysis:

strings svchost.exe

Sample 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.yar

Result:

cat htb_sample.yar

3. Manual YARA Rule Development Examples

Example 1: ZoxPNG RAT Used by APT17

  1. String Analysis:

  2. 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