Examples
Match a known marker in record 1
Input
release=2.1.0
Expected checks
Case-insensitiveContains "public_record_1"- Rules
rule public_record_1 { strings: $marker = "release=2.1.0" condition: $marker }- Show strings
Off- Show string lengths
Off- Show metadata
Off- Show counts
On- Show rule warnings
On- Show console module messages
On
Match a known marker in record 2
Input
owner=Ada
count=3
Expected checks
Case-insensitiveContains "public_record_2"- Rules
rule public_record_2 { strings: $marker = "owner=Ada" condition: $marker }- Show strings
Off- Show string lengths
Off- Show metadata
Off- Show counts
On- Show rule warnings
On- Show console module messages
On
Match a known marker in record 3
Input
sensor=west
celsius=-12
Expected checks
Case-insensitiveContains "public_record_3"- Rules
rule public_record_3 { strings: $marker = "sensor=west" condition: $marker }- Show strings
Off- Show string lengths
Off- Show metadata
Off- Show counts
On- Show rule warnings
On- Show console module messages
On
Match a known marker in record 4
Input
Hello, archive!Expected checks
Case-insensitiveContains "public_record_4"- Rules
rule public_record_4 { strings: $marker = "Hello, archive!" condition: $marker }- Show strings
Off- Show string lengths
Off- Show metadata
Off- Show counts
On- Show rule warnings
On- Show console module messages
On
Match a known marker in record 5
Input
The Times 03/Jan/2009Expected checks
Case-insensitiveContains "public_record_5"- Rules
rule public_record_5 { strings: $marker = "The Times 03/Jan/2009" condition: $marker }- Show strings
Off- Show string lengths
Off- Show metadata
Off- Show counts
On- Show rule warnings
On- Show console module messages
On
YARA Match: compile warnings
Input
CyberChef YaraExpected answer
Warning on line 5: string "$s" may slow down scanning
Warning on line 12: string "$s" may slow down scanning
Input matches rule "a".
Input matches rule "b".
- Rules
import "console" rule a { strings: $s=" " condition: $s and console.log("log rule a") } rule b { strings: $s=" " condition: $s and console.hex("log rule b: int8(0)=", int8(0)) }- Show strings
Off- Show string lengths
Off- Show metadata
Off- Show counts
Off- Show rule warnings
On- Show console module messages
Off
YARA Match: console messages
Input
CyberChef YaraExpected answer
log rule a
log rule b: int8(0)=0x43
Input matches rule "a".
Input matches rule "b".
- Rules
import "console" rule a { strings: $s=" " condition: $s and console.log("log rule a") } rule b { strings: $s=" " condition: $s and console.hex("log rule b: int8(0)=", int8(0)) }- Show strings
Off- Show string lengths
Off- Show metadata
Off- Show counts
Off- Show rule warnings
Off- Show console module messages
On
YARA Match: hashing rules
Input
Hello World!Expected answer
Input matches rule "HelloWorldMD5".
Input matches rule "HelloWorldSHA256".
- Rules
import "hash" rule HelloWorldMD5 { condition: hash.md5(0,filesize) == "ed076287532e86365e841e92bfc50d8c" } rule HelloWorldSHA256 { condition: hash.sha256(0,filesize) == "7f83b1657ff1fc53b92dc18148a1d65dfc2d4b1fa3d677284addd200126d9069" }- Show strings
On- Show string lengths
On- Show metadata
On- Show counts
On- Show rule warnings
Off- Show console module messages
Off
YARA Match: simple foobar
Input
foobar foobar bar foo foobarExpected answer
Rule "foo" matches (4 times):
Pos 0, length 3, identifier $re1, data: "foo"
Pos 7, length 3, identifier $re1, data: "foo"
Pos 18, length 3, identifier $re1, data: "foo"
Pos 22, length 3, identifier $re1, data: "foo"
Rule "bar" matches (4 times):
Pos 3, length 3, identifier $re1, data: "bar"
Pos 10, length 3, identifier $re1, data: "bar"
Pos 14, length 3, identifier $re1, data: "bar"
Pos 25, length 3, identifier $re1, data: "bar"
- Rules
rule foo {strings: $re1 = /foo/ condition: $re1} rule bar {strings: $re1 = /bar/ condition: $re1}- Show strings
On- Show string lengths
On- Show metadata
On- Show counts
On- Show rule warnings
On- Show console module messages
On
Format reference: YARA Rules background and specification
Parameters
| Parameter | Default value | Input and choices |
|---|---|---|
| Rules | "" | Text |
| Show strings | false | On or off |
| Show string lengths | false | On or off |
| Show metadata | false | On or off |
| Show counts | true | On or off |
| Show rule warnings | true | On or off |
| Show console module messages | true | On or off |