# -*- 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"))

for pat in [
    rb"Lcom/shopee/shpssdk/[\w$/]{3,100};",
    rb"Lcom/shopee/shpssdkbank/[\w$/]{3,100};",
]:
    cs = sorted(set(m.group().decode()[1:-1].replace("/", ".") for m in re.finditer(pat, d)))
    print("\n", pat.decode(), len(cs))
    for c in cs:
        if "R" != c.split(".")[-1] or "$" in c:
            print(" ", c)

for needle in [b"RISK_USB", b"RISK_WIFI", b"RISK_ROOT", b"RISK_HOOK", b"requestDefense"]:
    print(needle.decode(), d.count(needle))
