Rule

PowerShell rule + sample Web-shell rule + sample Hex match (PE header) Exfil URL pattern

Input

Supported Syntax (YARA subset)

ElementSyntaxExample
Rulerule NAME { meta: ... strings: ... condition: ... }rule MalDoc { ... }
Meta key=valuekey = "value" or key = numberseverity = "high"
Text string$id = "literal" + optional modifier$s1 = "FromBase64" nocase
Hex string$id = { XX XX ?? XX } (?? = wildcard byte)$mz = { 4D 5A 90 00 ?? ?? FF }
Regex string$id = /pattern/ + optional flags$r = /[a-z0-9]{32}/ nocase
String modifiersnocase, wide, ascii$x = "admin" nocase wide
Condition: presence$id (true if matches at least once)$s1
Condition: count#id > N or #id == N#enc > 2
Condition: any/all ofany of (...), all of (...), N of (...)3 of ($a, $b, $c, $d)
Condition: any/all of themany of them, all of themany of them
Logical operatorsand, or, not($a and $b) or $c
Wildcard ID setany of ($s*)2 of ($evil*)
Comments// line or /* block */// detection note
Not real YARA-X. This is a faithful-syntax browser-side matcher for the most common YARA features. Modules (pe, math, hash), filesize, and external variables are NOT supported. For full YARA functionality use the native runtime.
All sample patterns and inputs are synthetic. RFC 5737 / 1918 IPs, *.example.com hosts.