cursorrules — independently scanned and version-tracked by SaferSkills.
SaferSkills independently audited cursorrules (Rules) and scored it 100/100 (green). The audit ran 55 deterministic rules across Security, Supply Chain, Maintenance, Transparency, and Community; it found 0 high-severity and 0 lower-severity findings. The full rule-by-rule trace and per-finding evidence are below. Free, methodology-open.
Findings & checks · 0 flagged
Every scanned point with the score it earned and what moved between them.
First recorded scan — no prior version to compare against.
The primary manifest — the file an agent reads to learn what this artifact does.
<p align="center"> <img src="https://raw.githubusercontent.com/zhurong2020/pyobfus/main/docs/assets/logo.jpeg" alt="pyobfus Logo" width="200"> </p>
pyobfus (pronounced as "Python obfuscator") is a modern, AST-based python-obfuscator / code-obfuscator with framework-aware presets, reverse stack-trace mapping for AI-assisted debugging, and a machine-readable JSON CLI designed for Claude Code, Cursor, and MCP agents. A transparent, open-source alternative to PyArmor.
A Python code obfuscator built with AST-based transformations. Supports Python 3.9 through 3.14. Provides reliable name mangling, string encoding, control-flow flattening, AES-256 string encryption, and — unique to pyobfus — a reverse-mapping workflow that lets you (or your AI coding assistant) debug obfuscated stack traces without giving up the protection.
pyobfus-mcpThis repository ships two installable packages:
| Package | What it is | Install |
|---|---|---|
pyobfus | The Python obfuscator (CLI + library). | pip install pyobfus |
pyobfus-mcp | A Model Context Protocol (MCP) server that exposes pyobfus's tools to AI coding agents. | uvx pyobfus-mcp (zero-install) or pip install pyobfus-mcp |
The MCP server lives in pyobfus_mcp/ and is built on the official Model Context Protocol Python SDK (FastMCP). It registers eight MCP tools so Claude Desktop, Claude Code, Cursor, Windsurf, and Zed can call pyobfus directly from agent conversations — no shelling out:
| MCP tool | Implementation | Purpose |
|---|---|---|
protect_project | pyobfus_mcp/tools.py | One-call, self-verifying pipeline: scan → preset → obfuscate → byte-compile + import-smoke-test the output → return verified: true/false. The agent reports a green check instead of hoping the transform didn't break anything |
check_obfuscation_risks | pyobfus_mcp/tools.py | Pre-flight risk scan (eval/exec, dynamic attribute, framework reflection) |
generate_pyobfus_config | pyobfus_mcp/tools.py | Auto-detect framework → write a working pyobfus.yaml |
unmap_stack_trace | pyobfus_mcp/tools.py | Reverse obfuscated identifiers in a production stack trace |
list_presets | pyobfus_mcp/tools.py | Enumerate community / framework / Pro presets |
explain_preset | pyobfus_mcp/tools.py | Describe what a named preset changes |
recommend_tier | pyobfus_mcp/tools.py | Analyze a project and recommend community vs Pro tier, with reasoning |
start_pro_trial | pyobfus_mcp/tools.py | Return structured guidance for starting the 5-day Pro trial |
The server is registered in the official [MCP Registry](https://registry.modelcontextprotocol.io/) under io.github.zhurong2020/pyobfus-mcp. The transport is stdio. See pyobfus_mcp/README.md for per-client configuration snippets.
This repo is also a Claude Code plugin marketplace. The pyobfus-protect skill teaches an agent the full "protect Python before shipping — obfuscate and verify it still runs" workflow (MCP-first, CLI fallback):
/plugin marketplace add zhurong2020/pyobfus
/plugin install pyobfus@pyobfusSee skills/ for the skill and install details. (This is distinct from templates/ai-integration/, which are copy-in rule files for your project.)
eval/exec, dynamic attribute access, and framework reflection points before you obfuscate. JSON output with an ai_hint telling your AI assistant what to run next.pyobfus.yaml.# pyobfus:obfuscated header (id + mapping filename + the exact --unmap command) so an AI agent that lands in an obfuscated file from a traceback immediately knows it's pyobfus output and how to reverse the names.--preset fastapi | django | flask | pydantic | click | sqlalchemy with built-in exclusions for dispatch methods, decorators, ORM fields, migrations, and dependency-injection parameters.obfuscate, --check, --unmap, --init) emits the same structured schema with an ai_hint field, ready for Claude Code, Cursor, Windsurf, and MCP servers to consume.The following features are fully implemented and available in the current version:
__all__ list updates with obfuscated names--dry-run flag--preserve-param-names)The following advanced features are available with a Pro license:
--control-flow--dead-code--expire 2025-12-31--bind-machine--max-runs 100--preset trial - 30-day time-limited version--preset commercial - Maximum protection with machine binding--preset library - For pip-distributable libraries--preset maximum - Highest security with all protections--list-presets - View all presets#### New in v0.5.0 — patent-targeted mechanisms (CN 202610712171X)
Six mechanisms, available both as the pyobfus_pro API and — as of v0.5.1 — as opt-in pyobfus build flags (single-file / --no-cross-file mode): --selective-opacity, --seal-code, --vault, --scrub-traceback, --fingerprint <buyer-id>, --expire-hard <date>. (--bind-device / --period and --opacity-config TOML rules land in 0.5.3.)
__code__ materialization).pyobfus-unscrub CLI.Requires Python ≥ 3.9 as of v0.5.0 (3.8 dropped, EOL 2024-10).
See ROADMAP.md for the full feature timeline.
Try all Pro features for 5 days - no registration or credit card required!
# Start your free trial
pyobfus-trial start
# Check trial status
pyobfus-trial status
# Use Pro features during trial
pyobfus input.py -o output.py --level proWhat's included in the trial:
--control-flow)--string-encryption)--anti-debug)--dead-code)--expire, --bind-machine, --max-runs)--preset trial/commercial/library/maximum)After your trial, purchase a license to continue using Pro features.
Pro Edition Features:
Price: $45.00 USD (one-time payment)
Visit our purchase page: [pyobfus.github.io/purchase](https://zhurong2020.github.io/pyobfus/#purchase-professional-edition) for detailed information and secure checkout.
Quick purchase: [🚀 Buy Now](https://buy.stripe.com/00w4gr8ta9F78Fj8oI9k400) - Direct checkout link (Instant delivery • 30-day money-back guarantee)
3-Step Purchase Process:
PYOB-XXXX-XXXX-XXXX-XXXX pip install --upgrade pyobfus
pyobfus-license register PYOB-XXXX-XXXX-XXXX-XXXX
pyobfus-license status # Quick start with presets
pyobfus src/ -o dist/ --preset commercial # Maximum protection
pyobfus src/ -o dist/ --preset trial # 30-day trial version
pyobfus src/ -o dist/ --preset library # For pip distribution
# Individual features
pyobfus input.py -o output.py --string-encryption
pyobfus input.py -o output.py --anti-debug
pyobfus input.py -o output.py --control-flow
pyobfus input.py -o output.py --dead-code
# License restrictions
pyobfus src/ -o dist/ --expire 2025-12-31 --bind-machine --max-runs 100
# All Pro features
pyobfus input.py -o output.py --string-encryption --anti-debug --control-flow --dead-codeSupport: If you encounter any issues, contact [email protected] with your license key.
By purchasing pyobfus Professional Edition, you agree to our:
From PyPI (recommended):
pip install pyobfusFrom source (for development):
git clone https://github.com/zhurong2020/pyobfus.git
cd pyobfus
pip install -e .# Obfuscate a single file
pyobfus input.py -o output.py
# Obfuscate a directory (cross-file mode - default in v0.2.0+)
pyobfus src/ -o dist/
# Preview obfuscation without writing files (v0.2.0+)
pyobfus src/ -o dist/ --dry-run
# Legacy single-file mode (v0.2.0+)
pyobfus src/ -o dist/ --no-cross-file
# With configuration file
pyobfus src/ -o dist/ --config pyobfus.yaml
# Preserve parameter names for keyword arguments (v0.1.6+)
pyobfus src/ -o dist/ --preserve-param-names
# Verbose output with progress indicators (v0.2.0+)
pyobfus src/ -o dist/ --verboseBefore obfuscation:
def calculate_risk(age, score):
"""Calculate risk factor."""
risk_factor = 0.1
if score > 100:
risk_factor = 0.5
return age * risk_factor
patient_age = 55
patient_score = 150
risk = calculate_risk(patient_age, patient_score)
print(f"Risk score: {risk}")After obfuscation:
def I0(I1, I2):
I3 = 0.1
if I2 > 100:
I3 = 0.5
return I1 * I3
I4 = 55
I5 = 150
I6 = I0(I4, I5)
print(f'Risk score: {I6}')Note: Variable names (I0, I1, etc.) may vary slightly depending on code structure, but functionality is preserved.
Generate a configuration template for your project type:
# For Django projects
pyobfus --init-config django
# For Flask projects
pyobfus --init-config flask
# For Python libraries
pyobfus --init-config library
# For general projects
pyobfus --init-config generalThis creates a pyobfus.yaml file with sensible defaults for your project type.
Check your configuration file for errors before use:
pyobfus --validate-config pyobfus.yamlThe validator checks for:
exclude_pattern -> exclude_patterns)When you run pyobfus without -c, it automatically searches for:
pyobfus.yamlpyobfus.yml.pyobfus.yaml.pyobfus.ymlCreate pyobfus.yaml:
obfuscation:
level: community
exclude_patterns:
- "test_*.py"
- "**/tests/**"
- "__init__.py"
exclude_names:
- "logger"
- "config"
- "main"
remove_docstrings: true
remove_comments: trueThe exclude_names option preserves specified names from being renamed during obfuscation:
obfuscation:
exclude_names:
- MyPublicClass # Name preserved, but strings inside are still encoded
- exported_function # Name preserved for external callersImportant: exclude_names only affects name obfuscation, not string encoding:
# Original
SECRET_KEY = "admin-password-123"
# With exclude_names: [SECRET_KEY] and string_encoding: true
SECRET_KEY = _decode_str('YWRtaW4tcGFzc3dvcmQtMTIz')
# ✅ Name 'SECRET_KEY' is preserved
# ✅ String content is still encoded (Base64)Use cases:
Exclude patterns support glob syntax:
test_*.py - Exclude files starting with "test_"**/tests/** - Exclude all files in "tests" directories**/__init__.py - Exclude all __init__.py filessetup.py - Exclude specific filesSee pyobfus.yaml.example for more configuration examples.
pyobfus uses Python's ast module for syntax-aware transformations:
This approach ensures:
git clone https://github.com/zhurong2020/pyobfus.git
cd pyobfus
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -e ".[dev]"# Run unit tests
pytest tests/ -v
# With coverage
pytest tests/ -v --cov=pyobfus --cov-report=html
# Run integration tests
pytest integration_tests/ -vIntegration Testing Framework (v0.1.6+): Test pyobfus on real-world code without uploading to PyPI. See INTEGRATION_TESTING.md for details.
# Format code
black pyobfus/
# Type checking
mypy pyobfus/
# Linting
ruff check pyobfus/Obfuscate sensitive business logic before distributing Python applications.
Demonstrate code protection concepts and obfuscation techniques.
Add an additional layer of protection for commercial Python software.
--preserve-param-names flag to preserve parameter names while still obfuscating function bodies.Example:
# Before obfuscation
def process(data_path, output_dir):
temp_file = data_path + ".tmp"
return temp_file
result = process(data_path='./data', output_dir='./output') # ✅ Works
# After obfuscation (default behavior)
def I0(I1, I2):
I3 = I1 + ".tmp"
return I3
result = process(data_path='./data', output_dir='./output') # ❌ TypeError!
# After obfuscation (with --preserve-param-names)
def I0(data_path, output_dir):
I3 = data_path + ".tmp"
return I3
result = I0(data_path='./data', output_dir='./output') # ✅ Works!When to use `--preserve-param-names`:
def func(*, kwonly))Trade-off: Parameter names reveal some information about the function's interface, but function bodies and local variables are still fully obfuscated.
eval(), exec() with obfuscated code may require adjustments--preserve-param-names to maintain keyword argument compatibilityUse pyobfus if you:
# Install
pip install pyobfus
# Obfuscate a single file
pyobfus script.py -o script_obf.py
# Obfuscate an entire project
pyobfus src/ -o dist/
# Preview without writing files
pyobfus src/ -o dist/ --dry-runYes, pyobfus guarantees 100% functional equivalence. The obfuscated code produces identical outputs to your original code. We use Python's AST (Abstract Syntax Tree) for syntax-aware transformations, ensuring syntactically correct output.
Minimal impact:
Yes! Use our built-in templates:
# Django
pyobfus --init-config django
# Flask
pyobfus --init-config flask
# Then run obfuscation
pyobfus src/ -o dist/ -c pyobfus.yamlpyobfus supports Python 3.9 through 3.14. Generated code is compatible with all these versions regardless of which version you use to run pyobfus.
| Feature | pyobfus | PyArmor |
|---|---|---|
| Price | $45 (Pro) | $89 (Pro) |
| Free tier | Clear limits (5 files/1000 LOC) | Vague "trial" limitations |
| Open source | Yes (Core: Apache 2.0, Pro: Proprietary) | No |
| Native dependencies | None (pure Python output) | Requires runtime library |
| Python 3.12 support | Yes | Yes |
Choose pyobfus if: You want transparent pricing, open-source trust, and simpler deployment without native dependencies.
See our detailed comparison for more information.
Yes — and for many projects this is the most cost-effective approach. Use pyobfus as your always-on default layer (every module gets AST mangling + mapping for AI-debug compatibility), then stack PyArmor Pro's bytecode encryption or Nuitka's native compilation on the small set of modules that genuinely need stronger protection. See Layered Deployment Strategy in COMPARISON.md for the full reasoning.
pyobfus.yaml for names that must stay unchangedName mangling is irreversible - original variable names cannot be recovered. However, code logic remains intact (this is true for all obfuscators). For stronger protection, use Pro features:
Important: String encryption (AES-256) is designed as a deterrent against casual reverse engineering, not as cryptographic security.
Because obfuscated code must decrypt strings at runtime, the encryption key is necessarily embedded in the output. A determined attacker with access to the obfuscated code can:
This is a fundamental limitation of ALL client-side obfuscators (including PyArmor, Nuitka, etc.) - true cryptographic security would require server-side decryption, which is impractical for most use cases.
What string encryption DOES provide:
strings or grep searches from revealing sensitive textWhat string encryption does NOT provide:
Recommendation: For sensitive credentials (API keys, passwords), use environment variables or external secret management systems rather than embedding them in code.
| Tool | Approach | Output |
|---|---|---|
| pyobfus | AST transformation | .py files (pure Python) |
| Cython | Compile to C | .so/.pyd (platform-specific) |
| Nuitka | Compile to executable | Binary (platform-specific) |
Choose pyobfus if: You need cross-platform .py files without compilation overhead.
LICENSE-NOTICE.md):If you find pyobfus helpful, consider supporting its development:
<a href="https://www.buymeacoffee.com/zhurong052Q" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 60px !important;width: 217px !important;" ></a>
Your support helps maintain and improve pyobfus. Thank you!
If you use pyobfus in academic work or want to reference it, please cite the archived release. The concept DOI below always resolves to the latest version:
APA
Zhu, R. (2026). pyobfus: An AST-based Python obfuscator with reverse stack-trace mapping for AI-assisted development. Zenodo. https://doi.org/10.5281/zenodo.20846053
BibTeX
@software{zhu_pyobfus,
author = {Zhu, Rong},
title = {pyobfus: An AST-based Python obfuscator with reverse stack-trace mapping for AI-assisted development},
year = {2026},
publisher = {Zenodo},
doi = {10.5281/zenodo.20846053},
url = {https://doi.org/10.5281/zenodo.20846053}
}Machine-readable metadata is in CITATION.cff (GitHub's "Cite this repository" widget reads it).
~30 seconds. Free. No account. Every finding cites a rule and a line of evidence.