是否有从domainA加载内容、从domainB提供内容并欺骗http引荐来源网址为domainA的黑客?

发布于 2024-10-10 10:31:29 字数 427 浏览 0 评论 0原文

这个问题的第 1 部分是 iframe 问题。

您将domainA/page.html嵌入到domainB上的iframe中,http引用自然会是domainA。

那么下面的伪 JavaScript 是否足以保护domainA不被嵌入到domainB上的iframe中? JavaScript 的有效性并不重要,重要的是概念。

if( window.top.href != domainA ) window.top.href = domainA

第 2 部分基本上是欺骗域的任何其他方法。我想你可以在一个客户端一个客户端上伪造http引荐来源网址(例如通过修补离开浏览器的标头)......但这不是什么大问题。 (尽管解释这是如何工作的将是一个很棒的回应)。

Part 1 of this question is the iframe problem.

You embed domainA/page.html in an iframe on domainB, and the http referrer will naturally be domainA.

So is the following pseudo javascript sufficient to protect domainA from being embedded in an iframe on domainB? The javascript validity is not important, just the concept.

if( window.top.href != domainA ) window.top.href = domainA

Part 2 is basically any other method for spoofing the domain. I guess you can fake the http referrer on a client by client basis (by patching the headers leaving the browser for instance)... but this wouldn't be a big deal. (Though explaining how this works would be an awesome response).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鸠书 2024-10-17 10:31:29

这段代码会让你跳出国外网站的框架。

if (top.location != self.location) {
    top.location.replace(self.location)
}

如果有人试图通过将您包含在 iframe 中来保留其网站上的会员,则非常有用。

This code will break you out of a frame within a foreign site.

if (top.location != self.location) {
    top.location.replace(self.location)
}

Useful if someone is trying to keep members on their site by including you in a iframe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文