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

APK = Path(__file__).resolve().parent.parent / "apks" / "seabank_ph_base.apk"
needles = [
    b"GlobalAuthErrorImpl",
    b"errorcodehandler",
    b"sendOtp",
    b"register",
    b"verifyMobile",
    b"mobile/register",
    b"preRegister",
    b"riskToken",
    b"risk_token",
    b"8424 8050",
    b"-1201",
]
with zipfile.ZipFile(str(APK)) as zf:
    data = b"".join(zf.read(n) for n in zf.namelist() if n.endswith(".dex"))
    for n in needles:
        print(n.decode(), data.count(n))
    print("\n--- urls ---")
    for m in re.finditer(rb"https?://[a-zA-Z0-9._/-]{8,120}", data):
        u = m.group().decode()
        if "seabank" in u or "register" in u or "otp" in u or "mobile" in u:
            print(u)
