Cocos2dx-lua 解密
前言
本文仅供学习参考,请勿将其用于任何违法操作。本文中所涉及的技术和方法仅用于解析和理解游戏开发中可能存在的漏洞和调试技巧,并非用于破坏游戏平衡、修改游戏数据或进行其他违法行为。我们强烈呼吁读者遵守法律法规,尊重游戏开发者的劳动成果和游戏规则,并在合法范围内进行学习和研究。如因不当使用本文所述方法导致任何违法行为或造成任何不良后果,责任将完全由使用者自行承担。
简单破解Cocos2dx-lua 采用xxtea加密的lua
- 采用cocos2dx-lua引擎打包指令 –disable-compile 关闭编译为字节码的功能
批处理指令 cocos luacompile -s %SRC_TW_DIR% -d src -e -k %KEY% -b %SIGN% --disable-compile
脚本解密
强烈建议安装 Python 2.7.14版本 这个版本才能安装带有https的安装库
xxtemUpack.py
# -*- coding: utf-8 -*-
import xxtea
import os
def decrypt_xxtea_file(input_dir, output_dir, xxtea_key, xxtea_sign):
print("Begin to decrypt xxtea files in dir : " + input_dir)
# is original directory valid
if not os.path.isdir(input_dir):
print("Not a valid directory path")
return
# is output directory valid
if os.path.isfile(output_dir):
os.remove(output_dir)
if not os.path.isdir(output_dir):
os.mkdir(output_dir)
files = os.walk(input_dir)
for path, dir_list, file_list in files:
for directory in dir_list:
relevant_path = os.path.relpath(os.path.join(path, directory), input_dir)
new_path = os.path.join(output_dir, relevant_path)
if os.path.isfile(new_path):
os.remove(new_path)
if not os.path.isdir(new_path):
os.mkdir(new_path)
for file in file_list:
# 原文件绝对路径
orig_path = os.path.join(path, file)
# 源文件相对路径,方便计算解密文件路径
relevant_path = os.path.relpath(orig_path, input_dir)
# 解密文件绝对路径
new_path = os.path.join(output_dir, relevant_path)
# 读取原文件
orig_file = open(orig_path, "rb")
encrypt_bytes = orig_file.read()
orig_file.close()
# 解密文件
decrypt_bytes = xxtea.decrypt(encrypt_bytes[len(xxtea_sign):], xxtea_key)
new_file = open(new_path, "wb")
new_file.write(decrypt_bytes)
new_file.close()
print("Done with " + orig_path)
# decrypted
print("\r\ndecrypt done")
if __name__ == '__main__':
in_dir = "输入目录"
out_dir = "输出目录"
key = "密匙"
sign = "秘钥"
decrypt_xxtea_file(in_dir, out_dir, key, sign)
关于秘钥怎么获取
简单的方式 找到被加密的图片或者lua通过记事本打开 头部标记的便是key 简单寻找秘钥key 则通过查找apk中libs里的libcocos2dlua.so 通过key去搜索 附近便是sign
复杂的则需要idea动态调试去获取可参考一下文章