网站防嵌套猜想及实验验证

作者: 趁你还年轻233 | 来源:发表于2017-09-21 11:32 被阅读21次

一、基础知识

1.window.self
①self 和window.self都可以
②window Context下解析成window.self;worker Context下解析成WorkerGlobalScope.self
③访问window的四种方式

var w1 = window;
var w2 = self;
var w3 = window.window;
var w4 = window.self;
// w1, w2, w3, w4 all strictly equal, but only w2 will function in workers

2.window.top
Returns a reference to the topmost window in the window hierarchy.

var topWindow = window.top;

3.location对象

// Create anchor element and use href property for the purpose of this example// A more correct alternative is to browse to the URL and use document.location or window.locationvar url = document.createElement('a');
url.href = '[https://developer.mozilla.org:8080/en-US/search?q=URL#search-results-close-container'](https://developer.mozilla.org:8080/en-US/search?q=URL#search-results-close-container');;
console.log(url.href); // [https://developer.mozilla.org/en-US/search?q=URL#search-results-close-container](https://developer.mozilla.org/en-US/search?q=URL#search-results-close-container)
console.log(url.protocol); // https:
console.log(url.host); // [developer.mozilla.org:8080](http://developer.mozilla.org:8080/)
console.log(url.hostname); // [developer.mozilla.org](http://developer.mozilla.org/)
console.log(url.port); // 8080
console.log(url.pathname); // /en-US/search
console.log(url.search); // ?q=URL
console.log(url.hash); // #search-results-close-container
console.log(url.origin); // [https://developer.mozilla.org](https://developer.mozilla.org/)

二、分析猜想

不同hirearchy下,top.location&self.location分析及防嵌套猜想

1.localhost想嵌套www.baidu.com

localhost的index.html,写下这样一行代码

<iframe src="www.baidu.com"></iframe>

2.www.baidu.com被嵌套判断

www.baidu.com/80/index.html 中的script中会有一段

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

猜想:
此时self.location当然指的是https://www.baidu.com,但是此时的top.location是localhost,判断为真,那么www.baidu.com会强制将top.location也就是localhost(想嵌套别人网站的主动者),改为https://www.baidu.com,从而导致套路被反套路。
也就是,此时我的网站内容已不再,而是被嵌套进来的网站所替代。

由于www.baidu.com的index.html文件我们无从修改,至少目前是这样,因为我们不是www.baidu.com的管理者,也不是一个愿意冒着触碰法律危险去触碰信息安全的黑客。

所以我们需要一个属于自己的网站去验证我们的猜想。

三、实验验证

1.一个可以被访问的域名
https://frankkai.github.io,index.html中添加防嵌套代码

<script>
    if(self.location != top.location){
        top.location = self.location;
    }
</script>

2.本地localhost
开放一个端口,尝试嵌套frankkai.github.io
<iframe src="[https://frankkai.github.io"]</iframe>
3.实验结果及分析

经验证,网站防嵌套成功。√

相关文章

  • 网站防嵌套猜想及实验验证

    一、基础知识 1.window.self①self 和window.self都可以②window Context下...

  • 嵌套交叉验证(Nested cross-validation)

    传统交叉验证和嵌套交叉验证的区别 在开始分享嵌套交叉验证前,首先以K-Fold为例,区分K-Fold交叉验证和嵌套...

  • c++ day03

    函数的原型声明 理解函数参数的传值 哥德巴赫猜想验证 函数引用调用示例 函数的嵌套调用 函数递归 递归就是自己调用...

  • 填鸭式教学

    上篇文章我提到了启发式教学的思想,大概方式是先从实际生活中发现问题,然后做出猜想,再将猜想放到实验中进行验证,最终...

  • 愿力

    愿力,是你最想去验证的猜想。用观察,用逻辑,用实验,看看猜想对不对:我爱的姑娘到底爱不爱我?我的解题方法酷不酷?我...

  • A/B实验,了解一下。

    1 为什么要做A/B实验? A/B实验,是一种验证假设的方法,其核心方法及原理分别是对照实验及假设检验。 在实际实...

  • 2019-10-08

    实验一:Profile与插件在线开发及验证实验 一:配置步骤 1 .登陆OceanConnect平台,创建应用。 ...

  • Mac下折腾时间戳的哪些事情

    爬到如下数据: 对照网站原始数据,推测是时间戳。 1、验证猜想 打开在线时间戳转换工具https://tool.l...

  • 社会哲学及科学探究方法在政治学科的应用

    一、模式介绍 一、什么是科学探究方法? 1、观察现象 2、提出问题 3、给出猜想 4、实验证明 二、那科学探究方法...

  • 屏蔽K8S中的POD访问特定网址

    最近在看点评网站: 感觉里面防爬做的蛮好:验证方面采用随机验证类型(滑块、极验、连连看等等还有其他);而且网页间的...

网友评论

    本文标题:网站防嵌套猜想及实验验证

    本文链接:https://www.haomeiwen.com/subject/uyszsxtx.html