-
-
Save C0axx/3371cbfd3c67a57e5bf287ee5e02269d to your computer and use it in GitHub Desktop.
How to turn a python script into a statically linked executable with pyinstaller and staticx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example below is with mitm6 (https://github.com/fox-it/mitm6/) | |
// Note: Adding the '--add-binary' option here is specific to mitm6, not required in all cases. | |
# pip install pyinstaller | |
# pyinstaller --clean -F --add-binary="/usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0:." ./mitm6.py | |
// The step above will create a single binary in the ./dist/ directory called mitm6 | |
// Install staticx and dependencies | |
# apt update && apt install binutils patchelf | |
# pip install patchelf-wrapper | |
# pip install scons | |
# git clone https://github.com/JonathonReinhart/staticx | |
# cd staticx | |
# scons | |
# python setup.py install | |
// Now create the statically linked binary using staticx and the output from PyInstaller | |
# staticx /opt/tools/mitm6/mitm6/dist/mitm6 /tmp/mitm6.static | |
# file /tmp/mitm6.static | |
/tmp/mitm6.static: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=bc235534bcd37c68e25822e87e19cac99377d865, for GNU/Linux 3.2.0, not stripped |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment