Skip to main content

Parse and easily work with Yara rules.

Project description

Intro

Package I am working on to be used in parsing Yara rules into their individual components. Package may also contain utilities or extra features I develop for working with Yara rules over time.

Usage

pip install YaraParser
from YaraParser import YaraParser

test = """
/*
    This Yara ruleset is under the GNU-GPLv2 license (http://www.gnu.org/licenses/gpl-2.0.html) and open to any user or organization, as long as you use it under this license.
*/
rule Big_Numbers0
{
	meta:
		author = "_pusher_"
		description = "Looks for big numbers 20:sized"
		date = "2016-07"
	strings:
		$c0 = /[0-9a-fA-F]{20}/ fullword ascii
	condition:
		$c0
}
"""

parser = YaraParser(test)

rules = parser.parse_rules()

print(rules[0].__dict__)
{'name': 'Big_Numbers0', 'imports': [], 'tags': None, 'meta': 'meta:\n\t\tauthor = "_pusher_"\n\t\tdescription = "Looks for big numbers 20:sized"\n\t\tdate = "2016-07"\n\t', 'meta_kvp': [{'author': '_pusher_'}, {'description': 'Looks for big numbers 20:sized'}, {'date': '2016-07'}], 'strings': 'strings:\n\t\t$c0 = /[0-9a-fA-F]{20}/ fullword ascii\n\t', 'conditions': 'condition:\n\t\t$c0\n', 'raw_text': 'rule Big_Numbers0\n{\n\tmeta:\n\t\tauthor = "_pusher_"\n\t\tdescription = "Looks for big numbers 20:sized"\n\t\tdate = "2016-07"\n\n\tstrings:\n\t\t$c0 = /[0-9a-fA-F]{20}/ fullword ascii\n\n\tcondition:\n\t\t$c0\n}\n', 'logic_hash': 'cc15c2fe1e9d195ce446c522991f04a9dee858e9752b385473d82c85b5826051', 'compiles': True, 'compiles_error_msg': None}

Quick breakdown

YaraParser class returns a list of YaraRule objects corresponding to the Yara rule input string. These objects contain the following attributes:

  • Name
  • Imports
  • Tags
  • Meta
  • Meta_kvp
  • Strings
  • Conditions
  • Raw Text
  • Logic Hash (Hash of strings and conditions, can be used to prevent duplicate rules)
  • Compiles
  • Compile Error Msg

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

YaraParser-1.0.1.tar.gz (7.2 kB view details)

Uploaded Source

File details

Details for the file YaraParser-1.0.1.tar.gz.

File metadata

  • Download URL: YaraParser-1.0.1.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for YaraParser-1.0.1.tar.gz
Algorithm Hash digest
SHA256 f72483eac870cadfa72dba59b00364716aa002c6e819b0dbc2e16463d6f56e13
MD5 484cd265e4e5bb7b0ec8b74033ed506e
BLAKE2b-256 41e6228da90f16c172f693f3aa904f5e7bc79e4352e88d01fc1c3f100ac45438

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