('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.',)
Project description
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
andwhile
. - 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.0
Source code
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,
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
- Document and DocumentManager - the input source for transformers
- Transformers overview
- Options and callback
- Transformer Rewriter -- rewrite the Python code in different structure
- Transformer Formatter -- change the code visual layout
- Transformer Replacer -- replace symbols literally
- Transformer Codec -- encode the whole Python source file
- Utilities
- How obfupy is tested with real world projects
- Infrequently Asked Questions
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 obfupy-0.1.0.tar.gz
.
File metadata
- Download URL: obfupy-0.1.0.tar.gz
- Upload date:
- Size: 28.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.9.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36a522875e2fe821218c8acf8fe4057deb75b100760f02944d28291b8b0f0827 |
|
MD5 | 619c0507d9d9a23b836d4ccf34df9a4a |
|
BLAKE2b-256 | d6f7865f77fa64d0248a176ff951a6ff9cf9cc351689b768b4ac6e3e497b85b7 |