home *** CD-ROM | disk | FTP | other *** search
/ Hacks & Cracks / Hacks_and_Cracks.iso / hackersclub / km / library / articles / inetdea.txt < prev    next >
Text File  |  1998-03-25  |  13KB  |  220 lines

  1. Internet Daemons
  2. Author: Voyager[TNO]
  3. Date:         15. June 1996
  4.  
  5. Internet hosts communicate with each other using either TCP (Transmission Control Protocol) or UDP (User Datagram
  6. Protocol) on top of IP (Internet Protocol). Other protocols are used on top of IP, but TCP and UDP are the ones that are of
  7. interest to us. On a Unix system, the file /etc/protocols will list the available protocols on your machine 
  8.  
  9. On the Session Layer (OSI model) or the Internet Layer (DOD Protocol Model) data is moved between hosts by using ports.
  10. Each data communication will have a source port number and a destination port number. Port numbers can be divided into two
  11. types, well-known ports and dynamically allocated ports. Under Unix, well-known ports are defined in the file /etc/services. In
  12. addition, RFC (Request For Comments) 1700 "Assigned Numbers" provides a complete listing of all well-known ports.
  13. Dynamically allocated port numbers are assigned as needed by the system. 
  14.  
  15. Unix provides the ability to connect programs called daemons to well-known ports. The remote computer will connect to the
  16. well-known port on the host computer, and be connected to the daemon program. 
  17.  
  18. Daemon programs are traditionally started by inetd (The Internet Daemon). Daemon programs to be executed are defined in
  19. the inetd configuration file, /etc/inetd.conf. 
  20.  
  21. Most of these daemons run as a priveledged user, often as root. Many of these programs have vulnerabilities which can be
  22. exploited to gain access to remote systems. 
  23.  
  24. The daemons we are interested in are: 
  25.  
  26.         Service          Port Number    Description
  27.         ~~~~~~~~~~~~~    ~~~~~~~~~~~    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  28.         ftp              21             File Transfer [Control]
  29.         smtp             25             Simple Mail Transfer Protocol
  30.         tftp             69             Trivial File Transfer Protocol
  31.         finger           79             Finger
  32.         www-http         80             World Wide Web HTTP
  33.         sunrpc          111             SUN Remote Procedure Call
  34.         fln-spx         221             Berkeley rlogind with SPX auth
  35.         rsh-spx         222             Berkeley rshd with SPX auth
  36.         netinfo         716-719         NetInfo
  37.         ibm-res         1405            IBM Remote Execution Starter
  38.         nfs             2049            Network File System
  39.         x11             6000-6063       X Window System
  40.  
  41.         rcp/rshd                        Remote Copy/Remote Shell Daemon
  42.         nis                             Network Information Services
  43.  
  44.  
  45. The next part of this article will focus on specific daemons and their known vulnerabilities. The vulnerabilities with brief
  46. explanations will be explained here. For the more complicated exploits, which are beyond the scope of a concise article, more
  47. research will be required on the part of the reader. 
  48.  
  49.    ftp 21 File Transfer [Control]
  50.  
  51. FTP is the File Transfer Protocol. FTP requests are answered by the FTP daemon, ftpd. wuarchive's ftpd versions below 2.2
  52. have a vulnerability where you can execute any binary you can see with the 'site exec' command by calling it with a relative
  53. pathname with "../" at the beginning. Here is a sample exploit: 
  54.  
  55. Login to the system via ftp: 
  56.  
  57.         220 uswest.com FTP server (Version wu-2.1(1) ready.
  58.         Name (uswest.com:waltman): waltman
  59.         331 Password required for waltman.
  60.         Password: jim
  61.         230 User waltman logged in.
  62.         Remote system type is UNIX.
  63.         Using binary mode to transfer files.
  64.         ftp> quote "site exec cp /bin/sh /tmp/.tno"
  65.         200-cp /bin/sh /tmp/tno
  66.         ftp> quote "site exec chmod 6755 /tmp/.tno"
  67.         200-chmod 6755 /tmp/tno
  68.         ftp> quit
  69.         221 Goodbye.
  70.  
  71.    smtp 25 Simple Mail Transfer Protocol
  72.  
  73. Mail attacks are one of the oldest known methods of attacking Internet hosts. The most common mail daemon, and least
  74. secure, is sendmail. Other mail daemons include smail, MMDF,and IDA sendmail. Sendmail has had too many vulnerabilities to
  75. list them all. There is an entire FAQ written specifically on sendmail vulnerabilities, therefore we will not cover them heavily
  76. here. 
  77.  
  78. One well known vulnerability, useful only for historical purposes, is "Wizard Mode." In Wizard mode you could request a shell
  79. via Port 25 (The SMTP port). No modern system will be vulnerable to this attack. To exploit this vulnerability, you telnetted to
  80. port 25, typed WIZ to enter Wizard mode, and entered the password. The problem related to the way the encrypted
  81. password was stored. There was a bug that caused the system to believe that no password was as good as the real password. 
  82.  
  83. To quote Steven Bellovin: 
  84.  
  85.      The intended behavior of wizard mode was that if you supplied the right password, some other non-standard SMTP
  86.      commands were enabled, notably one to give you a shell. The hashed password -- one-way encrypted exactly as per
  87.      /etc/passwd -- was stored in the sendmail configuration file. But there was this bug; to explain it, I need to discuss some
  88.      arcana relating to sendmail and the C compiler. 
  89.  
  90.      In order to save the expense of reading and parsing the configuration file each time, sendmail has what's known as a
  91.      ``frozen configuration file''. The concept is fine; the implementation isn't. To freeze the configuration file, sendmail just
  92.      wrote out to disk the entire dynamic memory area (used by malloc) and the `bss' area -- the area that took up no space
  93.      in the executable file, but was initialized to all zeros by the UNIX kernel when the program was executed. The bss area
  94.      held all variables that were not given explicit initial values by the C source. Naturally, when delivering mail, sendmail just
  95.      read these whole chunks back in, in two giant reads. It was therefore necessary to store all configuration file information
  96.      in the bss or malloc areas, which demanded a fair amount of care in coding. 
  97.  
  98.      The wizard mode password was stored in malloc'ed memory, so it was frozen properly. But the pointer to it was
  99.      explicitly set to NULL in the source: 
  100.  
  101.              char    *wiz = NULL;
  102.  
  103.      That meant that it was in the initialized data area, *not* the bss. And it was therefore *not* saved with the frozen
  104.      configuration. So -- when the configuration file is parsed and frozen, the password is read, and written out. The next time
  105.      sendmail is run, though, the pointer will be reset to NULL. (The password is present, of course, but there's no way to
  106.      find it.) And the code stupidly believed in the concept of no password for the back door. 
  107.  
  108.      One more point is worth noting -- during testing, sendmail did the right thing with wizard mode. That is, it did check the
  109.      password -- because if you didn't happen to do the wizard mode test with a frozen configuration file -- and most testing
  110.      would not be done that way, since you have to refreeze after each compilation -- the pointer would be correct. 
  111.  
  112.    tftp 69 Trivial File Transfer Protocol
  113.  
  114. tftp is the Trivial File Transfer Protocol. tftp is most often used to attempt to grab password files from remote systems. tftp
  115. attacks are so simple and repetitive that scripts are written to automate the process of attacking entire domains. Here is one
  116. such script: Already published in the first book of Matic! 
  117.  
  118.    finger 79 Finger
  119.  
  120. The finger command displays information about another user, such as login name, full name, terminal name, idle time, login time,
  121. and location if known. finger requests are answered by the fingerd daemon. 
  122.  
  123. Robert Tappan Morris's Internet Worm used the finger daemon. The finger daemon allowed up to 512 bytes from the remote
  124. machine as part of the finger request. fingerd, however, suffered from a buffer overflow bug caused by a lack proper bounds
  125. checking. Anything over 512 got interpreted by the machine being fingered as an instruction to be executed locally, with
  126. whatever privileges the finger daemon had. 
  127.  
  128.    www-http 80 World Wide Web HTTP
  129.  
  130. HTML (HyperText Markup Language) allows web page user to execute programs on the host system. If the web page
  131. designer allows the web page user to enter arguments to the commands, the system is vulnerable to the usual problems
  132. associated with system() type calls. In addition, there is a vulnerability that under some circumstances will give you an X-Term
  133. using the UID that the WWW server is running under. 
  134.  
  135.    sunrpc 111 SUN Remote Procedure Call
  136.  
  137. Sun RPC (Remote Procedure Call) allows users to execute procedures on remote hosts. RPC has suffered from a lack of
  138. secure authentification. To exploit RPC vulnerabilities, you should have a program called "ont" which is not terribly difficult to
  139. find. 
  140.  
  141.    login 513 Remote login
  142.  
  143. Some versions of AIX and Linux suffer from a bug in the way that rlogind reads arguments. To exploit this vulnerability, issue
  144. this command from a remote system: 
  145.  
  146. rlogin host -l -froot
  147.  
  148. Where host is the name of the target machine and username is the username you would like to rlogin as (usully root). If this bug
  149. exists on the hosts system, you will be logged in, without being asked for a password. 
  150.  
  151.    rsh-spx 222 Berkeley rshd with SPX auth
  152.  
  153. Some versions of Dynix and Irix have a bug in rshd that allows you to run commands as root. To exploit this vulnerability, issue
  154. this command from the remote system: 
  155.  
  156. rsh host -l "" /bin/sh
  157.  
  158.    netinfo 716-719 NetInfo
  159.  
  160. NeXT has implemented a protocol known as NetInfo so that one NeXT machine can query another NeXT machine for
  161. information. A NetInfo server will by default allow unrestricted access to system databases. This can be fixed by the System
  162. Administrator. One of the pieces of information netinfo will give up is the password file. 
  163.  
  164.    ibm-res 1405 IBM Remote Execution Starter
  165.  
  166. rexd (the remote execution daemon) allows you to execute a program on another Unix machine. AIX, NeXT and HPUX
  167. versions of rexd have suffered from a vulnerability allowing unintended remote execution. The rexd daemon checks your uid on
  168. the machine you are coming from, therefore you must be root on the machine you are mounting the rexd attack from. To
  169. determine if your target machine is running rexd, use the 'rcp -p ' command. You will also need the exploit program known as
  170. 'on' which is available on fine H/P boards everywhere. 
  171.  
  172.    nfs 2049 Network File System
  173.  
  174. NFS, the Network File System, from Sun Microsystems has suffered from multiple security vulnerabilities. In addition, many
  175. system administrators configure NFS incorrectly, allowing unintended remote access. 
  176.  
  177. Using the command 'showmount -e ' you can view what file systems are exported from a machine. Many administrators allow
  178. read access to the /etc directory, allowing you to copy the password file. Other administrators allow write access to user
  179. directories, allowing you to create .rhosts files and gain access to the machine via rlogin or rsh. 
  180.  
  181. In addition to configuration issues, NFS is vulnerable to attacks using a uid masking bug, a mknod bug, and a general file
  182. handle guessing attack. Several hacked versions of the mount command have been written to exploit known vulnerabilities. 
  183.  
  184.    x11 6000-6063 X Window System
  185.  
  186. X-Windows has suffered and currently suffers from numerous vulnerabilities. One vulnerability allows you to access another
  187. users display, another allows you to view another users keystrokes. Another vulnerability allows a remote attacker to run every
  188. program that the root user starts in his or her .xsession file. Yet another X-Windows vulnerability allows a local user to create a
  189. root entry in the /etc/passwd file. 
  190.  
  191.    rcp
  192.  
  193. The SunOS 4.0.x rcp utility can be exploited by any trusted host listed in /etc/hosts.equiv or /.rhosts. To exploit this hole you
  194. must be running NFS (Network File System) on a Unix system or PC/NFS on a DOS system. 
  195.  
  196.    NIS
  197.  
  198. Sun's NIS (Network Information Service) also known as yp (Yellow Pages) has a vulnerability where you can request an NIS
  199. map from another NIS domain if you know the NIS domain name of the target system. There is no way to query a remote
  200. system for it's NIS domainname, but many NIS domain names are easily guessable. The most popular NIS map to request is
  201. passwd.byname, the NIS implementation of /etc/passwd. In addition, if you have access to a diskless Unix workstation, you
  202. can determine the NIS domain name of the server it boots from. 
  203.  
  204.  
  205.                    +--------------------------------------------------------+
  206.                    + Do not confuse NIS domain names with DNS domain names! +
  207.                    +--------------------------------------------------------+
  208.  
  209.  
  210.    Other attacks
  211.  
  212. In addition to these daemon based attacks, many other methods can be used to gain access to a remote computer. These
  213. include, but are not limited to: default accounts, password guessing, sniffing, source routing, DNS routing attacks, tcp sequence
  214. prediction and uucp configuration exploits. 
  215.  
  216. This should give you an idea on how daemon based attacks function. By no means is this a complete list of security
  217. vulnerabilities in privileged internet daemons. To discover more information about how these daemons operate, and how to
  218. exploit their vulnerabilities, I highly recommend reading source code, man pages and RFC's. 
  219.  
  220.