1. Reproducing the 5-Second Unpack on a Standard Binary
When you run pyinstaller --onefile app.py, the resulting ELF or Mach-O binary appends a predictable MEI\014\013\012\013\016 cookie at the end of the file. Tools like pyinstxtractor-ng scan backward for that magic sequence, read the table of contents in plaintext, and inflate every bundled .pyc module onto disk.
$ python pyinstxtractor.py dist/trading_engine [+] Found PyInstaller archive (Python 3.13) [+] Extracted 418 .pyc files into trading_engine_extracted/PYZ-00.pyz_extracted/ # Feeding any extracted .pyc into PyLingual or pycdc recovers readable .py source immediately.
2. Why Whole-Archive AES Alone Still Fails Against Memory Dumpers
Simply encrypting the outer archive stops static binwalk scans, but if your loader decrypts full PyCodeObject structures at import time, a single gdb attach, Frida script, or Python 3.12+ sys.monitoring callback can iterate gc.get_objects() and marshal every live code object back out of RAM.
3. Defense-in-Depth: SPZ2 + Per-Function Vectorcall Vaults + Native C BCC
PyKevlar eliminates both the static archive signature and the in-memory plaintext window in a single 1.08-second build:
pip install pykevlar pykevlar register "PKA1-..." pykevlar build trading_engine.py --protect core --enable-bcc --anti-llm -F -O dist
- Zero CArchive / Zlib Signatures (
SPZ2): Module names, TOC offsets, and payloads are stream-encrypted per build—pyinstxtractorfinds no magic cookie and aborts immediately. - Ephemeral Per-Function Decryption: At rest—and even after
import—each Python function holds a 4-byte stub. Only when invoked does CPython's C vectorcall trampoline authenticate and decrypt that single function's bytecode under ChaCha20-Poly1305, zeroing and re-sealing it on return. - True Bytecode Elimination (
--enable-bcc): Numeric, pricing, and licensing functions transpile straight into stripped ARM64 / x86_64 C machine code—leaving zero Python opcodes forPyLingualorpycdcto translate.