uncompyle6 python3.9 报错

  • Uncompyle6 安装与使用
    pip安装
    pip install uncompyle6
    uncompyle6加上需要反编译的文件参数即可,注意使用-o 选项输出到文件中
    uncompyle6 -o test.py test.pyc

  • 如使用python 3.9 报错,会报错
    Error: uncompyle6 requires Python 2.6-3.8

  • 我们只需要给uncompile包加一个3.9支持
    vim /usr/local/lib/python3.9/dist-packages/uncompyle6/bin/uncompile.py

image

另外报错是在做“DASCTF八月挑战赛”python逆向题目的时报错:

# uncompyle6 -o py.py py.pyc
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/xdis/load.py", line 297, in load_module_from_file_object
    co = marshal.loads(bytecode)
ValueError: bad marshal data (unknown type code)
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/dist-packages/xdis/load.py", line 297, in load_module_from_file_object
    co = marshal.loads(bytecode)
ValueError: bad marshal data (unknown type code)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/uncompyle6", line 8, in <module>
    sys.exit(main_bin())
  File "/usr/local/lib/python3.9/dist-packages/uncompyle6/bin/uncompile.py", line 193, in main_bin
    result = main(src_base, out_base, pyc_paths, source_paths, outfile,
  File "/usr/local/lib/python3.9/dist-packages/uncompyle6/main.py", line 316, in main
    deparsed = decompile_file(
  File "/usr/local/lib/python3.9/dist-packages/uncompyle6/main.py", line 183, in decompile_file
    (version, timestamp, magic_int, co, is_pypy, source_size, sip_hash) = load_module(
  File "/usr/local/lib/python3.9/dist-packages/xdis/load.py", line 167, in load_module
    return load_module_from_file_object(
  File "/usr/local/lib/python3.9/dist-packages/xdis/load.py", line 310, in load_module_from_file_object
    raise ImportError(
ImportError: Ill-formed bytecode file py.pyc
<class 'ValueError'>; bad marshal data (unknown type code)
  • 是因为py.pyc文件首部是损坏的,Struct.pyc文件包含一个完整可用的首部,用他修复py.pyc.

image

posted @ 2021-09-19 20:33  jzking121  阅读(6933)  评论(0编辑  收藏  举报