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?
gui.py
to pyc, and check its size. If its smaller than the originalpyc
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 originalgui.pyc
get replaced with your modified pyc. Do note that both have pyc header removed and are zlib compressed.