鱼C论坛

 找回密码
 立即注册
查看: 119|回复: 5

[已解决]pyinstaller生成的exe怎么反编译得到py文件

[复制链接]
发表于 2025-2-8 09:55:40 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
pyinstaller生成的exe怎么反编译得到py文件?
最佳答案
2025-2-8 20:23:24
教你如何反编译 PyInstaller 打包的文件
https://fishc.com.cn/thread-231886-1-1.html
(出处: 鱼C论坛)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2025-2-8 09:55:50 | 显示全部楼层
要反编译由 PyInstaller 生成的 exe 文件以提取出原始的 py 文件,你可以使用 `uncompyle6` 和 `pyinstxtractor` 工具。以下是一个简单的步骤:

步骤一:安装所需工具
你需要安装 uncompyle6pyinstxtractor 工具。
pip install uncompyle6
pip install pyinstxtractor

步骤二:提取 exe 文件
首先,使用 pyinstxtractor 提取 exe 文件
python pyinstxtractor.py your_exe_file.exe

这会在当前目录生成一个新文件夹,包含提取的内容。

步骤三:反编译 pyc 文件
在提取的文件夹中,你会找到 .pyc 文件,使用 uncompyle6 将其反编译为 py 文件。
uncompyle6 -o . extracted_directory/*.pyc

这样你就能得到反编译后的 .py 文件了。

请注意,反编译可能不会得到完全相同的源代码,但它应该足够接近原始代码。

完整示例代码
pip install uncompyle6
pip install pyinstxtractor

# 使用 pyinstxtractor 提取 exe 文件
python pyinstxtractor.py your_exe_file.exe

# 使用 uncompyle6 反编译 pyc 文件
uncompyle6 -o . extracted_directory/*.pyc

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

 楼主| 发表于 2025-2-8 10:00:11 | 显示全部楼层
(.venv) PS D:\PYTHON_NEW\pack20240926\pythonProject1> pip install pyinstxtractor
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
ERROR: Could not find a version that satisfies the requirement pyinstxtractor (from versions: none)
ERROR: No matching distribution found for pyinstxtractor
(.venv) PS D:\PYTHON_NEW\pack20240926\pythonProject1>
失败了
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2025-2-8 10:00:24 | 显示全部楼层
颂风侯 发表于 2025-02-08 10:00
(.venv) PS D:\PYTHON_NEW\pack20240926\pythonProjec ...


看来 `pyinstxtractor` 并未发布到 PyPI 上。你可以从 GitHub 下载 `pyinstxtractor` 的脚本并运行。以下是具体步骤:

1. 前往 [https://github.com/extremecoders-re/pyinstxtractor](https://github.com/extremecoders-re/pyinstxtractor) 下载 `pyinstxtractor.py` 文件。

2. 将 `pyinstxtractor.py` 下载到你的工作目录中。

3. 然后在你的命令行中运行以下命令来提取 exe 文件的内容:
python pyinstxtractor.py your_exe_file.exe

然后你可以继续使用 `uncompyle6` 来反编译 .pyc 文件:
uncompyle6 -o . extracted_directory/*.pyc

这里是更完整的步骤:

  • 从 [https://github.com/extremecoders-re/pyinstxtractor](https://github.com/extremecoders-re/pyinstxtractor) 下载 `pyinstxtractor.py` 文件。
  • 在你的命令行中运行以下命令提取 exe 文件的内容:
    python pyinstxtractor.py your_exe_file.exe
  • 使用 `uncompyle6` 反编译 .pyc 文件:
    uncompyle6 -o . extracted_directory/*.pyc


这样你就可以成功地反编译生成 .py 文件了。

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

发表于 2025-2-8 14:18:53 | 显示全部楼层
1
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2025-2-8 20:23:24 | 显示全部楼层    本楼为最佳答案   
教你如何反编译 PyInstaller 打包的文件
https://fishc.com.cn/thread-231886-1-1.html
(出处: 鱼C论坛)
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-2-24 02:00

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表