I have reverse engineered exe file using pyinstxtractor.py script. There were around 1120 files in PYZ archive.

F:\Python Test>python pyinstxtractor.py test.exe
[*] Processing test.exe
[*] Pyinstaller version: 2.1+
[*] Python version: 27
[*] Length of package: 4992914 bytes
[*] Found 11 files in CArchive
[*] Beginning extraction...please standby
[+] Possible entry point: pyiboot01_bootstrap
[+] Possible entry point: pyi_rth_multiprocessing
[+] Possible entry point: pyi_rth_pkgres
[+] Possible entry point: pyi_rth_win32comgenpy
[+] Possible entry point: pyi_rth__tkinter
[+] Possible entry point: gui
[*] Found 1120 files in PYZ archive
[*] Successfully extracted pyinstaller archive: test.exe

I have found the entry point that is gui file , and decompiled that file to source code after update of header bytes in hex editor.

Now my question is when i try to repack using this command

pyinstaller gui.py 

, the resultant exe doesn't have those 1120 files in its PYZ archive ( becoz i again extracted the contents of my final exe file). How can i embed that PYZ folder into this exe?

  • My question is similar to this one : stackoverflow.com/questions/45074603/… but it doesn't solve the problem. Any pointers help will be appreciated. – RS Gamer Jun 25 at 18:05
  • There's pyinstaller exe rebuilder for this exact task. However its out of date and may not work. – 0xec Jun 26 at 4:56
  • I did try Pyinstaller Exe Rebuilder but it gives error as: Failed to load Test.exe. It is not a pyinstaller exe. Source code says: # Python bytecode 2.7 (62211) # Decompiled from: Python 2.7.16 (v2.7.16:413a49145e, Mar 4 2019, 01:30:55) [MSC v.1500 32 bit (Intel)] Admire your work at tuts4you.com/e107_plugins/download/download.php?view.3541 Rest of steps are working fine, to get to code from exe; but i am facing problem while generating exe file. – RS Gamer Jun 26 at 5:41
  • I have also installed other dependencies like pip install Pillow pip install opencv-python pip install rsa pip install pycryptodome pip install filedict pip install pywin32 pip install python-telegram-bot When i compile with this ``` – RS Gamer Jun 26 at 5:49
  • 1
    One thing you can try is compile to gui.py to pyc, and check its size. If its smaller than the original pyc you can replace the corresponding bytes in the exe. However its a bit more work as pyinstaller stores the pyc, zlib compressed. You have to edit the pyinstxtractor script and comment out the statements which does the zlib decompression Line 239: if entry.cmprsFlag == 1:. So original gui.pyc get replaced with your modified pyc. Do note that both have pyc header removed and are zlib compressed. – 0xec Jun 26 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.