文章目录加载中
Web安全:点击劫持
# 攻击原理
点击劫持是一种视觉欺骗的攻击手段。攻击者通过 iframe
嵌套嵌入被攻击网页,诱导用户点击。如果用户之前登陆过被攻击网页,那么浏览器可能保存了信息,因此可以以用户的身份实现操作。
# 防范手段
js 防范手段(兼容性最好):
<head>
<style id="click-jack">
html {
display: none !important;
}
</style>
<script>
// 判断当前页面是否是iframe加载
if (self === top) {
const style = document.getElementById("click-jack");
document.body.removeChild(style);
} else {
top.location = self.location;
}
</script>
</head>
本文来自心谭博客:xin-tan.com,经常更新web和算法的文章笔记,前往github查看目录归纳:github.com/dongyuanxin/blog