# -*- coding: utf-8 -*-
import re
import zipfile

APK = r"C:\Users\Administrator\Desktop\notiMessage\reverse\apks\seabank_ph_base.apk"
classes = [
    b"Lcom/shopee/shpssdk/SPSRiskTokenCallback;",
    b"Lcom/shopee/shpssdkbank/SPSRiskTokenCallback;",
    b"Lcom/shopee/shpssdk/SPSResultCallback;",
    b"Lcom/shopee/shpssdkbank/SPSResultCallback;",
    b"Lcom/shopee/shpssdk/SHPSSDK;",
    b"Lcom/shopee/shpssdkbank/SPSAssessRisk;",
]
with zipfile.ZipFile(APK) as zf:
    data = b"".join(zf.read(n) for n in zf.namelist() if n.endswith(".dex"))
    for c in classes:
        name = c.decode()[1:-1].replace("/", ".")
        print("===", name, "===")
        idx = 0
        while True:
            idx = data.find(c, idx)
            if idx < 0:
                break
            ctx = data[max(0, idx - 150): idx + 400]
            for m in re.finditer(rb"[a-zA-Z][a-zA-Z0-9_$]{2,40}", ctx):
                s = m.group().decode()
                if any(k in s.lower() for k in ["token", "risk", "result", "callback", "assess", "get", "on"]):
                    if len(s) > 4:
                        print(" ", s)
            idx += 1
            break
