1

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?

6
  • 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
    Commented Jun 25, 2019 at 18:05
  • 1
    There's pyinstaller exe rebuilder for this exact task. However its out of date and may not work.
    – 0xec
    Commented Jun 26, 2019 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
    Commented Jun 26, 2019 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
    Commented Jun 26, 2019 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
    Commented Jun 26, 2019 at 6:28

1 Answer 1

1

You cannot simply make pyinstaller gui.py. You should resolve all dependencies: or installing packages using pip, or pulling them from extracted PYZ archive folder. In the PYZ folder you can find all files, but you need to rename it and rearrange to modules.

1
  • Hi van, and welcome to RE.SE! Although your answer does seem to cover most of the question, I think it could quite benefit additional information and details, if you feel like doing that. Regardless, thanks for sharing your knowledge and I hope we see you more :)
    – NirIzr
    Commented Jan 13, 2020 at 15:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.