home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit v2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Unix / c-src / broadscan.c < prev    next >
C/C++ Source or Header  |  1999-11-04  |  2KB  |  110 lines

  1.  /* Broadscan v 0.51
  2.     DUP Broadcast IP scanner
  3.     by Vacuum http://www.technotronic.com
  4.     11.24.98
  5.     This is a very lame scanner written to
  6.     stop people from asking how to find
  7.     DUP broadcast ip addresses. Use this in
  8.     conjunction with smurf, fraggle,
  9.     or papasmurf. DoS kiddies enjoy!
  10.     Revision history:
  11.     0.31 really lame:       implementation broadscan <octet> <octet>
  12.     0.50 not quite as lame: now implemented as broadscan www.xxx.yyy.zzz
  13.                            however .yyy was ignored and started scan at 1
  14.     0.51 still lame:        now recognizes .yyy cleaned up some of the sloppy code      
  15.  
  16.    Greets to horizon and bodhidarm
  17. */
  18.  
  19. #include <stdlib.h>
  20. #include <stdio.h>
  21. #include <sys/wait.h>
  22. #include <errno.h>
  23. #include <netdb.h>
  24. #include <signal.h>
  25.     
  26. FILE *stream;
  27.  
  28. #define DEBUG 1
  29.  
  30. void pingz0r(int first, int second, int start, int end)
  31. {
  32. int counter,flag;
  33. FILE *stream;
  34. char tempstring[2048];
  35. char parse[2048];
  36.  
  37. for (counter=start; counter <end; counter++)
  38. {
  39.  flag=0;
  40.  sprintf(tempstring,"ping -c 2 -n  %d.%d.%d.255 2>/dev/null",first,
  41.                      second, counter);
  42.  stream=popen(tempstring,"r");
  43.  while (fgets(parse,sizeof(parse),stream)!=NULL)
  44.  {
  45.   if (DEBUG) printf("Results:%s",parse);
  46.   if (strstr(parse,"DUP"))
  47.   {
  48.     flag=1;
  49.     fclose(stream);
  50.     break;
  51.   }
  52.  }
  53.  if (flag==1)
  54.  stream=fopen("broadcast.txt", "a"); 
  55.  fprintf(stream, "%d.%d.%d.255\n",first,second,counter);
  56.  fclose( stream);
  57. }
  58. }
  59.  
  60. main(int argc, char *argv[])
  61. {
  62.     char *curr_ip, *del, *cm[100];
  63.     int first, second, third, A4;
  64.  
  65. if (argc!=2)
  66.  {
  67.   printf("\nusage : %s <ipaddress>\n\n",argv[0]);
  68.   exit(0);
  69.  }
  70.  
  71.  curr_ip=argv[1];
  72.    del=(char *)strtok(curr_ip, ".");
  73.    first=atoi(del);
  74.    del=(char *)strtok(NULL, ".");
  75.    second=atoi(del);
  76.    del=(char *)strtok(NULL, ".");
  77.    third=atoi(del);
  78.    del=(char *)strtok(NULL, ".");
  79.    A4=atoi(del);
  80.  
  81.  
  82. if (first==127)
  83.  {
  84.  printf("%d is a localhost. You have no clue or are trying to break this program",first);
  85.  exit(0);
  86.  }
  87. if (first>254  || first <0)
  88.  {
  89.  printf("First octet is: %d. It must be between <1-254>",first);
  90.  exit(0);
  91.  }
  92. if (second>254 || second<0)
  93.  {
  94.  printf("Second octet is: %d. It must be <1-254>",second);
  95.  exit(0);
  96.  } 
  97. if (third>254 || third<0)
  98.  {
  99.  printf("Third octet is: %d. It must be <1-254>",second);
  100.  exit(0);
  101.  } 
  102.  
  103.  
  104. printf("Scanning for DUP broadcast ip addresses\n");
  105. printf("Results output to broadcast.txt\n");
  106.  
  107.     pingz0r(first,second,third,255);
  108. }
  109.  
  110.