-
Notifications
You must be signed in to change notification settings - Fork 335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unpacked .pyc files are invalid (with dirty solution) #14
Comments
I'm currently experiencing the same issue, and even though you gave the solution, I cannot figure out how to implement it myself. What do I need to change exactly in the load.py for it to work? EDIT: |
@appieGIT The dirty way aforementioned is a little tricky. Here is another way I did not try but expected to work: Adding a new line |
@Gowee I have tried this solution just now. It does start right now, which is something, but it keeps returning a parse error when decompyling the .pyc files with uncompyle6 or decompyle3. Is there any other solution you can think of? |
@AlbertJanSch Would you mind sharing a sample |
@Gowee Of course. I uploaded a sample called calendar.pyc here: https://www.sendspace.com/file/id2d1f |
@AlbertJanSch I see |
Gonna rephrase the solution in #14 (comment) for us, newbies. If you use rocky/python-decompile3 after extracting .pyc files and get "bad marshal data", do the following:
if my_magic_int == magic_int:
bytecode = fp.read()
co = marshal.loads(bytecode)
if my_magic_int == magic_int:
fp.seek(12)
bytecode = fp.read()
co = marshal.loads(bytecode)
Don't forget to revert the changes after you're done with decompilation. |
It still doesn't works for me.. :( I tried all you have said until this message. |
@CopyMist solution worked great for me. Tyty |
I know this is a fairly old issue, but also try skipping 16 and 8 as well. 16 worked for me in python 3.10, I've heard 8 also works potentially. |
When I try to decompile
.pyc
files generated by python-exe-unpacker, I got the following error:And those
.pyc
are also treated invalid by Python interpreter:After spending two hours figuring out what's wrong, I think it is valuable to note them down here even if this project seemingly has ended:
I suppose the problem resides around
https://github.com/countercept/python-exe-unpacker/blob/6c88e9b28cb40615b680cefdb5f47ce4cab17833/pyinstxtractor.py#L322
where the appended header (incl. magic number, timestamp, size, etc) seems to mismatch with the
.pyc
format used by some newer Python versions (in my case 3.7).To make uncompyle6 work well with malformed
.pyc
, dirty patch/usr/local/lib/python3.7/site-packages/xdis/load.py
to make suremarshal.loads
data starting from exactly 12th byte of original.pyc
(e.g. utilizingBytesIO
so that thefp
can be read twice) helps.The text was updated successfully, but these errors were encountered: