A terminal-based Python obfuscation and multi-layer encoding toolkit.
Encode, obfuscate, and wrap Python payloads through a modular RedTiger-inspired CLI.
Features Β· Installation Β· Usage Β· Architecture Β· Roadmap Β· Contributing Β· FAQ
β οΈ IMPORTANT DISCLAIMER β PyCry is an educational tool for exploring Python obfuscation techniques, encoding pipelines, and CLI architecture. It does not provide cryptographic security or encryption in any meaningful security sense. It must never be used to protect sensitive data, bypass security controls, or facilitate malicious activity. See the Security Disclaimer for full details.
PyCry is a Python developer utility and learning project that demonstrates how code obfuscation, encoding, and multi-layer payload wrapping work at a practical level.
It is built as a terminal UI application inspired by RedTiger-style CLI aesthetics β modular menus, banner-driven navigation, and chainable encode/decode operations. The goal is to give developers and students a hands-on toolkit for exploring:
- How Python bytecode and source can be transformed through encoding pipelines
- How
exec()wrappers and self-unpacking payloads work conceptually - How to build modular, menu-driven CLI applications in Python
- How multi-layer compression + encoding affects code readability and size
PyCry is explicitly not a security tool. It does not implement cryptographic primitives, does not protect data from a determined analyst, and should never be positioned as doing so.
| Feature | Description |
|---|---|
| Code Encrypt Direct | Obfuscate Python source code pasted directly into the terminal |
| Code Decrypt Direct | Reverse-process an obfuscated payload back to readable source |
| File Encrypt | Apply obfuscation pipeline to a .py file on disk |
| File Decrypt | Decode a previously obfuscated .py file |
| Multi-layer Payload Wrapping | Chain zlib compression, base64 encoding, and byte reversal |
| Exec Wrapper Generation | Produce self-unpacking Python stubs |
| Modular Menu System | Categorised terminal UI with keyboard-driven navigation |
| Banner & Color UI | RedTiger-inspired ASCII art banners and ANSI color output |
| Feature | Category | Status |
|---|---|---|
| Base64 Encode / Decode | Encoding Utilities | Planned |
| Hex Encode / Decode | Encoding Utilities | Planned |
| URL Encode / Decode | Encoding Utilities | Planned |
| Code Analyzer | Analysis Tools | Planned |
| Code Beautifier | Formatting Tools | Planned |
| Code Minifier | Formatting Tools | Planned |
| Variable Renamer | Obfuscation Tools | Planned |
| Comment Remover | Obfuscation Tools | Planned |
| Batch File Processing | Workflow | Planned |
| Plugin System | Architecture | Planned |
Screenshots will be added once the v1.0.0 terminal UI is finalised.
[ Banner / Main Menu Screenshot Here ]
[ File Encryption Workflow Screenshot Here ]
[ Code Obfuscation Output Screenshot Here ]
[ Multi-layer Decode Demo Screenshot Here ]
- Python 3.8 or higher
- pip (bundled with Python 3.8+)
- Terminal with ANSI color support (Linux, macOS, Windows Terminal)
# Clone the repository
git clone https://github.com/YOUR_USERNAME/pycry.git
cd pycry
# (Recommended) Create a virtual environment
python -m venv .venv
source .venv/bin/activate # Linux / macOS
.venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
# Launch PyCry
python -m pycrypip install pycry
pycrypipx install pycry
pycrypython -m pycryYou will be presented with the main menu:
ββββββββββββββββββββββββββββββββββββββββββββ
β P Y C R Y v1.0 β
β Python Obfuscation & Encoding Kit β
β βββββββββββββββββββββββββββββββββββββββββββ£
β [1] Code Operations β
β [2] File Operations β
β [3] Encoding Utilities β
β [4] Analysis Tools β
β [5] Settings β
β [0] Exit β
ββββββββββββββββββββββββββββββββββββββββββββ
# Interactive mode (recommended)
python -m pycry
# Navigate: File Operations β File Encrypt β enter path# CLI flags (planned for v1.1)
python -m pycry encrypt --input script.py --output obfuscated.py --layers 3python -m pycry decrypt --input obfuscated.py --output recovered.pypython -m pycry encrypt --code "print('hello world')" --layers 2from pycry.core import encoder, decoder
# Obfuscate source code
source = "print('hello, world')"
obfuscated = encoder.encode(source, layers=3)
# Recover original
recovered = decoder.decode(obfuscated)
print(recovered)PyCry chains multiple reversible transformations to produce an obfuscated but executable Python payload:
Input Source Code
β
βΌ
βββββββββββββββββββ
β 1. zlib β β Compress source bytes
β Compress β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β 2. Byte β β Reverse the compressed byte sequence
β Reversal β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β 3. Base64 β β Encode to printable ASCII
β Encode β
ββββββββββ¬βββββββββ
β
βΌ
βββββββββββββββββββ
β 4. exec() β β Wrap in self-unpacking Python stub
β Wrapper β
ββββββββββ¬βββββββββ
β
βΌ
Obfuscated Output (.py)
(still valid Python β runs via exec chain)
Each layer is fully reversible. The decode pipeline simply inverts the steps. This is not encryption β anyone with Python knowledge can reverse this manually in minutes.
pycry/
βββ pycry/ # Main package
β βββ __init__.py
β βββ __main__.py # Entry point: python -m pycry
β βββ cli/ # Menu system & terminal UI
β β βββ __init__.py
β β βββ menu.py # Main menu router
β β βββ banners.py # ASCII art & ANSI colors
β β βββ navigation.py # Input handling & flow control
β βββ core/ # Business logic (pure functions)
β β βββ __init__.py
β β βββ encoder.py # Encoding/obfuscation pipeline
β β βββ decoder.py # Decoding/deobfuscation pipeline
β β βββ transforms/ # Individual transform steps
β β βββ __init__.py
β β βββ compression.py
β β βββ base64_ops.py
β β βββ byte_ops.py
β β βββ wrappers.py
β βββ analysis/ # Code analysis tools (planned)
β β βββ __init__.py
β β βββ analyzer.py
β β βββ beautifier.py
β β βββ minifier.py
β βββ encoding/ # Encoding utility tools (planned)
β β βββ __init__.py
β β βββ base64_util.py
β β βββ hex_util.py
β β βββ url_util.py
β βββ utils/ # Shared utilities
β βββ __init__.py
β βββ file_io.py # Safe file read/write helpers
β βββ validators.py # Input validation
β βββ logging_conf.py # Logging setup
βββ tests/ # Test suite
β βββ __init__.py
β βββ test_encoder.py
β βββ test_decoder.py
β βββ test_transforms/
β βββ test_compression.py
β βββ test_base64_ops.py
β βββ test_byte_ops.py
βββ examples/ # Usage examples & demo scripts
β βββ basic_encode.py
β βββ multi_layer_demo.py
β βββ file_workflow_demo.py
βββ docs/ # Extended documentation
β βββ architecture.md
β βββ transforms.md
β βββ contributing.md
βββ .github/
β βββ workflows/
β β βββ ci.yml # Lint + test on push/PR
β β βββ release.yml # PyPI publish on tag
β βββ ISSUE_TEMPLATE/
β β βββ bug_report.md
β β βββ feature_request.md
β βββ PULL_REQUEST_TEMPLATE.md
βββ pyproject.toml # Build config (PEP 517/518)
βββ README.md
βββ CHANGELOG.md
βββ CONTRIBUTING.md
βββ CODE_OF_CONDUCT.md
βββ LICENSE
βββ .gitignore
pip install -e ".[dev]"pytest tests/ -v --cov=pycry --cov-report=term-missingruff check .
ruff format .
mypy pycry/pip install pre-commit
pre-commit install[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "pycry"
version = "1.0.0"
description = "A terminal-based Python obfuscation and multi-layer encoding toolkit"
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.8"
authors = [{ name = "Your Name", email = "you@example.com" }]
keywords = [
"obfuscation", "encoding", "cli", "python", "educational",
"developer-tools", "terminal", "payload-encoding"
]
classifiers = [
"Development Status :: 4 - Beta",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Education",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Utilities",
]
dependencies = [
"rich>=13.0.0", # Terminal formatting
"click>=8.0.0", # CLI framework
"black>=24.0.0", # Code beautifier backend
"pyminifier>=2.1", # Minifier backend (or custom impl)
]
[project.optional-dependencies]
dev = [
"pytest>=8.0",
"pytest-cov",
"ruff",
"mypy",
"pre-commit",
]
[project.scripts]
pycry = "pycry.__main__:main"
[project.urls]
Homepage = "https://github.com/YOUR_USERNAME/pycry"
Repository = "https://github.com/YOUR_USERNAME/pycry"
Issues = "https://github.com/YOUR_USERNAME/pycry/issues"
Changelog = "https://github.com/YOUR_USERNAME/pycry/CHANGELOG.md"
[tool.ruff]
line-length = 100
target-version = "py38"
[tool.mypy]
python_version = "3.8"
strict = true
ignore_missing_imports = true
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-v --cov=pycry"- Core encode/decode pipeline
- File encrypt/decrypt workflow
- Direct code input processing
- Multi-layer payload wrapping
- Terminal UI with banners
- Full test coverage (>80%)
- pyproject.toml packaging
- Published to PyPI
- Base64 encode/decode utility
- Hex encode/decode utility
- URL encode/decode utility
- CLI flag interface (
--input,--output,--layers) - Rich-powered terminal UI upgrade
- Code analyzer (metrics: LOC, complexity, token count)
- Code beautifier (black integration)
- Code minifier
- Comment remover
- Variable renamer (AST-based)
- Batch file processing (
--batch ./src/) - Plugin system (register custom transforms)
- Pipeline config files (YAML/TOML-defined chains)
- Output format options (raw, exec-wrapped, base64-only)
- Web UI (optional Flask/FastAPI companion)
- VSCode extension integration
- Jupyter notebook widget
- REST API mode
READ THIS CAREFULLY.
PyCry is an educational obfuscation tool. It does:
- β Encode Python source code through reversible transformations
- β
Wrap payloads in
exec()chains for self-unpacking - β Demonstrate encoding pipeline concepts clearly
PyCry does NOT:
- β Provide cryptographic security of any kind
- β Protect sensitive data, secrets, or credentials
- β Prevent a skilled analyst from reading the original source
- β Implement any recognised encryption standard (AES, RSA, ChaCha20, etc.)
- β Provide tamper resistance or integrity guarantees
If you need to protect real secrets or sensitive code, use proper cryptographic tools such as PyNaCl, cryptography, or hardware-backed secret stores.
The obfuscation produced by PyCry can be reversed by any developer with basic Python knowledge and a few minutes of time. It is not a security boundary.
This project is provided for educational and research purposes only.
- Do not use this tool to obfuscate malicious code, malware, or scripts intended to harm systems or users.
- Do not use this tool to bypass security controls, scanners, or monitoring systems.
- Do not distribute obfuscated code without making clear to recipients what it contains.
The author(s) accept no responsibility for misuse of this software. By using PyCry you agree that you are solely responsible for how you apply it.
Contributions are very welcome! PyCry is an educational project and a great place to learn CLI design, pipeline architecture, and Python packaging.
- Fork this repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/pycry.git - Create a branch:
git checkout -b feature/your-feature-name - Make your changes with tests
- Run the test suite:
pytest tests/ -v - Lint your code:
ruff check . && ruff format . - Open a Pull Request β fill in the PR template
- π’ Add type hints to existing functions
- π’ Write unit tests for the base64 transform
- π’ Improve docstrings across core modules
- π‘ Implement the hex encode/decode utility
- π‘ Implement the URL encode/decode utility
- π‘ Add
--versionand--helpCLI flags - π΄ Implement AST-based variable renamer
- π΄ Design and implement the plugin system interface
Please read CONTRIBUTING.md before opening a pull request.
Q: Is this real encryption?
No. PyCry uses encoding and compression, not cryptographic encryption. Anyone with Python can reverse it quickly. Do not use it to protect sensitive information.
Q: Why does it use exec()?
The self-unpacking stub pattern relies on
exec()to evaluate the decoded source at runtime. This is a common educational demonstration of how dynamic code execution works in Python. Many static analysis tools will flagexec()usage β this is expected and intentional in this context.
Q: Can I add custom transform steps?
Not yet directly, but the plugin system (planned for v1.3.0) will support registering custom transform functions. For now, you can add a module to
pycry/core/transforms/and wire it into the pipeline manually.
Q: Does this work on Windows?
Yes. ANSI color output requires Windows Terminal or a terminal emulator that supports ANSI escape codes. The legacy Windows console (
cmd.exewithout Windows Terminal) may show garbled output.
Q: Why not use an existing obfuscation tool like PyArmor?
PyCry is not intended to compete with production obfuscation tools. It is built to be readable, educational, and hackable β the goal is to understand how these pipelines work, not to produce unbreakable obfuscation.
Q: Can I use this in a university course or workshop?
Absolutely. That is exactly what this is designed for. Pair it with a lesson on Python's
astmodule, bytecode, andexec()semantics.
Q: What Python versions are supported?
Python 3.8 and above. Older versions are not tested and may not work.
MIT License
Copyright (c) 2024 [Your Name]
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.
See LICENSE for full text.
Your Name
PyCry β educational obfuscation & encoding toolkit
β Star this repo if you found it useful for learning!