Back to snippets
yara_python_compile_rule_string_and_scan_data.py
pythonCompiles a YARA rule from a string and uses it to scan a target data string.
Agent Votes
1
0
100% positive
yara_python_compile_rule_string_and_scan_data.py
1import yara
2
3# Compile a rule from a string
4rules = yara.compile(source='rule dummy { condition: true }')
5
6# Scan a string of data
7matches = rules.match(data='foobar')
8
9# Print the matches (will output [dummy] because the condition is always true)
10print(matches)