2016-05-12 92 views
0

这是一个我想用XSS尝试和攻击的简单表单。我正在使用Chrome。XSS不能在表单上工作

<?php 
    echo $_GET['comment']; 
    ?> 
    <script>alert('from HTML')</script> 

    <form method="GET" action=""> 
    Name: 
    <input type="text" name="name" /> 
    <br/><br/> 
    Comment: 
    <input type="text" name="comment" /> 
    <br/><br/> 
    <input type="submit" value="Submit" /> 
    </form> 

所以我进入comment文本框中输入下列:<script>alert('hi')</script>。但是,它不起作用。 弹出的唯一警报框是from HTML,我直接写入代码。 当看着下面被写入网页源:

<script>alert('hi')</script> 
<script>alert('from HTML')</script> 

为什么不执行第一个警报?

+0

使用启用了默认安全设置的Chrome后,您会得到如下内容:'XSS Auditor拒绝执行'http://x/xss.php?name =&comment =%3Cscript%3Ealert%28%27hello %27%29%3B%3C%2Fscript%3E',因为它的源代码是在请求中找到的。由于服务器既没有发送'X-XSS-Protection'也没有发送'Content-Security-Policy'标头,因此启用了审计程序。' – apokryfos

回答

1

检查浏览器开发人员工具中的控制台选项卡。我的猜测是您的浏览器启用了XSS保护。

+0

如何将其关闭? – Ben

+0

更好地使用Firefox(没有NoScript),在Chrome中关闭它似乎是一个难以理解的手段(http://security.stackexchange.com/questions/85044/cannot-turn-off-xss-filter-in- chrome,http://www.frameloss.org/2011/11/01/using-google-chrome-for-security-testing/)。或者:在PHP头部(“X-XSS-Protection:0”);',然后Chrome可以允许它。 –

+0

@MaximilianGerhardt作品完美!谢谢! – Ben

相关问题