如何反编译由
pye
编译的py concrete
文件?过去几个月我一直在尝试这样做,但仍然无法做到。
SourceDefender 只是使用 TgCrypto 来加密和解密代码。您可以包装解密函数来打印数据。
假设您想要解密
mystery.pye
。
将以下脚本保存为
wrapper.py
在同一工作目录中:
import tgcrypto
# Keep the original function reference
original_ctr256_decrypt = tgcrypto.ctr256_decrypt
DECOMPILED_CODE = ''
# Define wrapper function
def wrap_ctr256_decrypt(data: bytes, key: bytes, iv: bytes, state: bytes):
global DECOMPILED_CODE
result = original_ctr256_decrypt(data, key, iv, state)
DECOMPILED_CODE = result[9:-19].decode('utf-8')
print("Result:")
print(DECOMPILED_CODE)
return result
# Replace the original function with the wrapper
tgcrypto.ctr256_decrypt = wrap_ctr256_decrypt
使用命令
python3
运行 Python shell,然后在加密模块之前导入包装器:
import sourcedefender
import wrapper
# The following is the PYE file
import mystery
代码将打印在屏幕上。之后您仍然可以访问它,例如:
print(wrapper.DECOMPILED_CODE)
甚至:
with open("mystery.py", "w") as outfile:
outfile.write(wrapper.DECOMPILED_CODE)