为什么有些网站在嵌入 iframe 时没有显示?

信息安全 xss dvwa
2021-08-28 16:14:54

利用DVWA 的存储 XSS 选项,我使用以下有效负载:<iframe src="url">.

我想知道为什么有些网站可以工作,而其他网站在使用此有效负载时却不行。

例如:<iframe src="http://usatoday.com">有效,但<iframe src="http://google.com">无效(它显示一个空框)。这个网站也不行。

2个回答

网站通常使用用 JavaScript 编写的 iframe 中断器或X-Frame-Options标头来防止被 iframed。

就 google.com 而言,后者是这种情况:

fabian ~% curl -I www.google.com | grep Frame
X-Frame-Options: SAMEORIGIN

这可以通过以下 HTTP 标头进行控制:

Header set X-Frame-Options 

它有以下选项:

如果我们看谷歌:

root@bt:~# telnet google.com 80
Trying 173.194.34.192...
Connected to google.com.
Escape character is '^]'.
GET / HTTP/1.1

HTTP/1.1 302 Found
Location: http://www.google.es/
Cache-Control: private
Content-Type: text/html; charset=UTF-8
Set-Cookie: PREF=ID=33213a21c9470cd8:FF=0:TM=1372280788:LM=1372280788:S=uhe-vKiypMTkoLNP; expires=Fri, 26-Jun-2015 21:06:28 GMT; path=/; domain=.google.com
Set-Cookie: NID=67=pl37RO9ptszDuKjsU8ysb4W3bkos7KK0u28rPbWdM-hJsNo_gS_XFd1dtWSHM7zAeDjITumqHWIw6P836EqfGSZk51m7nioFM6SrQHZzVVEHgDjXL1CpTmGRrdjP4d_L; expires=Thu, 26-Dec-2013 21:06:28 GMT; path=/; domain=.google.com; HttpOnly
P3P: CP="This is not a P3P policy! See http://www.google.com/support/accounts/bin/answer.py?hl=en&answer=151657 for more info."
Date: Wed, 26 Jun 2013 21:06:28 GMT
Server: gws
Content-Length: 218
X-XSS-Protection: 1; mode=block
X-Frame-Options: SAMEORIGIN   <----

<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>302 Moved</TITLE></HEAD><BODY>
<H1>302 Moved</H1>
The document has moved
<A HREF="http://www.google.es/">here</A>.
</BODY></HTML>

我们可以看到他们已经设置了 X-Frame-Options 已经设置为 SAMEORIGIN。这会阻止您对网站进行 iFraming。