Exploit database

GH-e6e5922ef9ac5cc7d4897803cb452516

zero2005x/rokid-rv101-research

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

166 sources

Preferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source

Repository files15

Files from this repository share one source choice. Supporting files may cover other vulnerabilities.

research/ghostlock_refs/extracted/honor/cve-2026-43499-honor-main/scripts/parse/parse_arsc.py

Python · 3,793 bytes
#!/usr/bin/env python3
"""从 framework-res.apk 的 resources.arsc 提取 framework attr 的 resourceId。
解析 ResTable → package(id=0x01) → keyStrings,找指定 attr 名的 entry index。"""
import zipfile, struct, sys

def read_stringpool(data, base):
    """解析 ResStringPool_header,返回 (strings_list, 结束offset)。base 是 stringpool 起始。"""
    (sp_type, sp_hdr, sp_size, stringCount, styleCount, flags, stringsStart, stylesStart) = struct.unpack_from('<HHIIIIII', data, base)
    assert sp_type == 0x0001, hex(sp_type)
    utf8 = bool(flags & 0x100)
    offs = [struct.unpack_from('<I', data, base + sp_hdr + i*4)[0] for i in range(stringCount)]
    strings = []
    for i in range(stringCount):
        so = base + stringsStart + offs[i]
        if utf8:
            # UTF-8 池:两个变长长度前缀(utf16 字符数 + utf8 字节数)
            u16l = data[so]
            if u16l & 0x80:
                u16l = ((u16l & 0x7f) << 8) | data[so+1]
                p = so + 2
            else:
                p = so + 1
            u8l = data[p]
            if u8l & 0x80:
                u8l = ((u8l & 0x7f) << 8) | data[p+1]
                p += 2
            else:
                p += 1
            sdata = data[p:p+u8l]
            strings.append(sdata.decode('utf-8', 'replace'))
        else:
            l = struct.unpack_from('<H', data, so)[0]
            strings.append(data[so+2:so+2+l*2].decode('utf-16le', 'replace'))
    return strings, sp_size

def parse(arsc, target_attrs):
    # ResTable header
    (t_type, t_hdr, t_size, pkgCount) = struct.unpack_from('<HHII', arsc, 0)
    assert t_type == 0x0002, hex(t_type)
    off = t_hdr
    # 全局 string pool
    (g_type, g_hdr, g_size) = struct.unpack_from('<HHI', arsc, off)
    assert g_type == 0x0001
    off += g_size
    result = {}
    for pi in range(pkgCount):
        (p_type, p_hdr, p_size, p_id, p_name) = struct.unpack_from('<HHII256s', arsc, off)
        assert p_type == 0x0200, hex(p_type)
        p_name = p_name.decode('utf-16le', 'replace').split('\x00')[0]
        # typeStrings offset, lastPublicType, keyStrings offset, lastPublicKey
        (typeStringsOff, lastPubType, keyStringsOff, lastPubKey) = struct.unpack_from('<IIII', arsc, off + 8 + 4 + 256)
        type_strings, _ = read_stringpool(arsc, off + typeStringsOff)
        key_strings, _ = read_stringpool(arsc, off + keyStringsOff)
        print("package id=0x%02x name=%r types=%r" % (p_id, p_name, type_strings[:8]))
        if p_id == 0x01:
            print("  keyStrings 前20:", key_strings[:20])
        if p_id == 0x01:  # framework
            # 找 "attr" 的 type id
            attr_tid = None
            for i, ts in enumerate(type_strings):
                if ts == 'attr':
                    attr_tid = i + 1  # type id 从 1 开始
                    break
            print("attr type id =", attr_tid)
            for ta in target_attrs:
                found = None
                for i, ks in enumerate(key_strings):
                    if ks == ta:
                        found = i
                        break
                if found is not None:
                    resid = (p_id << 24) | ((attr_tid or 1) << 16) | found
                    result[ta] = resid
                    print("  %-16s key_idx=%d -> 0x%08x" % (ta, found, resid))
                else:
                    print("  %-16s NOT FOUND" % ta)
        off += p_size
    return result

if __name__ == '__main__':
    apk = sys.argv[1]
    if apk.endswith('.arsc'):
        arsc = open(apk, 'rb').read()
    else:
        with zipfile.ZipFile(apk) as z:
            arsc = z.read('resources.arsc')
    targets = ['label', 'debuggable', 'versionCode', 'versionName', 'hasCode', 'name']
    parse(arsc, targets)