简体   繁体   English

如何暂时禁用现代浏览器中的XSS保护进行测试?

[英]How to temporarily disable XSS protection in modern browsers for testing?

Is it possible to temporarily disable the XSS protection found in modern browsers for testing purposes? 是否可以临时禁用现代浏览器中的XSS保护以进行测试?

I'm trying to explain to a co-worker what happens when one sends this to an XSS-vulnerable web form: 我试图向同事解释当将其发送到易受XSS攻击的Web表单时会发生什么:

<script>alert("Danger");</script>

However, it appears that both Chrome and Firefox are preventing the XSS popup. 但是,Chrome和Firefox似乎都在阻止XSS弹出窗口。 Can I disable this protection so I can fully see the results of my actions? 我可以禁用此保护,以便完全看到我的操作结果吗?

In Chrome there is a flag with which you can start the browser. 在Chrome中,有一个标志,您可以使用该标志启动浏览器。 If you start the browser with this flag, you can do what you want: 如果使用此标志启动浏览器,则可以执行所需操作:

--disable-web-security 

For the convenience of those who don't know.... 为方便那些不懂的人....

"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" --args --disable-web-security “C:\\ Program Files(x86)\\ Google \\ Chrome \\ Application \\ chrome.exe”--args --disable-web-security

Use the above as the path of the shortcut 使用以上作为快捷方式的路径

If you only wan't to disable XSS you should use --disable-xss-auditor . 如果您只想禁用XSS,则应使用--disable-xss-auditor A complete argument would be something like: 一个完整的论点是:

"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" --disable-xss-auditor “C:\\ Program Files(x86)\\ Google \\ Chrome \\ Application \\ chrome.exe” - disable-xss-auditor

Make sure all chrome.exe processes are killed before running the command or it will have no effect. 确保在运行命令之前杀死所有chrome.exe进程,否则它将无效。 You can also pass more arguments if you wish, for example I often use a proxy argument because I don't want to enable a proxy for my entire system. 如果您愿意,也可以传递更多参数,例如我经常使用代理参数,因为我不想为整个系统启用代理。

"C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" --disable-xss-auditor --proxy-server=127.0.0.1:8080 “C:\\ Program Files(x86)\\ Google \\ Chrome \\ Application \\ chrome.exe”--disable-xss-auditor --proxy-server = 127.0.0.1:8080

You can redirect the user to another local web page when the form is submitted and print the infected data. 您可以在提交表单时将用户重定向到另一个本地网页并打印受感染的数据。 Chrome will not detect that. Chrome无法检测到这一点。

Hint: You can use sessions / cookies to store the infected data between the 2 pages. 提示:您可以使用会话/ cookie在两页之间存储受感染的数据。

Example in PHP: PHP中的示例:

index.php 的index.php

<?php    
    setcookie('infected', $_POST['infected']);

    if($_POST['infected'])
        header('location: show.php');
?>

<form action="index.php" method="POST" />
    <p>
        Username: <input type="text" name="infected" />
        <input type="submit" value="Add Comment" />
    </p>
</form>

show.php show.php

echo $_COOKIE['data'];

Is use of disable argument temporary? 使用disable参数是暂时的吗? In limited testing it seems permanent. 在有限的测试中它似乎永久。 XSS-Auditor remains disabled in Chrome windows started without any xss-auditor argument. 在没有任何xss-auditor参数的情况下启动的Chrome窗口中, XSS-Auditor保持禁用状态 To turn back on use "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe" --enable-xss-auditor 要重新使用“C:\\ Program Files(x86)\\ Google \\ Chrome \\ Application \\ chrome.exe”--enable-xss-auditor

I know this doesn't fix it but it may just need a message on the sites for now until Google fixes it. 我知道这不能解决问题但是现在可能需要在网站上留言,直到Google修复它。 something like, "If using Chrome you may experience....". 类似于“如果使用Chrome,您可能会遇到......”。 I found that even though I get the error screen that the content does in fact go in the database. 我发现,即使我得到内容确实进入数据库的错误屏幕。 I just hit back to get back into the site. 我回过头来回到网站。 Then go to the dashboard and it is there. 然后转到仪表板,它就在那里。 Pain in the ass but is a work around that doesn't need to set sites back. 屁股上的痛苦,但是一个解决方案,不需要设置网站。

You do not need to disable XSS protection. 您无需禁用XSS保护。

If you cannot load your page, it is because your "testing" has discovered a fault you need to fix. 如果您无法加载页面,那是因为您的“测试”发现了您需要修复的错误。

If you have no faults in your page, you will not be blocked by XSS. 如果您的页面没有错误,则不会被XSS阻止。

Fix your HTML so it properly "escapes" all input data from the URL, and you will not see XSS warnings. 修复您的HTML,以便正确“逃避”URL中的所有输入数据,您将看不到XSS警告。

It is better to not disable this, because chrome is better at looking through your HTML source for those errors than your eyeballs are! 最好不要禁用此功能,因为Chrome可以更好地查看HTML源代码中的错误,而不是您的眼球!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM