当前位置:WooYun >> 漏洞信息

漏洞概要 关注数(24) 关注此漏洞

缺陷编号:wooyun-2014-079041

漏洞标题:Supesite 前台注入 #2 (Insert)

相关厂商:Discuz!

漏洞作者: ′雨。

提交时间:2014-10-13 16:39

修复时间:2015-01-11 16:40

公开时间:2015-01-11 16:40

漏洞类型:SQL注射漏洞

危害等级:高

自评Rank:20

漏洞状态:厂商已经确认

漏洞来源: http://www.wooyun.org,如有疑问或需要帮助请联系 [email protected]

Tags标签:

4人收藏 收藏
分享漏洞:


漏洞详情

披露状态:

2014-10-13: 细节已通知厂商并且等待厂商处理中
2014-10-13: 厂商已经确认,细节仅向厂商公开
2014-10-16: 细节向第三方安全合作伙伴开放
2014-12-07: 细节向核心白帽子及相关领域专家公开
2014-12-17: 细节向普通白帽子公开
2014-12-27: 细节向实习白帽子公开
2015-01-11: 细节向公众公开

简要描述:

Insert 无视GPC
装supesite会有ucenter
如果在一个裤的话 可以尝试把uckey注入出来
然后……

详细说明:

来看看全局文件

if(!(get_magic_quotes_gpc())) {
$_GET = saddslashes($_GET);
$_POST = saddslashes($_POST);
$_COOKIE = saddslashes($_COOKIE);
}


判断gpc 是否开启 如果没有开启 就对get post cookie 转义
这里没有对files转义。
_______________________________________________
在batch.upload.php中

elseif (!empty($_POST)) { //如果POST不为空

//编辑标题
if(!empty($_GET['editaid']) && $editaid = intval($_GET['editaid'])) {
$editsubject = cutstr(trim(shtmlspecialchars($_POST['editsubject'])), 50);
updatetable('attachments', array('subject'=>$editsubject), array('aid'=>$editaid));
print <<<END
<script language="javascript">
var div = parent.document.getElementById("div_upload_" + $editaid);
var pf = parent.document.getElementById("phpframe");
pf.src = "about:blank";
div.innerHTML = "$editsubject";
</script>
END;
exit;
}

//上传文件
//上传模式
$mode = intval(postget('mode'));
if($mode>3) exit; //mode 直接让他为空
$hash = trim(preg_replace("/[^a-z0-9\-\_]/i", '', trim($_POST['hash'])));
if(strlen($hash) != 16) showresult($blang['unable_to_complete_this_craft']);//这里只判断hash的长度为不为16 没有进一步的验证 那么就让hash为1111111111111111

//个数
$filecount = 1;
$query = $_SGLOBAL['db']->query('SELECT COUNT(*) FROM '.tname('attachments').' WHERE hash=\''.$hash.'\'');
$count = $_SGLOBAL['db']->result($query, 0);
$allowmax = intval($_POST['uploadallowmax']);
if($allowmax > 0 && $count + $filecount > $allowmax) showresult($blang['the_number_has_reached_maximum']);
//类型
$allowtypearr = getallowtype(trim($_POST['uploadallowtype']));//取得上传的类型

//空间
$attachsize = 0;
include_once(S_ROOT.'./function/upload.func.php');
if(empty($mode)) { //让$mode为空即可
//本地上传
//检查
$filearr = $_FILES['localfile'];//获取files
if(empty($filearr['size']) || empty($filearr['tmp_name'])) showresult($blang['failure_to_obtain_upload_file_size']);
$fileext = fileext($filearr['name']);//获取后缀
if(!empty($allowtypearr)) {
if(empty($allowtypearr[$fileext])) showresult($blang['upload_not_allow_this_type_of_resources']." ($allowtype_ext)");
if($filearr['size'] > $allowtypearr[$fileext]['maxsize']) showresult($blang['file_size_exceeded_the_permissible_scope']);
}
//缩略图
if(!empty($_POST['uploadthumb0']) && !empty($_SCONFIG['thumbarray'][$_POST['uploadthumb0']])) {
$thumbarr = $_SCONFIG['thumbarray'][$_POST['uploadthumb0']];
} else {
$thumbarr = array($_POST['thumbwidth'], $_POST['thumbheight']);
}

//上传
$newfilearr = savelocalfile($filearr, $thumbarr);
if(empty($newfilearr['file'])) showresult($blang['uploading_files_failure']);
//数据库
if(empty($_POST['uploadsubject0'])) $_POST['uploadsubject0'] = cutstr(filemain($filearr['name']), 50);
//下面就带入到insert当中啦
$insertsqlarr = array(
'uid' => $uid,
'dateline' => $_SGLOBAL['timestamp'],
'filename' => saddslashes($filearr['name']),//对文件的名字转义
'subject' => trim(shtmlspecialchars($_POST['uploadsubject0'])),
'attachtype' => $fileext,//这里没有对文件的后缀转义
'isimage' => (in_array($fileext, array('jpg','jpeg','gif','png'))?1:0),
'size' => $filearr['size'],
'filepath' => $newfilearr['file'],
'thumbpath' => $newfilearr['thumb'],
'hash' => $hash
);
inserttable('attachments', $insertsqlarr)//insert;


'filename' => saddslashes($filearr['name']) 在查询的时候名字被转义了
'attachtype' => $fileext 来看一下$fileext
$fileext = fileext($filearr['name']);

function fileext($filename) {
return strtolower(trim(substr(strrchr($filename, '.'), 1)));
}


获取点以后的 没做转义 所以可以在后缀这进行注入了。

s7.jpg


可以看到 名字被转义 后缀那成功引入单引号

s8.jpg


出数据

漏洞证明:

s8.jpg

修复方案:

转义之

版权声明:转载请注明来源 ′雨。@乌云


漏洞回应

厂商回应:

危害等级:高

漏洞Rank:20

确认时间:2014-10-13 16:44

厂商回复:

感谢您提供的信息。
SupeSite目前已经停止维护,希望您关注我们的其他产品。

最新状态:

暂无