![](/img/trans.png)
[英]Trying to figure out how to hide my PHPSESSID to prevent session stealing
[英]Prevent iframe stealing
我认为有人在使用 iframe 窃取我的内容。 我的网站是一个论坛,一个用户刚刚向我报告了他们。
如果其他人这样做,我如何以编程方式(php、JavaScript、jQuery、HTML)找到他们的网站?
互联网上允许他们这样做吗,我可以采取行动吗?
使用 JavaScript,您可以做到
if(window.top==window){
//not inside iframe
} else {
if(parent.parent.someFunction){
parent.parent.someFunction();
} else {
alert("framing is not allowed")
}
}
或者
if (window.top !== window.self) window.top.location.replace(window.self.location.href);
一些现代浏览器还支持 X-FRAME-OPTIONS 标头,它可以有两个值:
* DENY – prevents the page from being rendered if it is contained in a frame
* SAMEORIGIN – same as above, unless the page belongs to the same domain as the top-level frameset holder.
支持标头的浏览器:
* IE8 and IE9
* Opera 10.50
* Safari 4
* Chrome 4.1.249.1042
* Firefox with NoScript
如果您能找出它是谁,您可以告诉他们他们不能以这种方式使用您的内容。 如果您拥有网站,您可以决定如何使用它。
看看 framkillers : http : //en.wikipedia.org/wiki/Framekiller
这是一种阻止网站在 iframe 中显示的技术。 请记住,即使是框架杀手也可以被杀死。
使用我在这里建议的相同方法: How to limit display of iframe from a external site to specific domain only
简而言之,您在每个页面中添加一个 PHP 脚本(在您的情况下,它可能只是一个,假设它是一个模板),该脚本将查看限制为一个(或多个)引用域。
此方法比 javascript 方法更好,因为用户可能已禁用它。
通过使用HTTP Referer过滤器,可以在一定程度上阻止 HTTP 访问。 也可以通过查看 HTTP 日志中的 Referer 来监控“通过主机服务器”的访问。 这不是一个完美的解决方案,但对于标准浏览器访问,您将获得大部分途径。 (“无热链接”设置有时会像这样工作。)
对于法律诉讼,请咨询律师 :-) 但是,我的第一个倾向是要求其他网站所有者停止。 他们可能只是很好。
您可以在您的网站(标题页)顶部使用此 js 代码
if (window.top !== window.self) window.top.location.replace(window.self.location.href);
您可以使用内容安全策略标头(例如frame-ancestors 'none';
阻止其他网站对您的数据进行frame-ancestors 'none';
将阻止每个网站将您的内容嵌入其网站上的 iframe https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.