0

我正在尝试在不将 fiddler 设置为其代理的情况下调试应用程序。

为此,我设置了基于 fiddler.core 的应用程序,该应用程序驻留在网络中的另一台计算机上,并向主机文件添加了一个条目。

这是应用程序的代码:

    private static Proxy googleEndpoint;

    static void Main(string[] args)
    {
        List<Fiddler.Session> oAllSessions =new List<Session>();

        Fiddler.FiddlerApplication.BeforeRequest += (i) => Console.WriteLine("Before request: "+i.fullUrl);
        FiddlerApplication.AfterSessionComplete += (i) =>
        {
            Console.WriteLine("After request: "+i.fullUrl);
            lock (oAllSessions)
            {
                oAllSessions.Add(i);
            }
        };

        //https://www.google.com.ua/

        googleEndpoint = FiddlerApplication.CreateProxyEndpoint(443, true, "www.google.com.ua");
        if (null != googleEndpoint)
        {
            Console.WriteLine("google.com.ua endpoint mounted");
        }
        else
        {
            Console.WriteLine("failed to mount google.com.ua endpoint");
        }

        Console.ReadKey();
        SaveSessionsToDesktop(oAllSessions);
    }

    private static void SaveSessionsToDesktop(List<Fiddler.Session> oAllSessions)
    {
        bool bSuccess = false;
        string sFilename = DateTime.Now.ToString("hh-mm-ss") + ".saz";
        try
        {
            try
            {
                Monitor.Enter(oAllSessions);
                TranscoderTuple oExporter = FiddlerApplication.oTranscoders.GetExporter("SAZ");

                if (null != oExporter)
                {
                    Dictionary<string, object> dictOptions = new Dictionary<string, object>();
                    dictOptions.Add("Filename", sFilename);
                    // dictOptions.Add("Password", "pencil");

                    bSuccess = FiddlerApplication.DoExport("SAZ", oAllSessions.ToArray(), dictOptions, null);
                }
                else
                {
                    Console.WriteLine("Save failed because the SAZ Format Exporter was not available.");
                }
            }
            finally
            {
                Monitor.Exit(oAllSessions);
            }

            WriteCommandResponse(bSuccess ? ("Wrote: " + sFilename) : ("Failed to save: " + sFilename));
        }
        catch (Exception eX)
        {
            Console.WriteLine("Save failed: " + eX.Message);
        }
    }

    public static void WriteCommandResponse(string s)
    {
        ConsoleColor oldColor = Console.ForegroundColor;
        Console.ForegroundColor = ConsoleColor.Yellow;
        Console.WriteLine(s);
        Console.ForegroundColor = oldColor;
    }

但是当我尝试https://www.google.com.ua从目标机器访问时,请求现在超时。

Fiddler 应用程序显示它已收到BeforeRequest事件中的请求,但它从未发送回复(AfterSessionComplete从未被调用)。

为什么会发生这种情况,我该如何解决?

我如何为端口 80 做同样的事情?

4

1 回答 1

1

我相信您牢记这样一个事实,除非您将客户端重新配置为信任 FiddlerServer 的根证书,否则它不会向 FiddlerCore 发出 HTTPS 请求。相反,它会在获得拦截证书后立即关闭连接。

如果您附加一个 BeforeResponse 事件处理程序,您会看到什么?它会火吗?

于 2013-01-29T20:48:13.370 回答