Skip to content

Instantly share code, notes, and snippets.

@TheButlah
Created March 6, 2018 00:26
Show Gist options
  • Save TheButlah/794ab2ad3266503b0d0e5a92a944bf80 to your computer and use it in GitHub Desktop.
Save TheButlah/794ab2ad3266503b0d0e5a92a944bf80 to your computer and use it in GitHub Desktop.
#include <unistd.h>
#include <stdio.h>
extern char** environ;
int main() {
printf("(%d->%d):(%d->%d)\n", getuid(), geteuid(), getgid(), getegid());
setuid(geteuid());
setgid(getegid());
printf("(%d->%d):(%d->%d)\n", getuid(), geteuid(), getgid(), getegid());
char* n = "/bin/sh";
char* newargs[] = {n, NULL};
execve(n, newargs, environ);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment