AST based Obfuscator for Python
Project description
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 withpass
statements (to handle even cases where a function has only a docstring). Defaults toTrue
obfuscateNames
will obfuscate all names except globally scoped variables, kwargs, builtins, and identifiers in a class namespace. Defaults toTrue
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)
Developing
See CONTRIBUTING.MD
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
bobskater-0.2.0.tar.gz
(9.1 kB
view hashes)
Built Distribution
bobskater-0.2.0-py3-none-any.whl
(10.0 kB
view hashes)
Close
Hashes for bobskater-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbae3c3c91d247902993140c7cdbcc08354f5d7371afbd84b194914a694f57bc |
|
MD5 | 46fabb513e2b1b7ca77d957b5cf9256c |
|
BLAKE2b-256 | 4bf35c23eb7965db8e58b08a65206d53fb909d5210181439b44220a6bf2b98e1 |