Skip to content

Latest commit

 

History

History
49 lines (31 loc) · 1.79 KB

Decompile-the-program-packaged-with-Pyinstaller.md

File metadata and controls

49 lines (31 loc) · 1.79 KB

pyinstaller 打包程序反编译

比赛中因为不熟悉pyinstaller打包方式,导致走了很多弯路。

  • 寻一个文件archive_viewer.py来分解出程序中的pyc文件,或者使用pyi-archive_viewer命令(可能需要pip安装pyinstaller

    python3 archive_viewer.py pwn 或者pyi-archive_viewer pwn

    image-20210402130116102

    这里需要两个文件,一个struct(后续需要用到),一个input_httpd(我们需要反编译的pyc文件)。

    提取指令:

    U: go Up one level
    O <name>: open embedded archive name
    X <name>: extract name
    Q: quit
  • 修复input_httpd的文件头。(Linux和Windows下修复方式不同,本文是Linux下)

    分别打开两个pyc,对比发现input_httpd缺少文件头。(实际是看了前人的帖子)

    vim struct.pyc
    :%!xxd
    # 修改
    :%!xxd -r
    :wq
    image-20210402130831724

    这是struct.pyc多出来的文件头,需要补充进input_httpd.pyc

    image-20210402131015952

    这是input_httpd.pyc文件,做个对比。

    我并没有选择使用vim来修改文件,只是用它来查看需要补充的文件头,修改的时候使用的Hex Fiend

  • uncompyle6来反编译pyc文件为py源代码文件。

    uncompyle6 input_httpd.pyc > input_httpd.py