Advertisement
Guest User

Untitled

a guest
Jan 7th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.57 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <unistd.h>
  5. #include <sys/types.h>
  6.  
  7. #define BUFSIZE 148
  8. #define FLAGSIZE 128
  9.  
  10. void vuln(char *buf){
  11.   gets(buf);
  12.   puts(buf);
  13. }
  14.  
  15. int main(int argc, char **argv){
  16.  
  17.   setvbuf(stdout, NULL, _IONBF, 0);
  18.  
  19.   // Set the gid to the effective gid
  20.   // this prevents /bin/sh from dropping the privileges
  21.   gid_t gid = getegid();
  22.   setresgid(gid, gid, gid);
  23.  
  24.   char buf[BUFSIZE];
  25.  
  26.   puts("Enter a string!");
  27.   vuln(buf);
  28.  
  29.   puts("Thanks! Executing now...");
  30.  
  31.   ((void (*)())buf)();
  32.  
  33.   return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement