⬢ DragonFlyBSD Kernel Audit
DF-3224 / dropdemo.c
← back to finding ↓ download raw
/*
 * dropdemo: setuid-root helper that FULLY drops credentials
 * (ruid=euid=svuid=0), the classic su/login-style sanitization,
 * then idles so its signal permission state can be probed.
 *
 * Installed root-owned setuid-root by the PoC harness:
 *   cc -o dropdemo dropdemo.c && chown root:wheel dropdemo && chmod 4555 dropdemo
 */
#include <stdio.h>
#include <unistd.h>
#include <errno.h>

int
main(void)
{
	if (setresuid(0, 0, 0) != 0) {
		perror("setresuid");
		return 1;
	}
	if (setresgid(0, 0, 0) != 0) {
		perror("setresgid");
		return 1;
	}
	fprintf(stderr, "[dropdemo %d] fully dropped: uid=%d euid=%d\n",
		getpid(), getuid(), geteuid());
	for (;;)
		sleep(60);
	return 0;
}