converting python into exe files on kali

useful for when you have a privesc in python, but the target windows machine doesn’t have python installed

# 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

# 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

# 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

# convert python to exe
wine c:/Python27/python.exe /opt/PyInstaller-2.1/pyinstaller.py –onefile evil.py

=> dist/evil.exe

note: modern antivirus might see pyinstaller generates EXEs as malicious… ┬ásome antivirus evasion products made heavy use of pyinstaller…

Leave a Reply

Your email address will not be published. Required fields are marked *