从luajit bytecode dump文件提取字符串资源
来源:互联网 发布:淘宝卖的aj哪里来的 编辑:程序博客网 时间:2024/05/18 13:06
当字符串长度小于128时这样子表述是没有问题的。
struct str{ unsigned char length; char str[0]};
事实上,长度信息这个整数应该是使用ULEB128编码方式编码的,理由是LuaJIT 2.0 Bytecode Dump Format里使用了这种格式:
LuaJIT 2.0 Bytecode Dump FormatDetails for the bytecode dump format can be found in src/lj_bcdump.h in the LuaJIT source code. Here's the concise format description:dump = header proto+ 0Uheader = ESC 'L' 'J' versionB flagsU [namelenU nameB*]proto = lengthU pdatapdata = phead bcinsW* uvdataH* kgc* knum* [debugB*]phead = flagsB numparamsB framesizeB numuvB numkgcU numknU numbcU [debuglenU [firstlineU numlineU]]kgc = kgctypeU { ktab | (loU hiU) | (rloU rhiU iloU ihiU) | strB* }knum = intU0 | (loU1 hiU)ktab = narrayU nhashU karray* khash*karray = ktabkkhash = ktabk ktabkktabk = ktabtypeU { intU | (loU hiU) | strB* }B = 8 bit, H = 16 bit, W = 32 bit, U = ULEB128 of W, U0/U1 = ULEB128 of W+1TODO: turn the description into human-readable text :-)
提取代码如下:
filelist = ['app.TiConfig.BiaoBai', 'app.TiConfig.ChuanYi', 'app.TiConfig.GouTong', 'app.TiConfig.GouWu', 'app.TiConfig.JiaWu', 'app.TiConfig.JiuCan', 'app.TiConfig.KanBing', 'app.TiConfig.LvXing', 'app.TiConfig.MuYu', 'app.TiConfig.YueHui']for fname in filelist: with open(fname, 'rb') as fin: with open(fname+'.txt', 'wt', encoding='utf-8') as fout: buffer = fin.read() buffer = buffer[::-1] # reverse firstNullIdx = buffer.index(b'\x00') secondNullIdx = buffer.index(b'\x00', firstNullIdx + 1) buffer = buffer[0:secondNullIdx] buffer = buffer[::-1] # reverse offset = 0 lst = [] while True: length = buffer[offset] - 5 # 与实际长度相差5 offset = offset + 1 slice = buffer[offset:offset+length] ## 字符串已取出, ## 下面的代码是针对该案例的进一步处理。 slice = slice.decode('utf-8') if slice == 'ti': break if len(slice) > 8: fout.write(slice+'\n') fout.writelines(lst) fout.write('\n') lst = [] else: lst.append(slice+'\n') offset = offset + length
参考资料
Little Endian Base 128, wikipedia, http://en.wikipedia.org/wiki/LEB128
LuaJIT 2.0 Bytecode Dump Format, http://wiki.luajit.org/Bytecode-2.0#LuaJIT-2.0-Bytecode-Dump-Format
0 0
- 从luajit bytecode dump文件提取字符串资源
- luajit 2.0 bytecode dump文件解析
- luajit笔记---编译bytecode(字节码文件)
- uLua运行LuaJIT编译后的bytecode文件
- uLua运行LuaJIT编译后的bytecode文件
- Oracle 从Dump 文件里提取 DDL 语句 方法说明
- Oracle 从Dump 文件里提取 DDL 语句 方法说明
- VC从EXE中提取资源文件
- 从ipa提取图片资源文件
- 关于luajit的bytecode模式
- luajit ios arm64 编译bytecode
- 从文件中随机提取一个字符串
- C++ 从文件中提取特定字符串
- luajit 2.1beta2 bytecode windows mac 下32 64编译文件
- iOS: 从ipa提取图片资源文件及从iOS设备提取ipa文件的方法
- iOS: 从ipa提取图片资源文件及从iOS设备提取ipa文件的方法
- iOS: 从ipa提取图片资源文件及从iOS设备提取ipa文件的方法
- 从MTK的BIN文件里提取图片资源
- Fragment和View的比较
- [PHP][PrestaShop]加载机制
- Aria2c 使用举例
- Substring
- UVa 294 - Divisors
- 从luajit bytecode dump文件提取字符串资源
- 我对软件公司和互联网公司的理解
- 15 自定义控件之水波纹
- 第一个java程序
- C++对象的构造函数和析构函数详解
- java 嵌套类
- 异 形 卵
- pom 压缩css与js
- 从12306验证码看人工智能未来发展