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

APK = Path(__file__).resolve().parent.parent / "apks" / "seabank_ph_base.apk"
needles = [
    b"mobile",
    b"register",
    b"otp",
    b"signUp",
    b"signup",
    b"preCheck",
    b"checkMobile",
    b"sendSms",
    b"verifyPhone",
    b"4067004",
    b"4067",
]
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:
        if n in data:
            print("hit", n.decode())
    print("\n--- api paths ---")
    for m in re.finditer(rb"/v[0-9]/[a-zA-Z0-9_/-]{6,80}", data):
        s = m.group().decode()
        if any(k in s.lower() for k in ("user", "auth", "register", "mobile", "otp", "sign", "risk", "phone")):
            print(s)
