Skip to content

Commit 9fe3876

Browse files
ExampleRule.yara rule
1 parent 23dba5b commit 9fe3876

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
Rules are generally composed of two sections: strings definition and condition.
3+
The strings definition section can be omitted if the rule doesn't rely on any string,
4+
but the condition section is always required. The strings definition section is where
5+
the strings that will be part of the rule are defined. Each string has an identifier
6+
consisting of a $ character followed by a sequence of alphanumeric characters and underscores,
7+
these identifiers can be used in the condition section to refer to the corresponding string.
8+
Strings can be defined in text or hexadecimal form, as shown in the following example:
9+
*/
10+
rule ExampleRule
11+
{
12+
strings:
13+
$my_text_string = "text here"
14+
$my_hex_string = { E2 34 A1 C8 23 FB }
15+
16+
condition:
17+
$my_text_string or $my_hex_string
18+
}
19+
/*
20+
Text strings are enclosed in double quotes just like in the C language.
21+
Hex strings are enclosed by curly brackets, and they are composed by a sequence of hexadecimal numbers
22+
that can appear contiguously or separated by spaces. Decimal numbers are not allowed in hex strings.
23+
24+
The condition section is where the logic of the rule resides. This section must contain a boolean
25+
expression telling under which circumstances a file or process satisfies the rule or not.
26+
Generally, the condition will refer to previously defined strings by using their identifiers.
27+
In this context the string identifier acts as a boolean variable which evaluate to true if the string
28+
was found in the file or process memory, or false if otherwise.
29+
*/

0 commit comments

Comments
 (0)