Encrypt data by storing it within a Python script that pretends to just be "obfuscated"
Project description
Obfuscatron
Encrypt data by storing it within a Python script that pretends to just be "obfuscated"
Features
- Store binary or text data within the identifiers of a Python script
- Obfuscated Python script can be executed (see notes below)
Currently, Obfuscatron is able to store data within the following Python syntax:
- Variables
- Class Names
- Function Names
- Type Hint Identifiers
Installation
$ pip install obfuscatron
$ pip install "git+https://github.com/Pebaz/obfuscatron"
Usage
$ obfuscatron FILE.py encode DATAFILE OUTFILE.py
$ obfuscatron OUTFILE.py decode DATAFILE
Example
Given this Python file to store some data:
custom_int_name = int
def function_add(first_number: custom_int_name, second_number: custom_int_name):
return first_number + second_number
def function_sub(first_number: custom_int_name, second_number: custom_int_name):
return first_number - second_number
def function_mul(first_number: custom_int_name, second_number: custom_int_name):
return first_number * second_number
def function_div(first_number: custom_int_name, second_number: custom_int_name):
return first_number / second_number
def function_mod(first_number: custom_int_name, second_number: custom_int_name):
return first_number % second_number
def function_exp(first_number: custom_int_name, second_number: custom_int_name):
return first_number ** second_number
custom_float_name = float
def func_float_add(first_num: custom_float_name, second_num: custom_float_name):
return first_num + second_num
def func_float_sub(first_num: custom_float_name, second_num: custom_float_name):
return first_num - second_num
def func_float_mul(first_num: custom_float_name, second_num: custom_float_name):
return first_num * second_num
def func_float_div(first_num: custom_float_name, second_num: custom_float_name):
return first_num / second_num
def func_float_mod(first_num: custom_float_name, second_num: custom_float_name):
return first_num % second_num
def func_float_exp(first_num: custom_float_name, second_num: custom_float_name):
return first_num ** second_num
custom_bool_name = bool
def function_and(first_bool: custom_bool_name, second_bool: custom_bool_name):
return first_bool and second_bool
def function_or(first_bool: custom_bool_name, second_bool: custom_bool_name):
return first_bool or second_bool
def function_xor(first_bool: custom_bool_name, second_bool: custom_bool_name):
return first_bool != second_bool
Turn this data:
name = Earth
radius = 39000000
terrestrial = True
foo = "😂"
name = Mars
radius = 12349282382
terrestrial = True
foo = "😂😂"
name = Jupiter
radius = 4300012323
terrestrial = False
foo = "😂😂😂"
Into this "obfuscated" Python file containing that data:
$ obfuscatron python-file.py encode original-data.txt obfuscated-python-file.py
Result:
_1bdf0020ac0e6cb = int
def _739d460d09a9(_ba3f70e5094d: _1bdf0020ac0e6cb, _90e68e0bb016d:
_1bdf0020ac0e6cb):
return _ba3f70e5094d + _90e68e0bb016d
def _fb4103c9b200(_ba3f70e5094d: _1bdf0020ac0e6cb, _90e68e0bb016d:
_1bdf0020ac0e6cb):
return _ba3f70e5094d - _90e68e0bb016d
def _0ba260174885(_ba3f70e5094d: _1bdf0020ac0e6cb, _90e68e0bb016d:
_1bdf0020ac0e6cb):
return _ba3f70e5094d * _90e68e0bb016d
def _f9d90a0d6672(_ba3f70e5094d: _1bdf0020ac0e6cb, _90e68e0bb016d:
_1bdf0020ac0e6cb):
return _ba3f70e5094d / _90e68e0bb016d
def _a3271bd8e033(_ba3f70e5094d: _1bdf0020ac0e6cb, _90e68e0bb016d:
_1bdf0020ac0e6cb):
return _ba3f70e5094d % _90e68e0bb016d
def _ec4dee8dd39d(_ba3f70e5094d: _1bdf0020ac0e6cb, _90e68e0bb016d:
_1bdf0020ac0e6cb):
return _ba3f70e5094d ** _90e68e0bb016d
_47bc061a1719dfeeb = float
def _ac6c1471eea643(_35f1426de: _47bc061a1719dfeeb, _24220208bf:
_47bc061a1719dfeeb):
return _35f1426de + _24220208bf
def _230ee4d679e58a(_35f1426de: _47bc061a1719dfeeb, _24220208bf:
_47bc061a1719dfeeb):
return _35f1426de - _24220208bf
def _d4dc6493bf79fe(_35f1426de: _47bc061a1719dfeeb, _24220208bf:
_47bc061a1719dfeeb):
return _35f1426de * _24220208bf
def _36599759ee0be1(_35f1426de: _47bc061a1719dfeeb, _24220208bf:
_47bc061a1719dfeeb):
return _35f1426de / _24220208bf
def _c098256f8e486f(_35f1426de: _47bc061a1719dfeeb, _24220208bf:
_47bc061a1719dfeeb):
return _35f1426de % _24220208bf
def _8edeab92c6b73c(_35f1426de: _47bc061a1719dfeeb, _24220208bf:
_47bc061a1719dfeeb):
return _35f1426de ** _24220208bf
_8709a8aa09751c5d = bool
def _653c1fd____b(_rp9q563626: _8709a8aa09751c5d, _0eqmvftj17s:
_8709a8aa09751c5d):
return _rp9q563626 and _0eqmvftj17s
def _pceiwy12s6f(_rp9q563626: _8709a8aa09751c5d, _0eqmvftj17s:
_8709a8aa09751c5d):
return _rp9q563626 or _0eqmvftj17s
def _9zleib3qmp0b(_rp9q563626: _8709a8aa09751c5d, _0eqmvftj17s:
_8709a8aa09751c5d):
return _rp9q563626 != _0eqmvftj17s
To get it back:
$ obfuscatron obfuscated-python-file.py decode get-original-data-back.txt
Notes
Since Python is a fully dynamic language, any section of code within a Python script can lookup specific variables, classes, and functions by name. Scripts using this feature of Python will not work after being obfuscated by Obfuscatron because Obfuscatron changes the names of all the identifiers in the script. To properly use Obfuscatron, use an input script that works (to not draw attention to the variable names storing data), and ensure that no dynamic name introspection occurs during runtime.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file obfuscatron-1.0.0.tar.gz
.
File metadata
- Download URL: obfuscatron-1.0.0.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.25.1 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83c9f5534a9b8dbb8e3094f048030972b76ef7819db38dba483037c0c179b961 |
|
MD5 | 2ca904dc0096a8dca6f0320a64ef1982 |
|
BLAKE2b-256 | c1d6ab2a42cf8381d350aaa6354fe8c656115f69949bf015d7c4e9041c21cc50 |