Skip to main content

Python interface for YARA

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yara-python-3.5.0.tar.gz (551.7 kB view details)

Uploaded Source

File details

Details for the file yara-python-3.5.0.tar.gz.

File metadata

  • Download URL: yara-python-3.5.0.tar.gz
  • Upload date:
  • Size: 551.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for yara-python-3.5.0.tar.gz
Algorithm Hash digest
SHA256 c743ef051127eacc903fd4bd63d552ecf00031b59a9a8e7d0d017063de24b69c
MD5 3184efa3da16e3a8304185f2641c4ffe
BLAKE2b-256 3e6cec2453fd811ea2f8c157d196b4dd76eb3c229362918fdb661358bd3e8645

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page