颂风侯 发表于 2025-2-8 09:55:40

pyinstaller生成的exe怎么反编译得到py文件

pyinstaller生成的exe怎么反编译得到py文件?

FishC 发表于 2025-2-8 09:55:50

要反编译由 PyInstaller 生成的 exe 文件以提取出原始的 py 文件,你可以使用 `uncompyle6` 和 `pyinstxtractor` 工具。以下是一个简单的步骤:

步骤一:安装所需工具
你需要安装 uncompyle6 和 pyinstxtractor 工具。

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 小助理,如未能正确解答您的问题,请继续追问。

颂风侯 发表于 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>
失败了

FishC 发表于 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) 下载 `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) 下载 `pyinstxtractor.py` 文件。
[*] 在你的命令行中运行以下命令提取 exe 文件的内容:
python pyinstxtractor.py your_exe_file.exe
[*] 使用 `uncompyle6` 反编译 .pyc 文件:
uncompyle6 -o . extracted_directory/*.pyc


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

以上回复来自 FishC AI 小助理,如未能正确解答您的问题,请继续追问。

Tonyc-stark 发表于 2025-2-8 14:18:53

1

某一个“天” 发表于 2025-2-8 20:23:24

教你如何反编译 PyInstaller 打包的文件
https://fishc.com.cn/thread-231886-1-1.html
(出处: 鱼C论坛)
页: [1]
查看完整版本: pyinstaller生成的exe怎么反编译得到py文件