gpt4 book ai didi

javascript - 基于 DOM 的跨站点脚本示例 : Java Script does not get executed

转载 作者:行者123 更新时间:2023-12-03 02:29:13 25 4
gpt4 key购买 nike

我最近阅读了以下有关基于 DOM 的 XSS 的文章:

https://www.netsparker.com/blog/web-security/dom-based-cross-site-scripting-vulnerability/

但是文章中提供的示例并不像描述的那样工作。我创建了 HTML 示例文件:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd ">

<html>
<head></head>
<body>
<script>
document.write("<b>Current URL</b> : " + document.baseURI);
</script>
<h1> Welcome on my Example Page </h1>
</body>
</html>

我已将上述文件放入 JBoss 服务器上部署的 Web 应用程序的应用程序文件夹中,并从浏览器调用了该资源(我已尝试过 IE 11 和 Firefox)。 IE 11 显示生成的 HTML 内容,如下所示:

当前 URL:未定义欢迎来到我的示例页面

而 Firefox 显示的 HTML 内容如下所示:

当前网址:https://localhost:8443/ukvlei/example.html欢迎来到我的示例页面

在这两种情况下,我都无法强制任何浏览器执行 # 符号后的 java 脚本函数,如文章中所述。当我输入时

https://localhost:8443/ukvlei/example.html#<script>alert(1)</script>

在浏览器的地址栏中,我得到以下 HTML 内容:

在 IE 11 下:

当前 URL:未定义欢迎来到我的示例页面

在火狐浏览器下:

当前网址:https://localhost:8443/ukvlei/example.html#%3Cscript%3Ealert(1)%3C/script%3E欢迎来到我的示例页面

我做错了什么,导致我无法在任何浏览器中执行java脚本?

谢谢!

最佳答案

您尚未通过 decodeURIComponent 运行 URI以便 URI 语法转换回文本。

关于javascript - 基于 DOM 的跨站点脚本示例 : Java Script does not get executed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48804482/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com