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

APK = Path(__file__).resolve().parent.parent / "apks" / "seabank_ph_base.apk"
needle = b"4067"
with zipfile.ZipFile(str(APK)) as zf:
    data = b"".join(zf.read(n) for n in zf.namelist() if n.endswith(".dex"))
    idx = 0
    while True:
        idx = data.find(needle, idx)
        if idx < 0:
            break
        ctx = data[max(0, idx - 80): idx + 120]
        import re
        strings = [m.group().decode("latin1") for m in re.finditer(rb"[\x20-\x7e]{3,80}", ctx)]
        print("--- at", idx, "---")
        for s in strings:
            print(" ", s)
        idx += 1
