Skip to main content

build status pypi python versions twitter twitter

bobskater

An AST based Python obfuscator that robustly mangles names and other obfuscations of Python code

Current limitations:

  • DOES NOT SUPPORT: Annotations, evals, templated strings, imports of the form import xxx.yyy
  • Very little configuration currently and instead takes a cautious approach in determining what identifiers to mangle. Globals, kwargs, class namespace identifiers, and others are not obfuscated but type of obfuscations should be use selected in the future.
  • It is only tested with Python v3.5 and might not work with other AST versions
  • Scoping for comprehensions are kind of hacky (and basically follows Python 2 comprehension scope leaking methodology)

Installation

pip install bobskater

Usage

bobskater provides a few mechanisms for direct use.

  • obfuscateString("") obfuscates a string of source code.
  • obfuscateFile('myfile.py') will obfuscate an entire file and overwrite the original

Both take keyword arguments for configuration:

  • removeDocstrings will remove docstrings by replacing them with pass statements (to handle even cases where a function has only a docstring). Defaults to True
  • obfuscateNames will obfuscate all names except globally scoped variables, kwargs, builtins, and identifiers in a class namespace. Defaults to True

There are no other obfuscations performed than the two mentioned above currently in bobskater

Example

from bobskater import obfuscateString

myFileContents = open('myfile.py', 'r').read()

#Will obfuscate myFileContents and return it into output. Names will not be mangled, only docstrings will be removed
output = obfuscateString(myFileContents, obfuscateNames=False)

Contributing

Testing:

pytest - Runs all the tests

Releasing:

Refer to the python docs on packaging for clarification. Make sure you've updated setup.py, and have installed twine, setuptools, and wheel python3 setup.py sdist bdist_wheel - Create a source distribution and a binary wheel distribution into dist/ twine upload dist/bobskater-x.x.x* - Upload all dist/ files to PyPI of a given version Make sure to tag the commit you released

Metadata

Release files for bobskater 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bobskater 0.2.1
File Size Uploaded Provenance Actions
bobskater-0.2.1.tar.gz 9.6 kB Without provenance Details for bobskater-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bobskater 0.2.1
File Interpreter ABI Platform Actions
bobskater-0.2.1-py3-none-any.whl Python 3 none any Details for bobskater-0.2.1-py3-none-any.whl

Total release size: 20.9 kB

Release files / bobskater-0.2.1.tar.gz

Download URL bobskater-0.2.1.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9f9f9c1895e97e3aef05852006180d1cb85889a29728ddfcab236f813e4127af
BLAKE2b-256 checksum
How to use checksums
e93c871961352f5eac15b5da8ee40958c1d40c731d0a676a9af966004f8c306d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8

Release files / bobskater-0.2.1-py3-none-any.whl

Download URL bobskater-0.2.1-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c274adba22380cd91b7b920c8dd6b7ac9f48b1cbccf5191ba0d4705e76fa9ad5
BLAKE2b-256 checksum
How to use checksums
d817228439747409fe93144b076a060d14c125d3198d0d00d73d5d5497856815
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.8

Security for bobskater 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page