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