While trying to help a fellow member from this post <a href="https://stackoverflow.com/questions/41407793/decompile-pyc-file-using-uncompyle2/41407984?noredirect=1#comment70021546_41407984" rel="nofollow">Decompile *.pyc file using uncompyle2</a>, i encountered the following error when trying to decompile *.pyc using
uncompyle6 , The error is as follows:
File "/usr/local/lib/python2.7/site-packages/uncompyle6/semantics/pysource.py", line 2231, in build_ast raise ParserError(e, tokens) uncompyle6.semantics.parser_error.ParserError: --- This code section failed: --- 2 0 JUMP_ABSOLUTE 120 'to 120' 3 SETUP_WITH 364 'to 370' 6 STOP_CODE 7 JUMP_ABSOLUTE 168 'to 168' 10 SETUP_WITH 22357 'to 22370' 13 LOAD_CONST 2 '' 16 LOAD_CONST 2 '' 19 POP_TOP 20 RETURN_VALUE -1 RETURN_LAST Parse error at or near `SETUP_WITH' instruction at offset 3Answer1:
You appear to be trying to decompile (decom<em>py</em>le) a piece of arbitrary data. You don't have any <em>valid</em> bytecode there, not for a regular Python interpreter.
JUMP_ABSOLUTE is used to jump back to the start of loops. It is not used with
with statements, which is what the
SETUP_WITH opcode deals with. The jumps are probably outside the code block and in this case <em>forward</em> rather than back, so
uncompile6 is correctly flagging this as invalid.
There is a possibility that the bytecode was <em>obfuscated</em>, where bytecode meaning is altered from their normal positions. Bytecode is just a sequence of bytes, with each byte given a specific meaning (together with operand values). The Dropbox Python interpreter, for example, has altered that table significantly in an attempt to stop the casual curious engineer from looking at their code (
pydecompyle6 compensates for this).