點擊劫持漏洞

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

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

http://www.javashuo.com/article/p-kfxvvnjv-ko.html

相關文章
相關標籤/搜索