Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions volatility3/framework/plugins/yarascan.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@
return yara_x.compile(fp.read().decode())
return yara.compile(file=fp)

@classmethod
def from_text(cls, rule) -> yara.Rules:
"""Initialize a Yara Rules object from one or more rules in string format.

You can provide rules in single-line or multi-line:
rule = "rule dummy { condition: true }"
rules = '''
rule dummy {
condition: true
}
rule dummy2 {
condition: true
}
'''
"""
if USE_YARA_X:
return yara_x.compile(source=formatted_rule)

Check failure on line 120 in volatility3/framework/plugins/yarascan.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (F821)

volatility3/framework/plugins/yarascan.py:120:42: F821 Undefined name `formatted_rule`
return yara.compile(source=formatted_rule)

Check failure on line 121 in volatility3/framework/plugins/yarascan.py

View workflow job for this annotation

GitHub Actions / lint

Ruff (F821)

volatility3/framework/plugins/yarascan.py:121:36: F821 Undefined name `formatted_rule`


class YaraScan(plugins.PluginInterface):
"""Scans kernel memory using yara rules (string or file)."""
Expand Down
Loading