# -*- coding: utf-8 -*-
import re
import zipfile
from pathlib import Path

APK = Path(__file__).resolve().parent.parent / "apks" / "maribank_sg_base.apk"
with zipfile.ZipFile(str(APK)) as zf:
    d = b"".join(zf.read(n) for n in zf.namelist() if n.endswith(".dex"))

patterns = [
    rb"Lcom/shopee/bke/lib/safemode/[a-zA-Z$][\w$]{0,30};",
    rb"Lcom/shopee/bke/lib/safemode/[a-z]+/[a-zA-Z$][\w$]{0,40};",
]
seen = set()
for pat in patterns:
    for m in re.finditer(pat, d):
        c = m.group().decode()[1:-1].replace("/", ".")
        if c.startswith("com.shopee.bke.lib.safemode.R"):
            continue
        if c not in seen:
            seen.add(c)
            print(c)

print("\n--- short obfuscated bke classes (root/adb) ---")
for m in re.finditer(rb"Lcom/shopee/bke/[a-z]+/[a-z]{1,2};", d):
    c = m.group().decode()[1:-1].replace("/", ".")
    if "lib" in c or "safemode" in c or "risk" in c:
        print(c)
