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

APK = r"C:\Users\Administrator\Desktop\notiMessage\reverse\apks\seabank_ph_base.apk"
targets = [
    b"Lcom/shopee/bke/biz/user/errorcodehandler/a;",
    b"Lcom/shopee/bke/biz/user/errorcodehandler/b;",
    b"Lcom/shopee/shpssdkbank/SPSAssessRisk;",
    b"Lcom/shopee/bke/biz/user/rn/helper/ErrorFlowHelper;",
]

with zipfile.ZipFile(APK) as zf:
    data = b"".join(zf.read(n) for n in zf.namelist() if n.endswith(".dex"))
    for t in targets:
        print("===", t.decode()[1:-1].replace("/", "."), "===")
        idx = 0
        while True:
            idx = data.find(t, idx)
            if idx < 0:
                break
            ctx = data[max(0, idx - 200): idx + 400]
            # crude string extraction nearby
            for m in __import__("re").finditer(rb"[\x20-\x7e]{4,80}", ctx):
                s = m.group().decode()
                if any(k in s.lower() for k in ["1201", "error", "kill", "finish", "risk", "root", "code", "handle"]):
                    print(" ", s)
            idx += 1
