Skip to main content

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 .pyc files
  • Debugging compiled Python modules
  • Educational analysis of Python internals

Features

  • Automatic detection of .py and .pyc files
  • 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:

  1. File Detection

    • Detects whether the input is .py or .pyc
  2. Header Parsing

    • Reads Python bytecode headers safely depending on version
  3. Marshal Loading

    • Extracts compiled code objects using Python's marshal module
  4. Disassembly

    • Converts bytecode into readable instructions
  5. Reconstruction

    • Attempts to rebuild Python-like source using heuristics
  6. 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

Metadata

Release files for py-cdec 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-cdec 0.1.0
File Size Uploaded Provenance Actions
py_cdec-0.1.0.tar.gz 17.5 kB Without provenance Details for py_cdec-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-cdec 0.1.0
File Interpreter ABI Platform Actions
py_cdec-0.1.0-py3-none-any.whl Python 3 none any Details for py_cdec-0.1.0-py3-none-any.whl

Total release size: 34.1 kB

Release files / py_cdec-0.1.0.tar.gz

Download URL py_cdec-0.1.0.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d5b9d1dad2b88fa5164523cd48ebea4eeec056f75ed96e6231af4161ec5f1476
BLAKE2b-256 checksum
How to use checksums
436741fb4ee98980d6e566215ed4422409d9362a2fa5ed673942bc35b31fa8c6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Release files / py_cdec-0.1.0-py3-none-any.whl

Download URL py_cdec-0.1.0-py3-none-any.whl
Size 16.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
cc1daaa10d773365659e90e94208be57b778766ef6e378cd7284eecd32660110
BLAKE2b-256 checksum
How to use checksums
cf6e6baac71393b4b38a03466fc7f43438c0241e97aa0b0d49d606b30aaf7d26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for py-cdec 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page