内容介绍
PyInstaller封装程序的反编译:
使用PyInstaller Extractor 提取由PyiIstaller生成的可执行文件内容
使用Uncompyle进行反编译
工具准备:
PyInstaller Extractor 项目地址:https://github.com/extremecoders-re/pyinstxtractor
软件版本:
Python 3.7.3
PyInstaller 3.6
PyInstxtractor 2.0
Uncompyle 3.6.4
准备pyinstxtractor.py、Main_cfg_editor.exe文件并在该目录下执行cmd命令
python pyinstxtractor.py Main_cfg_editor.exe
pip install uncompyle
uncompyle6 CV_Annotation2JSON.exe_extracted/CV_Annotation2JSON.pyc > CV_Annotation2JSON.py
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支持
Python39\Lib\site-packages\uncompyle6\bin\uncompile.py
如果报错为 <class ‘ValueError’>; bad marshal data (unknown type code)
ValueError: bad marshal data (unknown type code)
那么说明咱们得修改自己的pyc文件了
使用NotePad++查看16进制的文件,
https://github.com/chcg/NPP_HexEdit/releases下载HexEditor.dll放在Notepad++\plugins\HexEditor目录下
打开pyc文件使用NotePad++的插件功能选择View in HEX
打开struct.pyc复制第一行0到7的替换需要编译的pyc文件第一行0到7
然后重新执行uncompyle6