1. 程式人生 > >Fiddler捕捉資料包得到幾乎全是加密過的tunnel to【解決方法】

Fiddler捕捉資料包得到幾乎全是加密過的tunnel to【解決方法】

困擾了我很久的這個問題被解決了

這個東西一直都沒有辦法解決,讓我們在後面想要做到爬取手機應用上的資料根本就做不到。

因為,根據網路上設定的很多方法,改變了ip代理之後,我就發現我的手機上不了網路了。都上不了網路了,我還怎麼抓到對應的包呢?所以,在這陷入了深思。
手機上不了網!設定完代理之後手機上不了網!得到的所有包的資訊顯示的都是加密的(tunnel to)

這裡寫圖片描述
這樣類似的字樣,已經把我搞得頭都炸了!

解決方案

修改FiddlerScript
也就是改寫Fiddler代理指令碼。
這裡寫圖片描述

然後找到 OnBeforeRequest這個函式,用下面的函式來替換原來的函式
目的就是為了欺騙對方的伺服器。
修改之後,記得要儲存!!!!!


點選左上角的 Save Script 這個按鈕
之後,我們就可以發現,手機就變得可以上網了!!!
而且看到對應的包都是沒有被加密的! 我彷彿又看到一堆的資料在向我招手!!!

static function OnBeforeRequest(oSession: Session) {
        // Sample Rule: Color ASPX requests in RED
        // if (oSession.uriContains(".aspx")) {	oSession["ui-color"] = "red";	}

        // Sample Rule: Flag POSTs to fiddler2.com in italics
        // if (oSession.HostnameIs("www.fiddler2.com") && oSession.HTTPMethodIs("POST")) {	oSession["ui-italic"] = "yup";	}

        // Sample Rule: Break requests for URLs containing "/sandbox/"
        // if (oSession.uriContains("/sandbox/")) {
        //     oSession.oFlags["x-breakrequest"] = "yup";	// Existence of the x-breakrequest flag creates a breakpoint; the "yup" value is unimportant.
        // }

        if ((null != gs_ReplaceToken) && (oSession.url.indexOf(gs_ReplaceToken)>-1)) {   // Case sensitive
            oSession.url = oSession.url.Replace(gs_ReplaceToken, gs_ReplaceTokenWith); 
        }
        if ((null != gs_OverridenHost) && (oSession.host.toLowerCase() == gs_OverridenHost)) {
            oSession["x-overridehost"] = gs_OverrideHostWith; 
        }

        if ((null!=bpRequestURI) && oSession.uriContains(bpRequestURI)) {
            oSession["x-breakrequest"]="uri";
        }

        if ((null!=bpMethod) && (oSession.HTTPMethodIs(bpMethod))) {
            oSession["x-breakrequest"]="method";
        }

        if ((null!=uiBoldURI) && oSession.uriContains(uiBoldURI)) {
            oSession["ui-bold"]="QuickExec";
        }

        if (m_SimulateModem) {
            // Delay sends by 300ms per KB uploaded.
            oSession["request-trickle-delay"] = "300"; 
            // Delay receives by 150ms per KB downloaded.
            oSession["response-trickle-delay"] = "150"; 
        }

        if (m_DisableCaching) {
            oSession.oRequest.headers.Remove("If-None-Match");
            oSession.oRequest.headers.Remove("If-Modified-Since");
            oSession.oRequest["Pragma"] = "no-cache";
        }

        // User-Agent Overrides
        if (null != sUA) {
            oSession.oRequest["User-Agent"] = sUA; 
        }

        if (m_Japanese) {
            oSession.oRequest["Accept-Language"] = "ja";
        }

        if (m_AutoAuth) {
            // Automatically respond to any authentication challenges using the 
            // current Fiddler user's credentials. You can change (default)
            // to a domain\\username:password string if preferred.
            //
            // WARNING: This setting poses a security risk if remote 
            // connections are permitted!
            oSession["X-AutoAuth"] = "(default)";
        }

        if (m_AlwaysFresh && (oSession.oRequest.headers.Exists("If-Modified-Since") || oSession.oRequest.headers.Exists("If-None-Match")))
        {
            oSession.utilCreateResponseAndBypassServer();
            oSession.responseCode = 304;
            oSession["ui-backcolor"] = "Lavender";
        }
        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);
    }