AST based Obfuscator for Python
Project description
# bobskater
An AST based Python obfuscator that robustly mangles names in Python code
### Current limitations:
* DOES NOT SUPPORT: Annotations, evals, templated strings
* No configuration but instead takes a cautious approach in determining what identifiers to mangle. Globals, kwargs, class namespace identifiers, and others are not obfuscated but this should be user 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
```
from bobskater import obfuscateFile, obfuscateString
#Takes a file path and overwrites it with the obfuscated file
obfuscateFile(filePath)
#Takes a string of Python code and obfuscates it, returning the result
output = obfuscateString(open('myfile.py', 'r').read())
```
### Developing
The library is broken up into two parts. The first is `FrameTrackingNodeVisitor` which is an `ast.NodeVisitor` that is used to read an entire file and track all identifier usages and in which scopes they were defined, internally using `FrameTrackingNodeVisitor.Frame` and `FrameTrackingNodeVisitor.FrameEntry`. Public methods then allow querying of this internal representation (TODO: maybe the representation shouldn't be internal to the walker but should output it).
The second part is the `ReleaseObfuscationTransformer` which actually transforms the given AST into the obfuscated AST. It internall creates a `FrameTrackingNodeVisitor` to then query information from.
An AST based Python obfuscator that robustly mangles names in Python code
### Current limitations:
* DOES NOT SUPPORT: Annotations, evals, templated strings
* No configuration but instead takes a cautious approach in determining what identifiers to mangle. Globals, kwargs, class namespace identifiers, and others are not obfuscated but this should be user 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
```
from bobskater import obfuscateFile, obfuscateString
#Takes a file path and overwrites it with the obfuscated file
obfuscateFile(filePath)
#Takes a string of Python code and obfuscates it, returning the result
output = obfuscateString(open('myfile.py', 'r').read())
```
### Developing
The library is broken up into two parts. The first is `FrameTrackingNodeVisitor` which is an `ast.NodeVisitor` that is used to read an entire file and track all identifier usages and in which scopes they were defined, internally using `FrameTrackingNodeVisitor.Frame` and `FrameTrackingNodeVisitor.FrameEntry`. Public methods then allow querying of this internal representation (TODO: maybe the representation shouldn't be internal to the walker but should output it).
The second part is the `ReleaseObfuscationTransformer` which actually transforms the given AST into the obfuscated AST. It internall creates a `FrameTrackingNodeVisitor` to then query information from.
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.0.1.tar.gz
(8.1 kB
view hashes)
Built Distributions
bobskater-0.0.2-py3-none-any.whl
(11.8 kB
view hashes)
Close
Hashes for bobskater-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36ca78f8c6fda0f2e6a7ae57b20bc21c9e7f8849ba6e72c8dff0a5a16e2026f9 |
|
MD5 | 90ef4d7dd459c97364dc9a5b982cf769 |
|
BLAKE2b-256 | 4d0dd6aeb112e386c21711b8f5a36d2f76ef0ba980578bec7fc2594126d750ee |
Close
Hashes for bobskater-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a44bf8758a682e7f1ab2bde880f74b5d012049bcf159a6e7d2a2730ed666705 |
|
MD5 | 87307928683faacb59d8b44e3a37f678 |
|
BLAKE2b-256 | 508809cebf6cb3c81a9aeffe3c32cf21c05ec14e9cbc519947f810befd2a869f |