# -*- coding: utf-8 -*-
# Trích bối cảnh dex quanh 'messageContent' để tìm class + fields command request
import io, sys, re
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')

data = open(r'E:\ios\vf_dex\classes4.dex', 'rb').read()
count = 0
for m in re.finditer(rb'[\x20-\x7e]{4,}', data):
    s = m.group().decode('ascii', 'replace')
    if 'messageContent' not in s:
        continue
    count += 1
    i = m.start()
    ctx = data[max(0, i - 200):i + 500].decode('ascii', 'replace')
    print('--- match', count, 'at offset', i)
    print(ctx.replace('\x00', '·'))
    print()
    if count >= 10:
        break
