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

APK = Path(__file__).resolve().parent.parent / "apks" / "seabank_ph_base.apk"
needles = [
    b"getRiskTokenAsync",
    b"getRiskToken",
    b"getRiskSync",
    b"getRiskAsync",
    b"assessRisk",
]
with zipfile.ZipFile(str(APK)) as zf:
    for name in zf.namelist():
        if not name.endswith(".dex"):
            continue
        data = zf.read(name)
        hits = [n.decode() for n in needles if n in data]
        if not hits:
            continue
        print(name, hits)
        for m in re.finditer(
            rb"Lcom/shopee/shpssdk(?:bank)?/SHPSSDK;\.(\w+):\([^)]+\)[^;]+;", data
        ):
            print(" ", m.group().decode())
