# -*- coding: utf-8 -*-
import re
import zipfile

APK = r"C:\Users\Administrator\Desktop\notiMessage\reverse\apks\seabank_ph_base.apk"
with zipfile.ZipFile(APK) as zf:
    for name in zf.namelist():
        if not name.endswith(".dex"):
            continue
        data = zf.read(name)
        if b"bke_toast_not_support_root" not in data:
            continue
        print("===", name, "===")
        idx = data.find(b"bke_toast_not_support_root")
        ctx = re.sub(rb"[^\x20-\x7e]+", b" ", data[max(0, idx - 120): idx + 200])
        print(ctx.decode())
        for m in re.finditer(rb"Lcom/shopee/bke[^;]{0,120};", data[max(0, idx - 800): idx + 800]):
            s = m.group().decode()[1:-1].replace("/", ".")
            if "dialog" in s.lower() or "root" in s.lower() or "safemode" in s.lower() or "risk" in s.lower() or "toast" in s.lower():
                print(" ", s)
