Python Wheel Obfuscator

Overview

English | 简体中文

pywhlobf

Overview

pywhlobf obfuscates your wheel distribution by compiling python source file to shared library.

Usage

manylinux based docker images

Following images are based on pypa/manylinux platforms, with the tagging format as -. The full list can be found in pywhlobf/tags. If you want to obfuscate a wheel to support a different target platform, i.e. macOS or Windows platform, you should install pywhlobf from PyPI in the target platform and execute manually, as described in the next section.

  • pywhlobf/pywhlobf:0.1.2-manylinux1_x86_64
  • pywhlobf/pywhlobf:0.1.2-manylinux1_i686
  • pywhlobf/pywhlobf:0.1.2-manylinux2010_x86_64
  • pywhlobf/pywhlobf:0.1.2-manylinux2010_i686
  • pywhlobf/pywhlobf:0.1.2-manylinux2014_x86_64
  • pywhlobf/pywhlobf:0.1.2-manylinux2014_i686

As a known issue, pulling from docker hub is intolerably slow for users in China. To speed up, simply add swr.cn-east-3.myhuaweicloud.com/ prefix to names above, i.e. docker pull swr.cn-east-3.myhuaweicloud.com/pywhlobf/pywhlobf:0.1.2-manylinux2014_x86_64.

To properly run the docker container, user should provide the following arguments to the docker run command:

  • -e PYTHON_ABI_TAG=: required. Indicating the supported Python & ABI tag. Should be one of cp36-cp36m, cp37-cp37m, cp38-cp38, cp39-cp39.
  • --user "$(id -u):$(id -g)": required. This field will be used by boxboat/fixuid to make sure the permission of output files are correct.
  • --rm -it: optional but recommended. This options make sure the container is deleted on exit.

Example of usage:

# Show help doc.
docker run \
  --rm -it \
  --user "$(id -u):$(id -g)" \
  -e PYTHON_ABI_TAG=cp36-cp36m \
  pywhlobf/pywhlobf:0.1.2-manylinux2014_x86_64 \
  --help

<< OUTPUT
export HOME="/home/pywhlobf"
PYWHLOBF=/opt/python/cp36-cp36m/bin/pywhlobf
NAME
    pywhlobf

SYNOPSIS
    pywhlobf INPUT_WHL_OR_FOLDER OUTPUT_FOLDER 

POSITIONAL ARGUMENTS
    INPUT_WHL_OR_FOLDER
        Path to the input wheel file, or the folder containing wheel file(s).
    OUTPUT_FOLDER
        Path to the output folder.

FLAGS
    --temp_folder=TEMP_FOLDER
        Type: Optional[]
        Default: None
        Path to the root of temporary folder.
    --compiler_options=COMPILER_OPTIONS
        Type: Optional[]
        Default: None
        If provided, should be a dict containing only the supported keys of `Cython.Compiler.Options`, as shown in `https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#compiler-options`. Example: --compiler_options='{"docstrings": False}'
    --cythonize_options=CYTHONIZE_OPTIONS
        Type: Optional[]
        Default: None
        If provided, should be a dict containing only the supported parameters of `Cython.Build.cythonize, as shown in `https://cython.readthedocs.io/en/latest/src/userguide/source_files_and_compilation.html#Cython.Build.cythonize` and `https://github.com/cython/cython/blob/9a761a637fce6a7b70735ae2248963d63e569e14/Cython/Compiler/Options.py#L566` Example: --cythonize_options='{"compiler_directives": {"emit_code_comments": False}}'
    --processes=PROCESSES
        Type: Optional[]
        Default: None
        The number of worker processes to use. All CPUs are used by default.
    --show_warning=SHOW_WARNING
        Default: False
        If set, show the build warnings.
    --abi_tag=ABI_TAG
        Type: Optional[]
        Default: None
        If set, hardcode the ABI tag within the output wheel filename to this one.
    --platform_tag=PLATFORM_TAG
        Default: 'manylinux2014_x86_64'
        If set, hardcode the platform tag within the output wheel filename to this one.

NOTES
    You can also use flags syntax for POSITIONAL ARGUMENTS
OUTPUT

# Download wheel-0.36.2-py2.py3-none-any.whl.
curl \
  'https://files.pythonhosted.org/packages/65/63/39d04c74222770ed1589c0eaba06c05891801219272420b40311cd60c880/wheel-0.36.2-py2.py3-none-any.whl' \
  --output 'wheel-0.36.2-py2.py3-none-any.whl'

# Obfuscate wheel-0.36.2-py2.py3-none-any.whl
# NOTE: `-v "$(pwd)":/data` mounts the current working directory to /data within the container.
docker run \
  --rm -it \
  --user "$(id -u):$(id -g)" \
  -e PYTHON_ABI_TAG=cp36-cp36m \
  -v "$(pwd)":/data \
  pywhlobf/pywhlobf:0.1.2-manylinux2014_x86_64 \
  '/data/wheel-0.36.2-py2.py3-none-any.whl' \
  '/data/tmp'

<< OUTPUT
export HOME="/home/pywhlobf"
PYWHLOBF=/opt/python/cp36-cp36m/bin/pywhlobf
[INFO] Processing /data/wheel-0.36.2-py2.py3-none-any.whl...
[INFO] input_whl=/data/wheel-0.36.2-py2.py3-none-any.whl
[INFO] distribution=wheel, version=0.36.2, build_tag=None
[INFO] extract_folder=/tmp/tmpt_epivyo
[INFO] Build options: compiler_options=None, cythonize_options=None, processes=None
[INFO] Building 16 python files...
[INFO] The following source files are removed:
[INFO]   wheel/__main__.py
[INFO]   wheel/macosx_libfile.py
[INFO]   wheel/__init__.py
[INFO]   wheel/pkginfo.py
[INFO]   wheel/metadata.py
[INFO]   wheel/wheelfile.py
[INFO]   wheel/util.py
[INFO]   wheel/bdist_wheel.py
[INFO]   wheel/vendored/__init__.py
[INFO]   wheel/vendored/packaging/__init__.py
[INFO]   wheel/vendored/packaging/_typing.py
[INFO]   wheel/vendored/packaging/tags.py
[INFO]   wheel/cli/pack.py
[INFO]   wheel/cli/__init__.py
[INFO]   wheel/cli/convert.py
[INFO]   wheel/cli/unpack.py
[INFO] Repacking...
[INFO] output_whl_name=wheel-0.36.2-cp36-cp36m-manylinux2014_x86_64.whl
[INFO] output_whl=/data/tmp/wheel-0.36.2-cp36-cp36m-manylinux2014_x86_64.whl
[INFO] Done.
[INFO]
OUTPUT

cd tmp && ls -alh

<< OUTPUT
total 6416
drwxr-xr-x  3 huntzhan  staff    96B Feb 23 14:33 .
drwxr-xr-x  4 huntzhan  staff   128B Feb 23 14:33 ..
-rw-r--r--  1 huntzhan  staff   3.1M Feb 23 14:33 wheel-0.36.2-cp36-cp36m-manylinux2014_x86_64.whl
OUTPUT

unzip wheel-0.36.2-cp36-cp36m-manylinux2014_x86_64.whl

<< OUTPUT
Archive:  wheel-0.36.2-cp36-cp36m-manylinux2014_x86_64.whl
  inflating: wheel/__init__.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/__main__.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/bdist_wheel.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/macosx_libfile.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/metadata.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/pkginfo.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/util.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/wheelfile.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/cli/__init__.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/cli/convert.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/cli/pack.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/cli/unpack.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/vendored/__init__.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/vendored/packaging/__init__.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/vendored/packaging/_typing.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel/vendored/packaging/tags.cpython-36m-x86_64-linux-gnu.so
  inflating: wheel-0.36.2.dist-info/LICENSE.txt
  inflating: wheel-0.36.2.dist-info/METADATA
  inflating: wheel-0.36.2.dist-info/WHEEL
  inflating: wheel-0.36.2.dist-info/entry_points.txt
  inflating: wheel-0.36.2.dist-info/top_level.txt
  inflating: wheel-0.36.2.dist-info/RECORD
OUTPUT

Install from PyPI

pip install pywhlobf
pywhlobf -- --help

Example:

pywhlobf wheel-0.36.2-py2.py3-none-any.whl ./tmp

<< OUTPUT
[INFO] input_whl=wheel-0.36.2-py2.py3-none-any.whl
[INFO] distribution=wheel, version=0.36.2, build_tag=None
[INFO] extract_folder=/var/folders/ts/x73fvp7d4g390cw9rx8cwkn80000gn/T/tmp7pb3euza
[INFO] Build options: compiler_options=None, cythonize_options=None, processes=None
[INFO] Building 16 python files...
[INFO] The following source files are removed:
[INFO]   wheel/metadata.py
[INFO]   wheel/macosx_libfile.py
[INFO]   wheel/util.py
[INFO]   wheel/__init__.py
[INFO]   wheel/pkginfo.py
[INFO]   wheel/bdist_wheel.py
[INFO]   wheel/wheelfile.py
[INFO]   wheel/__main__.py
[INFO]   wheel/cli/pack.py
[INFO]   wheel/cli/convert.py
[INFO]   wheel/cli/__init__.py
[INFO]   wheel/cli/unpack.py
[INFO]   wheel/vendored/__init__.py
[INFO]   wheel/vendored/packaging/tags.py
[INFO]   wheel/vendored/packaging/_typing.py
[INFO]   wheel/vendored/packaging/__init__.py
[INFO] Repacking...
[INFO] output_whl_name=wheel-0.36.2-cp38-cp38-macosx_10_15_x86_64.whl
[INFO] output_whl=tmp/wheel-0.36.2-cp38-cp38-macosx_10_15_x86_64.whl
[INFO] Done.
OUTPUT

cd ./tmp && unzip wheel-0.36.2-cp38-cp38-macosx_10_15_x86_64.whl
tree

<< OUTPUT
.
├── wheel
│   ├── __init__.cpython-38-darwin.so
│   ├── __main__.cpython-38-darwin.so
│   ├── bdist_wheel.cpython-38-darwin.so
│   ├── cli
│   │   ├── __init__.cpython-38-darwin.so
│   │   ├── convert.cpython-38-darwin.so
│   │   ├── pack.cpython-38-darwin.so
│   │   └── unpack.cpython-38-darwin.so
│   ├── macosx_libfile.cpython-38-darwin.so
│   ├── metadata.cpython-38-darwin.so
│   ├── pkginfo.cpython-38-darwin.so
│   ├── util.cpython-38-darwin.so
│   ├── vendored
│   │   ├── __init__.cpython-38-darwin.so
│   │   └── packaging
│   │       ├── __init__.cpython-38-darwin.so
│   │       ├── _typing.cpython-38-darwin.so
│   │       └── tags.cpython-38-darwin.so
│   └── wheelfile.cpython-38-darwin.so
├── wheel-0.36.2-cp38-cp38-macosx_10_15_x86_64.whl
└── wheel-0.36.2.dist-info
    ├── LICENSE.txt
    ├── METADATA
    ├── RECORD
    ├── WHEEL
    ├── entry_points.txt
    └── top_level.txt

5 directories, 23 files
OUTPUT
You might also like...
A modern Python application packaging and distribution tool

PyOxidizer PyOxidizer is a utility for producing binaries that embed Python. The over-arching goal of PyOxidizer is to make complex packaging and dist

Subpar is a utility for creating self-contained python executables. It is designed to work well with Bazel.

Subpar Subpar is a utility for creating self-contained python executables. It is designed to work well with Bazel. Status Subpar is currently owned by

FreezeUI is a python package that creates applications using cx_freeze and GUI by converting .py to .exe .
FreezeUI is a python package that creates applications using cx_freeze and GUI by converting .py to .exe .

FreezeUI is a python package use to create cx_Freeze setup files and run them to create applications and msi from python scripts (converts .py to .exe or .msi .

Psgcompiler A PySimpleGUI Application - Transform your Python programs in Windows, Mac, and Linux binary executables
Psgcompiler A PySimpleGUI Application - Transform your Python programs in Windows, Mac, and Linux binary executables

psgcompiler A PySimpleGUI Application "Compile" your Python programs into an EXE for Windows, an APP for Mac, and a binary for Linux Installation Old-

Python-easy-pack For Linux/Unix, Changed by laman28

Python-easy-pack For Linux/Unix, Changed by laman28

A library which implements low-level functions that relate to packaging and distribution of Python

What is it? Distlib is a library which implements low-level functions that relate to packaging and distribution of Python software. It is intended to

PBN Obfuscator: A overpowered obfuscator for python, which will help you protect your source code
PBN Obfuscator: A overpowered obfuscator for python, which will help you protect your source code

PBN Obfuscator PBN Obfuscator is a overpowered obfuscator for python, which will

A Python wheel containing PostgreSQL

postgresql-wheel A Python wheel for Linux containing a complete, self-contained, locally installable PostgreSQL database server. All servers run as th

Bitcoin-chance-wheel - Try your luck at getting bitcoins
Bitcoin-chance-wheel - Try your luck at getting bitcoins

Program Features - ✍️ Why did we name this tool the Lucky Wheel? - ✍️ This tool

Python & JavaScript Obfuscator made in Python 3.

Python Code Obfuscator A script that converts code into full on random numerical expressions. Simple Scripts: Python Mode... Input: Function that deco

A Python & JavaScript Obfuscator made in Python 3.

Python Code Obfuscator A script that converts code into full on random numerical expressions. Simple Scripts: Python Mode... Input: Function that deco

A Python obfuscator using HTTP Requests and Hastebin.
A Python obfuscator using HTTP Requests and Hastebin.

🔨 Jawbreaker 🔨 Jawbreaker is a Python obfuscator written in Python3, using double encoding in base16, base32, base64, HTTP requests and a Hastebin-l

A great and handy python obfuscator for protecting code.
A great and handy python obfuscator for protecting code.

Python Code Obfuscator A handy and necessary tool that can protect your code anytime! Mostly Command Line tool that will obfuscate your code. Features

LaxrFar Python Obfuscator

LaxrFar Python Obfuscator Usage First do the things from "Upload to Webserver" o

If you are worried about being found perhaps try taking cover under a blanket.  Pure Python PowerShell Obfuscator
If you are worried about being found perhaps try taking cover under a blanket. Pure Python PowerShell Obfuscator

If you are worried about being found perhaps try taking cover under a blanket. Pure Python PowerShell Obfuscator

Batch obfuscator based on the obfuscation method used by the trick bot launcher

Batch obfuscator based on the obfuscation method used by the trick bot launcher

Scapy: the Python-based interactive packet manipulation program & library. Supports Python 2 & Python 3.
Scapy: the Python-based interactive packet manipulation program & library. Supports Python 2 & Python 3.

Scapy Scapy is a powerful Python-based interactive packet manipulation program and library. It is able to forge or decode packets of a wide number of

Comments
  • Tool generates incorrect platform tag in output filename when run on Linux when using wheel version >0.34.2

    Tool generates incorrect platform tag in output filename when run on Linux when using wheel version >0.34.2

    pywhlobf currently (as of 0.2.3) generates an uninstallable wheel on linux due to an error in the platform tag in the output filename:

    As an example:

    Running pywhlobf test-0.1.0-py3-none-any.whl dist will produce the output dist/test-0.1.0-cp38-cp38-linux-x86_64.whl. Attempting to run pip3.8 install dist/test-0.1.0-cp38-cp38-linux-x86_64.whl will produce the error ERROR: test-0.1.0-cp38-cp38-linux-x86_64.whl is not a supported wheel on this platform. because linux-x86_64 is not a valid platform tag, it should be linux_x86_64 (note the use of an underscore rather than a dash). Manually renaming the file to the correct pattern solves the issue.

    This seems to be related to changes in wheel.bdist_wheel.get_platform in versions 0.35.0 and above.

    Related: https://github.com/huntzhan/pywhlobf/issues/1

    bug 
    opened by hutchisr 2
  • No python file to build, abort

    No python file to build, abort

    [root@localhost dist]# pywhlobf xx-0.1.0-py3-none-any.whl ./tmp
    [INFO] Processing xx-0.1.0-py3-none-any.whl...
    [INFO] input_whl=xx-0.1.0-py3-none-any.whl
    [INFO] distribution=xx, version=0.1.0, build_tag=None
    [INFO] extract_folder=/tmp/tmpg9_34b_h
    [INFO] No python file to build, abort.
    [INFO]
    

    May I ask what document is missing?

    opened by bulingda 2
  • ERROR: wheel-0.36.2-cp38-cp38-linux-x86_64.whl is not a supported wheel on this platform

    ERROR: wheel-0.36.2-cp38-cp38-linux-x86_64.whl is not a supported wheel on this platform

    after building a sample whl file from readme, i got the following error.

    ERROR: wheel-0.36.2-cp38-cp38-linux-x86_64.whl is not a supported wheel on this platform.
    

    Screenshot from 2021-09-21 12-52-38

    Screenshot from 2021-09-21 13-00-46

    opened by satya-500 1
Releases(22.1.0)
Owner
Hunt Zhan
Co-founder & Research Engineer @mnvai, Formerly: @microsoft, @tencent
Hunt Zhan
py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts.

py2app is a Python setuptools command which will allow you to make standalone Mac OS X application bundles and plugins from Python scripts. py2app is

Ronald Oussoren 222 Dec 30, 2022
Python virtualenvs in Debian packages

dh-virtualenv Contents Overview Presentations, Blogs & Other Resources Using dh-virtualenv How does it work? Running tests Building the package in a D

Spotify 1.5k Dec 16, 2022
A tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine or expire obfuscated scripts.

PyArmor Homepage (中文版网站) Documentation(中文版) PyArmor is a command line tool used to obfuscate python scripts, bind obfuscated scripts to fixed machine

Dashingsoft 1.9k Jan 1, 2023
Freeze (package) Python programs into stand-alone executables

PyInstaller Overview PyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app withou

PyInstaller 9.9k Jan 8, 2023
shiv is a command line utility for building fully self contained Python zipapps as outlined in PEP 441, but with all their dependencies included.

shiv shiv is a command line utility for building fully self-contained Python zipapps as outlined in PEP 441, but with all their dependencies included!

LinkedIn 1.5k Dec 28, 2022
Core utilities for Python packages

packaging Reusable core utilities for various Python Packaging interoperability specifications. This library provides utilities that implement the int

Python Packaging Authority 451 Jan 4, 2023
A library and tool for generating .pex (Python EXecutable) files

PEX Contents Overview Installation Simple Examples Integrating pex into your workflow Documentation Development Contributing Overview pex is a library

Pants Build 2.2k Jan 1, 2023
A distutils extension to create standalone Windows programs from Python code

py2exe for Python 3 py2exe is a distutils extension which allows to build standalone Windows executable programs (32-bit and 64-bit) from Python scrip

py2exe 526 Jan 4, 2023
Create standalone executables from Python scripts, with the same performance and is cross-platform.

About cx_Freeze cx_Freeze creates standalone executables from Python scripts, with the same performance, is cross-platform and should work on any plat

Marcelo Duarte 1k Jan 4, 2023
Build Windows installers for Python applications

Pynsist is a tool to build Windows installers for your Python applications. The installers bundle Python itself, so you can distribute your applicatio

Thomas Kluyver 818 Jan 5, 2023