obfupy


Nameobfupy JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/wqking/obfupy
Summaryobfupy is a Python 3 library that can obfuscate whole Python 3 projects, transform the source code to obfuscated and hard to understand code. obfupy aims to produce correct and functional code.
upload_time2024-08-21 01:50:01
maintainerNone
docs_urlNone
authorwqking
requires_python>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # obfupy -- Python source code obfuscator aiming to produce correct and functional code

obfupy is a Python 3 library that can obfuscate entire Python 3 projects, transforming source code into obfuscated and difficult-to-understand code.
obfupy aims to produce correct and functional code. Several non-trivial real-world projects were tested using obfupy,
such as Flask, Nodezator, Algorithms collection, and Django (not all features are enabled for Django).

## Facts and features

- **Obfuscation methods**
  - Rewrite the "if" conditional to include many confusing branches.
  - Rename local variable names.
  - Extract the function and have the original function call the extracted function, then rename the parameters in the extracted function.
  - Create alias for function arguments.
  - Obfuscate numeric and string constants and replace them with random variable names.
  - Replace built-in function names (e.g. "print") with random variable names.
  - Add useless control flow to `for` and `while`.
  - Remove doc strings.
  - Remove comments.
  - Add extra spaces around operators.
  - Make indents larger to make it harder to read.
  - Add extra blank lines between code lines.
  - Encode the whole Python source file with base64, zip, bz2, byte obfuscator, and easy to add your own codec.
- **Customizable**
  - There are multiple layers of independent transformers. You can choose which transformers to use and which not to use.
  - The non-trivial transformers such as Rewriter, Formatter, support comprehensive options to enable/disable features. If any feature doesn't work well for your project, you can just disable it.
- **Well tested**
  - There are tests that cover all features.
  - Tested with several real world non-trivial projects such as Flask, Nodezator, Algorithms collection, and Django.

## License

Apache License, Version 2.0  

## Version 0.1.1

## Source code

[https://github.com/wqking/obfupy](https://github.com/wqking/obfupy)

## Dependencies

obfupy requires Python 3.9 or later, it doesn't have any other dependencies.

## Install

**Install from pip package**  
`pip install obfupy`

**Install from source code**  
Clone obfupy repository, change directory to the root of obfupy, then,  
`pip install -e .`

**Use from source code without installation**  
Clone obfupy repository, add following lines in the beginning of your script,  
```
import sys
sys.path.append(PATH_TO_OBFUPY)
```

## Quick start

A typical Python script using obfupy looks like,   

```python
import obfupy.documentmanager as documentmanager
import obfupy.util as util
import obfupy.transformers.rewriter as rewriter
import obfupy.transformers.formatter as formatter

inputPath = PATH_TO_THE_SOURCE_CODE
outputPath = PATH_TO_OUTPUT

# Prepare source code files as DocumentManager
fileList = util.findFiles(inputPath)
documentManager = documentmanager.DocumentManager()
documentManager.addDocument(util.loadDocumentsFromFiles(fileList))

# Transform the source code with various transformers

# Transformer Rewriter
rewriter.Rewriter().transform(documentManager)
# Transformer Formatter
formatter.Formatter().transform(documentManager)
# There are other transformers

# Write the obfuscated code to outputPath
util.writeOutputFiles(documentManager, inputPath, outputPath)
```

## Documentations

* [Get started -- the scaffolding script](https://github.com/wqking/obfupy/tree/master/doc/scaffolding.md)
* [Document and DocumentManager - the input source for transformers](https://github.com/wqking/obfupy/tree/master/doc/documentmanager.md)
* [Transformers overview](https://github.com/wqking/obfupy/tree/master/doc/transformer_overview.md)
* [Options and callback](https://github.com/wqking/obfupy/tree/master/doc/options_and_callback.md)
* [Transformer Rewriter -- rewrite the Python code in different structure](https://github.com/wqking/obfupy/tree/master/doc/transformer_rewriter.md)
* [Transformer Formatter -- change the code visual layout](https://github.com/wqking/obfupy/tree/master/doc/transformer_formatter.md)
* [Transformer Replacer -- replace symbols literally](https://github.com/wqking/obfupy/tree/master/doc/transformer_replacer.md)
* [Transformer Codec -- encode the whole Python source file](https://github.com/wqking/obfupy/tree/master/doc/transformer_codec.md)
* [Utilities](https://github.com/wqking/obfupy/tree/master/doc/util.md)
* [How obfupy is tested with real world projects](https://github.com/wqking/obfupy/tree/master/doc/real_world_projects.md)
* [Infrequently Asked Questions](https://github.com/wqking/obfupy/tree/master/doc/faq.md)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/wqking/obfupy",
    "name": "obfupy",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "wqking",
    "author_email": "wqking@NOSPAMoutlook.com",
    "download_url": "https://files.pythonhosted.org/packages/6c/fe/79018685c043a274c7f3a9679be42d53b436a6408783ab0c0d420e8bfe35/obfupy-0.1.1.tar.gz",
    "platform": "any",
    "description": "# obfupy -- Python source code obfuscator aiming to produce correct and functional code\r\n\r\nobfupy is a Python 3 library that can obfuscate entire Python 3 projects, transforming source code into obfuscated and difficult-to-understand code.\r\nobfupy aims to produce correct and functional code. Several non-trivial real-world projects were tested using obfupy,\r\nsuch as Flask, Nodezator, Algorithms collection, and Django (not all features are enabled for Django).\r\n\r\n## Facts and features\r\n\r\n- **Obfuscation methods**\r\n  - Rewrite the \"if\" conditional to include many confusing branches.\r\n  - Rename local variable names.\r\n  - Extract the function and have the original function call the extracted function, then rename the parameters in the extracted function.\r\n  - Create alias for function arguments.\r\n  - Obfuscate numeric and string constants and replace them with random variable names.\r\n  - Replace built-in function names (e.g. \"print\") with random variable names.\r\n  - Add useless control flow to `for` and `while`.\r\n  - Remove doc strings.\r\n  - Remove comments.\r\n  - Add extra spaces around operators.\r\n  - Make indents larger to make it harder to read.\r\n  - Add extra blank lines between code lines.\r\n  - Encode the whole Python source file with base64, zip, bz2, byte obfuscator, and easy to add your own codec.\r\n- **Customizable**\r\n  - There are multiple layers of independent transformers. You can choose which transformers to use and which not to use.\r\n  - The non-trivial transformers such as Rewriter, Formatter, support comprehensive options to enable/disable features. If any feature doesn't work well for your project, you can just disable it.\r\n- **Well tested**\r\n  - There are tests that cover all features.\r\n  - Tested with several real world non-trivial projects such as Flask, Nodezator, Algorithms collection, and Django.\r\n\r\n## License\r\n\r\nApache License, Version 2.0  \r\n\r\n## Version 0.1.1\r\n\r\n## Source code\r\n\r\n[https://github.com/wqking/obfupy](https://github.com/wqking/obfupy)\r\n\r\n## Dependencies\r\n\r\nobfupy requires Python 3.9 or later, it doesn't have any other dependencies.\r\n\r\n## Install\r\n\r\n**Install from pip package**  \r\n`pip install obfupy`\r\n\r\n**Install from source code**  \r\nClone obfupy repository, change directory to the root of obfupy, then,  \r\n`pip install -e .`\r\n\r\n**Use from source code without installation**  \r\nClone obfupy repository, add following lines in the beginning of your script,  \r\n```\r\nimport sys\r\nsys.path.append(PATH_TO_OBFUPY)\r\n```\r\n\r\n## Quick start\r\n\r\nA typical Python script using obfupy looks like,   \r\n\r\n```python\r\nimport obfupy.documentmanager as documentmanager\r\nimport obfupy.util as util\r\nimport obfupy.transformers.rewriter as rewriter\r\nimport obfupy.transformers.formatter as formatter\r\n\r\ninputPath = PATH_TO_THE_SOURCE_CODE\r\noutputPath = PATH_TO_OUTPUT\r\n\r\n# Prepare source code files as DocumentManager\r\nfileList = util.findFiles(inputPath)\r\ndocumentManager = documentmanager.DocumentManager()\r\ndocumentManager.addDocument(util.loadDocumentsFromFiles(fileList))\r\n\r\n# Transform the source code with various transformers\r\n\r\n# Transformer Rewriter\r\nrewriter.Rewriter().transform(documentManager)\r\n# Transformer Formatter\r\nformatter.Formatter().transform(documentManager)\r\n# There are other transformers\r\n\r\n# Write the obfuscated code to outputPath\r\nutil.writeOutputFiles(documentManager, inputPath, outputPath)\r\n```\r\n\r\n## Documentations\r\n\r\n* [Get started -- the scaffolding script](https://github.com/wqking/obfupy/tree/master/doc/scaffolding.md)\r\n* [Document and DocumentManager - the input source for transformers](https://github.com/wqking/obfupy/tree/master/doc/documentmanager.md)\r\n* [Transformers overview](https://github.com/wqking/obfupy/tree/master/doc/transformer_overview.md)\r\n* [Options and callback](https://github.com/wqking/obfupy/tree/master/doc/options_and_callback.md)\r\n* [Transformer Rewriter -- rewrite the Python code in different structure](https://github.com/wqking/obfupy/tree/master/doc/transformer_rewriter.md)\r\n* [Transformer Formatter -- change the code visual layout](https://github.com/wqking/obfupy/tree/master/doc/transformer_formatter.md)\r\n* [Transformer Replacer -- replace symbols literally](https://github.com/wqking/obfupy/tree/master/doc/transformer_replacer.md)\r\n* [Transformer Codec -- encode the whole Python source file](https://github.com/wqking/obfupy/tree/master/doc/transformer_codec.md)\r\n* [Utilities](https://github.com/wqking/obfupy/tree/master/doc/util.md)\r\n* [How obfupy is tested with real world projects](https://github.com/wqking/obfupy/tree/master/doc/real_world_projects.md)\r\n* [Infrequently Asked Questions](https://github.com/wqking/obfupy/tree/master/doc/faq.md)\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "obfupy is a Python 3 library that can obfuscate whole Python 3 projects, transform the source code to obfuscated and hard to understand code. obfupy aims to produce correct and functional code.",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/wqking/obfupy"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6cfe79018685c043a274c7f3a9679be42d53b436a6408783ab0c0d420e8bfe35",
                "md5": "db28c1f979dac28a8968502955a2e211",
                "sha256": "0c6d689972eb20bdce8cfc031d61bb8a07382abd92126833cf01dd2f9a705a67"
            },
            "downloads": -1,
            "filename": "obfupy-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "db28c1f979dac28a8968502955a2e211",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 28678,
            "upload_time": "2024-08-21T01:50:01",
            "upload_time_iso_8601": "2024-08-21T01:50:01.622419Z",
            "url": "https://files.pythonhosted.org/packages/6c/fe/79018685c043a274c7f3a9679be42d53b436a6408783ab0c0d420e8bfe35/obfupy-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-21 01:50:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wqking",
    "github_project": "obfupy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "obfupy"
}
        
Elapsed time: 0.70002s