0%

python_pyc反编译

https://mp.weixin.qq.com/s/7ggXt0TkEuN2SabVin5oLA

python pyinstaller 打包exe免杀

pyinstaller

https://www.virustotal.com/gui/file/8bc40da35383f54998be34e32c0ff22e25dd9c4c8f5df1c10e6f0bb9e431c8b0?nocache=1 3/69

py2exe

使用py2exe 打包完文件后 会生成多个文件 二 pyinstaller 会生产一个exe

https://www.virustotal.com/gui/file/823d00a6d1ab82bbfaa5e997d5192b72cca7dba0e9b2d18d69ecf15e75fff9e7?nocache=1 5/69

反编译pyinstaller打包的exe文件

https://github.com/countercept/Python-exe-unpacker

pyinstaller在打包pyc时,会去掉pyc的magic时间戳。需要进行手工修复。pyinstaller在打包的系统库的时候是不会去掉magic的,所以查看一下系统库的magic即可

在将exe 转换为pyc文件有两种方法 如下

将 exe 文件转换为 pyc 文件

使用 pyinstxtractor.py

https://sourceforge.net/projects/pyinstallerextractor/

将exe 和 pyinstxtractor.py 放在同一目录下

python pyinstxtractor.py test.exe

然后会生成

截图


使用pyi-archive_viewer

二是使用pyi-archive_viewer命令(需要安装pyinstaller)

pyi-archive_viewer test.exe

截图
截图

这样会生成一个test2.pyc文件 然后恢复被pyinstaller 打包后删除的字节

修复pyc 文件

test.exe_extracted文件下 存在struct 和 test 两文件 截图

使用010editor打开 将struct的第一行插入到test的第一行 截图 截图

添加后 截图 另存为test.pyc即可

将pyc文件转换为python代码

在线pyc反编译

https://tool.lu/pyc

截图
使用 uncompyle6

(需要使用pip 安装 pip install uncompyle6 但是不支持python3.9版本)

uncompyle6 test.pyc 即可查看python代码 截图 也可以将内容保存到test.py uncompyle6 test.pyc > test.py

踩坑: (在使用时 由于本机内python环境比较复杂 有三个环境 结果搞得版本不统一 然后一直报错pyc的magic 失败 看了下https://fishc.com.cn/forum.php?mod=viewthread&tid=131172&highlight=pyc%2B%B7%B4%BB%E3%B1%E0 意识到了这个问题) 在虚拟机上就可以成功避免这种问题

Reference

https://xz.aliyun.com/t/10450#toc-11

https://fishc.com.cn/thread-131172-1-1.html

https://jishuin.proginn.com/p/763bfbd69fa1

https://www.cxymm.net/article/qq_36078992/103596170

欢迎关注我的其它发布渠道

------------- 💖 🌞 本 文 结 束 😚 感 谢 您 的 阅 读 🌞 💖 -------------