A vulnerable kernel module for facilitating the testing of exploits.
The vuln.ko module creates a character device at /dev/vuln with permissions 0666. To interface with the kernel module, make ioctl calls to the file. Here are some key ioctl calls:
VULN_SET_FUNCsets the function pointer that will get called by the kernel module.VULN_SET_ARG1sets the first argument to the function set inVULN_SET_FUNC.VULN_GET_DATAreturns a pointer to a page of space in the kernel.VULN_SET_DATAallows a userspace program to write up to a page of bytes to memory that lies in the kernel at the address pointed byVULN_GET_DATA. This is particularly useful for testing ROP payloads.VULN_GET_ROOTreturns a pointer to a function that callscommit_creds(prepare_kernel_cred(0)).VULN_TRIGGERcalls the function pointer set byVULN_SET_FUNCon the arguments set byVULN_SET_ARG1throughVULN_SET_ARG4.
$ make
$ sudo insmod ./module/vuln.ko
$ ./example/example
current uid: 1000
triggering exploit...
current uid: 0