home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / security / misc / 1660 < prev    next >
Encoding:
Text File  |  1992-11-07  |  2.6 KB  |  103 lines

  1. Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!cs.utexas.edu!sun-barr!olivea!spool.mu.edu!agate!tfs.com!tfs.com!merde!shipley
  2. From: shipley@merde.tcs.com (Pete Shipley)
  3. Newsgroups: comp.security.misc
  4. Subject: Re: Setuid script - is this unsecure?
  5. Message-ID: <1992Nov6.090515.14775@tfs.com>
  6. Date: 6 Nov 92 09:05:15 GMT
  7. References: <1d6fdiINNf5q@bnsgd245.bnr.co.uk>
  8. Sender: news@tfs.com (News Administrator @ts2.tfs.com)
  9. Organization: Processed People for a Processed America
  10. Lines: 90
  11. Nntp-Posting-Host: merde
  12.  
  13. In article <1d6fdiINNf5q@bnsgd245.bnr.co.uk> rickt@bnr.co.uk (Rick Tait) writes:
  14. >I recently installed these shell scripts on my machine (on which I am root),
  15. >and I'd like to know if I'm compromising it's security. Basically, they
  16. >just allow the users to mount/umount/eject the floppy disk (pcfs).
  17.  
  18. instead of a shell script try this C program:
  19.  
  20. Note the the real way it to run "check -s" on the unix file system first
  21. also an attack is still possible if you edit (adb) the raw device
  22. after the floppy is mounted and create a specal device (eg: mem of kmem)
  23.  
  24.  
  25.  
  26. #include <stdio.h>
  27.  
  28. /*
  29.  
  30. Note: /etc/fstab should contain the following:
  31.  
  32. /dev/fd0   /pcfs       pcfs rw,noauto 0 0
  33. /dev/fd0   /floppy  4.2 rw,noauto,nosuid 0 0
  34. */
  35.  
  36.  
  37.  
  38. static char by[] = "@(#) pcfs.c Pete Shipley [1991]\n";
  39.  
  40. static char *mount = "/usr/etc/mount";
  41. static char *umount = "/usr/etc/umount";
  42.  
  43. static char *where = "/pcfs";
  44. static char *what = "/dev/fd0";
  45.  
  46. static char *use ="Usage: %s [ -u | -d | -m ]\n\
  47. \t-d\tmount MS-DOS diskette\n\
  48. \t-m\tmount unix diskette\n\
  49. \t-u\tunmount diskette\n";
  50.  
  51. extern int strncmp(), setuid(), perror(), fprintf(), getuid();
  52. extern void execl();
  53.  
  54. int
  55. main(ac, av)
  56. char *av[];
  57. int ac;
  58. {
  59. char *cp;
  60. char  **cpp;
  61. extern char **environ;
  62.  
  63.     if(ac != 2) goto error;
  64.  
  65.  
  66.     for (cpp = environ; cp = *cpp; /* void */) {
  67.         char  **xpp;
  68.  
  69.         if(strncmp(cp, "LD_", 3) == 0) {
  70.             for (xpp = cpp; xpp[0] = xpp[1]; xpp++);
  71.         } else {
  72.             cpp++;
  73.         }
  74.     }
  75.  
  76.  
  77.     /* not nessary
  78.     if( setuid(getuid()) == -1) {
  79.     (void) perror("setuid");
  80.     exit(1);
  81.     } */
  82.  
  83.     switch(av[1][1]) {
  84.     case 'u':
  85.         execl(umount, umount, where, (char *)0);
  86.     case 'd':
  87.         execl(mount, mount, "-t", "pcfs", what, where, (char *)0);
  88.     case 'm':
  89.         execl(mount, mount, "-t", "4.2", "-o", "nosuid", what, where, (char *)0);
  90. error:
  91.     default:
  92.         (void) fprintf(stderr, use, av[0]);
  93.         exit(1);
  94.     }
  95.     exit(0);
  96. }
  97.  
  98. -- 
  99. ---------------
  100. Pete Shipley:
  101. email: shipley@berkeley.edu             Flames:  cimarron@postgres.berkeley.edu
  102. Spelling corections: /dev/null          Quote: "Anger is an energy"
  103.