python - cx_freeze 生成的 EXE 能否完全反编译回可读的 Python 代码?

标签 python decompiling pyside cx-freeze

我是 python 的新手,我正在评估使用 Python + PySide 开发桌面程序,发现 cx_freeze在将我的 python 代码转换为可执行文件方面效果很好,而且它是跨平台的。

我的问题是,其他人能否将 cx_freeze 生成的 EXE 反编译回完全可读的代码,就像我的原始源代码一样?

注意:我不担心有人破解我的程序,只是不想让别人拿走我的代码并以此为基础进行开发。

谢谢。

最佳答案

似乎当前接受的答案不再正确。

以下是如何从使用 cx_freeze 卡住的项目中恢复原始源代码。

注意:它是在“Hello world”项目上完成的,但是,使用相同的方法,我已经能够从我的项目中反编译 1000 多行代码源代码卡住 cx_freeze,并恢复几乎原始的源代码!

1) 使用cx_freeze

创建一个包含

test.py文件
import time
print('hello')
time.sleep(2)
print('world')

然后创建可执行文件

cxfreeze test.py --target-name=test.exe

然后通常您会将其分发给最终用户:

enter image description here

现在让我们尝试对其进行逆向工程!

2) 获取.pyc字节码

打开 dist/lib/library.zip 并提取文件 test__main__.pyc

3) 使用decompyle6获取源码

import uncompyle6
with open('test_main_reverse_eng.py', 'w') as f:
    uncompyle6.decompile_file('test__main__.pyc', f)

4) 惊喜!

这是原始源代码!

# uncompyle6 version 3.7.1
# Python bytecode 3.7 (3394)
# Decompiled from: Python 3.7.6 (tags/v3.7.6:43364a7ae0, Dec 19 2019, 00:42:30) [MSC v.1916 64 bit (AMD64)]
# Embedded file name: test.py
# Compiled at: 2020-06-16 21:02:17
# Size of source mod 2**32: 58 bytes
import time
print('hello')
time.sleep(2)
print('world')

关于python - cx_freeze 生成的 EXE 能否完全反编译回可读的 Python 代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5497399/

相关文章:

python - Alembic:从脚本内的模式比较获取 SQL 输出

java - 是否有可能使具有特定 Java 代码的 Java 反编译器崩溃?

java - 当我们执行 javap classname 时私有(private)方法不存在

python - pyside/pyqt : when converting str() to QTreeWidgetItem() the str() is shortened to the [0] of str()

python - QTreeView标题显示文本

python - Cloud Dataflow 写入 BigQuery Python 错误

python - 从文本中删除一行

python画平行六面体

c - 如何从可执行文件中恢复源代码?

python - 如何用cython构建整个python项目