原理
fiddler抓包原理
fiddler 調試器注冊到操作系統因特網服務中,系統所有的網絡請求都會走fiddler的代理,所以fiddler才能抓包。
Debug traffic from any client and browser
Fiddler helps you debug traffic from any browser: Internet Explorer, Chrome, Firefox, Safari, Opera, and more. Once you start Fiddler, the web debugger registers itself as the system proxy for Microsoft Windows Internet Services (WinINet), the HTTP layer used by Internet Explorer, Microsoft Office, and many other products. As the system proxy, all HTTP requests from WinINet flow through Fiddler before reaching the target web servers. Similarly, all HTTP responses flow through Fiddler before being returned to the client application.
Additionally, most devices that support Wi-Fi or Ethernet can be configured to send their traffic to Fiddler; this includes iOS, Android, Windows Phone and Windows RT devices.
fiddler解密https原理
其實fiddler就是中間人攻擊,依次經過如下過程
- fiddler接到客戶端的https請求,fiddler將請求轉發給服務器
- 服務器生成公鑰證書,返回給fiddler;fiddler攔截下真的公鑰證書,並生成偽造的公鑰證書給客戶端;
- 客戶端使用偽造的公鑰證書加密共享密鑰發送給fiddler,fiddler使用偽造的私鑰解密獲取共享密鑰
- fiddler將解密后的共享密鑰,使用真正的公鑰加密發送給服務器端,服務器使用共享密鑰與fiddler通信
- fiddler使用共享密鑰與客戶端通信
以上是fiddler抓包解密的原理,這個原理是建立在https建立連接的基礎上的,請參考https建立連接過程
下面開始抓包設置教程
設置fiddler抓包
File—–>capture traffic
設置抓https和解密https
Tools—–>fiddler options—–>https—–>capture https traffic—->decrypt https traffic—>Ignore server certificate errors—->Actions—–>Trust root certificate—->之后都是確定
安裝根證書后,可以點擊Actions—–>open windows certificate manager查看安裝到系統的根證書
根證書的作用:fiddler對每個域名都會生成公鑰證書,瀏覽器會用根證書驗證公鑰證書的合法性,所以,根證書是https 抓包必不可少的部分
效果
我們那支付寶登陸界面做測試,支付寶登陸頁面
常見問題
http tunnel、http connect
有一種情況,host都是tunnel to, url 后邊都帶着443,這是什么意思呢?
查看,請求頭會發現使用了Connect方法,Connect方法通常會建議代理(fiddler)與目標服務器建立http tunnel;盡管Connect也可以用於http,但是一般是用於SSL通信;
CONNECT www.google.com:443
- 1
這句話表示,代理與服務器的443端口建立了http tunnel,在此之后,所有由客戶端發送的內容,都會經由http 代理,轉發給www.google.com:443端口;更多http tunnel&http connect資料可以參考http tunnel&connect
解密失敗
有的時候,發現解密失敗,這是可以查看connect的log。如圖
通過查看響應,我們看到,是由於沒有設置解密導致的,
This is a CONNECT tunnel, through which encrypted HTTPS traffic flows.
Fiddler’s HTTPS Decryption feature is enabled, but this specific tunnel was configured not to be decrypted. Settings can be found inside Tools > Fiddler Options > HTTPS.
A SSLv3-compatible ServerHello handshake was found. Fiddler extracted the parameters below.
Tools > Fiddler Options > HTTPS,選中解密https,選擇正確的來源,解密成功。
當然,如果不想顯示Connect,你也可以設置rules----->hide connects
隱藏connect;
如果還是解密失敗,可以查看Log標簽頁,錯誤信息都會在這里邊顯示。
抓不到手機微信
有網友跟我說,抓不到手機微信的數據,這是因為,微信走的http2協議,fiddler不支持http2協議,所以用wireshark抓,但http2也是加密的,所以抓到的數據看不懂。
手機 https 抓包
如果是抓手機 https,請參考這篇文章fiddler 手機 https 抓包 ,對於手機 https抓包做了更有針對性的解釋。