| 1 |
<!DOCTYPE html> |
| 2 |
<html><head> |
| 3 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> |
| 4 |
<title>test.yara</title> |
| 5 |
<meta name="generator" content="KF5::SyntaxHighlighting - Definition (YARA) - Theme (Breeze Light)"/> |
| 6 |
</head><body style="background-color:#ffffff;color:#1f1c1b"><pre> |
| 7 |
<span style="color:#898887;">// Sample YARA file for Syntax Highlighting</span> |
| 8 |
<span style="color:#898887;">// Obtained from: https://yara.readthedocs.io/en/stable/writingrules.html</span> |
| 9 |
|
| 10 |
<span style="color:#898887;">/*</span> |
| 11 |
<span style="color:#898887;"> This is a multi-line comment ...</span> |
| 12 |
<span style="color:#898887;">*/</span> |
| 13 |
|
| 14 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">silent_banker</span> : banker |
| 15 |
{ |
| 16 |
<span style="font-weight:bold;">meta</span>: |
| 17 |
description = <span style="color:#bf0303;">"This is just an example"</span> |
| 18 |
threat_level = <span style="color:#b08000;">3</span> |
| 19 |
in_the_wild = <span style="color:#aa5500;">true</span> |
| 20 |
<span style="font-weight:bold;">strings</span>: |
| 21 |
<span style="color:#0057ae;">$a</span> = {<span style="color:#ff5500;">6A 40 68 00 30 00 00 6A 14 8D 91</span>} |
| 22 |
<span style="color:#0057ae;">$b</span> = {<span style="color:#ff5500;">8D 4D B0 2B C1 83 C0 27 99 6A 4E 59 F7 F9</span>} |
| 23 |
<span style="color:#0057ae;">$c</span> = <span style="color:#bf0303;">"UVODFRYSIHLNWPEJXQZAKCBGMT"</span> |
| 24 |
<span style="font-weight:bold;">condition</span>: |
| 25 |
<span style="color:#0057ae;">$a</span> <span style="font-weight:bold;">or</span> <span style="color:#0057ae;">$b</span> <span style="font-weight:bold;">or</span> <span style="color:#0057ae;">$c</span> |
| 26 |
} |
| 27 |
|
| 28 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">dummy</span> |
| 29 |
{ |
| 30 |
<span style="font-weight:bold;">condition</span>: |
| 31 |
<span style="color:#aa5500;">false</span> |
| 32 |
} |
| 33 |
|
| 34 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">ExampleRule</span> |
| 35 |
{ |
| 36 |
<span style="font-weight:bold;">strings</span>: |
| 37 |
<span style="color:#0057ae;">$my_text_string</span> = <span style="color:#bf0303;">"text here"</span> |
| 38 |
<span style="color:#0057ae;">$my_hex_string</span> = {<span style="color:#ff5500;"> E2 34 A1 C8 23 FB </span>} |
| 39 |
|
| 40 |
<span style="font-weight:bold;">condition</span>: |
| 41 |
<span style="color:#0057ae;">$my_text_string</span> <span style="font-weight:bold;">or</span> <span style="color:#0057ae;">$my_hex_string</span> |
| 42 |
} |
| 43 |
|
| 44 |
<span style="color:#898887;">// Hexadecimal strings</span> |
| 45 |
|
| 46 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">WildcardExample</span> |
| 47 |
{ |
| 48 |
<span style="font-weight:bold;">strings</span>: |
| 49 |
<span style="color:#0057ae;">$hex_string</span> = {<span style="color:#ff5500;"> E2 34 ?? C8 A? FB </span>} |
| 50 |
|
| 51 |
<span style="font-weight:bold;">condition</span>: |
| 52 |
<span style="color:#0057ae;">$hex_string</span> |
| 53 |
} |
| 54 |
|
| 55 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">JumpExample</span> |
| 56 |
{ |
| 57 |
<span style="font-weight:bold;">strings</span>: |
| 58 |
<span style="color:#0057ae;">$hex_string</span> = {<span style="color:#ff5500;"> F4 23 </span>[<span style="color:#b08000;">4</span>-<span style="color:#b08000;">6</span>]<span style="color:#ff5500;"> 62 B4 </span>} |
| 59 |
|
| 60 |
<span style="font-weight:bold;">condition</span>: |
| 61 |
<span style="color:#0057ae;">$hex_string</span> |
| 62 |
} |
| 63 |
|
| 64 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">AlternativesExample</span> |
| 65 |
{ |
| 66 |
<span style="font-weight:bold;">strings</span>: |
| 67 |
<span style="color:#0057ae;">$hex_string</span> = {<span style="color:#ff5500;"> F4 23 </span>(<span style="color:#ff5500;"> 62 B4 </span>|<span style="color:#ff5500;"> 56 </span>|<span style="color:#ff5500;"> 45 ?? 67 </span>)<span style="color:#ff5500;"> 45 </span>} |
| 68 |
|
| 69 |
<span style="font-weight:bold;">condition</span>: |
| 70 |
<span style="color:#0057ae;">$hex_string</span> |
| 71 |
} |
| 72 |
|
| 73 |
<span style="color:#898887;">// Text strings</span> |
| 74 |
|
| 75 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">CaseInsensitiveTextExample</span> |
| 76 |
{ |
| 77 |
<span style="font-weight:bold;">strings</span>: |
| 78 |
<span style="color:#0057ae;">$text_string</span> = <span style="color:#bf0303;">"foobar"</span> <span style="font-weight:bold;">nocase</span> |
| 79 |
|
| 80 |
<span style="font-weight:bold;">condition</span>: |
| 81 |
<span style="color:#0057ae;">$text_string</span> |
| 82 |
} |
| 83 |
|
| 84 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">WideCharTextExample</span> |
| 85 |
{ |
| 86 |
<span style="font-weight:bold;">strings</span>: |
| 87 |
<span style="color:#0057ae;">$wide_and_ascii_string</span> = <span style="color:#bf0303;">"Borland"</span> <span style="font-weight:bold;">wide</span> <span style="font-weight:bold;">ascii</span> |
| 88 |
|
| 89 |
<span style="font-weight:bold;">condition</span>: |
| 90 |
<span style="color:#0057ae;">$wide_and_ascii_string</span> |
| 91 |
} |
| 92 |
|
| 93 |
<span style="color:#898887;">// XOR strings</span> |
| 94 |
|
| 95 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">XorExample1</span> |
| 96 |
{ |
| 97 |
<span style="font-weight:bold;">strings</span>: |
| 98 |
<span style="color:#0057ae;">$xor_string</span> = <span style="color:#bf0303;">"This program cannot"</span> <span style="font-weight:bold;">xor</span> |
| 99 |
|
| 100 |
<span style="font-weight:bold;">condition</span>: |
| 101 |
<span style="color:#0057ae;">$xor_string</span> |
| 102 |
} |
| 103 |
|
| 104 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">XorExample2</span> |
| 105 |
{ |
| 106 |
<span style="font-weight:bold;">strings</span>: |
| 107 |
<span style="color:#0057ae;">$xor_string_00</span> = <span style="color:#bf0303;">"This program cannot"</span> |
| 108 |
<span style="color:#0057ae;">$xor_string_01</span> = <span style="color:#bf0303;">"Uihr!qsnfs`l!b`oonu"</span> |
| 109 |
<span style="color:#0057ae;">$xor_string_02</span> = <span style="color:#bf0303;">"Vjkq</span><span style="color:#3daee9;">\"</span><span style="color:#bf0303;">rpmepco</span><span style="color:#3daee9;">\"</span><span style="color:#bf0303;">acllmv"</span> |
| 110 |
<span style="color:#898887;">// Repeat for every single byte XOR</span> |
| 111 |
<span style="font-weight:bold;">condition</span>: |
| 112 |
<span style="font-weight:bold;">any</span> <span style="font-weight:bold;">of</span> <span style="font-weight:bold;">them</span> |
| 113 |
} |
| 114 |
|
| 115 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">XorExample3</span> |
| 116 |
{ |
| 117 |
<span style="font-weight:bold;">strings</span>: |
| 118 |
<span style="color:#0057ae;">$xor_string</span> = <span style="color:#bf0303;">"This program cannot"</span> <span style="font-weight:bold;">xor</span> <span style="font-weight:bold;">wide</span> <span style="font-weight:bold;">ascii</span> |
| 119 |
<span style="font-weight:bold;">condition</span>: |
| 120 |
<span style="color:#0057ae;">$xor_string</span> |
| 121 |
} |
| 122 |
|
| 123 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">XorExample4</span> |
| 124 |
{ |
| 125 |
<span style="font-weight:bold;">strings</span>: |
| 126 |
<span style="color:#0057ae;">$xor_string_00</span> = <span style="color:#bf0303;">"T</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">h</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">i</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">s</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;"> </span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">p</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">r</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">o</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">g</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">r</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">a</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">m</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;"> </span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">c</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">a</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">n</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">n</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">o</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">t</span><span style="color:#3daee9;">\x00</span><span style="color:#bf0303;">"</span> |
| 127 |
<span style="color:#0057ae;">$xor_string_01</span> = <span style="color:#bf0303;">"U</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">i</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">h</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">r</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">!</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">q</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">s</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">n</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">f</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">s</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">`</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">l</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">!</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">b</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">`</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">o</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">o</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">n</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">u</span><span style="color:#3daee9;">\x01</span><span style="color:#bf0303;">"</span> |
| 128 |
<span style="color:#0057ae;">$xor_string_02</span> = <span style="color:#bf0303;">"V</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">j</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">k</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">q</span><span style="color:#3daee9;">\x02\"\x02</span><span style="color:#bf0303;">r</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">p</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">m</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">e</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">p</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">c</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">o</span><span style="color:#3daee9;">\x02\"\x02</span><span style="color:#bf0303;">a</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">c</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">l</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">l</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">m</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">v</span><span style="color:#3daee9;">\x02</span><span style="color:#bf0303;">"</span> |
| 129 |
<span style="color:#898887;">// Repeat for every single byte XOR operation.</span> |
| 130 |
<span style="font-weight:bold;">condition</span>: |
| 131 |
<span style="font-weight:bold;">any</span> <span style="font-weight:bold;">of</span> <span style="font-weight:bold;">them</span> |
| 132 |
} |
| 133 |
|
| 134 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">XorExample5</span> |
| 135 |
{ |
| 136 |
<span style="font-weight:bold;">strings</span>: |
| 137 |
<span style="color:#0057ae;">$xor_string</span> = <span style="color:#bf0303;">"This program cannot"</span> <span style="font-weight:bold;">xor</span>(<span style="color:#b08000;">0x01</span>-<span style="color:#b08000;">0xff</span>) |
| 138 |
<span style="font-weight:bold;">condition</span>: |
| 139 |
<span style="color:#0057ae;">$xor_string</span> |
| 140 |
} |
| 141 |
|
| 142 |
<span style="color:#898887;">// Base64 strings</span> |
| 143 |
|
| 144 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">Base64Example1</span> |
| 145 |
{ |
| 146 |
<span style="font-weight:bold;">strings</span>: |
| 147 |
<span style="color:#0057ae;">$a</span> = <span style="color:#bf0303;">"This program cannot"</span> <span style="font-weight:bold;">base64</span> |
| 148 |
|
| 149 |
<span style="font-weight:bold;">condition</span>: |
| 150 |
<span style="color:#0057ae;">$a</span> |
| 151 |
} |
| 152 |
|
| 153 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">Base64Example2</span> |
| 154 |
{ |
| 155 |
<span style="font-weight:bold;">strings</span>: |
| 156 |
<span style="color:#0057ae;">$a</span> = <span style="color:#bf0303;">"This program cannot"</span> <span style="font-weight:bold;">base64</span>(<span style="color:#bf0303;">"!@#$%^&*(){}[].,|ABCDEFGHIJ</span><span style="color:#3daee9;">\x09</span><span style="color:#bf0303;">LMNOPQRSTUVWXYZabcdefghijklmnopqrstu"</span>) |
| 157 |
|
| 158 |
<span style="font-weight:bold;">condition</span>: |
| 159 |
<span style="color:#0057ae;">$a</span> |
| 160 |
} |
| 161 |
|
| 162 |
<span style="color:#898887;">// Regular expressions</span> |
| 163 |
|
| 164 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">RegExpExample1</span> |
| 165 |
{ |
| 166 |
<span style="font-weight:bold;">strings</span>: |
| 167 |
<span style="color:#0057ae;">$re1</span> = <span style="color:#ff5500;">/</span><span style="color:#ff5500;">md5: </span><span style="color:#3daee9;">[0-9a-fA-F]</span><span style="color:#3daee9;">{32}</span><span style="color:#ff5500;">/</span> |
| 168 |
<span style="color:#0057ae;">$re2</span> = <span style="color:#ff5500;">/</span><span style="color:#ff5500;">state: </span><span style="color:#3daee9;">(</span><span style="color:#ff5500;">on</span><span style="color:#3daee9;">|</span><span style="color:#ff5500;">off</span><span style="color:#3daee9;">)</span><span style="color:#ff5500;">/</span> |
| 169 |
|
| 170 |
<span style="font-weight:bold;">condition</span>: |
| 171 |
<span style="color:#0057ae;">$re1</span> <span style="font-weight:bold;">and</span> <span style="color:#0057ae;">$re2</span> |
| 172 |
} |
| 173 |
|
| 174 |
<span style="color:#898887;">// Conditions</span> |
| 175 |
|
| 176 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">Example</span> |
| 177 |
{ |
| 178 |
<span style="font-weight:bold;">strings</span>: |
| 179 |
<span style="color:#0057ae;">$a</span> = <span style="color:#bf0303;">"text1"</span> |
| 180 |
<span style="color:#0057ae;">$b</span> = <span style="color:#bf0303;">"text2"</span> |
| 181 |
<span style="color:#0057ae;">$c</span> = <span style="color:#bf0303;">"text3"</span> |
| 182 |
<span style="color:#0057ae;">$d</span> = <span style="color:#bf0303;">"text4"</span> |
| 183 |
|
| 184 |
<span style="font-weight:bold;">condition</span>: |
| 185 |
(<span style="color:#0057ae;">$a</span> <span style="font-weight:bold;">or</span> <span style="color:#0057ae;">$b</span>) <span style="font-weight:bold;">and</span> (<span style="color:#0057ae;">$c</span> <span style="font-weight:bold;">or</span> <span style="color:#0057ae;">$d</span>) |
| 186 |
} |
| 187 |
|
| 188 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">CountExample</span> |
| 189 |
{ |
| 190 |
<span style="font-weight:bold;">strings</span>: |
| 191 |
<span style="color:#0057ae;">$a</span> = <span style="color:#bf0303;">"dummy1"</span> |
| 192 |
<span style="color:#0057ae;">$b</span> = <span style="color:#bf0303;">"dummy2"</span> |
| 193 |
|
| 194 |
<span style="font-weight:bold;">condition</span>: |
| 195 |
#a == <span style="color:#b08000;">6</span> <span style="font-weight:bold;">and</span> #b > <span style="color:#b08000;">10</span> |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">AtExample</span> |
| 200 |
{ |
| 201 |
<span style="font-weight:bold;">strings</span>: |
| 202 |
<span style="color:#0057ae;">$a</span> = <span style="color:#bf0303;">"dummy1"</span> |
| 203 |
<span style="color:#0057ae;">$b</span> = <span style="color:#bf0303;">"dummy2"</span> |
| 204 |
|
| 205 |
<span style="font-weight:bold;">condition</span>: |
| 206 |
<span style="color:#0057ae;">$a</span> <span style="font-weight:bold;">at</span> <span style="color:#b08000;">100</span> <span style="font-weight:bold;">and</span> <span style="color:#0057ae;">$b</span> <span style="font-weight:bold;">at</span> <span style="color:#b08000;">200</span> |
| 207 |
} |
| 208 |
|
| 209 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">InExample</span> |
| 210 |
{ |
| 211 |
<span style="font-weight:bold;">strings</span>: |
| 212 |
<span style="color:#0057ae;">$a</span> = <span style="color:#bf0303;">"dummy1"</span> |
| 213 |
<span style="color:#0057ae;">$b</span> = <span style="color:#bf0303;">"dummy2"</span> |
| 214 |
|
| 215 |
<span style="font-weight:bold;">condition</span>: |
| 216 |
<span style="color:#0057ae;">$a</span> <span style="font-weight:bold;">in</span> (<span style="color:#b08000;">0..100</span>) <span style="font-weight:bold;">and</span> <span style="color:#0057ae;">$b</span> <span style="font-weight:bold;">in</span> (<span style="color:#b08000;">100.</span>.<span style="font-weight:bold;">filesize</span>) |
| 217 |
} |
| 218 |
|
| 219 |
<span style="color:#898887;">// File size</span> |
| 220 |
|
| 221 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">FileSizeExample</span> |
| 222 |
{ |
| 223 |
<span style="font-weight:bold;">condition</span>: |
| 224 |
<span style="font-weight:bold;">filesize</span> > <span style="color:#b08000;">200</span>KB |
| 225 |
} |
| 226 |
|
| 227 |
<span style="color:#898887;">// Executable entry point</span> |
| 228 |
|
| 229 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">EntryPointExample</span> |
| 230 |
{ |
| 231 |
<span style="font-weight:bold;">strings</span>: |
| 232 |
<span style="color:#0057ae;">$a</span> = {<span style="color:#ff5500;"> 9C 50 66 A1 ?? ?? ?? 00 66 A9 ?? ?? 58 0F 85 </span>} |
| 233 |
|
| 234 |
<span style="font-weight:bold;">condition</span>: |
| 235 |
<span style="color:#0057ae;">$a</span> <span style="font-weight:bold;">in</span> (<span style="font-weight:bold;">entrypoint</span>..<span style="font-weight:bold;">entrypoint</span> + <span style="color:#b08000;">10</span>) |
| 236 |
} |
| 237 |
|
| 238 |
|
| 239 |
<span style="color:#898887;">// Accessing data at a given position</span> |
| 240 |
|
| 241 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">IsPE</span> |
| 242 |
{ |
| 243 |
<span style="font-weight:bold;">condition</span>: |
| 244 |
<span style="color:#898887;">// MZ signature at offset 0 and ...</span> |
| 245 |
<span style="font-weight:bold;">uint16</span>(<span style="color:#b08000;">0</span>) == <span style="color:#b08000;">0x5A4D</span> <span style="font-weight:bold;">and</span> |
| 246 |
<span style="color:#898887;">// ... PE signature at offset stored in MZ header at 0x3C</span> |
| 247 |
<span style="font-weight:bold;">uint32</span>(<span style="font-weight:bold;">uint32</span>(<span style="color:#b08000;">0x3C</span>)) == <span style="color:#b08000;">0x00004550</span> |
| 248 |
} |
| 249 |
|
| 250 |
<span style="color:#898887;">// Sets of strings</span> |
| 251 |
|
| 252 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">OfExample1</span> |
| 253 |
{ |
| 254 |
<span style="font-weight:bold;">strings</span>: |
| 255 |
<span style="color:#0057ae;">$a</span> = <span style="color:#bf0303;">"dummy1"</span> |
| 256 |
<span style="color:#0057ae;">$b</span> = <span style="color:#bf0303;">"dummy2"</span> |
| 257 |
<span style="color:#0057ae;">$c</span> = <span style="color:#bf0303;">"dummy3"</span> |
| 258 |
|
| 259 |
<span style="font-weight:bold;">condition</span>: |
| 260 |
<span style="color:#b08000;">2</span> <span style="font-weight:bold;">of</span> (<span style="color:#0057ae;">$a</span>,<span style="color:#0057ae;">$b</span>,<span style="color:#0057ae;">$c</span>) |
| 261 |
} |
| 262 |
|
| 263 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">OfExample2</span> |
| 264 |
{ |
| 265 |
<span style="font-weight:bold;">strings</span>: |
| 266 |
<span style="color:#0057ae;">$foo1</span> = <span style="color:#bf0303;">"foo1"</span> |
| 267 |
<span style="color:#0057ae;">$foo2</span> = <span style="color:#bf0303;">"foo2"</span> |
| 268 |
<span style="color:#0057ae;">$foo3</span> = <span style="color:#bf0303;">"foo3"</span> |
| 269 |
|
| 270 |
<span style="font-weight:bold;">condition</span>: |
| 271 |
<span style="color:#b08000;">2</span> <span style="font-weight:bold;">of</span> (<span style="color:#0057ae;">$foo</span>*) <span style="color:#898887;">// equivalent to 2 of ($foo1,$foo2,$foo3)</span> |
| 272 |
} |
| 273 |
|
| 274 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">OfExample3</span> |
| 275 |
{ |
| 276 |
<span style="font-weight:bold;">strings</span>: |
| 277 |
<span style="color:#0057ae;">$a</span> = <span style="color:#bf0303;">"dummy1"</span> |
| 278 |
<span style="color:#0057ae;">$b</span> = <span style="color:#bf0303;">"dummy2"</span> |
| 279 |
<span style="color:#0057ae;">$c</span> = <span style="color:#bf0303;">"dummy3"</span> |
| 280 |
|
| 281 |
<span style="font-weight:bold;">condition</span>: |
| 282 |
<span style="color:#b08000;">1</span> <span style="font-weight:bold;">of</span> <span style="font-weight:bold;">them</span> <span style="color:#898887;">// equivalent to 1 of ($*)</span> |
| 283 |
} |
| 284 |
|
| 285 |
<span style="color:#898887;">// Iterating over string occurrences</span> |
| 286 |
|
| 287 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">Occurrences</span> |
| 288 |
{ |
| 289 |
<span style="font-weight:bold;">strings</span>: |
| 290 |
<span style="color:#0057ae;">$a</span> = <span style="color:#bf0303;">"dummy1"</span> |
| 291 |
<span style="color:#0057ae;">$b</span> = <span style="color:#bf0303;">"dummy2"</span> |
| 292 |
|
| 293 |
<span style="font-weight:bold;">condition</span>: |
| 294 |
<span style="font-weight:bold;">for</span> <span style="font-weight:bold;">all</span> i <span style="font-weight:bold;">in</span> (<span style="color:#b08000;">1</span>,<span style="color:#b08000;">2</span>,<span style="color:#b08000;">3</span>) : ( @a[i] + <span style="color:#b08000;">10</span> == @b[i] ) |
| 295 |
} |
| 296 |
|
| 297 |
<span style="color:#898887;">// Referencing other rules</span> |
| 298 |
|
| 299 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">Rule1</span> |
| 300 |
{ |
| 301 |
<span style="font-weight:bold;">strings</span>: |
| 302 |
<span style="color:#0057ae;">$a</span> = <span style="color:#bf0303;">"dummy1"</span> |
| 303 |
|
| 304 |
<span style="font-weight:bold;">condition</span>: |
| 305 |
<span style="color:#0057ae;">$a</span> |
| 306 |
} |
| 307 |
|
| 308 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">Rule2</span> |
| 309 |
{ |
| 310 |
<span style="font-weight:bold;">strings</span>: |
| 311 |
<span style="color:#0057ae;">$a</span> = <span style="color:#bf0303;">"dummy2"</span> |
| 312 |
|
| 313 |
<span style="font-weight:bold;">condition</span>: |
| 314 |
<span style="color:#0057ae;">$a</span> <span style="font-weight:bold;">and</span> Rule1 |
| 315 |
} |
| 316 |
|
| 317 |
<span style="color:#898887;">// Metadata</span> |
| 318 |
|
| 319 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">MetadataExample</span> |
| 320 |
{ |
| 321 |
<span style="font-weight:bold;">meta</span>: |
| 322 |
my_identifier_1 = <span style="color:#bf0303;">"Some string data"</span> |
| 323 |
my_identifier_2 = <span style="color:#b08000;">24</span> |
| 324 |
my_identifier_3 = <span style="color:#aa5500;">true</span> |
| 325 |
|
| 326 |
<span style="font-weight:bold;">strings</span>: |
| 327 |
<span style="color:#0057ae;">$my_text_string</span> = <span style="color:#bf0303;">"text here"</span> |
| 328 |
<span style="color:#0057ae;">$my_hex_string</span> = {<span style="color:#ff5500;"> E2 34 A1 C8 23 FB </span>} |
| 329 |
|
| 330 |
<span style="font-weight:bold;">condition</span>: |
| 331 |
<span style="color:#0057ae;">$my_text_string</span> <span style="font-weight:bold;">or</span> <span style="color:#0057ae;">$my_hex_string</span> |
| 332 |
} |
| 333 |
|
| 334 |
<span style="color:#898887;">// External variables</span> |
| 335 |
|
| 336 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">ExternalVariableExample1</span> |
| 337 |
{ |
| 338 |
<span style="font-weight:bold;">condition</span>: |
| 339 |
ext_var == <span style="color:#b08000;">10</span> |
| 340 |
} |
| 341 |
|
| 342 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">ExternalVariableExample2</span> |
| 343 |
{ |
| 344 |
<span style="font-weight:bold;">condition</span>: |
| 345 |
bool_ext_var <span style="font-weight:bold;">or</span> <span style="font-weight:bold;">filesize</span> < int_ext_var |
| 346 |
} |
| 347 |
|
| 348 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">ExternalVariableExample3</span> |
| 349 |
{ |
| 350 |
<span style="font-weight:bold;">condition</span>: |
| 351 |
string_ext_var <span style="font-weight:bold;">contains</span> <span style="color:#bf0303;">"text"</span> |
| 352 |
} |
| 353 |
|
| 354 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">ExternalVariableExample4</span> |
| 355 |
{ |
| 356 |
<span style="font-weight:bold;">condition</span>: |
| 357 |
string_ext_var <span style="font-weight:bold;">matches</span> <span style="color:#ff5500;">/</span><span style="color:#3daee9;">[a-z]</span><span style="color:#3daee9;">+</span><span style="color:#ff5500;">/</span> |
| 358 |
} |
| 359 |
|
| 360 |
<span style="font-weight:bold;">rule</span> <span style="color:#644a9b;">ExternalVariableExample5</span> |
| 361 |
{ |
| 362 |
<span style="font-weight:bold;">condition</span>: |
| 363 |
<span style="color:#898887;">/* case insensitive single-line mode */</span> |
| 364 |
string_ext_var <span style="font-weight:bold;">matches</span> <span style="color:#ff5500;">/</span><span style="color:#3daee9;">[a-z]</span><span style="color:#3daee9;">+</span><span style="color:#ff5500;">/is</span> |
| 365 |
} |
| 366 |
|
| 367 |
<span style="color:#898887;">// Including files</span> |
| 368 |
|
| 369 |
<span style="font-weight:bold;">include</span> <span style="color:#bf0303;">"other.yar"</span> |
| 370 |
<span style="font-weight:bold;">include</span> <span style="color:#bf0303;">"./includes/other.yar"</span> |
| 371 |
<span style="font-weight:bold;">include</span> <span style="color:#bf0303;">"../includes/other.yar"</span> |
| 372 |
</pre></body></html> |