Skip to content

Instantly share code, notes, and snippets.

@chadyred
Last active October 28, 2018 15:37
Show Gist options
  • Save chadyred/c4105d46f510ec1b33fffaa66f0ffe85 to your computer and use it in GitHub Desktop.
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
#!/tmp/sh
echo "Content repository of" `whoami`
# ou echo "Contenu du répertoire de" $(whoami)
ls -a /home/user
#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