Skip to content
The Python interface for YARA http://virustotal.github.io/yara/
Branch: master
Clone or download
CalebFenton Fix typo causing build to fail
Also, update yara submodule.

Latest yara version spells INSUFFICIENT correctly, but yara-python master hasn't been updated yet.
Latest commit a7acb4c Feb 9, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
yara @ c4b7f01 Fix typo causing build to fail Feb 9, 2017
.gitmodules
LICENSE Initial commit Sep 11, 2015
MANIFEST.in Add manifest file Feb 23, 2016
README.rst
config.h Allow building yara-python with libyara statically linked Sep 15, 2015
setup.cfg Allow building yara-python with libyara statically linked Sep 15, 2015
setup.py
tests.py Add test case for modules callback Jun 15, 2016
yara-python.c Fix typo causing build to fail Feb 9, 2017

README.rst

yara-python

With this library you can use YARA from your Python programs. It covers all YARA's features, from compiling, saving and loading rules to scanning files, strings and processes.

Here it goes a little example:

>>> import yara
>>> 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')]

Installation

The easiest way of installing YARA is by using pip:

$ pip install yara-python

But you can also get the source from GitHub and compile it yourself:

$ git clone --recursive https://github.com/VirusTotal/yara-python
$ cd yara-python
$ python setup.py build
$ sudo python setup.py install

Notice the --recursive option used with git. This is important because we need to download the yara subproject containing the source code for libyara (the core YARA library). It's also important to note that the two methods above link libyara statically into yara-python. If you want to link dynamically against a shared libyara library use:

$ sudo python setup.py install --dynamic-linking

For this option to work you must build and install YARA separately before installing yara-python.

Documentation

Find more information about how to use yara-python at http://yara.readthedocs.org/en/latest/yarapython.html.

You can’t perform that action at this time.