当前位置:网站首页>扩展知识——JS的劫持技术
扩展知识——JS的劫持技术
2022-07-13 17:35:00 【M78_国产007】
1、黑客劫持网络数据包 然后暴力解码(逆向工程)个人隐私数据被窃取
这里不作说明,感兴趣的自己了解
2、系统的内置功能的重写
例如:
<script>
var _log=console.log
console.log=function (str) {
_log(str)
//把hello发送给后台
_log("我执行了就代表发送给后台了")
}
console.log("hello")
//控制台打印了hello和我执行了就代表发送给后台了
</script>3、this关键字的引用劫持
1、call()方法,相当于偷取别人的方法
例如:
<script>
var obj={name: "karen" ,say:function( ){console.log(this.name)}}
var obj2={name : "jack"}
obj.say.call(obj2)//相当于是obj2在调用say方法
//打印jack
</script>2、apply()方法,与call()方法功能一样,只是填入的数据装在数组中。
代码展示两者差别:
<script>
var obj={name: "karen" ,say:function(str1,str2){console.log(this.name,str1,str2)}}
var obj2={name : "jack"}
obj.say.call(obj2,10,20)//"jack" 10 20
obj.say.apply(obj2,[10,20])//"jack" 10 20
//两个方法结果相同,可以清楚的看到apply传的实参是数组,但是实际打印的并不是,所以是在只是将每个数据放在数组内。
</script>特殊点注意:运用窃取技术,数字也能获取到方法
<script>
var arr=[10,230,40,6,2]
var maxnum=Math.max.apply(0,arr)// 相当于假装0也有max方法
//0.max(10,230,40,6,2)==>230
console.log(maxnum)//230
</script>3、bind()在函数定义时,事先就绑定其调用时候的调用者。
例如:
<script>
var obj2={name:"jack"}
var obj={
name:"karen",
say:function(){
console.log(this)
}.bind(obj2) //事先将这个方法指定为obj2调用
}
obj.say() //{name:"jack"}
var obj3={name:"marry"}
obj.say.call(obj3) //{name:"jack"}
obj.say.apply(obj3,[])//{name:"jack"}
</script>总结
根据官方的源代码推出一些规律
1.所有的函数对象都有call方法---Function.prototype 有call方法
2.obj.say.call(obj2) 运行的函数是say函数(哪个函数调call方法就是哪个函数运行)
3.obj.say.call(obj2) 调用这个函数的对象是obj2(obj2调用say函数)
已知所有函数都有call方法,所以call函数也有call方法,进一步提升
<script>
function fn () {
console.log(1)
}
function fn2 () {
console.log(2)
}
fn.call.call(fn2) //打印2
/*
解析:
fn.call是一个函数它有call方法
fn.call引用了一个函数 这个函数运行
fn.call是一个函数这个函数是谁调用的? fn2
*/
</script>边栏推荐
- 数据库进阶
- 油猴脚本更改tw样式
- Mindjet MindManager adding image labels
- Data operation - query
- 万建峰老师 干货分享2022年7月13日
- Teacher Wan Jianfeng dry goods sharing July 13, 2022
- 【一知半解】AQS
- Register the implementation.
- Dark blue themed boss, can you add a typewriter function so that you can choose when typing
- P1664 clock in every day and feel good [getting started]
猜你喜欢

ABAP Bapi copy the standard project template to achieve project initiation

渗透测试之靶场安装与攻击机配置

Brother bird talks about cloud native security best practices | book at the end of the article

一种可灰度的接口迁移方案

Range installation and attacker configuration for penetration testing

“偷师”大厂:可以参考的七种产品开发策略

Software architecture diagram and mode introduction

蓝桥杯:单片机组第十三届省赛第二场

2022 gopherchina's producers and speech content have been announced···
![[hero planet July training leetcode problem solving daily] day 13 two-way linked list](/img/88/ffd37493f0adea18ee5b988e5cef9b.png)
[hero planet July training leetcode problem solving daily] day 13 two-way linked list
随机推荐
Software architecture diagram and mode introduction
微服务模式:Sidecar
油猴脚本更改tw样式
Senior explanation - the difference between FPGA and MCU [basic concept of Bi design]
Practice of Flink CDC in Dajian cloud warehouse
Collation of basic MySQL operations
数组变化,但是无法更新视图(原因和思考)
Is the sub database and sub table really suitable for your system? Talk about how to select sub databases, sub tables and newsql
Dark-blue 主题的大佬,可否加入一个打字机的功能,让打字的时候可以进行选择
Centos7 network configuration and docker installation, MySQL image pulling and docker basic commands
动态规划-LeetCode509.斐波那契数
Blue Bridge Cup: the second game of the 13th provincial competition of single chip microcomputer group
学长讲解 - FPGA与单片机的区别 【毕设基础概念】
正则表达式
Idea自动化生成数据库中对应表的实体类
流批一体在京东的探索与实践
Summary of wechat red envelope project test
Array changes, but the view cannot be updated (reason and thinking)
Aunt Qian's real-time risk control practice based on Flink
Flink CDC 在大健云仓的实践