Last active
October 28, 2018 15:37
-
-
Save chadyred/c4105d46f510ec1b33fffaa66f0ffe85 to your computer and use it in GitHub Desktop.
change-uid-gid-based-one-right-of-file => gcc -m32 -o droit-user droit-user.c
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
#!/tmp/sh | |
echo "Content repository of" `whoami` | |
# ou echo "Contenu du répertoire de" $(whoami) | |
ls -a /home/user |
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 <unistd.h> | |
#include <errno.h> | |
#include <stdio.h> | |
#include <sys/types.h> | |
extern char **environ; | |
extern int errno; | |
int main (int argc, char **argv) { | |
uid_t uid, euid; | |
char *name[2]; | |
uid=getuid(); | |
euid=geteuid(); | |
name[0] = "/tmp/sh"; | |
name[1] = "/tmp/exec_as_uid_set_by_c_script"; | |
printf ("UID %d - EUID %d\n", uid, euid); | |
setreuid (1408, 1408); | |
setuid(1408); | |
setgid(1408); | |
uid=getuid(); | |
euid=geteuid(); | |
printf ("UID %d - EUID %d\n", uid, euid); | |
execve(name[0], name, environ); | |
printf ("Error : %d\n", errno); | |
return errno; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment