Stop Python exe script from converting back - python

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

Related

Blocking deciphering py.exe file

You know that a python file converted to an exe file can be deciphered and its codes can be displayed.
What is the way to prevent this decryption event? I don't want to people see the codes.
You can use Nuitka to convert .py file into a C-based standalone executable. Then, pass a resulting .exe file through VMProtect to obfuscate the binaries.

Program that can compile a python file from an alredy compiled python file

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

How to convert a created EXE file back to Python?

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.

Repack PyInstaller exe after extracting

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.

My exe doesn't execute after I decompiled and changed the code

I have an .exe file where file compiled by py2exe in my .exe folder I have some .dll files, one .exe file and library.zip file and inside this zip I have to many .pyccompiled files.
I have decompiled this files from library.zip using Easy Python Decompiler and that program created me new file where I can see and change my code.
I have opened this file where I needed and I changed my code using python editor and finaly I saved as new script code with the some name and extension .pyc
with purpose to replace first .pyc.
zip again library folder and I tried to run .exe prgram but after the changes the program doesn't execute.
What have I done wrong in my task? Do I need to re-compile again in some way?
pyc and py file are NOT the same. While they represent the same code, they are totally different :
the py file represents the code you are typing, can be interpreted by the python interpreter, is not native, and is portable
the pyc file is a compiled version of the py file, that is not portable, not intended to be modified by an human, but faster
You cannot swap them and expect it to work. You will need to compile it to pyc before. You will find more information here : How can I manually generate a .pyc file from a .py file

Categories