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

APK = Path(__file__).resolve().parent.parent / "apks" / "seabank_ph_base.apk"
needle = b"uapi/v2/register"
with zipfile.ZipFile(str(APK)) as zf:
    data = b"".join(zf.read(n) for n in zf.namelist() if n.endswith(".dex"))
    idx = data.find(needle)
    print("found at", idx)
    if idx >= 0:
        ctx = data[max(0, idx - 400): idx + 400]
        for m in re.finditer(rb"[\x20-\x7e]{4,120}", ctx):
            print(" ", m.group().decode("latin1"))
