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

APK = Path(__file__).resolve().parent.parent / "apks" / "seabank_ph_base.apk"
needle = b"riskToken"
with zipfile.ZipFile(str(APK)) as zf:
    for name in zf.namelist():
        if not name.endswith(".dex"):
            continue
        data = zf.read(name)
        idx = data.find(needle)
        if idx < 0:
            continue
        ctx = data[max(0, idx - 300): idx + 300]
        print("===", name, "===")
        import re
        for m in re.finditer(rb"[\x20-\x7e]{4,100}", ctx):
            print(" ", m.group().decode("latin1"))
