# Path: multiscanner/common/utils.py
# def convert_encoding(data, encoding='UTF-8', errors='replace'):
#     """
#     Converts dicts, lists, and strs to the encoding. It uses data.decode to do this.
# 
#     data - The data to be converted
#     encoding - The encoding method to use
#     error - The codec error handling method to use
#     """
#     if isinstance(data, dict):
#         if PY3:
#             return dict((convert_encoding(key), convert_encoding(value)) for key, value in data.items())
#         else:
#             return dict((convert_encoding(key), convert_encoding(value)) for key, value in data.iteritems())
#     elif isinstance(data, list):
#         return [convert_encoding(element) for element in data]
#     elif isinstance(data, str):
#         if PY3:
#             # I think this works?
#             return data.encode(encoding=encoding, errors=errors).decode(encoding=encoding, errors=errors)
#         else:
#             return data.decode(encoding, errors)
#     elif isinstance(data, bytes):
#         return data.decode(encoding=encoding, errors=errors)
#     else:
#         return data
# 
# Path: multiscanner/config.py
# MS_WD = os.path.dirname(os.path.abspath(__file__))
# MODULESDIR = os.path.join(MS_WD, 'modules')
# CONFIG = determine_configuration_path(None)
# def get_configuration_paths():
# def determine_configuration_path(filepath):


    import pefile
import bitstring
import string
import bz2
import hashlib
import binascii
import struct
from time import strftime, localtime
from multiscanner.common.utils import convert_encoding
from multiscanner.config import PY3
    stk_size = bitstring.BitArray(bin=stk_size_bits)
    stk_size_xor = stk_size[8:16] ^ stk_size[16:24] ^ stk_size[24:32]
    # pad to 8 bits
    stk_size_xor = bitstring.BitArray(bytes=stk_size_xor.tobytes())
    pehash_bin.append(stk_size_xor)

    # Heap Commit Size
    hp_size = bitstring.BitArray(hex(exe.OPTIONAL_HEADER.SizeOfHeapCommit))
    if PY3:
        hp_size_bits = hp_size.bin.zfill(32)
    else:
        hp_size_bits = string.zfill(hp_size.bin, 32)
    # now xor the bits
    hp_size = bitstring.BitArray(bin=hp_size_bits)
    hp_size_xor = hp_size[8:16] ^ hp_size[16:24] ^ hp_size[24:32]
    # pad to 8 bits
    hp_size_xor = bitstring.BitArray(bytes=hp_size_xor.tobytes())
    pehash_bin.append(hp_size_xor)

    # Section chars
    for section in exe.sections:
        # virutal address
        sect_va = bitstring.BitArray(hex(section.VirtualAddress))
        sect_va = bitstring.BitArray(bytes=sect_va.tobytes())
        sect_va_bits = sect_va[8:32]
        pehash_bin.append(sect_va_bits)

        # rawsize
        sect_rs = bitstring.BitArray(hex(section.SizeOfRawData))
        sect_rs = bitstring.BitArray(bytes=sect_rs.tobytes())

# Path: multiscanner/common/utils.py
# def convert_encoding(data, encoding='UTF-8', errors='replace'):
#     """
#     Converts dicts, lists, and strs to the encoding. It uses data.decode to do this.
# 
#     data - The data to be converted
#     encoding - The encoding method to use
#     error - The codec error handling method to use
#     """
#     if isinstance(data, dict):
#         if PY3:
#             return dict((convert_encoding(key), convert_encoding(value)) for key, value in data.items())
#         else:
#             return dict((convert_encoding(key), convert_encoding(value)) for key, value in data.iteritems())
#     elif isinstance(data, list):
#         return [convert_encoding(element) for element in data]
#     elif isinstance(data, str):
#         if PY3:
#             # I think this works?
#             return data.encode(encoding=encoding, errors=errors).decode(encoding=encoding, errors=errors)
#         else:
#             return data.decode(encoding, errors)
#     elif isinstance(data, bytes):
#         return data.decode(encoding=encoding, errors=errors)
#     else:
#         return data
# 
# Path: multiscanner/config.py
# MS_WD = os.path.dirname(os.path.abspath(__file__))
# MODULESDIR = os.path.join(MS_WD, 'modules')
# CONFIG = determine_configuration_path(None)
# def get_configuration_paths():
# def determine_configuration_path(filepath):


# Path: multiscanner/modules/Metadata/PEFile.py
    import pefile
import bitstring
import string
import bz2
import hashlib
import binascii
import struct
from time import strftime, localtime
from multiscanner.common.utils import convert_encoding
from multiscanner.config import PY3

    stk_size = bitstring.BitArray(bin=stk_size_bits)
    stk_size_xor = stk_size[8:16] ^ stk_size[16:24] ^ stk_size[24:32]
    # pad to 8 bits
    stk_size_xor = bitstring.BitArray(bytes=stk_size_xor.tobytes())
    pehash_bin.append(stk_size_xor)

    # Heap Commit Size
    hp_size = bitstring.BitArray(hex(exe.OPTIONAL_HEADER.SizeOfHeapCommit))
    if PY3:
        hp_size_bits = hp_size.bin.zfill(32)
    else:
        hp_size_bits = string.zfill(hp_size.bin, 32)
    # now xor the bits
    hp_size = bitstring.BitArray(bin=hp_size_bits)
    hp_size_xor = hp_size[8:16] ^ hp_size[16:24] ^ hp_size[24:32]
    # pad to 8 bits
    hp_size_xor = bitstring.BitArray(bytes=hp_size_xor.tobytes())
    pehash_bin.append(hp_size_xor)

    # Section chars
    for section in exe.sections:
        # virutal address
        sect_va = bitstring.BitArray(hex(section.VirtualAddress))
        sect_va = bitstring.BitArray(bytes=sect_va.tobytes())
        sect_va_bits = sect_va[8:32]
        pehash_bin.append(sect_va_bits)

        # rawsize
        sect_rs = bitstring.BitArray(hex(section.SizeOfRawData))
        sect_rs = bitstring.BitArray(bytes=sect_rs.tobytes())

        if PY3: