Recently I converted a .py file to a .exe file.
I lost the original .py file and I'm left with the exe file. I converted it with pyinstaller.
Is there anyway to reverse this to get my original .py file back?
Yes, easily. Anyone can decompile a . NET assembly and get source code which can be compiled again into the same assembly.
Use pyinstxtractor.py
:
python pyinstxtractor.py yourFileName.exe
This will extract .exe
and create a folder named yourFileName.exe_extracted
.
Inside the yourFileName.exe_extracted
folder, find the file without any extension.
Edit it with HxD editor and from any __pycache__
file created with the same version of Python, copy the first row and insert it into your file.
Save and Rename the file with .pyc
extension.
Decompile the compiled bytecode (.pyc
) to .py
using any online tool, like https://www.toolnb.com/tools-lang-en/pyc.html
You could try this python-exe-unpacker from In Ming Loh. Not guaranteed to work though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With