Skip to content

Instantly share code, notes, and snippets.

@bigendiansmalls
Created November 13, 2019 11:52
Show Gist options
  • Save bigendiansmalls/4eba4bca5ea7c6c7a7743f8c57eb51b8 to your computer and use it in GitHub Desktop.
Save bigendiansmalls/4eba4bca5ea7c6c7a7743f8c57eb51b8 to your computer and use it in GitHub Desktop.
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/wait.h> /* for wait */
#include <pwd.h>
#include <grp.h>
int main (int argc, char** argv) {
gid_t newGrp;
int shellOnly = 0;
char * newv = {0};
if (argc > 1) {
if (strcmp(argv[1], "-n") != -1) {
shellOnly = 1;
}
}
if (setuid(0) != 0) {
perror("Setuid failed, no suid-bit set?");
return 1;
} else {
if (shellOnly != 1) {
printf("Executing ACEE-enhanced shell.\n");
execv("modwshl", argv);
} else {
printf("Executing UID-0 shell.\n");
execl("/bin/sh", newv);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment