Post 87 - Message in a bottle(s)

26 Dec 2025

Day 13 YARA Rules YARA mean one!

When to use YARA

YARA Values

YARA Rules

Built from several key elements:

Text strings

Simplest and most common type of string in YARA rules. represents words or short fragments within a file, script, or memory. Default treatment is case-sensitive ASCII but can use modifiers after the definition. Example:

rule text_string_sample
{
    strings:
        $string1 = "Word"

    condition:
        $string1
}

Modifiers can be used to counter uncertainty and attacker use of encoding, case tricks, and even encryption as obfuscation methods.

Hexadecimal strings

YARA can search for specific byte patterns in hex notation, useful for detecting malware fragments like file headers, shellcode, or binary signatures that can’t be plain text. Example:

rule hex_string_sample
{
    strings:
        $mz = { 4D 5A 90 00 } // MZ header of a windows exe
        $hex_string = { E3 41 ?? C8 G? VB }
    
    condition:
        $mz and $hex_string
}

Regex strings

Allows flexible search patterns that can match multiple variations of the same malicious string. Especially useful for URLs, encoded commands, and filenames that share a structure but are slightly different. Very powerful but should be used carefully because too broad a definition can match a wide range of data and slow down scans. Example:

rule regex_string_sample
{
    strings:
        $url = /http:\/\/.*malware.*/ nocase
        $cmd = /powershell/*-enc\s+[A-Za-z0-9+/+]+/ nocase
    
    condition:
        $url and $cmd
}

Conditions

The Task

Create a rule based on the playbook to find a secret message from McSkidy. Would have been much easier if I had entered the one character I thought I had. No recommended stuff with the room.