Created
January 3, 2018 08:26
-
-
Save h080294/53f954981d61d0fa0930fb83679cfd5a to your computer and use it in GitHub Desktop.
某手游lua文件解密脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
import io | |
import os | |
import base64 | |
import pyDes | |
import binascii | |
import sys | |
import crypto | |
import json | |
import zlib | |
sys.modules['Crypto'] = crypto | |
from crypto.Cipher import AES | |
""" | |
解密lua脚本 | |
""" | |
def decdata(c): | |
key = '\xe9\x74\x7d\x92\xcc\x32\x2e\x7d\x11\x2e\x7c\x34\x51\xd7\xb3\x6a' | |
iv = c[0:16] | |
main_data = c[16:] | |
print "取走iv值的文件长度", | |
print len(main_data) | |
cryptor = AES.new(key, AES.MODE_CBC, iv) | |
pad_compress_data = cryptor.decrypt(main_data) | |
print "解密后未压缩的文件大小", | |
print len(pad_compress_data) | |
str_len = len(pad_compress_data) | |
pad = ord(pad_compress_data[-1]) | |
print "pad值是:", pad | |
compress_data = pad_compress_data[0:str_len-pad] | |
print "compress_data结束位置:", str_len-pad | |
plain_text = zlib.decompress(compress_data) | |
# plain_text = zlib.compress(compress_data) | |
return plain_text | |
if __name__ == '__main__': | |
indir = '/Users/johnhao/Downloads/anti/com.happyelements.AndroidAnimal.qq_1.53_53/assets/src' #输入文件夹 | |
outdir= '/Users/johnhao/Downloads/happyelement' #输出文件夹 | |
exstr='.lua' #输入文件的扩展名 | |
for path, subdirs, files in os.walk(indir): | |
for filename in files: | |
if filename.endswith(exstr): | |
infilename = path + os.sep + filename | |
size = os.path.getsize(infilename) | |
with open(infilename, 'rb') as inFile: | |
data = inFile.read() | |
inFile.close() | |
if True: | |
try: | |
print "加密的文件长度是", | |
print len(data) | |
result = decdata(data) | |
print "解密后文件的长度", | |
print len(result) | |
except: | |
print "FAILED!!!!", | |
print infilename | |
break | |
outfilename = outdir + infilename.replace(indir, '', 1) | |
print outfilename | |
outPath, outFilename = os.path.split(outfilename) | |
if not os.path.exists(outPath): | |
os.makedirs(outPath) | |
with open(outfilename, 'wb') as outFile: | |
outFile.write(result) | |
outFile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment