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

idx = d.find(b"getDfpByMMKV")
print("idx", idx)
window = d[max(0, idx - 20000) : idx + 20000]
classes = re.findall(rb"Lcom/[a-zA-Z0-9_$/]{5,200};", window)
unique = sorted(set(x.decode()[1:-1].replace("/", ".") for x in classes))
print("classes in 40k window:", len(unique))
for c in unique:
    cl = c.lower()
    if any(k in cl for k in ("crypto", "dfp", "finger", "device", "user", "jni", "utils", "manager", "wrapper", "register", "login")):
        print(c)
