YARA的Python接口
ak-yara-python的Python项目详细描述
雅拉Python
通过这个库,您可以使用YARA 你的Python程序。它涵盖了YARA的所有特性,从编译到保存 以及加载规则来扫描文件、字符串和进程。在
这里有一个小例子:
>>>importyara>>>rule=yara.compile(source='rule foo: bar {strings: $a = "lmn" condition: $a}')>>>matches=rule.match(data='abcdefgjiklmnoprstuvwxyz')>>>print(matches)[foo]>>>print(matches[0].rule)foo>>>print(matches[0].tags)['bar']>>>print(matches[0].strings)[(10L,'$a','lmn')]
安装
安装YARA最简单的方法是使用pip:
^{pr2}$但您也可以从GitHub获取源代码并自行编译:
$ git clone --recursive https://github.com/VirusTotal/yara-python
$ cd yara-python
$ python setup.py build
$ sudo python setup.py install
请注意--recursive选项与git一起使用。这很重要,因为 我们需要下载包含源代码的yara子项目 libyara(核心YARA库)。还有一点很重要,那就是 上面的方法将libyara静态链接到yarapython中。如果你想链接 动态地针对共享的libyara库使用:
$ sudo python setup.py install --dynamic-linking
要使此选项起作用,您必须构建并安装 YARA安装前分开 yara-python。在
文档
有关如何使用yara python的更多信息,请访问 https://yara.readthedocs.org/en/latest/yarapython.html。在
- 项目
标签: