Awesome Open Source
Awesome Open Source

.. image:: :target: .. image:: :target:


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:

.. code-block:: python

>>> import yara
>>> rule = yara.compile(source='rule foo: bar {strings: $a = "lmn" condition: $a}')
>>> matches = rule.match(data='abcdefgjiklmnoprstuvwxyz')
>>> print(matches)
>>> print(matches[0].rule)
>>> print(matches[0].tags)
>>> print(matches[0].strings)
[(10L, '$a', 'lmn')]


The easiest way of installing YARA is by using pip:

.. code-block:: bash

$ pip install yara-python

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

.. code-block:: bash

$ git clone --recursive $ cd yara-python $ python build $ sudo python 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:

.. code-block:: bash

$ python build --dynamic-linking

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


Find more information about how to use yara-python at

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
c (15,685
yara (61