点击劫持漏洞

0x01:什么是点击劫持

点击劫持是一种视觉上的欺骗手段,攻击者使用一个透明的、不可见的iframe,覆盖在一个网页上,然后诱使用户在该网页上进行操作,此时用户在不知情的情况下点击了透明的iframe页面。通过调整iframe页面的位置,可以诱使用户恰好点击在iframe页面的一些功能性按钮上,攻击者常常配合社工手段完成攻击。

 

0x02 漏洞危害

攻击者精心构建的另一个置于原网页上面的透明页面。其他访客在用户毫不知情的情况下点击攻击者的页面从而完成攻击。具体危害取决Web应用。

 

0x03 POC代码

受害者点击“脱掉衣服“按钮,iframe会立即加载,请求www.baidu.com页面

<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<head>
<title>点劫持POC</title>
<style>
iframe { width: 1440px; height: 900px; position: absolute; top: -0px; left: -0px; z-index: 2; -moz-opacity: 0; opacity: 0; filter: alpha(opacity=0); }
button { position: absolute; top: 250px; left: 770px; z-index: 1; width: 80px; height:20px; }
</style>
</head>
<body>
<button>脱掉衣服</button>
<img src="http://b.hiphotos.baidu.com/image/pic/item/3ac79f3df8dcd1001341dbcd768b4710b8122f78.jpg">

<iframe src="http://wwwbaidu.com" scrolling="no"></iframe>
</body>
</html>

0x04 修复方案

X-FRAME-OPTIONS是目前最可靠的方法。X-FRAME-OPTIONS是微软提出的一个http头,专门用来防御利用iframe嵌套的点击劫持攻击。并且在IE8、Firefox3.6、Chrome4以上的版本均能很好的支持。

这个头有三个值:

DENY  // 拒绝任何域加载
SAMEORIGIN / / 允许同源域下加载
ALLOW-FROM  // 可以定义允许frame加载的页面地址

PHP代码:

header('X-Frame-Options:Deny');

header('X-Frame-Options:SAMEORIGIN);

配置 Apache

配置 Apache 在所有页面上发送 X-Frame-Options 响应头,需要把下面这行添加到 'site' 的配置中:
Header always append X-Frame-Options SAMEORIGIN

配置 nginx

配置 nginx 发送 X-Frame-Options 响应头,把下面这行添加到 'http', 'server' 或者 'location' 的配置中:
add_header X-Frame-Options SAMEORIGIN;

配置 IIS

配置 IIS 发送 X-Frame-Options 响应头,添加下面的配置到 Web.config 文件中:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-Frame-Options" value="SAMEORIGIN" />
</customHeaders>
</httpProtocol>
</system.webServer>

 

参考链接:

http://www.freebuf.com/articles/web/67843.html

http://www.cnblogs.com/lianzhilei/p/6429514.html

posted @ 2017-08-05 21:26  seeker01  阅读(8551)  评论(1编辑  收藏  举报