博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Fiddler 抓取Https时 显示 Tunnel to 443 的解决方案

Posted on 2021-09-02 19:23  孤峰皓月  阅读(2690)  评论(1编辑  收藏  举报

设置好Fiddler,部分https抓包时,显示 Tunnel to 443,注意不是全部,如果是全部显示Tunnel to 443,那需要把证书推送到系统证书里面。

 

 

1.打开 Fiddler ,找到 FiddlerScript标签,Go to: 这里选 OnBeforeRequest

.

 

 

 

 

 

 

在这个方法的末尾加上如下代码:

var hosts = 'zkd.me develop.dog';
         FiddlerApplication.Log.LogFormat("Logger session {0}, Url: {1}, isHttps: {2}, port: {3}", oSession.id, oSession.fullUrl, oSession.isHTTPS, oSession.port);
        if(hosts.indexOf(oSession.host) > -1){
            FiddlerApplication.Log.LogFormat("Capture session {0}, Url: {1}, isHttps: {2}, port: {3}", oSession.id, oSession.fullUrl, oSession.isHTTPS, oSession.port);
            if(oSession.HTTPMethodIs('CONNECT')){
                FiddlerApplication.Log.LogString('create fake tunnel response');
                oSession['x-replywithtunnel'] = 'FakeTunnel';
                return;
            }
 
            if (oSession.isHTTPS){
                FiddlerApplication.Log.LogString('switch https to http request');
                oSession.fullUrl = oSession.fullUrl.Replace("https://","http://");
                oSession.port = 80;
            }   
 
            FiddlerApplication.Log.LogFormat("Processed session {0}, Url: {1}, isHttps: {2}, port: {3}", oSession.id, oSession.fullUrl, oSession.isHTTPS, oSession.port);
        }
        FiddlerApplication.Log.LogFormat("Logger session {0}, Url: {1}, isHttps: {2}, port: {3}", oSession.id, oSession.fullUrl, oSession.isHTTPS, oSession.port);
 
var hosts = 'zkd.me develop.dog'; 
这里需要改成我们自己的要抓包的域名

2.修改好后,一定要点 Save Script 这个按钮,要不然改了没用


 

 

//如何让HTTP请求和HTTPS请求显示不一样的颜色?

if(oSession.isHTTPS && oSession.url.indexOf(oSession.host)> -1){
oSession["ui-color"] = "blue";
}
if(!oSession.isHTTPS && oSession.url.indexOf(oSession.host)> -1){
oSession["ui-color"] = "green";
}

 

 

 

 

 

参考自:https://blog.csdn.net/amrenyu/article/details/80745674