def __init__(self, path, output_dir=None):
        super(PyInstaller, self).__init__(path, output_dir)
        self.py_inst_archive = pyinstxtractor.PyInstArchive(self.file_path)

        # A hack to check the existence of the file
        self.open_executable()
        self.close()

        self.py_inst_archive.open()
Пример #2
0
def main_source(file, source):
    global bindata, source_file
    source_file = file
    if source == '':
        source = '_source.py'

    arch = pyinstxtractor.PyInstArchive(file)
    if arch.open():
        if arch.checkFile() and arch.getCArchiveInfo():
            arch.parseTOC()
            arch.extractFiles()
            arch.close()
            print('[*] Successfully extracted pyinstaller archive: {0}'.format(file))
        arch.close()

    if os.path.isfile(file.replace('.exe', '')) != True:
        print('[*] Not found {} file!'.format(file.replace('.exe', '')))
        file = input('[?] Select a "Possible entry point" file from the top list -> ')+'.exe'

    try:
        os.remove(file.replace('exe', 'pyc'))
    except:
        pass

    os.rename(file.replace('.exe', ''), file.replace('exe', 'pyc'))
    pycfile = file.replace('exe', 'pyc')
    archive = zipfile.ZipFile('base_library.zip', 'r')
    bindata = binascii.unhexlify(binascii.hexlify(archive.read('abc.pyc')).split(b'e3')[0])
    archive.close()

    open('newf5a99.pyc', 'w').close()
    with open('newf5a99.pyc', 'r+b') as new:
        new.write(bindata)
        with open(pycfile, 'rb') as old:
            new.write(old.read())
    os.remove(pycfile)
    os.rename('newf5a99.pyc', pycfile)

    if source == '_source.py':
        if os.path.isdir('../'+file.replace('.exe', '')+source) != True:
            os.mkdir('../'+file.replace('.exe', '')+source)
        
        with open('../'+file.replace('.exe', '')+source+'/'+file.replace('.exe', '')+'_source.py', "w") as fileobj:
            uncompyle6.decompile_file(pycfile, fileobj)
    
    else:
        if os.path.isdir('../'+source) != True:
            os.mkdir('../'+source)
        
        with open('../'+source+'/'+source, "w") as fileobj:
            uncompyle6.decompile_file(pycfile, fileobj)

    return file