home *** CD-ROM | disk | FTP | other *** search
/ HaCKeRz KrOnIcKLeZ 3 / HaCKeRz_KrOnIcKLeZ.iso / ircscripts / warirc / feprobe.c < prev    next >
C/C++ Source or Header  |  1996-04-23  |  2KB  |  78 lines

  1. #include "tcpip.h"
  2.  
  3. void ssyn(int sendsock, u_long srcaddr, u_long dstaddr, u_short srcport, 
  4.     u_short dstport, u_long seq)
  5. {
  6.   char *pack, *tpack;
  7.   int sent;
  8.   struct sockaddr_in stuffz;
  9.  
  10.   tpack = create_tcp(htons(srcport),
  11.             htons(dstport), htonl(seq), 0, TH_SYN, NULL, 0);
  12.   pack  = create_ip (srcaddr, dstaddr, IPPROTO_TCP, 75, 1,
  13.             tpack, 20);
  14.   stuffz.sin_family      = AF_INET;
  15.   stuffz.sin_port        = htons(dstport);
  16.   stuffz.sin_addr.s_addr = dstaddr;
  17.   sent  = sendto(sendsock, pack, 40, 0, (struct sockaddr *)&stuffz, 
  18.             sizeof(stuffz));
  19.   if (sent != 40) { perror("sending SYN"); exit(-1); }
  20. }
  21. int getpack(int listsock, u_long srcaddr, u_long dstaddr, u_short srcport, 
  22.     u_short dstport, u_long seq)
  23. {
  24.  return 1;
  25. }
  26.  
  27. main (int c, char *v[])
  28. {
  29.   int ssock, lsock;
  30.   struct hostent *hent;
  31.   struct servent *srvent;
  32.   u_long us, them, fuckk;
  33.   u_short sport, eport;
  34.   u_short skrap;
  35.   u_char flags;
  36.   struct tcphdr *tcphead;
  37. /*  char pass[8]; */
  38.  
  39.   if (c!=5) { printf("usage: %s <host> <start port> <end port> <from host>\n", v[0]);
  40.      exit(-1); }
  41. /*  strncpy(pass, getpass("Password: "), 8);
  42.  * if (!strncmp(pass, "r@1$xz%#", 8)) { printf("right!\n"); } else {
  43.  *    printf("wrong - bye bye\n"); exit(0); }
  44.  */
  45.   hent = gethostbyname(v[4]);
  46.   if (hent == NULL) {
  47.     printf("couldn't get \"from\" hostname!@#\n");
  48.     exit(-1);
  49.   }
  50.   bcopy(hent->h_addr, (char *)&us, hent->h_length);
  51.   hent = gethostbyname(v[1]);
  52.   if (hent!=NULL)
  53.     bcopy(hent->h_addr, (char *)&them, hent->h_length);
  54.   else {
  55.     printf("could not resolve: %s\n", v[1]);
  56.     exit(-1);
  57.   }
  58.   sport = atoi(v[2]);
  59.   if (sport==0) {
  60.     printf("can't use %s as a starting port..\n", v[2]);
  61.     exit(-1);
  62.   }
  63.   eport = atoi(v[3]);
  64.   if (eport==0) {
  65.     printf("can't use %s as an ending port..\n", v[3]);
  66.     exit(-1);
  67.   }
  68.   ssock = socket(AF_INET, SOCK_RAW, 255);
  69.   if (ssock == -1) { perror("getting send socket"); exit(-1); }
  70.   lsock = socket(AF_INET, SOCK_RAW, 6);
  71.   if (lsock == -1) { perror("getting listen socket"); exit(-1); }
  72.   printf("sending fake half-open scan to %s from %s\n", v[1], v[4]);
  73.   for (skrap=sport;skrap<eport+1; skrap++) {
  74.     ssyn(ssock, us, them, getpid()+skrap, skrap, 10000000+skrap+getpid());
  75.     usleep(100);
  76.   }
  77. }
  78.