A Python source-code obfuscator with an interactive TUI and CLI
Layered packing · AST transformations · Decoy classes · Junk code — while keeping your program's behavior identical to the original.
⚠️ Disclaimer: Use only on code you own or have explicit rights to protect. Obfuscation is not encryption — determined reverse engineers can still unpack it. Don't use it to hide malicious behavior.
- Layered packing (1–12 layers) — compiled bytecode is marshalled, compressed, XOR-encrypted, encoded (base85 / base64 / hex) and wrapped in multiple loader shells
- Identifier renaming — three styles:
random, confusable (_O0Il1lOI), hex (_xa3f9...) - String transformation —
chr()-join, reversed slicing, andbytes.fromhex().decode(), chosen randomly per string - Number obfuscation — integers rewritten as XOR expressions (
1500→1011471512 ^ 1011472240) - Junk code injection — dead code behind opaque predicates (
if (v ^ v) != 0:— always false, but not obviously so) - Decoy classes — fake, never-used classes with Chinese docstrings, Unicode identifiers (
self.队列67) and realistic-looking fake logic injected between your real code - Trash output — the final file is flooded with garbage comments (中文 / 日本語 / 한국어 / Deutsch / Русский), dead variables, fake configs and decoy classes between loader lines
- Anti-debug stub — exits if a debugger trace is detected
- Integrity check — SHA-256 hash verification; refuses to run if tampered
- Docstring stripping, zlib / lzma compression
- Config save/load (JSON), backups, syntax validation
- Python 3.9+ (uses
ast.unparse) - Zero dependencies — standard library only
git clone https://github.com/3uer/lilfuscator-python.git
cd lilfuscator-pythonSingle file, zero dependencies: Lilfuscator.py.
python Lilfuscator.py --selftest # 12 checks: 4 profiles x 3 scripts, behavior-identical
⚠️ The packed payload is marshalled bytecode — run the obfuscated file with the same Python minor version used to build it (3.9+).
# Basic: input, output, number of layers (1-12)
python Lilfuscator.py myscript.py myscript_obf.py 5
# With a profile
python Lilfuscator.py myscript.py myscript_obf.py 5 --profile strong
# Help
python Lilfuscator.py --helpRun without arguments to get the 2.x-style menu UI: banner, live state
panel, main menu (1 select input - file or paste, 2 settings,
3 obfuscate, 4/5 save/load lilfuscator.json, 0 exit) and a
21-item settings menu (layers, rename, strings, numbers, compression,
encoding, payload chunks, backups, smoke test, preserve-names, junk,
decoys, trash, anti-debug, integrity, docstrings, name style). Any
manual change marks the profile as custom.
Run without arguments:
python Lilfuscator.py| Profile | Layers | Renaming | Strings | Junk | Decoys | Trash | Anti-debug |
|---|---|---|---|---|---|---|---|
fast |
1 | — | — | — | — | — | — |
balanced |
3 | ✓ | ✓ | ✓ | ✓ (2) | ✓ (3) | — |
strong |
5 | ✓ (confusable) | ✓ | ✓ | ✓ (5) | ✓ (6) | ✓ |
Any manual change in Settings switches the profile to custom.
| Key | Action | What it does |
|---|---|---|
1 |
Select input | Load a .py file from disk, or paste code directly into the terminal (finish with an empty line + y) |
2 |
Settings | Open the configuration menu (see below) |
3 |
Obfuscate | Run the obfuscator with the current config, write the output, back up any existing file, syntax-validate |
4 |
Save current config | Write the current settings to lilfuscator.json |
5 |
Load config | Read settings back from lilfuscator.json (keeps the currently loaded source) |
0 |
Exit | Quit |
| Key | Setting | What it means |
|---|---|---|
1 |
Profile | Pick fast / balanced / strong, or mark as custom |
2 |
Layers | Packing shells around the payload (1–12). More = slower startup, bigger file, harder to read |
3 |
Rename names | Toggle identifier renaming. Imports, builtins, methods and dunder names are never touched |
4 |
Transform strings | Toggle string obfuscation (chr-join / reverse / hex-decode, 70% of strings) |
5 |
Compression | Toggle payload compression; when ON, asks for zlib or lzma (lzma = smaller, slightly slower) |
6 |
Payload chunks | Toggle splitting the encoded payload into randomized chunks |
7 |
Chunk count | How many chunks (2–40) |
8 |
Backup | Keep a timestamped .bak copy if the output file already exists |
9 |
Smoke test | Syntax-validate the generated file after writing |
10 |
Preserve names | Comma-separated list of names the renamer must never touch (default: __init__, __main__, main, app, cli, ...) |
11 |
Save config | Write settings to lilfuscator.json |
12 |
Load config | Load settings from lilfuscator.json |
13 |
Name style | Renaming style: random letters / confusable (O0Il1) / hex |
14 |
Numbers | Toggle integer obfuscation (N → a ^ b) |
15 |
Junk code | Toggle dead-code injection behind opaque predicates; when ON, asks for density (1–10) |
16 |
Docstrings strip | Remove module/class/function docstrings |
17 |
Anti-debug | Insert a stub that aborts execution when a debugger trace is active |
18 |
Integrity check | Wrap the output in a SHA-256 self-check; modified files refuse to run |
19 |
Encoding | Payload encoding: auto (random per layer) / b85 / b64 / hex |
20 |
Decoy classes | Toggle fake Chinese-documented classes injected between your real code; when ON, asks for count (1–10) |
21 |
Trash output | Flood the final file with garbage comments, dead variables, fake configs and decoys; density (1–10) |
0 |
Back | Return to the main menu |
python Lilfuscator.py taskforge.py taskforge_obf.py 5 --profile strong
python taskforge_obf.py # behaves exactly like the original- Your source is parsed into an AST.
- Transformations: docstrings stripped → identifiers renamed → numbers XOR-ified → strings encoded → junk code injected → decoy classes inserted.
- The result is compiled to bytecode and marshalled.
- The blob is compressed, XOR-encrypted with a random key, encoded and split into chunks — wrapped in a loader shell. Repeated per layer.
- The outermost file gets an integrity wrapper and (optionally) the trash treatment.
- Entry point must be guarded by
if __name__ == "__main__":if you rely on it — it keeps working, just note the whole file runs at import time. - Code that introspects its own source (
inspect.getsource,__file__-relative reads of itself) or relies on exact function/variable names (e.g.getattrwith string literals) may need those names added to Preserve names. - Keyword arguments of library functions are never renamed (safe), and method parameters are kept as-is for the same reason.
MIT — see LICENSE