# -*- coding: utf-8 -*- # 从 classes4.dex 中 BLE 常量附近抽取可读字符串,定位相关类名与命令常量 import re path = "/tmp/inmo_apk_scan/classes4.dex" with open(path, "rb") as f: data = f.read() def printables(b): return b.decode("latin1") # 关键偏移 targets = { "BLE_UUID_SERVICE": data.find(b"BLE_UUID_SERVICE\x00"), "00002020": data.find(b"00002020"), "BLE_SCROLL_DOWN": data.find(b"BLE_SCROLL_DOWN"), } print("target offsets:", targets) # 在 BLE_UUID 附近抽长字符串(>=4 可打印) region = data[4_900_000:4_922_000] runs = re.findall(rb'[\x20-\x7e\x80-\xff]{4,}', region) print(f"\n=== BLE 区域可读串 ({len(runs)} 条,前 120 条) ===") seen = set() for r in runs: try: s = r.decode("utf-8") except: s = r.decode("latin1") if s in seen: continue seen.add(s) print(s) if len(seen) >= 120: break # 提取类名线索:Lxxx/xxx; 形式 classes = set(re.findall(rb'L[/\w\$]+;', region)) print(f"\n=== 该区域出现的类名 ({len(classes)} 个) ===") for c in sorted(classes): try: print(c.decode("utf-8")) except: pass