Wine
is a compatibility layer to run Windows
applications in POSIX
systems like Linux
.
One great example is the possibility to create .exe
files using Python
.
Please note that in the recent versions of Windows such as Windows 11, Microsoft is forcing you to sign the
.exe
files in order to be able to run them.
It can be installed with your package manager.
sudo apt-get install wine
Note that it’s necessary to have x86 arch also enabled, so maybe you have to run this:
sudo dpkg --add-architecture i386 && sudo apt-get update && sudo apt-get install wine32
To install Python
you must download the version that you want to run. In this case we are using 2.7
sudo wine msiexec /i /home/kali/Downloads/python-2.7.18.msi
It will be installed in /root/.wine/drive_c/Python27
Once it is installed, you would see that you have the /root/.wine/
folder. Let’s install pip.
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo wine /root/.wine/drive_c/Python27/python.exe get-pip.py
sudo wine /root/.wine/drive_c/Python27/python.exe -m pip help
To install dependencies and use in the executable,
sudo wine /root/.wine/drive_c/Python27/python.exe -m pip install <dependency>
To compile the executable
sudo wine /root/.wine/drive_c/Python27/Scripts/pyinstaller.exe --onefile --noconsole <python_file.py>
Python 2.7 reached end of its life on January 1st, 2020. Please upgrade your Python!!
In the recent versions of Windows your .exe
file will be identified by Windows Defender. So long I wasn’t able to avoid this using alternative packages to pyinstaller
or using obfuscation. Let me know if there is some workaround to signing the files!