home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / XINE-1.ZIP / XINE-1.013 < prev    next >
Text File  |  1996-10-25  |  17KB  |  356 lines

  1.                                         /-----------------------------\
  2.                                         | Xine - issue #1 - Phile 013 |
  3.                                         \-----------------------------/
  4.  
  5.                     b0z0 and Kernel Panic
  6.                     proudly brings into your hands
  7.  
  8.              -------------------------------------------
  9.              | LowLevel Internet Hacking with Injector |
  10.              -------------------------------------------
  11.  
  12. a) Introduction
  13. ----------------
  14.  
  15. This is an article dealing with low level aspects of TCP/IP. It comes
  16. toghether with a program, Injector, that helps to understand and to
  17. play with TCP/IP networks. Please have a look in the doc directory of
  18. Injector that you get with this zine. With Injector you can look for
  19. packets that pass on your ethernet and enter new packets entirely
  20. formatted by you. Even you can quite easily write C programs that looks
  21. for a specified packet and when they get it to respond adeguately. 
  22.  
  23. First of all a small intorduction to how TCP/IP works. This is only a
  24. brief survey, so don't expect to learn too much from it. Please refer
  25. to some good books (I personally prefer D.E. Comer's book
  26. "Internetworking with TCP/IP"). The definitive references for the
  27. Internet are the RFCs, but they aren't suited for first-time learning.
  28.  
  29. The key to the functionality of Internet is layering. When an
  30. application on a given host transimits data to another host it is
  31. passed through many -more or less indipendent- protocol layers. Every
  32. layer does a part of work in sending the data. Because they are, at
  33. least conceptualy, indipendent, there can be different protocol
  34. specification for every layer. On the Internet we have three different
  35. layer:
  36.  
  37. * The transport layer. This takes a stream of data from application
  38. and divides it in packets. It performs also a port multiplexing, so
  39. every applications on a machine has a port number. On the Internet the
  40. protocol for this layer are the TCP (Transport Control Protocol) and
  41. the UDP (User Datagram Protocol). The TCP additionaly assures (by
  42. retrasmission) that the data is correctly passed over the network. The
  43. packet generated by the transport layer are passed down to the next
  44. layer.
  45.  
  46. * The internet layer. This assigns every host an unique identification
  47. (hardware indipendent) and handles routing of packet from the source
  48. route to the destination. It' doesn't assure that the packet is
  49. correctly delivered, this is a duty of the previsious layer or the
  50. application. Additionaly it provides that packets (which are now
  51. called datagrams) are of a suitable length for the next layer by
  52. eventually fragmenting them (and of coures reassembling them on the
  53. destination host). The protocol uses here is the IP (Internet Protocol).
  54.  
  55. * The link layer. This depends on the various type of hardware
  56. connection. There can be broadcast networks, many host sharing the
  57. same medium -at least logically- or point to point links, i.e. two
  58. host linked togheter. In the former case the protocols used are mainly
  59. Blue Book Ethernet, IEEE 802 (Ethernet, Token Ring), X.25 in
  60. unconnected mode, in the later PPP (Point to Point Protocol), SLIP
  61. (Serial Line Internet Protocol) or so called virtual circuits (for
  62. example IP in IP encapsulation wormholes or X.25 in connected
  63. mode). Here the packet of date are called frames.
  64.  
  65. Every layer adds to the packet some additional data for internal use
  66. (for example checksums, progressive numbers, host and port addresses,
  67. lengths, etc.). So when flowing on the communication medium the format
  68. of a frame is usually: link layer overhead, internet layer overhead,
  69. transport layer overrhead, useful application data. Additionaly there
  70. are other helper packets of various protocols, for example ARP and
  71. RARP for finding Ethernet addresses, LCP,IPCP and others for PPP
  72. conection negotiation, ICMP (Internet Control Message Protocol) as an
  73. aid to IP and others. Application data can be either from user-level
  74. application (FTP, Telnet, HTTP, etc,) or system applications (DNS for
  75. name resolving, NFS when we speak of exported file systems,
  76. RIP,EGP,BGP and such for route enstablishing). Both of them undergo
  77. the layering scheme. Keep in mind that system application (DNS, NFS
  78. and routing info) usually use UDP for efficency, instead user level
  79. applications use TCP for easyness because TCP already provides a
  80. reliable communication chanell.
  81.  
  82. Injector is useful in understanding Ethernet networks. I have put a
  83. brief extract from the RFCs in this zine as reference for packet
  84. building, but get the full RFCs as soon as you can!
  85.  
  86. b) A little Injector tutorial
  87. -----------------------------
  88.  
  89. - Creating packets
  90.  If you want to know how to create a packet check the "Summary of useful
  91. data in building TCP/IP packets" and give a look at our included examples.
  92. Explaining how to create packets is a very hard thing, so I decided to
  93. include a reference so you may be able to do it yourself :) Here is just
  94. some stuff that you need to be able to create packets using the included
  95. summary.
  96. First of all, a tipical packet is like this:
  97.  
  98.                    ------------------------------------
  99.                    | Ethernet header |   main packet  |
  100.                    ------------------------------------
  101.  
  102.  The ethernet header is needed and it is used to determinate from where
  103. this packet is, what it is etc. Be sure to include the 'e' charachter in
  104. the packet ('e' means end of the ethernet header) when you finished with
  105. the ethernet header.
  106.  Then of course also the main packet is divided in various parts. Let see
  107. a TCPIP main packet:
  108.  
  109.                       ------------------------------
  110.                       | IP datagram |  TCP packet  |
  111.                       ------------------------------
  112.  
  113.  In the same way the an UDPIP is:
  114.  
  115.                       ------------------------------
  116.                       | IP datagram |  UDP packet  |
  117.                       ------------------------------
  118.  
  119.  And then, at it's time, the TCP (or UDP) is divided into various sub
  120. parts, but this is well explained in the summary.
  121.  But this is only for packets that uses the Internet Protocol (IP) such
  122. as TCP, UDP, ICMP and EGP. For example the ARP (Adress Resolution
  123. Protocol) isn't preceeded by an IP datagram, so the main packet will be
  124. just composed from the ARP packet. 
  125.  Concluding with an example a TCP packet will look like:
  126.  
  127.                 ------------------------------------------
  128.                 | eth. header | IP datagram | TCP packet |
  129.                 ------------------------------------------
  130.  
  131.  ...or better:
  132.  
  133.          -----------------------------------------------------
  134.          | Eth. header | IP datagram | TCP Header | TCP Data |
  135.          -----------------------------------------------------
  136.  
  137.  ...while the ARP which doesn't use the IP will simply be:
  138.  
  139.                 ------------------------------------------
  140.                 | eth. header |       ARP packet         |
  141.                 ------------------------------------------
  142.  
  143.  So pay attention when creating packets and when reading the summary! This
  144. isn't a simple topic and i hope that you understanded this very-very short
  145. intro. But i repeat: get a good book or yell us :)
  146.  
  147. - Injector as a packet sniffer
  148.  Once you have entered in Injector (and configured the net hardware :) )
  149. you'll be able to see what is going up in your local network. The console
  150. is divided in two parts:
  151.    * the network watcher
  152.    * the command part
  153.  In the network watcher all the packets that pass over the network are
  154. displayed. Injector tryes to identify the packets types, their source and
  155. their destination and of course it displays it's contents. 
  156.  In the command part you can type the various commands that Injector
  157. offers to you. Also errors will be displayed here.
  158.  If you are sniffing in a quite big local network you may be very confused
  159. by a great traffic of packets. To prevent this you may set a filter to the
  160. displayed output. Injector can filter the packets by:
  161.  
  162.    * Type of packet. You can only look for TCP/IP packets using the
  163.     command "onlyip" and then turn back to all packet (ie.
  164.     IPX) displaying by using the command "allpack".
  165.    * Type of packet in IP datagram. You can look only for TCP packets
  166.     using the "onlytcp" command and then set it back to full
  167.     displaying (UDP, ICMP...) by using "allpkt"
  168.    * Source port. You can watch only packet from a port using the command
  169.     "maskpsrc [port number]". To watch again all the packet just set
  170.     the port to 0.
  171.    * Destination port. As for source port, but you must use the "maskpdst"
  172.     command.
  173.    * Source IP. You can watch only packet from an IP using the command
  174.     "maskipsrc [ip adress]". To reset this set the IP to 0.0.0.0. 
  175.     Setting the IP to 192.12.0.0 means that packet from 192.12.*.* are
  176.     displayed.
  177.    * Destination IP. As for source IP but using the command "maskipdst".
  178.  
  179.  Of course if you would like to see what's up in the net for a lot of time
  180. it wouldn't be very pleasant to stay there day and night. And here comes
  181. the log options. There are two types of logging:
  182.  
  183.    * The normal log, which stores everything that you see on the network
  184.     wathcer (type of packet, source, destination, contents and special
  185.     stuff for some types of packet). This is activated by using the
  186.     command "logon". The log session is closed with "logoff". The
  187.     entire logging will be appended to the file INJECTOR.LOG.
  188.    * The raw log, which store everything in a byte-by-byte log. Infact
  189.     this type of log will store in a file (RAW.LOG) every byte that
  190.     comed trought the network. This of course isn't very friendly if
  191.     you would just to see what's going up in the network. The raw 
  192.     logging is infact present as a help for packet creation. Infact
  193.     with the raw log you will have the opportunity to see how the
  194.     packet _really_ is and this may be of help to you when you'll 
  195.     have to create your own packets. To activate the raw log you
  196.     must just enter "do rawlog" and press a key to stop it.
  197.  
  198.  This are basically all the options that Injector used as a sniffer gives
  199. you.
  200.  
  201.     
  202. - Injecting packets
  203.  This is the real power of Injector: you can send *everything* that you
  204. want (well, if the packet are someway logical and not just random data 
  205. it is much better ;)) in your local network (and, of course, the local
  206. network will then send this ahead in the Internet if you want this).
  207.  After we have created a packet we can now inject it. Injector may just
  208. send the packet by using "inject" function. If our packet is named
  209. ping.pkt (i suppose it is compiled and ready to be sent) our injecting
  210. session may look like this:
  211.  
  212. set infile ping.pkt
  213. do inject
  214.  
  215. we have just defined that the packet that we would like to inject is
  216. ping.pkt and then sent it. But we may also have to set an ethernet adress
  217. for source or destination of this packet. So let's do it:
  218.  
  219. setmyeth 11:11:11:11:11:11
  220. setethto 22:22:22:22:22:22
  221. set filleth 1
  222. set fillethto 1
  223. set infile ping.pkt
  224. do inject
  225.  
  226. we have just sent a packet with an ethernet header different from the
  227. packet file one. Infact we have set up the source (setmyeth) and the
  228. destination (setethto) hardware adress and then defined that we will fill
  229. the source adress (we set filleeth to a value. 1 is just for example) and
  230. the destination adress (we set fillethto). Then we finally sent the
  231. packet. Of course you may not know or you may not have the possibilty to
  232. know the hardware adress of a machine on your local network. So let's look
  233. how to get it (we suppose that you want to get the hardware adress of
  234. the IP 192.168.0.2) and set is as it was our ethernet adress:
  235.  
  236. set arpip 192.168.0.2
  237. do getarp
  238.  
  239. In this way we now will have defined as our ethernet adress the ethernet
  240. adress of the machine with the IP equal to 192.168.0.2. Infact the "do
  241. getarp" functions send an ARP request, which is, in a few words, a request
  242. for the harware adress for an IP. Of course if the machine doesn't exist
  243. or is down the program will tell us that the adress haven't been set. We
  244. can also do the same for the destination ethernet adress. Just do:
  245.  
  246. set arpip 192.168.0.1
  247. do getarpto
  248.  
  249. that's it. Pay attention! If you are working on a network and would like
  250. to go outside of it you must of course set the destination ethernet adress
  251. as the hardware adress of your gateway! Note also that all the TCP packet
  252. MUST have the ethernet destination set to the right hardware adress. The
  253. hardware source may be quite always 255:255:255:255, the same is for the
  254. hardware to, if you don't count TCP packets.
  255.  Well, let's suppose that we created a ping packet (the ping.pkt) and we
  256. would like to change the IP from adresses in the ping without exiting
  257. Injector. What shall we do? See...
  258.  
  259. setmyip 192.168.0.5
  260. set fillipfrom 1
  261. set infile ping.pkt
  262. do injectip
  263.  
  264. The funcion "injectip" infact verifies if it have to fill the source IP
  265. (if the variable fillipfrom is set it takes the IP from the setmyip), the
  266. destination IP (if the variable fillipto is set it takes IP from the
  267. settoip), the source port (this isn't avaiable in ICMP packets, but if it
  268. can be applied (TCP or UDP packets) it put the value of portfrom in the
  269. right place) or the destination port (if portto is defined). After this it
  270. will made the right changes it will recalculate the checksums and will
  271. send the packet with new interesting data! Simple eh? 
  272.  Now let's see another example. We are dealing with the echo.pkt sample
  273. included in the package. The packet starts an udp echo war between the
  274. port 7 of the 192.168.0.1 and the 192.168.0.2. Let's imagine that we would
  275. like to start an udp chargen war (on port 19) between two servers on our
  276. net, respectively the 10.0.0.4 and 10.0.0.7 (of course they must have the
  277. chargen active :) ) but we don't know how to change the packet manually
  278. with an editor. Let's see how to do it:
  279.  
  280. set infile echo.pkt
  281. setmyip 10.0.0.4
  282. settoip 10.0.0.7
  283. set fillipfrom 1
  284. set fillipto 1
  285. set portfrom 19
  286. set portto 19
  287. do injectip
  288.  
  289. As you may have already understanded we have first defined the file with
  290. the packet, then defined the IPs of the two servers, defined that our
  291. function will fill the packet with them, then we have defined the source
  292. and destination port and finally sent the modified packet. Of course,
  293. depending on the packet you have built, Injector will put, if allowed
  294. (the port is only present in TCP and UDP packets. If you are sending an 
  295. ICMP packet, a ping, the ports will be totally ignored), the various
  296. values in the right place, recalculate the checksums and send it.
  297.  Let's imagine that the sysadm of the 10.0.0.7 have just disabled the
  298. chargen. Naaaa, what a mess! :) But hey! You can still create a good
  299. dialog between the chargen (19) of the 10.0.0.4 and the echo (7) of
  300. 10.0.0.7. So (i consider that you haven't quit or changed anything from
  301. the last example) we can just undefine the To port. It's simple
  302.  
  303. unset portto
  304. do injectip
  305.  
  306. this will unset the portto, so Injector will use the original port that
  307. was in the echo.pkt file, that's 7. We may also have done the same thing
  308. in a more polite way:
  309.  
  310. set portto 7
  311. do injectip
  312.  
  313. but i had to demostrate to you the unset command :) 
  314.  There is also a flood example function that comes with injector. This
  315. will just send a determinate number (let's say 666) of packets. Let's see:
  316.  
  317. set infile ping.pkt
  318. set pktnumber 666
  319. do flood
  320.  
  321. This will just send 666 packets ping.pkt. If the packet was just like a
  322. real ping it will produce the effect of a "ping -f" on a *nix. Notice that
  323. the flood function just send packets without changing them, so with this
  324. you won't be able to do SYN-Flood attacks or something like. But to do
  325. this (and here is where i was trying to come :) ) you can just add your
  326. own function in Injector. Infact Injector, that of course come with full
  327. source code, has the ability to be expanded in a very simple way by
  328. anyone! In this way you will be able to create everything (for example
  329. create a new synflood function that will send syn request packets but will
  330. also change the sequence number, the source ip and the port) using the
  331. already prepared functions. Just give a look at the main documentation if
  332. you want to know more about adding functions.
  333. Anyway don't desperate, also the SYN-Flood capability is included, but the
  334. rule is that you can enhance a function or make a new one in a very short
  335. time using the already prebuilt Injector functions.
  336.  So just wake up hack the world :)
  337. And, as the last example, let's see how can we do a SYN-flood session.
  338. Come on:
  339.  
  340. set arpip 192.168.0.1
  341. do getarpto
  342. set fillethto 1
  343. set synip 192.168.0.1
  344. set synportfrom 5
  345. set synportto 80
  346. set synpkt 100
  347. do synflood
  348.  
  349. As you can see we will first set our ethernet adress to the destination
  350. one (again, TCP _must_ have a good hardware adress... the gateway adress
  351. if you want to exit from your network) and set that the program will fill
  352. it. Then we define which host to attack, from which to which port and how
  353. many packets (yay, 100 is a little to much... but the example will fill
  354. the bill). And the game is done, just execute it!
  355.  
  356.