Exploit database

GH-5fd8ef322ef5cc51c148ecb7362c28e5

rebilibin/ghostlock-oppo-watch3pro

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 files57
rebilibin/ghostlock-oppo-watch3proRevision 3f63fa67f79d
Next files →

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

dis3.py

Python · 10,100 bytes
#!/usr/bin/env python3
"""Accurate ARM32 disassembler for kernel_decompressed.bin (base 0xC0008000).
Handles cond codes properly, BL/B masks, MOVW/MOVT, data processing with
barrel shift, LDR/STR (imm/reg/halfword/signed/byte), LDM/STM, MUL/MLA,
MRS/MSR, BX/BLX, CLZ, SWP, LDRD/STRD, CPS, PLD, DMB/DSB/ISB.
"""
import struct, sys, re

BASE = 0xC0008000

def load(path):
    with open(path, 'rb') as f:
        return f.read()

def read_u32(data, addr):
    off = addr - BASE
    if off < 0 or off + 4 > len(data):
        return None
    return struct.unpack('<I', data[off:off+4])[0]

SYMS = {}
def load_syms(path):
    with open(path, 'r', encoding='utf-8', errors='replace') as f:
        for line in f:
            m = re.match(r'^([0-9a-fA-F]{8})\s+(\S)\s+(\S+)', line)
            if m:
                SYMS[int(m.group(1), 16)] = m.group(3)

def sym(addr):
    return SYMS.get(addr)

COND = {0:'EQ',1:'NE',2:'CS',3:'CC',4:'MI',5:'PL',6:'VS',7:'VC',
        8:'HI',9:'LS',10:'GE',11:'LT',12:'GT',13:'LE',14:'',15:'??'}
OP = {0:'AND',1:'EOR',2:'SUB',3:'RSB',4:'ADD',5:'ADC',6:'SBC',7:'RSC',
      8:'TST',9:'TEQ',10:'CMP',11:'CMN',12:'ORR',13:'MOV',14:'BIC',15:'MVN'}

def ror(v, r):
    r &= 31
    if r == 0:
        return v
    return ((v >> r) | (v << (32 - r))) & 0xFFFFFFFF

def imm(inst):
    return ror(inst & 0xFF, ((inst >> 8) & 0xF) * 2)

def fmt_shift(inst):
    shift_imm = (inst >> 7) & 0x1F
    st = (inst >> 5) & 0x3
    rm = inst & 0xF
    if st == 0:
        return f"r{rm}" if shift_imm == 0 else f"r{rm}, lsl #{shift_imm}"
    if st == 1:
        return f"r{rm}, lsr #{shift_imm if shift_imm else 32}"
    if st == 2:
        return f"r{rm}, asr #{shift_imm if shift_imm else 32}"
    return f"r{rm}, rrx" if shift_imm == 0 else f"r{rm}, ror #{shift_imm}"

def fmt_reg_shift(inst):
    rm = inst & 0xF
    st = (inst >> 5) & 0x3
    rs = (inst >> 8) & 0xF
    if st == 0:
        return f"r{rm}, lsl r{rs}"
    if st == 1:
        return f"r{rm}, lsr r{rs}"
    if st == 2:
        return f"r{rm}, asr r{rs}"
    return f"r{rm}, ror r{rs}"

def disasm(data, addr, max_inst=4096):
    out = []
    for i in range(max_inst):
        a = addr + i * 4
        inst = read_u32(data, a)
        if inst is None:
            break
        cond = COND[(inst >> 28) & 0xF]
        cc = cond + ' ' if cond else ''
        d = None
        # ---------- MOVW / MOVT ----------
        if (inst & 0x0FF00000) == 0x03000000:
            rd = (inst >> 12) & 0xF
            val = ((inst >> 16) & 0xF) << 12 | (inst & 0xFFF)
            d = f"{cc}movw r{rd}, #{val:#x}"
        elif (inst & 0x0FF00000) == 0x03400000:
            rd = (inst >> 12) & 0xF
            val = ((inst >> 16) & 0xF) << 12 | (inst & 0xFFF)
            d = f"{cc}movt r{rd}, #{val:#x}"
        # ---------- Branch / BL ----------
        elif (inst & 0x0E000000) == 0x0A000000:
            imm24 = inst & 0x00FFFFFF
            if imm24 & 0x800000:
                imm24 -= 0x1000000
            target = (a + 8 + (imm24 << 2)) & 0xFFFFFFFF
            link = 'bl' if (inst >> 24) & 1 else 'b'
            s = sym(target)
            d = f"{cc}{link} 0x{target:08x}" + (f"  ; {s}" if s else '')
        # ---------- BLX imm ----------
        elif (inst & 0x0FFFFFFF) == 0x012FFF30:
            d = f"{cc}blx r{inst & 0xF}"
        elif (inst & 0x0FFFFFF0) == 0x012FFF10:
            d = f"{cc}bx r{inst & 0xF}"
        # ---------- MRS / MSR ----------
        elif (inst & 0x0FBF0FFF) == 0x010F0000:
            d = f"{cc}mrs r{(inst>>12)&0xF}, cpsr"
        elif (inst & 0x0FB0FFF0) == 0x0120F000:
            d = f"{cc}msr cpsr_{'f' if inst&0x8000 else 'c'}, r{inst&0xF}"
        # ---------- PUSH / POP / LDM / STM ----------
        elif (inst & 0x0FFF0000) == 0x092D0000:
            regs = [f"r{j}" for j in range(16) if (inst >> j) & 1]
            d = f"{cc}push {{{','.join(regs)}}}"
        elif (inst & 0x0FFF0000) == 0x08BD0000:
            regs = [f"r{j}" for j in range(16) if (inst >> j) & 1]
            d = f"{cc}pop {{{','.join(regs)}}}"
        elif (inst & 0x0E400000) == 0x08000000:
            p = (inst >> 24) & 1; u = (inst >> 23) & 1; w = (inst >> 21) & 1
            rn = (inst >> 16) & 0xF
            regs = [f"r{j}" for j in range(16) if (inst >> j) & 1]
            mode = 'ia' if u else 'db'
            d = f"{cc}{'ldm' if inst&0x100000 else 'stm'}{mode} r{rn}{'!' if w else ''}, {{{','.join(regs)}}}"
        # ---------- LDR/STR (imm / reg) ----------
        elif (inst & 0x0C000000) == 0x04000000:
            i_bit = (inst >> 25) & 1
            p = (inst >> 24) & 1; u = (inst >> 23) & 1; b = (inst >> 22) & 1
            w = (inst >> 21) & 1; l = (inst >> 20) & 1
            rn = (inst >> 16) & 0xF; rd = (inst >> 12) & 0xF
            mnem = f"{cc}{'ldr' if l else 'str'}{'b' if b else ''}"
            if i_bit:
                off = fmt_shift(inst)
                if not p:
                    d = f"{mnem} r{rd}, [r{rn}], {off}"
                else:
                    d = f"{mnem} r{rd}, [r{rn}, {off}]{'!' if w else ''}"
            else:
                off = inst & 0xFFF
                if not u:
                    off = -off
                if not p:
                    d = f"{mnem} r{rd}, [r{rn}], {off:#x}"
                else:
                    d = f"{mnem} r{rd}, [r{rn}, {off:#x}]{'!' if w else ''}"
        # ---------- LDR/STR halfword / signed byte / double ----------
        elif (inst & 0x0E000090) == 0x00000090:
            p = (inst >> 24) & 1; u = (inst >> 23) & 1; w = (inst >> 21) & 1
            l = (inst >> 20) & 1; rn = (inst >> 16) & 0xF; rd = (inst >> 12) & 0xF
            off = ((inst >> 4) & 0xF0) | (inst & 0xF)
            if not u: off = -off
            if (inst & 0x60) == 0x00: mnem = 'strh' if not l else 'ldrh'
            elif (inst & 0x60) == 0x40: mnem = 'ldrsb'
            elif (inst & 0x60) == 0x20: mnem = 'ldrsh'
            else: mnem = 'strd' if not l else 'ldrd'
            if (inst & 0x40) == 0x40 and (inst & 0x20) == 0x20:
                # LDRD/STRD: rd is even, rd+1 implicit
                d = f"{cc}{mnem} r{rd}, r{rd+1}, [r{rn}, {off:#x}]{'!' if w else ''}" if p else f"{cc}{mnem} r{rd}, r{rd+1}, [r{rn}], {off:#x}"
            else:
                d = f"{cc}{mnem} r{rd}, [r{rn}, {off:#x}]{'!' if w else ''}" if p else f"{cc}{mnem} r{rd}, [r{rn}], {off:#x}"
        # ---------- MUL / MLA / UMULL / SMULL ----------
        elif (inst & 0x0FC000F0) == 0x00000090:
            rd = (inst >> 16) & 0xF; rs = (inst >> 8) & 0xF; rm = inst & 0xF
            d = f"{cc}mul r{rd}, r{rm}, r{rs}"
        elif (inst & 0x0FC000F0) == 0x00200090:
            rd = (inst >> 16) & 0xF; rn = (inst >> 12) & 0xF; rs = (inst >> 8) & 0xF; rm = inst & 0xF
            d = f"{cc}mla r{rd}, r{rm}, r{rs}, r{rn}"
        elif (inst & 0x0FC000F0) == 0x00800090:
            rd = (inst >> 16) & 0xF; rs = (inst >> 8) & 0xF; rm = inst & 0xF
            d = f"{cc}umull r{rd}, r{(inst>>12)&0xF}, r{rm}, r{rs}"
        elif (inst & 0x0FC000F0) == 0x00C00090:
            rd = (inst >> 16) & 0xF; rs = (inst >> 8) & 0xF; rm = inst & 0xF
            d = f"{cc}smull r{rd}, r{(inst>>12)&0xF}, r{rm}, r{rs}"
        # ---------- CLZ ----------
        elif (inst & 0x0FFF0FF0) == 0x016F0F10:
            rd = (inst >> 12) & 0xF; rm = inst & 0xF
            d = f"{cc}clz r{rd}, r{rm}"
        # ---------- SWP ----------
        elif (inst & 0x0FB00FF0) == 0x01000090:
            rd = (inst >> 12) & 0xF; rm = inst & 0xF; rn = (inst >> 16) & 0xF
            d = f"{cc}swp{'b' if inst & 0x400000 else ''} r{rd}, r{rm}, [r{rn}]"
        # ---------- Data processing ----------
        elif (inst & 0x0C000000) == 0x00000000:
            opcode = (inst >> 21) & 0xF
            rn = (inst >> 16) & 0xF; rd = (inst >> 12) & 0xF
            s = 's' if (inst & (1 << 20)) else ''
            if (inst & 0x02000000):
                im = imm(inst)
                if opcode in (8, 9, 10, 11):
                    d = f"{cc}{OP[opcode]} r{rn}, #{im:#x}"
                elif opcode == 13 and rn == 0:
                    d = f"{cc}mov{s} r{rd}, #{im:#x}"
                elif opcode == 15 and rn == 0:
                    d = f"{cc}mvn{s} r{rd}, #{im:#x}"
                else:
                    d = f"{cc}{OP[opcode]}{s} r{rd}, r{rn}, #{im:#x}"
            else:
                if (inst & 0x10):  # register shift by register
                    rm = fmt_reg_shift(inst)
                else:
                    rm = fmt_shift(inst)
                if opcode in (8, 9, 10, 11):
                    d = f"{cc}{OP[opcode]} r{rn}, {rm}"
                elif opcode == 13 and rn == 0:
                    d = f"{cc}mov{s} r{rd}, {rm}"
                elif opcode == 15 and rn == 0:
                    d = f"{cc}mvn{s} r{rd}, {rm}"
                else:
                    d = f"{cc}{OP[opcode]}{s} r{rd}, r{rn}, {rm}"
        # ---------- SWI ----------
        elif (inst & 0x0F000000) == 0x0F000000:
            d = f"{cc}swi #{inst & 0xFFFFFF}"
        # ---------- CPS ----------
        elif (inst & 0x0F100000) == 0x01000000 and (inst & 0x000000F0) == 0x00000000 and (inst & 0x02000000):
            d = f"{cc}cps"
        # ---------- Barriers ----------
        elif (inst & 0x0FFF0FFF) == 0x0E070F90 and ((inst >> 4) & 0xF) == 0:
            d = f"{cc}dmb"
        elif (inst & 0x0FFF0FFF) == 0x0E070F90 and ((inst >> 4) & 0xF) == 4:
            d = f"{cc}dsb"
        elif (inst & 0x0FFF0FFF) == 0x0E070F90 and ((inst >> 4) & 0xF) == 8:
            d = f"{cc}isb"
        # ---------- NOP ----------
        elif inst == 0xE1A00000:
            d = "nop"
        else:
            d = f"{cc}.word 0x{inst:08x}"
        out.append(f"{a:08x}: {d}")
    return out

if __name__ == '__main__':
    load_syms(r'G:\k70bootloader\Rootme-main\symbols.txt')
    data = load(r'G:\k70bootloader\Rootme-main\kernel_decompressed.bin')
    start = int(sys.argv[1], 16) if len(sys.argv) > 1 else 0xc0196c4c
    count = int(sys.argv[2], 16) if len(sys.argv) > 2 else 0x200
    for line in disasm(data, start, count):
        print(line)