Skip to main content

A tool for obscuring, or making python source difficult to read.

Project description

obscurepy

Build Status codecov

Description

A tool for obscuring, or making python source code difficult to read.

Table of Contents

  1. Installation
  2. Limitations
  3. Usage
  4. Disclaimer
  5. License

Installation

This command will install obscurepy:

python -m pip install obscurepy

I would recommend installing it in a virtual environment as opposed to globally:

python -m venv venv
source venv/bin/activate
python -m pip install obscurepy

Limitations

As this program is still in active development, there are many limitations. Below are some examples of what obscurepy can do. If it isn't in the example, obscurepy probably can't do it. This example serves to represent the ablities of each release. This example should be functional, both the original source and obscured source should execute.

An example:

class FirstClass:
    pass


class SecondClass(FirstClass):
    # this is a comment
    class_variable = 6

    def __init__(self, param_1):
        self.my_property = param_1

    def class_function(self, param_1, param_2):
        self.prop_1 = param_1
        self.prop_2 = param_2


def first_function():
    def with_another():
        c = 42
        return c
    return with_another()

def second_function(param_1, param_2, param_3):
    d = 'string'
    return d + str(param_1)

def third_function():
    e = 100.0
    return e

a = FirstClass()

b = SecondClass(1)

print(first_function())

print(second_function(1, 2, 3))

print(third_function())

a = SecondClass(1)

a.class_function(1, 2)

first_function()
class _0x3fe:
    pass

class _0x452(_0x3fe):
    _0x5bb = int('0x6', 16)

    def __init__(_0x1aa, _0x2a1):
        _0x1aa._0x4ca = _0x2a1

    def _0x5db(_0x1aa, _0x2a1, _0x2a2):
        _0x1aa._0x251 = _0x2a1
        _0x1aa._0x252 = _0x2a2

def _0x5ed():

    def _0x50c():
        _0x63 = int('0x2a', 16)
        return _0x63
    return _0x50c()

def _0x641(_0x2a1, _0x2a2, _0x2a3):
    _0x64 = ''.join([chr(x) for x in [115, 116, 114, 105, 110, 103]])
    return _0x64 + str(_0x2a1)

def _0x5e0():
    _0x65 = float.fromhex('0x1.9000000000000p+6')
    return _0x65
_0x61 = _0x3fe()
_0x62 = _0x452(int('0x1', 16))
print(_0x5ed())
print(_0x641(int('0x1', 16), int('0x2', 16), int('0x3', 16)))
print(_0x5e0())
_0x61 = _0x452(int('0x1', 16))
_0x61._0x5db(int('0x1', 16), int('0x2', 16))
_0x5ed()

Usage

The following command can be used to obscure a single file:

obscure --filepath=my_module.py

The following command can be used to obscure a multi file project:

obscure -p --project_dir=my_project

Alternatively, you can specify an output directory for both single file and multi file obscuring:

obscure --filepath=my_module.py --output_dir=desired_output_directory
obscure --project_dir=my_project --output_dir=desired_output_directory

Disclaimer

Obscurepy is no substitution for standard security practices. Obscurepy will not protect your code, nor will it protect the constants within your code. Python is an interpreted language and by nature anyone with access to your source code can reverse engineer it or simply extract any constant replacement to determine the value. Obscurepy is not meant to be used with security in mind. Obscurepy can make your source code difficult to read and it may deter people from trying. It will not stop any determined person from figuring out what your code does. I suggest looking into PyArmor if a more sophisticated method of obfuscation is required.

License

MIT License

Copyright (c) 2021 Andrew Christiansen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE

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

obscurepy-0.8.1.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

obscurepy-0.8.1-py3-none-any.whl (33.6 kB view details)

Uploaded Python 3

File details

Details for the file obscurepy-0.8.1.tar.gz.

File metadata

  • Download URL: obscurepy-0.8.1.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1+

File hashes

Hashes for obscurepy-0.8.1.tar.gz
Algorithm Hash digest
SHA256 62b82c2371ad7b67a60c80502fdc07906cdc562422b21a35f802609db405032d
MD5 f2da06cf863254820ecca40ac7dc6d83
BLAKE2b-256 c4e3875d5f1c4cd764cba39aca1d65f9f563a4b50881ee8591af3f2b28f1a7db

See more details on using hashes here.

File details

Details for the file obscurepy-0.8.1-py3-none-any.whl.

File metadata

  • Download URL: obscurepy-0.8.1-py3-none-any.whl
  • Upload date:
  • Size: 33.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.9.1+

File hashes

Hashes for obscurepy-0.8.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9aabda548fa50d5cbdfe1cd01543981c7e9cf9ce3ee58136bbb031414ee6ecbe
MD5 c15c14e1afcbd09bb590cd4e15074441
BLAKE2b-256 fe2ebe6a5694b5febd32a50a8629ae780e9c6a08aedd7c715b453fecc0ad8c1a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page