比赛中因为不熟悉pyinstaller打包方式,导致走了很多弯路。
-
寻一个文件archive_viewer.py来分解出程序中的
pyc
文件,或者使用pyi-archive_viewer
命令(可能需要pip
安装pyinstaller
)python3 archive_viewer.py pwn
或者pyi-archive_viewer pwn
这里需要两个文件,一个
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
这是
struct.pyc
多出来的文件头,需要补充进input_httpd.pyc
。这是
input_httpd.pyc
文件,做个对比。我并没有选择使用
vim
来修改文件,只是用它来查看需要补充的文件头,修改的时候使用的Hex Fiend
。 -
uncompyle6
来反编译pyc
文件为py
源代码文件。uncompyle6 input_httpd.pyc > input_httpd.py