### 简要描述:
挖最后一个。。。然后干活去了。。。这个绕过和之前几个都不一样,各浏览器通用、无触发条件、可盗取cookie并getshell、绕过全局防过滤函数,非重复漏洞。
### 详细说明:
既然挖thinksaas,那么就看看他的富文本XSS究竟过滤好了没。
可惜还是让我失望了。不过也不是厂商的错,毕竟这东西确实很难做的完美。我会在漏洞修复处给一个很好解决方案。
先看原理吧。
```
function cleanJs($text) {
$text = trim ( $text );
//$text = stripslashes ( $text );
// 完全过滤注释
$text = @preg_replace ( '/<!--?.*-->/', '', $text );
// 完全过滤动态代码
$text = @preg_replace ( '/<\?|\?>/', '', $text );
// 完全过滤js
$text = @preg_replace ( '/<script?.*\/script>/', '', $text );
// 过滤多余html
$text = @preg_replace ( '/<\/?(html|head|meta|link|base|body|title|style|script|form|iframe|frame|frameset|math|maction|marquee)[^><]*>/i', '', $text );
// 过滤on事件lang js
while ( preg_match ( '/(<[^><]+)(data|onmouse|onexit|onclick|onkey|onsuspend|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)[^><]+/i', $text, $mat ) ) {
$text = str_replace ( $mat [0], $mat [1], $text );
}
while ( preg_match ( '/(<[^><]+)(window\.|javascript:|js:|about:|file:|document\.|vbs:|cookie)([^><]*)/i', $text, $mat ) ) {
$text = str_replace ( $mat [0], $mat [1] . $mat [3], $text );
}
return $text;
}
```
这是最新的富文本过滤函数。暂且不看满满的那些onxxx属性和标签,就看看`<script>`,哪里过滤了:
```
$text = @preg_replace ( '/<script?.*\/script>/', '', $text );
$text = @preg_replace ( '/<\/?(html|head|meta|link|base|body|title|style|script|form|iframe|frame|frameset|math|maction|marquee)[^><]*>/i', '', $text );
```
就这两处过滤了`<script`。
我来说说二处的缺陷,第一处没有用i修饰,所以可以用大写绕过。第二处把`<script>`替换成空,我可以`<scr<script>ipt>`绕过。
所以有些时候,你过于关注有什么标签、什么属性能触发XSS,然后用很细致地方法去过滤,比如这里后面的属性区域都用了while循环过滤。但却忽视了最简单的方式,也就是script标签,这才是最大的漏洞。
### 漏洞证明:
随便找一处可以插入富文本的地方,比如小组。
创建一个小组,描述处填写下面的POC:
```
<SCRI<SCRIPT></SCRIPT>PT>alert(1)</SCR<SCRIPT></SCRIPT>IPT>
```
[<img src="https://images.seebug.org/upload/201408/12173720c69e0266b9031f0c450cd168415dc610.jpg" alt="01.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201408/12173720c69e0266b9031f0c450cd168415dc610.jpg)
查看小组的时候触发:
[<img src="https://images.seebug.org/upload/201408/12173757d12fa2f68f59ab8349bce278e5c2817e.jpg" alt="02.jpg" width="600" onerror="javascript:errimg(this);">](https://images.seebug.org/upload/201408/12173757d12fa2f68f59ab8349bce278e5c2817e.jpg)
暂无评论