Isolet Chan
Isolet Chan

Reputation: 427

Fiddler not capturing connections via proxy

I have a C# program with some connections made via some external proxy.

Fiddler is not able to capture these requests which do not use fiddler as a proxy

Is there any way to make these connections go via fiddler first in any C# way or fiddler settings way?

Upvotes: 0

Views: 420

Answers (1)

L.B
L.B

Reputation: 116108

You can use FiddlerCore and chain the proxies..

Proxy p = new Proxy(new List<string>() { "122.129.107.3:8080" }); //real proxies...

WebClient wc = new WebClient();
wc.Proxy = new WebProxy("127.0.0.1", 8888); //local proxy(fiddler core)
wc.Headers["User-Agent"] = "SO/1.0";
var html = wc.DownloadString("http://google.com");

public class Proxy
{
    List<string> _Proxies = null;
    public Proxy(List<string> proxies)
    {
        _Proxies = proxies;
        Fiddler.FiddlerApplication.BeforeRequest += FiddlerApplication_BeforeRequest;
        Fiddler.FiddlerApplication.Startup(8888, false, true);
    }

    static long _Sequence = 0;
    void FiddlerApplication_BeforeRequest(Fiddler.Session oSession)
    {
        var sequence = Interlocked.Increment(ref _Sequence);
        string proxy = _Proxies[(int)(sequence % _Proxies.Count)];

        oSession["x-OverrideGateway"] = proxy;

        Console.WriteLine(String.Format("Proxy[{0}]> {1}", proxy, oSession.host));
    }
}

Just pass a list of proxies to this class. It will use a different one for each request. Your client will use only this Proxy class

Upvotes: 2

Related Questions