Questions tagged [yara]

YARA is a tool aimed at (but not limited to) helping malware researchers to identify and classify malware samples.

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/plusvic/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 https://yara.readthedocs.io/en/latest/yarapython.html.

63 questions
3
votes
1 answer

Memory error when using androguard module in Yara Rules

I tried installing Yara 3.8.1 with androguard module. During the installation, I faced this issue, so I applied the patch given by @reox to the androguard.c file and it solved the problem. After that I tried a simple Yara rule with import…
Mehran Torki
  • 977
  • 1
  • 9
  • 37
3
votes
7 answers

Issue: “OSError: /usr/lib/libyara.so: cannot open shared object file: No such file or directory” while running cuckoo.py

I have installed cuckoo and all the dependencies and have also created VM using virtual box. I am getting an error "OSError: /usr/lib/libyara.so: cannot open shared object file: No such file or directory" whenever i try to run cuckoo.py using…
user3009648
  • 31
  • 1
  • 1
  • 2
2
votes
1 answer

Scanning directory with YARA python

Stuck with this problem for some time now. I am scanning a directory with my own yara rules, it works when I tried my code for a single file, but when I use the same code on a for loop, it doesn't match anything. I've tried searching my problem, but…
2
votes
1 answer

Locating EOCD in ZIP files by offset

I'm trying to write a collection of yara signatures that will tag zip files based on artifacts of their creation. I understand the EOCD has a magic number of 0x06054b50, and that it is located at the end of the archive structure. It has a variable…
solumnant
  • 61
  • 1
  • 7
2
votes
1 answer

Do Yara rules support non-ascii characters

I am trying to include non-ascii characters within a yara rule Firstly in the yara rule name and also with a string, for condition of the rule In both case I am getting error: "non-ascii character" when testing the rule. So it seems non-ascii…
1
vote
1 answer

Is there a way to get specific information of yara rules on Python?

I need to create a database where I store yara rules, specifically i need data from meta section like the author, filetype and description (if they exist), also I need the name of the rule I've been trying to look for any python module that could…
1
vote
2 answers

Could not import module Yara

I am currently attempting to run Volatility3, but I have encountered an error which is caused by yara failing on import. The main issue is I am unable to import yara even on CMD by typing python then import yara, doing so would get an error like…
Remicaster
  • 226
  • 4
  • 8
1
vote
0 answers

Security vulnerability reported as backdoor when using OpenSSL's librypto.a library

My C code uses librypto.a library to link to the compiled source code at the final stage for implementing RSA algorithm. When a vulnerability scan was done, it comes back with a YARA signature match for the following: YARA signature "ldpreload"…
Sundar
  • 11
  • 1
1
vote
1 answer

Yara one rule against multiple files

I'm using Yara to detect multiple strings in multiple files for example: File A : toto File B : titi Both file are in a directory repo Yara rule (test.yar) : rule test { strings: $ = "toto" $ = "titi" condition: all of them } And i run the commnand…
nox
  • 323
  • 2
  • 8
1
vote
0 answers

Yara Rule - Regex - Matching first two octets of IP address

Writing a YARA rule and stuck at a point where I cannot seem to find the correct regex to use. The object of the rule is to scan the headers of emails and match any IPv4 address found that begins with 10.13 Relevant documentation:…
bdaley094
  • 13
  • 2
1
vote
0 answers

Is it possible to get current system time from any of YARA modules?

As a part of assignment I have to write a YARA rule that identifies binaries compiled in the last 24 hours. For this, I need to write a condition in YARA rule where it compares the compile time of binary with the current system time to check whether…
Monk
  • 33
  • 6
1
vote
1 answer

yara-python cannot be imported to AWS Lambda

I'm trying to import the yara library into an AWS Lambda function but I am consistently given the following error: module initialization error: /var/lang/lib/libyara.so: cannot open shared object file: No such file or directory I have tried adding…
1
vote
0 answers

YARA Rules - Can you accumulate a value over a range of bytes and then comapre it?

I'm trying to write a YARA rule which will iterate some range of bytes, will xor them with something and add to some accumulator in order to compare the final result with a predefined value Is this possible? As far as I know you cannot declare…
user1326293
  • 923
  • 2
  • 9
  • 24
1
vote
0 answers

How to just use only one rule in yara rules file?

In a yara rules file-malware.yar, content like rule rules_one {} rule rules_two {} ... there are many rule in the file, I use yr_compiler_add_file to add file, then use yr_compiler_get_rules to get rules. I get all rules from the rules file, now I…
xina1i
  • 748
  • 4
  • 9
  • 21
1
vote
1 answer

Install and configure Yara/phpmalwarefinder on AMI (Amazon) Linux

I've installed Yara successfully by following the instructions here: https://yara.readthedocs.io/en/v3.8.1/gettingstarted.html#compiling-and-installing-yara including doing ./configure --with-crypto and didn't see any error messages. When I get to…
pendo
  • 792
  • 2
  • 5
  • 27
1
2 3 4 5