0

I'm trying to make a decoder for .pyc files, and need to figure out how the structure is.

I have found several suggestions but they all use the marshal module to load the code and then dis to disassemble it.

I have found a few simple explanations of the general structure which led me to build a simple decompiler. The best post was this: How to create a code object in python?

However, I need more direct information to be able to decode all the information. Such as what markers indicate what, what flags are used and how to decode them and type decoding.

So does anyone know where I can find any documentation on how to decode a pyc file? and/or its general structure?

Regards

Ephreal
  • 1,835
  • 2
  • 18
  • 35
  • Does this help [The structure of .pyc files](https://nedbatchelder.com/blog/200804/the_structure_of_pyc_files.html) – itprorh66 Jun 11 '22 at 20:36
  • @itprorh66 Sorry no, I've found that also but it is for python version 2.x. I preferable want to find something for version 3.7 and above – Ephreal Jun 11 '22 at 21:12
  • Check out https://github.com/rocky/python-decompile3 – wim Jun 13 '22 at 15:34

1 Answers1

0

I found that I can look in the marshal.c file for the current version of python3. This gives me the different flags to look for in the bytecode, and in turn, helps with the decoding.

Regards

Ephreal
  • 1,835
  • 2
  • 18
  • 35