Strong best-effort Python bytecode, marshal, and source analyzer/decompiler
Project description
py-cdec
Strong best-effort Python .pyc, marshal, and source analyzer/decompiler.
Overview
py-cdec is a Python tool designed to analyze and decompile Python bytecode (.pyc) files and marshal payloads into readable Python-like source code.
It uses heuristic-based reconstruction techniques to recover structure, functions, and readable output from compiled Python artifacts.
This tool is useful for:
- Reverse engineering Python bytecode
- Learning how Python compilers structure code
- Inspecting unknown
.pycfiles - Debugging compiled Python modules
- Educational analysis of Python internals
Features
- Automatic detection of
.pyand.pycfiles - Bytecode disassembly support
- Marshal payload extraction and inspection
- Heuristic-based source reconstruction
- Recursive code object analysis
- CLI interface for quick usage
- Lightweight and dependency-free design
Installation
Install via pip:
pip install py-cdec
Or install locally:
git clone https://github.com/Gisnsl/py-cdec.git
cd py-cdec
pip install .
Usage (Python API)
You can use py-cdec directly inside your Python code.
from pathlib import Path
from py_cdec import PycDecompiler
# Automatically handles both .pyc and .py files
pyc_path = Path("myfile.pyc") # or myfile.py
decompiler = PycDecompiler(pyc_path)
# Print the decompiled source code directly
print(decompiler)
Usage (CLI)
Run directly from terminal:
py-cdec sample.pyc
Show Disassembly
To view Python bytecode instructions:
py-cdec sample.pyc --show-dis
How It Works
py-cdec internally performs several steps:
-
File Detection
- Detects whether the input is
.pyor.pyc
- Detects whether the input is
-
Header Parsing
- Reads Python bytecode headers safely depending on version
-
Marshal Loading
- Extracts compiled code objects using Python's marshal module
-
Disassembly
- Converts bytecode into readable instructions
-
Reconstruction
- Attempts to rebuild Python-like source using heuristics
-
Output Formatting
- Produces readable structured output
Project Goals
The main goal of py-cdec is not perfect decompilation, but:
- Producing readable reconstructed code
- Helping developers understand compiled Python internals
- Providing a safe inspection tool for bytecode analysis
Security Notice
âڑ ï¸ڈ WARNING:
Never execute unknown .pyc or marshal payloads directly.
They may contain malicious code even if they appear safe.
Always inspect before execution.
Telegram Contact
Developer: @maho_s9
License
MIT License
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file py_cdec-0.1.0.tar.gz.
File metadata
- Download URL: py_cdec-0.1.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5b9d1dad2b88fa5164523cd48ebea4eeec056f75ed96e6231af4161ec5f1476
|
|
| MD5 |
fe1f7d253a0c579536ee040c1f11c98a
|
|
| BLAKE2b-256 |
436741fb4ee98980d6e566215ed4422409d9362a2fa5ed673942bc35b31fa8c6
|
File details
Details for the file py_cdec-0.1.0-py3-none-any.whl.
File metadata
- Download URL: py_cdec-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc1daaa10d773365659e90e94208be57b778766ef6e378cd7284eecd32660110
|
|
| MD5 |
07781d4a663af1997e33c166f03e3327
|
|
| BLAKE2b-256 |
cf6e6baac71393b4b38a03466fc7f43438c0241e97aa0b0d49d606b30aaf7d26
|