簡體   English   中英

如何從SVG文檔JavaScript獲取父文檔對象?

[英]How I can get parent document object From SVG document JavaScript?

我正在學習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接口和SVGDocument接口,這兩個接口均來自提供一些常用方法的基本Document接口。 Cookie是HTMLDocument界面的一部分,因此只有HTML文檔可以獲取Cookie。

如果您正在談論通過<object><embed><iframe>標簽將<svg>嵌入html文檔中的情況,那么parent.documenttop.document將為您提供來自html的父html文檔。 SVG對象中的腳本腳本,前提是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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM