Convert Python to Exe files
Can be useful when you have a priv esc exploit in python but target Windows machine does not have python installed.
Most reliable way, that seems to work every time, is compiling the python via PyInstaller on a Windows box.
Following compiles an exe based on the specified Python script.
1 2 |
python pyinstaller.py --onefile C:\temp\PoC_Exploit.py |
Using pyinstaller on Kali to convert a Python script to Exe file:
1 2 3 4 5 |
# install python for windows wget https://www.python.org/ftp/python/2.7.8/python-2.7.8.msi wine msiexec /i python-2.7.8.msi rm python-2.7.8.msi |
1 2 3 4 5 |
# install pywin32 wget http://downloads.sourceforge.net/project/pywin32/pywin32/Build%20220/pywin32-220.win32-py2.7.exe wine pywin32–220.win32-py2.7.exe rm pywin32–220.win32-py2.7.exe |
1 2 3 4 5 |
# install pyinstaller wget https://github.com/pyinstaller/pyinstaller/releases/download/v2.1/PyInstaller-2.1.zip unzip PyInstaller-2.1.zip -d /opt rm PyInstaller-2.1.zip |
1 2 3 |
# convert python to exe wine c:/Python27/python.exe /opt/PyInstaller-2.1/pyinstaller.py --onefile exploit.py |