Home  >  Article  >  Backend Development  >  360扫描网站揭示有漏洞

360扫描网站揭示有漏洞

WBOY
WBOYOriginal
2016-06-13 10:38:131052browse

360扫描网站提示有漏洞

我已经对输入字符串过滤了,但是还会提示。请问如何解决
get_magic_quotes_gpc() ? $_REQUEST['key'] : addslashes($_REQUEST['key']);过滤方法。

search.php?key=Your%20Story%3C/title%3E%3C/head%3E%3Cbody%3E%3Cscript%3Ealert(42873);%3C/sCript%3E

用户输入这个就会在我网站最上面显示网站名称。不解

------解决方案--------------------
Your%20Story%3C/title%3E%3C/head%3E%3Cbody%3E%3Cscript%3Ealert(42873);%3C/sCript%3E
不知道你的这个串是哪里来的

Your Story

<script>alert(42873);</script>

------解决方案--------------------
简单的说,addslashes这个只能过滤单引号,其他字符并不能转义,htmlspecialchars这函数不要忘记使用
------解决方案--------------------
get_magic_quotes_gpc() ? $_REQUEST['key'] : addslashes($_REQUEST['key']);过滤方法。

你这段代码没啊。。。。。

PHP code
function escape($value){    $value = is_array($value) ? array_map('escape',$value):htmlspecialchars(trim($value));    return get_magic_quotes_gpc()?$value:addslashes($value);}$_GET     = array_map('escape', $_GET); $_POST     = array_map('escape', $_POST); $_COOKIE     = array_map('escape', $_COOKIE); $_REQUEST     = array_map('escape', $_REQUEST);<br><font color="#e78608">------解决方案--------------------</font><br>addslashes是过滤单引号和NULL字符的, 对标签根本无效, 要展示给用户的非文档内容一律htmlspecialchars.<br><font color="#e78608">------解决方案--------------------</font><br>很明显是你根据用户提交的k拼接JS代码的时候出问题了, 估计你是希望将用户提交的key拼给JS动态展示给用户, 仔细检查JS拼接那里是否使用了htmlspecialchars吧.<div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn