C++ python bytecode disassembler and decompiler
  • C++ 84.5%
  • Python 14.9%
  • CMake 0.5%
Find a file
2023-11-09 14:20:15 -08:00
.github/workflows Update CodeQL configuration 2023-02-27 13:12:11 -08:00
bytes Add basic bytecode and disassembly support for Python 3.12 2023-11-09 12:17:03 -08:00
scripts Add basic bytecode and disassembly support for Python 3.12 2023-11-09 12:17:03 -08:00
tests Add basic bytecode and disassembly support for Python 3.12 2023-11-09 12:17:03 -08:00
.gitignore Issue-165 Added support for f-strings (literal string interpolation https://www.python.org/dev/peps/pep-0498/) 2020-10-17 20:52:57 +11:00
ASTNode.cpp Reduce code duplication for pre-3.11 binary ops, based on #348 2023-06-01 13:55:17 -07:00
ASTNode.h Added support for opcodes: (in DESC) 2023-07-18 18:33:03 +03:00
ASTree.cpp Add basic bytecode and disassembly support for Python 3.12 2023-11-09 12:17:03 -08:00
ASTree.h Use C++ streams over C style IO 2023-06-02 01:12:59 +02:00
bytecode.cpp Add basic bytecode and disassembly support for Python 3.12 2023-11-09 12:17:03 -08:00
bytecode.h Move some output stream parameters forward. 2023-06-05 13:56:25 -07:00
bytecode_ops.inl Add basic bytecode and disassembly support for Python 3.12 2023-11-09 12:17:03 -08:00
CMakeLists.txt Add basic bytecode and disassembly support for Python 3.12 2023-11-09 12:17:03 -08:00
data.cpp Fix the pointer's behavior on getting buffer 2023-08-25 18:00:26 -07:00
data.h Fix some issues with formatted_print: 2023-06-05 13:49:04 -07:00
FastStack.h Support for conditonal expression (if-expression) 2022-03-29 12:30:06 +02:00
LICENSE Added GPL v3 license file 2009-07-25 00:43:46 +00:00
pyc_code.cpp Fix LOAD_GLOBAL and cell var references in Python 3.11+ 2023-01-19 13:05:06 -08:00
pyc_code.h Fix LOAD_GLOBAL and cell var references in Python 3.11+ 2023-01-19 13:05:06 -08:00
pyc_module.cpp Add basic bytecode and disassembly support for Python 3.12 2023-11-09 12:17:03 -08:00
pyc_module.h Add basic bytecode and disassembly support for Python 3.12 2023-11-09 12:17:03 -08:00
pyc_numeric.cpp Reduce unnecessary uses of std::list 2022-12-01 11:35:14 -08:00
pyc_numeric.h Reduce unnecessary uses of std::list 2022-12-01 11:35:14 -08:00
pyc_object.cpp Don't create special objects for NULL, just use NULL directly. 2017-07-05 16:36:04 -07:00
pyc_object.h Make cast() checked by default and add try_cast() for cases where a cast 2022-12-01 16:13:31 -08:00
pyc_sequence.cpp Remove unnecessary sequence interface on PycDict 2023-11-09 14:20:15 -08:00
pyc_sequence.h Remove unnecessary sequence interface on PycDict 2023-11-09 14:20:15 -08:00
pyc_string.cpp Add basic bytecode and disassembly support for Python 3.12 2023-11-09 12:17:03 -08:00
pyc_string.h Simplify string object printing to reduce code duplication 2023-06-09 09:09:03 -07:00
pycdas.cpp Simplify string object printing to reduce code duplication 2023-06-09 09:09:03 -07:00
pycdc.cpp Clean up file handling in main()s, and remove a leak 2023-06-05 13:54:26 -07:00
PythonBytecode.txt Add basic bytecode and disassembly support for Python 3.12 2023-11-09 12:17:03 -08:00
README.markdown Update README.markdown 2022-10-02 15:44:29 +05:30

Decompyle++

A Python Byte-code Disassembler/Decompiler

Decompyle++ aims to translate compiled Python byte-code back into valid and human-readable Python source code. While other projects have achieved this with varied success, Decompyle++ is unique in that it seeks to support byte-code from any version of Python.

Decompyle++ includes both a byte-code disassembler (pycdas) and a decompiler (pycdc).

As the name implies, Decompyle++ is written in C++. If you wish to contribute, please fork us on github at https://github.com/zrax/pycdc

Building Decompyle++

  • Generate a project or makefile with CMake (See CMake's documentation for details)

    • The following options can be passed to CMake to control debug features:
      Option Description
      -DCMAKE_BUILD_TYPE=Debug Produce debugging symbols
      -DENABLE_BLOCK_DEBUG=ON Enable block debugging output
      -DENABLE_STACK_DEBUG=ON Enable stack debugging output
  • Build the generated project or makefile

    • For projects (e.g. MSVC), open the generated project file and build it
    • For makefiles, just run make
    • To run tests (on *nix or MSYS), run make check

Usage

To run pycdas, the PYC Disassembler: ./pycdas [PATH TO PYC FILE] The byte-code disassembly is printed to stdout.

To run pycdc, the PYC Decompiler: ./pycdc [PATH TO PYC FILE] The decompiled Python source is printed to stdout. Any errors are printed to stderr.

Marshalled code objects: Both tools support Python marshalled code objects, as output from marshal.dumps(compile(...)).

To use this feature, specify -c -v <version> on the command line - the version must be specified as the objects themselves do not contain version metadata.

Authors, Licence, Credits

Decompyle++ is the work of Michael Hansen and Darryl Pogue.

Additional contributions from:

  • charlietang98
  • Kunal Parmar
  • Olivier Iffrig
  • Zlodiy

It is released under the terms of the GNU General Public License, version 3; See LICENSE file for details.