# Path: malwareconfig/yarascanner.py
# class YaraScanner:
#     def __init__(self):
#         # Create the list of rules
#         try:
#             yara_path = os.path.join(os.path.dirname(__file__), 'yaraRules')
#             self.yara_rules = os.listdir(yara_path)
#             self.rule_file = os.path.join(yara_path, 'yaraRules.yar')
#             self.compiled_rules = yara.compile(self.rule_file)
#             self.rule_list = []
#         except yara.SyntaxError as e:
#             print("Unable to compile rules. Do you have dotnet enabled")
# 
#     # Yara Scanner Returns the Rule Name
#     def yara_scan(self, raw_data):
#         matches = self.compiled_rules.match(data=raw_data)
#         rule_list = []
# 
#         for match in matches:
#             rule_list.append(match.rule)
#         self.rule_list = rule_list


import re
import hashlib
import pefile
import io
import yara
from binascii import hexlify
from androguard.core.bytecodes import apk
from androguard.core.bytecodes import dvm
from androguard import misc
from malwareconfig.yarascanner import YaraScanner
from zipfile import ZipFile





class FileParser:
    def __init__(self, file_path=None, rawdata=None):
        if file_path:
            file_object = open(file_path, 'rb')
        else:
            file_object = io.BytesIO(rawdata)
            file_object.name = "DummyFile.ext"
        self.file_name = file_object.name
        self.file_data = file_object.read()
        self.file_size = len(self.file_data)
        self.malware_name = ''
        self.yarascan()
        file_object.close()

    def yarascan(self):

# Path: malwareconfig/yarascanner.py
# class YaraScanner:
#     def __init__(self):
#         # Create the list of rules
#         try:
#             yara_path = os.path.join(os.path.dirname(__file__), 'yaraRules')
#             self.yara_rules = os.listdir(yara_path)
#             self.rule_file = os.path.join(yara_path, 'yaraRules.yar')
#             self.compiled_rules = yara.compile(self.rule_file)
#             self.rule_list = []
#         except yara.SyntaxError as e:
#             print("Unable to compile rules. Do you have dotnet enabled")
# 
#     # Yara Scanner Returns the Rule Name
#     def yara_scan(self, raw_data):
#         matches = self.compiled_rules.match(data=raw_data)
#         rule_list = []
# 
#         for match in matches:
#             rule_list.append(match.rule)
#         self.rule_list = rule_list


# Path: malwareconfig/fileparser.py
import re
import hashlib
import pefile
import io
import yara
from binascii import hexlify
from androguard.core.bytecodes import apk
from androguard.core.bytecodes import dvm
from androguard import misc
from malwareconfig.yarascanner import YaraScanner
from zipfile import ZipFile






class FileParser:
    def __init__(self, file_path=None, rawdata=None):
        if file_path:
            file_object = open(file_path, 'rb')
        else:
            file_object = io.BytesIO(rawdata)
            file_object.name = "DummyFile.ext"
        self.file_name = file_object.name
        self.file_data = file_object.read()
        self.file_size = len(self.file_data)
        self.malware_name = ''
        self.yarascan()
        file_object.close()

    def yarascan(self):

        scanner = YaraScanner()