How can I decompile .pyc files from Python 3.10?
Asked Answered
T

5

8

I did try uncompyle6, decompyle3, and others, but none of them worked with Python 3.10.

Is it even possible to do this right now?

Tion answered 26/2, 2022 at 17:43 Comment(2)
Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.Statuette
python 3.10 is very fresh version and you may need to wait for tools for this version.Kiln
G
20

Use pycdc. Github: https://github.com/zrax/pycdc

git clone https://github.com/zrax/pycdc
cd pycdc
cmake .
make
make check
pycdc C:\Users\Bobby\example.pyc
Gearwheel answered 4/3, 2022 at 14:50 Comment(5)
To use pycdc you'll have to to clone the repo, cd into that dir, run 'cmake .' (you might have to install cmake), then run 'make', then 'make checks', then you can run pycdc. It worked for me with Python 3.10 bytecode.Hydrogeology
These instructions do not work on windows.Stater
@CodeMed: As others have subsequently posted, if you don't have make available, MSBuild.exe pycdc.vcxproj should build it, and the resulting pycdc.exe executable should do the same job.Agbogla
pycdc is an executable, so calling it with python will throw an error. Just use pycdc /path/to/your/pyc as the last step.Morita
Also 90% work on python 3.11 (cannot do these: LIST_EXTEND BEFORE_WITH CALL_FUNCTION_EX CHECK_EXC_MATCH COPY DICT_MERGE JUMP_BACKWARD LIST_TO_TUPLE LOAD_ASSERTION_ERROR MAKE_CELL MAP_ADD POP_JUMP_BACKWARD_IF_FALSE POP_JUMP_BACKWARD_IF_TRUE POP_JUMP_FORWARD_IF_NONE POP_JUMP_FORWARD_IF_NOT_NONE PUSH_EXC_INFO RETURN_GENERATOR SWAP UNPACK_EX)Faucal
B
3

on Windows (presume you have both Cmake and MSBuild.exe)

git clone https://github.com/zrax/pycdc
cd pycdc
cmake .
MSBuild.exe pycdc.vcxproj
cd pycdc/Debug
pycdc.exe yourfile.pyc
Bille answered 28/2, 2023 at 13:48 Comment(1)
I have installed both Cmake and MSBuild but I am not able to generate the .vcxproj. Could you please help me with this ?Trossachs
R
1

Please try https://pylingual.io, which supports the latest Python versions (3.6 ~ 3.12). The service implements an open service that runs an NLP-based translation model + control flow analysis.

Rawlinson answered 9/4 at 13:53 Comment(0)
S
0

It seems to get less reliable with time and additional Python releases. Decompiling is undesirable from a security standpoint, and expect Python devs will continue to try to prevent. Last I tried gave partial results with code missing (windows/cmake/msbuild method w/v3.10). I have not tried the pylingual.io option. It requires submitting your code up to their cloud service.

Sanmiguel answered 9/5 at 21:22 Comment(0)
A
0

If we use ubuntu, open the Terminal:

sudo snap install pycdc #this helps to avoid the error: Command 'pycdc' not found when following MDKawsar's answer

Then tell the terminal where that python *.pyc script is:

pycdc /home/jbsidis/Downloads/scripts/assets/main.pyc

You will see the result

Almire answered 13/7 at 16:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.