# -*- coding: utf-8 -*-
# Bối cảnh rộng quanh JSON mẫu + LOG_REMOTE_STEPS trong dex
import io, sys, re
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

def ctx(path, needle, before, after, label, maxn=5):
    data = open(path, 'rb').read()
    n = 0
    for m in re.finditer(re.escape(needle.encode()), data):
        n += 1
        i = m.start()
        chunk = data[max(0, i - before):i + after].decode('ascii', 'replace')
        chunk = chunk.replace('\x00', '·')
        print(f'===== {label} #{n} =====')
        print(chunk)
        print()
        if n >= maxn:
            break

ctx(r'E:\ios\vf_dex\classes15.dex', '"vinCode": "PPXAE4F44M0000026"', 400, 1600, 'JSON MAU classes15')
ctx(r'E:\ios\vf_dex\classes6.dex', 'LOG_REMOTE_STEPS', 300, 700, 'REMOTE_STEPS classes6')
