# -*- 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:
    for name in sorted(zf.namelist()):
        low = name.lower()
        if not name.endswith(".json"):
            continue
        if "user" not in low and "auth" not in low and "register" not in low and "ekyc" not in low:
            continue
        data = zf.read(name).decode("utf-8", errors="replace")
        hits = []
        for m in re.finditer(r'"[^"]+"\s*:\s*"[^"]{8,200}"', data):
            s = m.group()
            sl = s.lower()
            if any(k in sl for k in ("unavailable", "register", "dfp", "phone", "otp", "system is")):
                hits.append(s[:220])
        if hits:
            print("\n===", name, "===")
            for h in hits[:40]:
                print(h)
