# Path: malwareconfig/crypto.py
# def decrypt_rsa(key, data):
# def decrypt_xor(key, data):
# def decrypt_arc4(key, data):
# def decrypt_des_ecb(key, data, iv=None):
# def decrypt_des_cbc(key, data, iv=None):
# def decrypt_des3(key, data):
# def decrypt_aes(key, data):
# def decrypt_aes_cbc_iv(key, iv, data):
# def decrypt_blowfish(key, data):
# def decrypt_RC6(key, encrypted, P, Q, rounds):
#     def rol(a, i):
#     def ror(a, i):
#     def to_int(bytestring):
#     def decrypt_block(block, S):
# def derive_pbkdf2(key, salt, iv_length, key_length, iterations=8):
#     T = 2 * rounds + 4
#     L = to_int(key)
#     S = []
#     S = [0 for i in range(T)]
#     S[0] = P
#     A = 0
#     B = 0
#         A = S[i] = rol((S[i] + A + B), 3)
#         B = L[j] = rol((L[j] + A + B), (A + B))
# 
# Path: malwareconfig/common.py
# class Decoder(object):
#     decoder_name = ""
#     decoder_version = 1
#     decoder_author = ""
#     decoder_description = ""
#     file_info = object
# 
#     def set_file(self, file_info):
#         self.file_info = file_info
# 
#     def get_config(self):
#         pass


from base64 import b64decode
from binascii import unhexlify, hexlify
from malwareconfig import crypto
from malwareconfig.common import Decoder


class HawkEye(Decoder):
    decoder_name = "HawkEye"
    decoder__version = 1
    decoder_author = "@kevthehermit"
    decoder_description = "Decoder For Hawkeye Cred Stealer"

    def __init__(self):
        self.config = {}

    def get_config(self):
        '''
        This is the main entry
        :return:
        '''

        # Get the user string list
        user_strings = self.file_info.dotnet_user_strings()

        # Version Check

        key = 'HawkEyeKeylogger'
        salt = '0\x009\x009\x00u\x007\x008\x007\x009\x007\x008\x007\x008\x006\x00'

        # Older Version
        if 'InvisibleSoft' in user_strings:
            key = 'InvisibleSoft'

        # Derive Key

# Path: malwareconfig/crypto.py
# def decrypt_rsa(key, data):
# def decrypt_xor(key, data):
# def decrypt_arc4(key, data):
# def decrypt_des_ecb(key, data, iv=None):
# def decrypt_des_cbc(key, data, iv=None):
# def decrypt_des3(key, data):
# def decrypt_aes(key, data):
# def decrypt_aes_cbc_iv(key, iv, data):
# def decrypt_blowfish(key, data):
# def decrypt_RC6(key, encrypted, P, Q, rounds):
#     def rol(a, i):
#     def ror(a, i):
#     def to_int(bytestring):
#     def decrypt_block(block, S):
# def derive_pbkdf2(key, salt, iv_length, key_length, iterations=8):
#     T = 2 * rounds + 4
#     L = to_int(key)
#     S = []
#     S = [0 for i in range(T)]
#     S[0] = P
#     A = 0
#     B = 0
#         A = S[i] = rol((S[i] + A + B), 3)
#         B = L[j] = rol((L[j] + A + B), (A + B))
# 
# Path: malwareconfig/common.py
# class Decoder(object):
#     decoder_name = ""
#     decoder_version = 1
#     decoder_author = ""
#     decoder_description = ""
#     file_info = object
# 
#     def set_file(self, file_info):
#         self.file_info = file_info
# 
#     def get_config(self):
#         pass


# Path: malwareconfig/decoders/hawkeye.py
from base64 import b64decode
from binascii import unhexlify, hexlify
from malwareconfig import crypto
from malwareconfig.common import Decoder



class HawkEye(Decoder):
    decoder_name = "HawkEye"
    decoder__version = 1
    decoder_author = "@kevthehermit"
    decoder_description = "Decoder For Hawkeye Cred Stealer"

    def __init__(self):
        self.config = {}

    def get_config(self):
        '''
        This is the main entry
        :return:
        '''

        # Get the user string list
        user_strings = self.file_info.dotnet_user_strings()

        # Version Check

        key = 'HawkEyeKeylogger'
        salt = '0\x009\x009\x00u\x007\x008\x007\x009\x007\x008\x007\x008\x006\x00'

        # Older Version
        if 'InvisibleSoft' in user_strings:
            key = 'InvisibleSoft'

        # Derive Key

        d_iv, d_key = crypto.derive_pbkdf2(key, salt, 16, 32, iterations=1000)