Hacker Tools and Their Signatures, Part One: bind8x.c
last updated April 11, 2001 |
||||||||||
Purpose This article is the first in a series of papers detailing hacker exploits/tools and their signatures. This installment will examine the Berkley Internet Name Domain exploit bind8x.c. The discussion will cover the details of bind8x.c and provide signatures that will assist an IDS analyst in detecting it. This paper assumes that the reader has some basic knowledge of TCP/IP and understands the tcpdump format. BIND and DNS "DNS is a distributed database that is used by TCP/IP to map between hostnames and IP addresses."[1] In short, this means when a user types in www.securityfocus.com on his/her browser, the computer does not automatically know what the user is requesting. The user's computer then goes out to the DNS server that was assigned to it and asks the DNS server to tell it the IP address of the requested URL. This also holds true for resolving IP addresses to hostnames. A good example of what really happens is shown in Figure 1. Figure 1 shows a TCPDUMP read-out from my home computer as it talks to its DNS server.
Figure 1: DNS Communications By looking at the first packet we can see that the destination port is 53 and that the packet itself is a UDP packet. I think that part of the packet is pretty clear. It's the DNS part of the packet that we need to make sense of. Before we look at DNS lets look at the header for DNS in Figure 2.
Figure 2: DNS Header Format [2] Figure 2 gives us a good idea at what we are looking at in the packet. From this header we can see that 23838(hex 5d1e) is the identification number in the DNS packet. The ID number is sent to the server by the client and is then returned to the client by the server. The purpose of this is to allow the client to match responses with requests. The next item we want to look at is the + sign. In the math world this is the addition sign; however, in the DNS world it means that the RD (recursion desired) flag is set. The 'A' means that we want an IP address. Packet number 2 only has one area that needs explaining. That is the letter q - possibly meaning a query. Finally, in the third packet we see that my computer was able to obtain the IP address of www.securityfocus.com and had began making its initial connection. BIND BIND stands for Berkley Internet Name Domain. In the Linux environment BIND can usually be found under named. The configuration file is located at /etc/named.conf. Named (if enabled at startup) normally runs on UDP/TCP port 53. I am not going to get into details on how to set up DNS or even security best practices related to DNS. As of this writing the most current version of BIND available that is considered safe is BIND 8.2.3. The program (bind8X.c) we will look at exploits 8.2.2. Bind8x.c Bind8x.c was written by Ix and lucysoft. It exploits vulnerabilities found in BIND 8.2.2. When run, Bind8x.c gives you root access to the victim machine (providing it is running a vulnerable version of BIND). If you would like to see the code, see http://packetstorm.securify.com/0102-exploits/bind8x.c. Compiling this program is relatively easy - all you need to do is gcc -o bind8x bind8x.c. That provided me with the program I needed. I ran this program on my home network, against a Red Hat 6.1 box (192.168.1.25) that had no patches applied and all services wide open. Figure 3 is a TCPDUMP trace of the packets that we will analyze.
Figure 3: TCPDUMP of Bind8x.c What's so interesting about these packets? First, we see that the packets are inverse queries. What are inverse queries? Inverse queries are the reverse mappings of standard query operations[3]. Another interesting item we want to look at is '48879', which is the ID. If you look closely at the packet we see that 48879 = beef (great signature!). By looking at 0980 in the first packet we also see a few items of interest. Figure 4 is a print out from ethereal:
Figure 4: Inverse Query Packet Read Out Figure 4 shows the normal DNS items. But let us look at 'Answers'. 'Answers' shows us that the Name goes past end of captured data in packet. This is where the overflows are beginning. The next packet is the victim's reply. To sum it up in a few short words it's saying "Name goes past end of captured data in packet>: type unused, class unknown". In other words, it has no clue what's going on. Lets take a look at the ethereal output for the next packet.
Figure 5: Ethereal Output Once again we can look inside the packet and come up with a great signature. If you look at the ID you will see 'dead'. Remember 57005 == dead. This time though, look at how many questions were sent over - seven(7). These little items are great if you are trying to develop IDS signatures for specific "hacker" tools. The reply to that packet looks like this.
Figure 6: TCPDUMP Output of .25's Reply The next couple of packets we see here show us 192.168.1.5 making a connection with 192.168.1.25. Then we will see 192.168.1.25 give .5 root access (the gold). The initial connection is shown in Figure 7.
Figure 7 Notice the high port (36864) that 192.168.1.5 is trying to connect to. To save some space I will omit ACK packets, unless they are vital to the sequence of events. Here comes root!!
Figure 8 The bolded hex numbers in bold come out to 'uname -a; id;'. Again, notice the high destination port.
Figure 9 Note that .25 is now sending all of its computer information to .5.
Figure 10 Ok, we now have root. The bolded hex numbers above = uid=0(root) gid=0(root). Summary This paper has discussed DNS, BIND and the exploit bind8x.c. We have come up with a couple of signatures as well. First, we have the inverse query UDP packet with an ID of 'beef' and a total size of 484 bytes. Second, we have the response UDP packet with an ID of 'dead' and a total size of 538 bytes. Finally, we have a TCP destination port of 36864. By using this port the attacker will get root (if vulnerable). Hopefully, this discussion has provided enough information to help anyone who is scratching their head about packets that are similar to the ones discussed here. If readers have further questions or concerns, below are some good related links that may provide some helpful information. References
[1] Stevens,W.R 1994, TCP/IP Illustrated Vol. 1. Addison-Wesley, Reading Mass p. 187 Toby Miller is a contributing author to the book Intrusion Detection Signatures and Analysis (NEW RIDERS Publishing) and is a contributing author to Maximum Security Rev. 3 (SAMS Publishing). He has done work both in the Linux security world and Intrusion Detection/Firewall world. Mr. Miller has published numerous papers for both SANS and Securityfocus.com. He can be reached at tmiller@va.prestige.net. |
||||||||||
|