我一直在阅读文档,我一直很难弄明白这一点。翻译会有很大帮助。
我在网上看到了Yara的Perl规则示例:
rule BadBoy
{
strings:
$a = "win.exe"
$b = "http://foo.com/badfile1.exe"
$c = "http://bar.com/badfile2.exe"
condition:
$a and ($b or $c)
}如何用Python编写和编译这个规则?
发布于 2016-05-10 07:07:41
从python到import yara
直接从文件:
然后,在将YARA规则应用于数据之前,需要编译YARA规则,可以从文件路径编译这些规则:
rules = yara.compile()您可以传递格式化规则的文件名,也可以插入用于编译的字符串。
为了传递字符串,必须使用字典结构,其中键是数据的命名空间,值是属性值。
import yara
rules = yara.compile(sources={
'identifier_for_instance_of rule':'rule BadBoy {
'strings': [('$a', 'win.exe'),('$b', 'http://foo.com/badfile1.exe') , ('$c', 'http://bar.com/badfile2.exe')],
'condition': '$a and ($b or $c)'
}'})https://stackoverflow.com/questions/37118739
复制相似问题