Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pecli/paths.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import os


PACKAGE_ROOT = os.path.dirname(os.path.abspath(__file__))


def data_path(filename):
return os.path.join(PACKAGE_ROOT, "data", filename)
6 changes: 3 additions & 3 deletions pecli/plugins/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import datetime
import os

import pkg_resources
import yara

from pecli.paths import data_path
from pecli.plugins.base import Plugin


Expand Down Expand Up @@ -233,7 +233,7 @@ def check_tls(self, pe):

def check_peid(self, data):
"""Check on PEid signatures"""
peid_db = pkg_resources.resource_filename("pecli", 'data/PeID.yar')
peid_db = data_path("PeID.yar")
rules = yara.compile(filepath=peid_db)
matches = rules.match(data=data)
if len(matches) > 0:
Expand Down Expand Up @@ -294,7 +294,7 @@ def check_pe_resource(self, pe) -> bool:
return suspicious

def check_yara(self, pe, data: bytes) -> None:
yara_rules = pkg_resources.resource_filename("pecli", "data/other.yar")
yara_rules = data_path("other.yar")
if not os.path.isfile(yara_rules):
print("Problem accessing the yara database")
return
Expand Down
4 changes: 2 additions & 2 deletions pecli/plugins/crypto.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#! /usr/bin/env python
import os

import pkg_resources
import yara

from pecli.paths import data_path
from pecli.plugins.base import Plugin


Expand All @@ -25,7 +25,7 @@ def convert_physical_addr(self, pe, addr):
return (None, None)

def run(self, args, pe, data):
crypto_db = pkg_resources.resource_filename("pecli", "data/yara-crypto.yar")
crypto_db = data_path("yara-crypto.yar")
if not os.path.isfile(crypto_db):
print("Problem accessing the yara database")
return
Expand Down