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

APK = Path(__file__).resolve().parent.parent / "apks" / "seabank_ph_base.apk"
needles = [
    b"v2/register",
    b"/register",
    b"RegisterRequest",
    b"registerPhone",
    b"signUp",
    b"preRegister",
    b"riskToken",
]
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:
        c = data.count(n)
        if c:
            print(n.decode(), c)
    print("\n--- classes near register ---")
    for m in re.finditer(rb"Lcom/shopee/bke/[^;]{0,120}register[^;]{0,40};", data, re.I):
        print(m.group().decode()[1:-1].replace("/", "."))
