Skip to main content

Build static self-extracting app from dynamic executable

Project description

StaticX Build Status PyPI

Bundle dynamic executables with their library dependencies so they can be run anywhere, just like a static executable.

Requirements

StaticX currently works only with Linux 64-bit dynamic executables.

The following external tools need to be installed to run StaticX:

  • ldd - Part of GNU C Library
  • readelf - Part of binutils
  • objcopy - Part of binutils
  • patchelf
    • Packages available for Debian 8+, Fedora 14+, others
    • install with pip install patchelf-wrapper

The following additional tools must be installed to build StaticX from source:

Installation

From PyPI

StaticX is avaiable on PyPI. The wheels are built on Travis CI and include a bootloader built with musl-libc.

You can install using Pip. StaticX is compatible with Python Python 3.5+ (pip3):

sudo pip3 install staticx

From source

If you have musl libc installed, you can use it to build the staticx bootloader, resulting in smaller, better binaries. To do so, set the BOOTLOADER_CC environment variable to your musl-gcc wrapper path wehn invoking pip or setup.py:

sudo BOOTLOADER_CC=/usr/local/musl/bin/musl-gcc pip3 install https://github.com/JonathonReinhart/staticx/archive/master.zip
cd staticx
sudo BOOTLOADER_CC=/usr/local/musl/bin/musl-gcc pip3 install .

Usage

Basic wrapping of an executable

staticx /path/to/exe /path/to/output

StaticX will automatically discover and bundle most normal linked libraries. However, libraries loaded by an application at runtime via dlopen() cannot currently be detected. These can be manually included in the application bundle by using the -l option (any number can be specified by repeating the -l option).

staticx -l /path/to/fancy/library /path/to/exe /path/to/output

Caveats

StaticX employs a number of tricks to run applications with only their bundled libraries to ensure compatibilitiy. Because of this, there are some caveats that apply to StaticX-bundled applications:

  • The dynamic linker is instructed (via nodeflib) to only permit bundled libraries to be loaded.
  • Target NSS configuration (/etc/nsswitch.conf) is ignored (for GLIBC-linked applications) which means that some advanced name services (e.g. Active Directory) will not be available at runtime. For example, looking up the UID number of a domain user will not work.

Run-time Information

StaticX sets the following environment variables for the wrapped user program:

  • STATICX_BUNDLE_DIR: The absolute path of the "bundle" directory, the temporary dir where the archive has been extracted.
  • STATICX_PROG_PATH: The absolute path of the program being executed.

License

This software is released under the GPLv2, with an exception allowing the bootloader to be distributed. See LICENSE.txt for more details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

staticx-0.13.2.tar.gz (76.7 kB view details)

Uploaded Source

Built Distribution

staticx-0.13.2-py3-none-manylinux1_x86_64.whl (192.1 kB view details)

Uploaded Python 3

File details

Details for the file staticx-0.13.2.tar.gz.

File metadata

  • Download URL: staticx-0.13.2.tar.gz
  • Upload date:
  • Size: 76.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for staticx-0.13.2.tar.gz
Algorithm Hash digest
SHA256 1d09083b1e5d4e4012582f9201e3d3a8923d92792cd3f3bb7346d7114d79a081
MD5 b1e6cdf73f399c71071f41232c60c7f2
BLAKE2b-256 8694a30c393cdafe5026f35d5a70f7c3cdab3cc09f51012d170fdcdffe3721d9

See more details on using hashes here.

File details

Details for the file staticx-0.13.2-py3-none-manylinux1_x86_64.whl.

File metadata

  • Download URL: staticx-0.13.2-py3-none-manylinux1_x86_64.whl
  • Upload date:
  • Size: 192.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.4.2 requests/2.25.1 setuptools/52.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.2

File hashes

Hashes for staticx-0.13.2-py3-none-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7df9a14fd8fedbd315ad86efce93228a820e25623ecbf640ec86a7d840c4eccc
MD5 38d46b188d74acf23b21d0938b4df530
BLAKE2b-256 bf6b660102191b2fddd14a4a41495b6bf2b598ffa204aa5a5f24e8b6af9d03c4

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page