How do I convert a EXE file created with PyInstaller back to a .py file?
I already tried python-exe-unpack-master, but that didn't work. Further I've seen this article: How do you reverse engineer an EXE "compiled" with PyInstaller but I don't know how to extract the EXE's append data.
Is there a other way? Or can someone explain me more about the method I gave.
You can extract the contents of the .exe file using PyInstaller Extractor. Run it like this:
python pyinstxtractor.py executable.exe
You will get your python file.
Related
For example, I have a Python file like this:
print("Hello World")
Now I am converting it to an .exe file using pyinstaller.
But I found a method to convert it back:
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
Is there any way to prevent converting the .exe file converting back to his .py file?
Thanks.
You can use an obfuscation tool such as PyArmor and add at-least some level of code-protection to your original python script.
The official documentation of PyArmor has more info on this here https://pyarmor.readthedocs.io/en/latest/advanced.html#bundle-obfuscated-scripts-to-one-executable-file
I've written a simple python script that uses openpyxl to read IP's out of an excel file and does a whois lookup on it and writes the results to a new excel file. Everything works great in Spyder but when I package it as an exe using pyinstaller I get an error when I run the exe.
The traceback says "'Worksheet' object has no attribute 'values'" like it's not reading the values from the original excel file. I've tried using the full path of the file but still get the same error. The excel file is in the same directory as the exe. Do I need to package the exe in a different way? Specifically tell it to package the openpyxl library?
I've done a lot of googling and can't find much info. Any help is appreciated! Thank you
I'm searching a way to compile a python file into an exe from an alredy compiled python file.
For example:
I have main_script.py, I used PyInstaller to convert it into main_script.exe
Into main_script.exe there is a part of code that convert some hardcoded lines of python into a new exe (or maybe even creating a python file, converting it and then deleting the python file).
Now when I start main_script.exe I need to have new_exe.exe and another_exe.exe in my cwd (Current Working Directory).
I searched a lot but I didn't found anything useful, can someone help me? Thanks
I'm a newbie using python, I'm trying to create a .exe from a .py file. But, when I create this .exe, It only work if the images are in the same folder as the .exe file( but on the prompt code that a I use I think that it would compact everything together ). I read some topics here about it, but I didn't find the reason for this error.
pyinstaller -y -F -w -i "C:/Users/silvag1/Desktop/final/mc.ico" --add-data "C:/Users/silvag1/Desktop/final/photo.png";"." --add-data "C:/Users/silvag1/Desktop/final/mc.ico";"." "C:/Users/silvag1/Desktop/final/final.py"
I thought that if I use the --add-data, everything would be compacted in a single file.
I've already read Bundling data files with PyInstaller (--onefile)
but I didn't understand. So, just to be clear, my purpose is create only one file( a .exe) using a .py.
Remove the -add-data & it's argument
Build the .exe as you normally do
After you do, You'll have a dest folder & .spec file
The data is added to the spec file, you'll find there an array of data called analysis
add your image path & escape the slashes as you see in the file
use pyinstaller to build & this time build the .spec file, it will work
another way to do this is here, (I didn't test)
Is it possible to repack/rebuild a PyInstaller exe file after extracting the files from it using PyInstaller Extractor? I also decomplied most of the files with Easy Python Decomplier. I modified one .py file and I want the new exe file to contain this modified file. How can I repack the application?
You may leave all not modified files as *.pyc.
Once you have full modules structure ready, just find the original entrypoint and pack the bundle again, it should work.