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

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

idx = data.find(needle)
window = data[max(0, idx - 12000) : idx + 12000]
classes = sorted(set(m.group().decode()[1:-1].replace("/", ".")
                     for m in re.finditer(rb"Lcom/[^;\x00]{5,200};", window)))
print("all classes near getDfp empty (filtered):")
for c in classes:
    cl = c.lower()
    if any(k in cl for k in ("dfp", "finger", "shps", "bke", "jni", "utils", "sdk", "device", "monitor", "crypto", "register")):
        print(c)

print("\nall com classes count:", len(classes))
