yara-x 1.4.0__cp38-abi3-manylinux_2_28_x86_64.whl → 1.6.0__cp38-abi3-manylinux_2_28_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of yara-x might be problematic. Click here for more details.
yara_x/__init__.pyi
CHANGED
|
@@ -1,10 +1,33 @@
|
|
|
1
|
-
import
|
|
1
|
+
import collections
|
|
2
2
|
|
|
3
|
+
from typing import Any, Dict, BinaryIO, TextIO, Optional, Tuple, final
|
|
4
|
+
|
|
5
|
+
class CompileError(Exception):
|
|
6
|
+
r"""
|
|
7
|
+
Error occurred while compiling rules.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
class ScanError(Exception):
|
|
11
|
+
r"""
|
|
12
|
+
Error occurred during a scan operation.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
class TimeoutError(Exception):
|
|
16
|
+
r"""
|
|
17
|
+
Error indicating that a timeout occurred during a scan operation.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
@final
|
|
3
21
|
class Compiler:
|
|
4
22
|
r"""
|
|
5
23
|
Compiles YARA source code producing a set of compiled [`Rules`].
|
|
6
24
|
"""
|
|
7
|
-
def
|
|
25
|
+
def __new__(
|
|
26
|
+
cls,
|
|
27
|
+
relaxed_re_syntax: bool = False,
|
|
28
|
+
error_on_slow_pattern: bool = False,
|
|
29
|
+
includes_enabled: bool = True,
|
|
30
|
+
) -> Compiler:
|
|
8
31
|
r"""
|
|
9
32
|
Creates a new [`Compiler`].
|
|
10
33
|
|
|
@@ -22,10 +45,13 @@ class Compiler:
|
|
|
22
45
|
|
|
23
46
|
The `error_on_slow_pattern` argument tells the compiler to treat slow
|
|
24
47
|
patterns as errors, instead of warnings.
|
|
48
|
+
|
|
49
|
+
The `includes_enabled` argument controls whether the compiler should
|
|
50
|
+
enable or disable the inclusion of files with the `include` directive.
|
|
25
51
|
"""
|
|
26
52
|
...
|
|
27
53
|
|
|
28
|
-
def add_source(self, src: str, origin:
|
|
54
|
+
def add_source(self, src: str, origin: Optional[str] = None) -> None:
|
|
29
55
|
r"""
|
|
30
56
|
Adds a YARA source code to be compiled.
|
|
31
57
|
|
|
@@ -47,7 +73,20 @@ class Compiler:
|
|
|
47
73
|
"""
|
|
48
74
|
...
|
|
49
75
|
|
|
50
|
-
def
|
|
76
|
+
def add_include_dir(self, dir: str) -> None:
|
|
77
|
+
r"""
|
|
78
|
+
Adds a directory to the list of directories where the compiler should
|
|
79
|
+
look for included files.
|
|
80
|
+
"""
|
|
81
|
+
...
|
|
82
|
+
|
|
83
|
+
def enable_includes(self, yes: bool) -> None:
|
|
84
|
+
r"""
|
|
85
|
+
Enables or disables the inclusion of files with the `include` directive.
|
|
86
|
+
"""
|
|
87
|
+
...
|
|
88
|
+
|
|
89
|
+
def define_global(self, ident: str, value: Any) -> None:
|
|
51
90
|
r"""
|
|
52
91
|
Defines a global variable and sets its initial value.
|
|
53
92
|
|
|
@@ -96,7 +135,7 @@ class Compiler:
|
|
|
96
135
|
"""
|
|
97
136
|
...
|
|
98
137
|
|
|
99
|
-
def errors(self) ->
|
|
138
|
+
def errors(self) -> Any:
|
|
100
139
|
r"""
|
|
101
140
|
Retrieves all errors generated by the compiler.
|
|
102
141
|
|
|
@@ -105,7 +144,7 @@ class Compiler:
|
|
|
105
144
|
"""
|
|
106
145
|
...
|
|
107
146
|
|
|
108
|
-
def warnings(self) ->
|
|
147
|
+
def warnings(self) -> Any:
|
|
109
148
|
r"""
|
|
110
149
|
Retrieves all warnings generated by the compiler.
|
|
111
150
|
|
|
@@ -126,34 +165,89 @@ class Compiler:
|
|
|
126
165
|
"""
|
|
127
166
|
...
|
|
128
167
|
|
|
129
|
-
|
|
168
|
+
@final
|
|
169
|
+
class Scanner:
|
|
170
|
+
r"""
|
|
171
|
+
Scans data with already compiled YARA rules.
|
|
172
|
+
|
|
173
|
+
The scanner receives a set of compiled [`Rules`] and scans data with those
|
|
174
|
+
rules. The same scanner can be used for scanning multiple files or in-memory
|
|
175
|
+
data sequentially, but you need multiple scanners for scanning in parallel.
|
|
176
|
+
"""
|
|
177
|
+
|
|
178
|
+
def __new__(cls, rules: Rules) -> Scanner:
|
|
130
179
|
r"""
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
180
|
+
Creates a new [`Scanner`] with a given set of [`Rules`].
|
|
181
|
+
"""
|
|
182
|
+
...
|
|
134
183
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
184
|
+
def scan(self, data: bytes) -> ScanResults:
|
|
185
|
+
r"""
|
|
186
|
+
Scans in-memory data.
|
|
187
|
+
"""
|
|
188
|
+
...
|
|
138
189
|
|
|
139
|
-
|
|
190
|
+
def scan_file(self, path: str) -> ScanResults:
|
|
191
|
+
r"""
|
|
192
|
+
Scans a file
|
|
193
|
+
"""
|
|
194
|
+
...
|
|
195
|
+
|
|
196
|
+
def set_global(self, ident: str, value: Any) -> None:
|
|
197
|
+
r"""
|
|
198
|
+
Sets the value of a global variable.
|
|
199
|
+
|
|
200
|
+
The variable must has been previously defined by calling
|
|
201
|
+
[`Compiler::define_global`], and the type it has during the definition
|
|
202
|
+
must match the type of the new value.
|
|
203
|
+
|
|
204
|
+
The variable will retain the new value in subsequent scans, unless this
|
|
205
|
+
function is called again for setting a new value.
|
|
206
|
+
|
|
207
|
+
The type of `value` must be: `bool`, `str`, `bytes`, `int` or `float`.
|
|
208
|
+
|
|
209
|
+
# Raises
|
|
210
|
+
|
|
211
|
+
[TypeError](https://docs.python.org/3/library/exceptions.html#TypeError)
|
|
212
|
+
if the type of `value` is not one of the supported ones.
|
|
213
|
+
"""
|
|
214
|
+
...
|
|
215
|
+
|
|
216
|
+
def set_timeout(self, seconds: int) -> None:
|
|
217
|
+
r"""
|
|
218
|
+
Sets a timeout for each scan.
|
|
219
|
+
|
|
220
|
+
After setting a timeout scans will abort after the specified `seconds`.
|
|
221
|
+
"""
|
|
222
|
+
...
|
|
223
|
+
|
|
224
|
+
def console_log(self, callback: collections.abc.Callable[[str], Any]) -> None:
|
|
225
|
+
r"""
|
|
226
|
+
Sets a callback that is invoked every time a YARA rule calls the
|
|
227
|
+
`console` module.
|
|
228
|
+
|
|
229
|
+
The `callback` function is invoked with a string representing the
|
|
230
|
+
message being logged. The function can print the message to stdout,
|
|
231
|
+
append it to a file, etc. If no callback is set these messages are
|
|
232
|
+
ignored.
|
|
140
233
|
"""
|
|
141
234
|
...
|
|
142
235
|
|
|
236
|
+
@final
|
|
143
237
|
class Formatter:
|
|
144
238
|
r"""
|
|
145
239
|
Formats YARA rules.
|
|
146
240
|
"""
|
|
147
|
-
def
|
|
148
|
-
|
|
149
|
-
align_metadata: bool,
|
|
150
|
-
align_patterns: bool,
|
|
151
|
-
indent_section_headers: bool,
|
|
152
|
-
indent_section_contents: bool,
|
|
153
|
-
indent_spaces: int,
|
|
154
|
-
newline_before_curly_brace: bool,
|
|
155
|
-
empty_line_before_section_header: bool,
|
|
156
|
-
empty_line_after_section_header: bool,
|
|
241
|
+
def __new__(
|
|
242
|
+
cls,
|
|
243
|
+
align_metadata: bool = True,
|
|
244
|
+
align_patterns: bool = True,
|
|
245
|
+
indent_section_headers: bool = True,
|
|
246
|
+
indent_section_contents: bool = True,
|
|
247
|
+
indent_spaces: int = 2,
|
|
248
|
+
newline_before_curly_brace: bool = False,
|
|
249
|
+
empty_line_before_section_header: bool = True,
|
|
250
|
+
empty_line_after_section_header: bool = False,
|
|
157
251
|
) -> Formatter:
|
|
158
252
|
r"""
|
|
159
253
|
Creates a new [`Formatter`].
|
|
@@ -169,73 +263,87 @@ class Formatter:
|
|
|
169
263
|
"""
|
|
170
264
|
...
|
|
171
265
|
|
|
172
|
-
def format(self, input:
|
|
266
|
+
def format(self, input: TextIO, output: TextIO) -> None:
|
|
173
267
|
r"""
|
|
174
268
|
Format a YARA rule
|
|
175
269
|
"""
|
|
176
270
|
...
|
|
177
271
|
|
|
272
|
+
@final
|
|
178
273
|
class Match:
|
|
179
274
|
r"""
|
|
180
275
|
Represents a match found for a pattern.
|
|
181
276
|
"""
|
|
277
|
+
@property
|
|
182
278
|
def offset(self) -> int:
|
|
183
279
|
r"""
|
|
184
280
|
Offset where the match occurred.
|
|
185
281
|
"""
|
|
186
282
|
...
|
|
187
283
|
|
|
284
|
+
@property
|
|
188
285
|
def length(self) -> int:
|
|
189
286
|
r"""
|
|
190
287
|
Length of the match in bytes.
|
|
191
288
|
"""
|
|
192
289
|
...
|
|
193
290
|
|
|
194
|
-
|
|
291
|
+
@property
|
|
292
|
+
def xor_key(self) -> Optional[int]:
|
|
195
293
|
r"""
|
|
196
294
|
XOR key used for decrypting the data if the pattern had the xor
|
|
197
295
|
modifier, or None if otherwise.
|
|
198
296
|
"""
|
|
199
297
|
...
|
|
200
298
|
|
|
299
|
+
@final
|
|
201
300
|
class Pattern:
|
|
202
301
|
r"""
|
|
203
302
|
Represents a pattern in a YARA rule.
|
|
204
303
|
"""
|
|
304
|
+
|
|
305
|
+
@property
|
|
205
306
|
def identifier(self) -> str:
|
|
206
307
|
r"""
|
|
207
308
|
Pattern identifier (e.g: '$a', '$foo').
|
|
208
309
|
"""
|
|
209
310
|
...
|
|
210
311
|
|
|
312
|
+
@property
|
|
211
313
|
def matches(self) -> tuple:
|
|
212
314
|
r"""
|
|
213
315
|
Matches found for this pattern.
|
|
214
316
|
"""
|
|
215
317
|
...
|
|
216
318
|
|
|
319
|
+
@final
|
|
217
320
|
class Rule:
|
|
218
321
|
r"""
|
|
219
322
|
Represents a rule that matched while scanning some data.
|
|
220
323
|
"""
|
|
324
|
+
|
|
325
|
+
@property
|
|
221
326
|
def identifier(self) -> str:
|
|
222
327
|
r"""
|
|
223
328
|
Returns the rule's name.
|
|
224
329
|
"""
|
|
225
330
|
...
|
|
226
331
|
|
|
332
|
+
@property
|
|
227
333
|
def namespace(self) -> str:
|
|
228
334
|
r"""
|
|
229
335
|
Returns the rule's namespace.
|
|
230
336
|
"""
|
|
231
337
|
...
|
|
232
338
|
|
|
339
|
+
@property
|
|
233
340
|
def tags(self) -> tuple:
|
|
234
341
|
r"""
|
|
235
342
|
Returns the rule's tags.
|
|
236
343
|
"""
|
|
237
344
|
...
|
|
238
345
|
|
|
346
|
+
@property
|
|
239
347
|
def metadata(self) -> tuple:
|
|
240
348
|
r"""
|
|
241
349
|
A tuple of pairs `(identifier, value)` with the metadata associated to
|
|
@@ -243,12 +351,14 @@ class Rule:
|
|
|
243
351
|
"""
|
|
244
352
|
...
|
|
245
353
|
|
|
354
|
+
@property
|
|
246
355
|
def patterns(self) -> tuple:
|
|
247
356
|
r"""
|
|
248
357
|
Patterns defined by the rule.
|
|
249
358
|
"""
|
|
250
359
|
...
|
|
251
360
|
|
|
361
|
+
@final
|
|
252
362
|
class Rules:
|
|
253
363
|
r"""
|
|
254
364
|
A set of YARA rules in compiled form.
|
|
@@ -261,30 +371,34 @@ class Rules:
|
|
|
261
371
|
"""
|
|
262
372
|
...
|
|
263
373
|
|
|
264
|
-
def serialize_into(self, file:
|
|
374
|
+
def serialize_into(self, file: BinaryIO) -> None:
|
|
265
375
|
r"""
|
|
266
376
|
Serializes the rules into a file-like object.
|
|
267
377
|
"""
|
|
268
378
|
...
|
|
269
379
|
|
|
270
380
|
@staticmethod
|
|
271
|
-
def deserialize_from(
|
|
381
|
+
def deserialize_from(file: BinaryIO) -> Rules:
|
|
272
382
|
r"""
|
|
273
383
|
Deserializes rules from a file-like object.
|
|
274
384
|
"""
|
|
275
385
|
...
|
|
276
386
|
|
|
387
|
+
@final
|
|
277
388
|
class ScanResults:
|
|
278
389
|
r"""
|
|
279
390
|
Results produced by a scan operation.
|
|
280
391
|
"""
|
|
281
|
-
|
|
392
|
+
|
|
393
|
+
@property
|
|
394
|
+
def matching_rules(self) -> Tuple[Rule, ...]:
|
|
282
395
|
r"""
|
|
283
396
|
Rules that matched during the scan.
|
|
284
397
|
"""
|
|
285
398
|
...
|
|
286
399
|
|
|
287
|
-
|
|
400
|
+
@property
|
|
401
|
+
def module_outputs(self) -> Dict[str, Any]:
|
|
288
402
|
r"""
|
|
289
403
|
Module output from the scan.
|
|
290
404
|
"""
|
|
@@ -299,11 +413,12 @@ def compile(src: str) -> Rules:
|
|
|
299
413
|
"""
|
|
300
414
|
...
|
|
301
415
|
|
|
416
|
+
@final
|
|
302
417
|
class Module:
|
|
303
418
|
r"""A YARA-X module."""
|
|
304
|
-
def
|
|
419
|
+
def __new__(cls, name: str) -> Module:
|
|
420
|
+
r"""Creates a new [`Module`] with the given name, which must be a valid YARA-X module name."""
|
|
305
421
|
...
|
|
306
|
-
|
|
307
|
-
def invoke(data: str) -> dict:
|
|
422
|
+
def invoke(self, data: str) -> Any:
|
|
308
423
|
r"""Parse the data and collect module metadata."""
|
|
309
|
-
...
|
|
424
|
+
...
|
yara_x/yara_x.abi3.so
CHANGED
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: yara-x
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.6.0
|
|
4
4
|
Classifier: Programming Language :: Rust
|
|
5
5
|
Classifier: Programming Language :: Python :: Implementation :: CPython
|
|
6
6
|
Classifier: Programming Language :: Python :: Implementation :: PyPy
|
|
@@ -8,7 +8,6 @@ Classifier: License :: OSI Approved :: BSD License
|
|
|
8
8
|
Summary: Python bindings for YARA-X
|
|
9
9
|
Keywords: pattern-matching,cybersecurity,forensics,malware,yara
|
|
10
10
|
Home-Page: https://virustotal.github.io/yara-x
|
|
11
|
-
License: BSD-3-Clause
|
|
12
11
|
Requires-Python: >=3.9
|
|
13
12
|
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
|
|
14
13
|
Project-URL: homepage, https://virustotal.github.io/yara-x
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
yara_x/__init__.py,sha256=nMyCIYe2XAcE0xoh-kWfMlEZjVx9_cnT6O6Iaxh9JoM,107
|
|
2
|
+
yara_x/__init__.pyi,sha256=DVMCd5-GS1-Hm2Ib0DpW7OWWF6AOg7mNDXaV0MfRN9s,12469
|
|
3
|
+
yara_x/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
yara_x/yara_x.abi3.so,sha256=f1LxcJrZQiFCUTbCXHTQbwuMXBtOyHMePLuknjz_QUg,32183648
|
|
5
|
+
yara_x-1.6.0.dist-info/METADATA,sha256=SKakLaVrPLSAsxlTaGVTeEuxTR-Csa2pKQCcQ3CbaTA,1831
|
|
6
|
+
yara_x-1.6.0.dist-info/WHEEL,sha256=o9MoQ468Z3FUwUKdyNbg6iGSdiXCzIugopu8jtWvISc,107
|
|
7
|
+
yara_x-1.6.0.dist-info/RECORD,,
|
yara_x-1.4.0.dist-info/RECORD
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
yara_x/__init__.py,sha256=nMyCIYe2XAcE0xoh-kWfMlEZjVx9_cnT6O6Iaxh9JoM,107
|
|
2
|
-
yara_x/__init__.pyi,sha256=XHHI2JILfrN55nB7Mf2ySKBF2vLGrp6LijAkCQESekc,9621
|
|
3
|
-
yara_x/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
yara_x/yara_x.abi3.so,sha256=wqFNRx_xb9gZBzmZ8R2OiGUpwavOdEAhbfKXuC8eZOo,29064344
|
|
5
|
-
yara_x-1.4.0.dist-info/METADATA,sha256=XVKyoxe5wKEIcIWJMX7ZTW8a5QtnHIkrvLkkoV4CL7s,1853
|
|
6
|
-
yara_x-1.4.0.dist-info/WHEEL,sha256=spMIA-rpx8X09oWaHinlErLVFzZemFOBJ65bg0tT6J4,107
|
|
7
|
-
yara_x-1.4.0.dist-info/RECORD,,
|