Search code examples
proxyfiddlercore

FiddlerCore: how to use system proxy right?


I want to sniff some https traffic of a browser. My network settings use the proxy configuration "Use automatic configuration script: 'http://proxyconf-domain.net/'"

Now my code looks like this:

FiddlerApplication.AfterSessionComplete += FiddlerApplicationOnAfterSessionComplete;

FiddlerApplication.Startup(8888, FiddlerCoreStartupFlags.Default);

...

private void FiddlerApplicationOnAfterSessionComplete(Session oSession)
{
    if (oSession.LocalProcessID == 22228)
    {
        Console.WriteLine("Chrome Traffic");
    }
}

Problem: After Startup my system proxy settings are lost so the browser cannot connect to internet and i have to reset them manually. But i want FiddlerCore to work like the Fiddler App.

The FiddlerCoreStartupFlags.Default has the RegisterAsSystemProxy flag. The Fiddler App has the same settings: FiddlerSettings But the Fiddler App is capturing the traffic and the browser keeps its proxy settings.

Do I have to read the system proxy and set it in my code for FiddlerCore or something else?


Solution

  • After Startup my system proxy settings are lost so the browser cannot connect to internet and i have to reset them manually. But i want FiddlerCore to work like the Fiddler App.

    This is because you have not called Shutdown() method when your program exits. Call Shutdown() to tell FiddlerCore to stop listening on the specified port, and unregister as the system proxy. For example:

        FiddlerApplication.AfterSessionComplete += FiddlerApplicationOnAfterSessionComplete;
        FiddlerApplication.Startup(8888, FiddlerCoreStartupFlags.Default);
        ...
    
        //when your program exits
        Fiddler.FiddlerApplication.Shutdown();
        ...
    

    In many cases, you're better off simply calling Fiddler.FiddlerApplication.oProxy.Detach().