# -*- coding: utf-8 -*- # 扫描官方 APK,寻找 0x2020 服务 UUID 与 aa55 帧构造代码 import os, re, subprocess, zipfile, io APK = "/Users/xs/Desktop/ruoyi/glass/2.0.052-CH_79454350.apk" TMP = "/tmp/inmo_apk_scan" os.makedirs(TMP, exist_ok=True) # 解压 with zipfile.ZipFile(APK) as z: names = z.namelist() dexes = [n for n in names if n.endswith(".dex")] sos = [n for n in names if n.endswith(".so")] print("dex:", dexes) print("so :", sos) for n in dexes + sos: data = z.read(n) out = os.path.join(TMP, os.path.basename(n)) with open(out, "wb") as f: f.write(data) def scan_file(path, label): with open(path, "rb") as f: data = f.read() print(f"\n=== {label} ({len(data)} bytes) ===") # 1) ASCII 字符串片段 for needle in [b"00002020", b"00002021", b"2020-0000", b"2021-0000", b"aa55", b"AA55", b"0x2020", b"0x2021", b"e49a", b"BLE_UUID"]: idx = 0 hits = 0 while True: i = data.find(needle, idx) if i < 0: break hits += 1 if hits <= 3: ctx = data[max(0,i-30):i+len(needle)+30] try: txt = ctx.decode("latin1") except: txt = repr(ctx) print(f" [{needle.decode()}] @{i}: ...{txt}...") idx = i + 1 if hits: print(f" -> {needle.decode()} 命中 {hits} 次") # 2) 裸字节 0xAA 0x55 序列(帧头) for m in re.finditer(rb'\xaa\x55', data): i = m.start() if i <= 3: # 避免重复 ctx = data[i:i+24] print(f" [RAW aa55] @{i}: {ctx.hex()}") for n in dexes: scan_file(os.path.join(TMP, os.path.basename(n)), "dex:"+os.path.basename(n)) for n in sos: scan_file(os.path.join(TMP, os.path.basename(n)), "so:"+os.path.basename(n))