import struct
import os
#这里定义一个读取字符串长度的函数
def DecUnsignedLEB128(file):
result = struct.unpack("i", file.read(4))[0]#读取4字节中的第一个字节
result = result&0x000000ff
file.seek(-3, 1) #倒退回前面的第三个字节 # 不能直接从1字节强转为4字节,所以先取4字节,再清空3字节
if (result > 0x7f):
next = struct.unpack("i", file.read(4))[0]
next = next&0x000000ff #第一位是个位
file.seek(-3, 1)
result = (result&0x7f) | (next&0x7f)<<7
if(next > 0x7f):
next = struct.unpack("i", file.read(4))[0]
next = next&0x000000ff #加入十位
file.seek(-3, 1)
result = result | (next&0x7f)<<14
if(next > 0x7f):
next = struct.unpack("i", file.read(4))[0]
next = next&0x000000ff
file.seek(-3, 1)
result = result | (next&0x7f
读取.dex文件中的所有字符串
最新推荐文章于 2023-11-16 14:38:14 发布
本文介绍了一种使用Python解析.dex文件中所有字符串的方法。通过定义DecUnsignedLEB128函数来读取字符串长度,然后读取并处理string table,最终将所有字符串保存到外部文本文件。
摘要由CSDN通过智能技术生成