Example #1
0
        public Core(int unsecurePort, int securePort)
        {
            FiddlerApplication.SetAppDisplayName("DaX.Core");

            FiddlerApplication.OnNotification           += FiddlerApplication_OnNotification;
            FiddlerApplication.Log.OnLogString          += Log_OnLogString;
            FiddlerApplication.BeforeRequest            += FiddlerApplication_BeforeRequest;
            FiddlerApplication.OnReadResponseBuffer     += FiddlerApplication_OnReadResponseBuffer;
            FiddlerApplication.ResponseHeadersAvailable += FiddlerApplication_ResponseHeadersAvailable;
            FiddlerApplication.BeforeResponse           += FiddlerApplication_BeforeResponse;
            FiddlerApplication.AfterSessionComplete     += FiddlerApplication_AfterSessionComplete;


            Console.WriteLine(String.Format("Starting {0} ...", FiddlerApplication.GetVersionString()));

            CONFIG.IgnoreServerCertErrors = false;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            oFCSF = FiddlerCoreStartupFlags.Default & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy;
            FiddlerApplication.Startup(unsecurePort, oFCSF);

            FiddlerApplication.Log.LogFormat("Created endpoint listening on port {0}", unsecurePort);

            FiddlerApplication.Log.LogFormat("Starting with settings: [{0}]", oFCSF);
            FiddlerApplication.Log.LogFormat("Gateway: {0}", CONFIG.UpstreamGateway.ToString());
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(securePort, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat("Created secure endpoint listening on port {0}, using a HTTPS certificate for '{1}'", securePort, sSecureEndpointHostname);
            }
        }
        public static void Start(ushort listenPort, string hostname = "localhost")
        {
            if (FiddlerApplication.IsStarted())
            {
                throw new Exception("Fiddler Proxy 已启动.");
            }
            CurrentPort    = listenPort;
            _hostname      = hostname;
            isStartDarkweb = false;
            FiddlerApplication.SetAppDisplayName("WFS6910");
            FiddlerApplication.ResponseHeadersAvailable += ResponseHeadersAvailable;
            FiddlerApplication.Log.OnLogString          += Log_OnLogString;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);
            InstallCertificate();

            var startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(CurrentPort)
                .RegisterAsSystemProxy()
                .DecryptSSL()
                //.AllowRemoteClients()
                //.ChainToUpstreamGateway()
                .MonitorAllConnections()
                //.HookUsingPACFile()
                //.CaptureLocalhostTraffic()
                //.CaptureFTP()
                .OptimizeThreadPool()
                //.SetUpstreamGatewayTo("http=CorpProxy:80;https=SecureProxy:443;ftp=ftpGW:20")
                .Build();

            FiddlerApplication.Startup(startupSettings);
            FiddlerApplication.oProxy.DetachedUnexpectedly += OProxy_DetachedUnexpectedly;
        }
Example #3
0
 static void Main(string[] args)
 {
     if (args.Length < 1)
     {
         String exeName = System.Reflection.Assembly.GetExecutingAssembly().Location;
         Console.WriteLine($"Usage: {exeName} <process name or partial name>");
         Console.WriteLine($"\t e.g. {exeName} microsoftedgecp");
         Console.ReadLine();
     }
     procName = args[0];
     Console.WriteLine($"Process to watch: {procName}");
     InstallCertificate();
     FiddlerApplication.SetAppDisplayName("FiddlerCoreDemoApp");
     FiddlerApplication.BeforeRequest  += FiddlerApplication_BeforeRequest;
     FiddlerApplication.OnNotification += FiddlerApplication_OnNotification;
     //FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;
     Console.CancelKeyPress += Console_CancelKeyPress;
     Fiddler.CONFIG.IgnoreServerCertErrors = true;
     FiddlerApplication.Startup(9093, true, true, false);
     Console.WriteLine($"Fiddler is started? {FiddlerApplication.IsStarted().ToString()}");
     do
     {
         Console.ReadLine();
     } while (!isDone);
 }
Example #4
0
        public MainForm()
        {
            InitializeComponent();

            FiddlerApplication.SetAppDisplayName("RemoveAreaLimit");
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;

            FiddlerApplication.Startup(port, oFCSF);

            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);

            FiddlerApplication.BeforeRequest  += OnBeforeRequest;
            FiddlerApplication.BeforeResponse += OnBeforeResponse;
        }
Example #5
0
 static FiddlerHelper()
 {
     FiddlerApplication.SetAppDisplayName(AppName);
     CONFIG.IgnoreServerCertErrors = false;
     FiddlerApplication.RequestHeadersAvailable += session =>
     {
         SessionHelper.OpSession((mapping, iSession) =>
         {
             mapping.Add(iSession.id, iSession);
         }, session);
     };
     FiddlerApplication.BeforeRequest += session =>
     {
         session.bBufferResponse = true;
     };
 }
Example #6
0
 //开始运行抓取
 public void Start()
 {
     oAllSessions = new List <Fiddler.Session>();
     //在请求发出之前做的操作,可以捕获、修改请求内容
     Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)
     {
         oS.bBufferResponse = true;
         //检验链接中是否存在关键词,不用可以注释掉
         if (UrlExistKey(oS.fullUrl))
         {
             Monitor.Enter(oAllSessions);
             oAllSessions.Add(oS);
             Monitor.Exit(oAllSessions);
         }
         oS["X-AutoAuth"] = "(default)";
     };
     //响应结果返回,Fiddler接收到之后,浏览器等接收之前,可以捕获、修改响应内容
     Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS)
     {
         oS.bBufferResponse = true;
         //检验链接中是否存在关键词,不用可以注释掉
         if (UrlExistKey(oS.fullUrl))
         {
             Monitor.Enter(oAllSessions);
             oAllSessions.Add(oS);
             oS.utilDecodeResponse();
             Write(string.Format("{0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl));
             Write(oS.GetResponseBodyAsString());
             Monitor.Exit(oAllSessions);
         }
         oS["X-AutoAuth"] = "(default)";
     };
     FiddlerApplication.SetAppDisplayName("PPSHUAI");
     //第三个参数为True,要求捕获https
     FiddlerApplication.Startup(port, true, true, true);
     oProxy = FiddlerApplication.CreateProxyEndpoint(port, true, sHostname);
     //此处调用makecert.exe设置证书
     if (Fiddler.CertMaker.trustRootCert() == true)
     {
         MessageBox.Show("证书安装成功", "操作提示");
     }
     else
     {
         MessageBox.Show("证书安装出错", "操作提示");
     }
     ifWork = true;
 }
Example #7
0
        void InitFiddler()
        {
            // 设置别名
            FiddlerApplication.SetAppDisplayName("FiddlerCoreApp");

            InstallCertificate();

            /*CertMaker.createRootCert();
             * // CertMaker.dll使用BouncyCastle C#库(BCMakeCert.dll)从头开始生成新证书。这些证书仅存储在内存中,并与iOS设备兼容。
             * X509Certificate2 oRootCert = CertMaker.GetRootCertificate();//Returns the Root certificate that Fiddler uses to generate per-site certificates used for HTTPS interception.
             *
             * System.Security.Cryptography.RSACryptoServiceProvider.UseMachineKeyStore = true;
             * System.Security.Cryptography.DSACryptoServiceProvider.UseMachineKeyStore = true;
             *
             * X509Store certStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine);
             *  certStore.Open(OpenFlags.ReadWrite);
             * try
             * {
             *  certStore.Remove(oRootCert);
             *  certStore.Add(oRootCert);
             *  FiddlerApplication.oDefaultClientCertificate = oRootCert;
             * }
             * catch(Exception e)
             * {
             *  log(e.Message);
             * }
             * finally
             * {
             *  certStore.Close();
             * }*/

            // 忽略服务器证书错误:
            CONFIG.IgnoreServerCertErrors = true;
            // 发送请求之前执行的操作
            FiddlerApplication.BeforeRequest        += BeforeRequest;
            FiddlerApplication.BeforeResponse       += BeforeResponse;
            FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS)
            {
                //Console.WriteLine("Finished session:\t" + oS.fullUrl);
                // this.Invoke(()=> Console.Title = "Session list contains: " + oAllSessions.Count.ToString() + " sessions" );
                //log("Session list contains: " + oAllSessions.Count.ToString() + " sessions");
            };

            Fiddler.FiddlerApplication.OnNotification  += delegate(object sender, NotificationEventArgs oNEA) { log("** NotifyUser: "******"** LogString: " + oLEA.LogString); };
        }
Example #8
0
        static FiddlerEngine()
        {
            FiddlerApplication.SetAppDisplayName("NetCloneFuzzer");

            FiddlerApplication.OnNotification  += HandleOnNotification;
            FiddlerApplication.Log.OnLogString += HandleOnLogString;

            FiddlerApplication.AfterSessionComplete += HandleAfterSessionComplete;

            CONFIG.IgnoreServerCertErrors = true;

            //FiddlerCore will immediately dump streaming response data
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.ForgetStreamedData", true);
            FiddlerApplication.Prefs.SetBoolPref("fiddler.certmaker.PreferCertEnroll", false);

            //startupOptions &= ~FiddlerCoreStartupFlags.AllowRemoteClients;
        }
Example #9
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //LoginWindow window = new LoginWindow(this, new QqUser());
            //window.ShowDialog();
            while (!InstallCertificate())
            {
                switch (MessageBox.Show(this, "请信任该证书!", "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No))
                {
                case MessageBoxResult.Yes:
                    break;

                default:
                    Close();
                    return;
                }
            }
            FiddlerApplication.SetAppDisplayName("Gun Eleme");

            status_DataGrid.ItemsSource = elemeHistoryList;
        }
Example #10
0
        static void Main()
        {
            ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;

            FiddlerApplication.SetAppDisplayName("FiddlerToSplunk");
            FiddlerApplication.OnNotification       += OnNotification;
            FiddlerApplication.Log.OnLogString      += OnLogString;
            FiddlerApplication.AfterSessionComplete += SessionComplete;

            _service = new Service(Scheme.Https, "localhost", 8089, new Namespace(user: "******", app: "search"));

            _args = new TransmitterArgs {
                Host = "localhost", Source = "FiddlerToSplunk", SourceType = "JSON"
            };

            SplunkSetup("admin", "changeme").Wait();

            FiddlerApplication.Startup(8877, true, false, true);

            MainFeedbackLoop();

            FiddlerApplication.Shutdown();
        }
Example #11
0
        public void Start(object url)
        {
            bDone = false;
            FiddlerApplication.SetAppDisplayName("FiddlerCoreDemoApp");
            this.url = url.ToString();
            FiddlerApplication.OnNotification  += (object sender, NotificationEventArgs oNEA) => Console.WriteLine("** NotifyUser: "******"** LogString: " + oLEA.LogString);

            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            FiddlerApplication.BeforeRequest += FBeforeRequest;

            string sSAZInfo = "NoSAZ";

            Console.WriteLine(String.Format("Starting {0} ({1})...", FiddlerApplication.GetVersionString(), sSAZInfo));

            CONFIG.IgnoreServerCertErrors = true;

            int iPort = 8877;

            FiddlerApplication.Startup(iPort, true, true);

            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
        }
        static void Main(string[] args)
        {
            List <Session> oAllSessions = new List <Session>();

            // <-- Personalize for your Application, 64 chars or fewer
            FiddlerApplication.SetAppDisplayName("FiddlerCoreDemoApp");

            #region AttachEventListeners
            //
            // It is important to understand that FiddlerCore calls event handlers on session-handling
            // background threads.  If you need to properly synchronize to the UI-thread (say, because
            // you're adding the sessions to a list view) you must call .Invoke on a delegate on the
            // window handle.
            //
            // If you are writing to a non-threadsafe data structure (e.g. List<t>) you must
            // use a Monitor or other mechanism to ensure safety.
            //

            // Simply echo notifications to the console.  Because Fiddler.CONFIG.QuietMode=true
            // by default, we must handle notifying the user ourselves.
            FiddlerApplication.OnNotification  += (object sender, NotificationEventArgs oNEA) => { Console.WriteLine("** NotifyUser: "******"** LogString: " + oLEA.LogString); };

            FiddlerApplication.BeforeRequest += delegate(Session oS)
            {
                // Console.WriteLine("Before request for:\t" + oS.fullUrl);
                // In order to enable response tampering, buffering mode MUST
                // be enabled; this allows FiddlerCore to permit modification of
                // the response in the BeforeResponse handler rather than streaming
                // the response to the client as the response comes in.
                oS.bBufferResponse = false;
                Monitor.Enter(oAllSessions);
                oAllSessions.Add(oS);
                Monitor.Exit(oAllSessions);

                // Set this property if you want FiddlerCore to automatically authenticate by
                // answering Digest/Negotiate/NTLM/Kerberos challenges itself
                // oS["X-AutoAuth"] = "(default)";

                /* If the request is going to our secure endpoint, we'll echo back the response.
                 *
                 * Note: This BeforeRequest is getting called for both our main proxy tunnel AND our secure endpoint,
                 * so we have to look at which Fiddler port the client connected to (pipeClient.LocalPort) to determine whether this request
                 * was sent to secure endpoint, or was merely sent to the main proxy tunnel (e.g. a CONNECT) in order to *reach* the secure endpoint.
                 *
                 * As a result of this, if you run the demo and visit https://localhost:7777 in your browser, you'll see
                 *
                 * Session list contains...
                 *
                 *  1 CONNECT http://localhost:7777
                 *  200                                         <-- CONNECT tunnel sent to the main proxy tunnel, port 8877
                 *
                 *  2 GET https://localhost:7777/
                 *  200 text/html                               <-- GET request decrypted on the main proxy tunnel, port 8877
                 *
                 *  3 GET https://localhost:7777/
                 *  200 text/html                               <-- GET request received by the secure endpoint, port 7777
                 */

                if ((oS.oRequest.pipeClient.LocalPort == iSecureEndpointPort) && (oS.hostname == sSecureEndpointHostname))
                {
                    oS.utilCreateResponseAndBypassServer();
                    oS.oResponse.headers.SetStatus(200, "Ok");
                    oS.oResponse["Content-Type"]  = "text/html; charset=UTF-8";
                    oS.oResponse["Cache-Control"] = "private, max-age=0";
                    oS.utilSetResponseBody("<html><body>Request for httpS://" + sSecureEndpointHostname + ":" + iSecureEndpointPort.ToString() + " received. Your request was:<br /><plaintext>" + oS.oRequest.headers.ToString());
                }
            };

            /*
             *  // The following event allows you to examine every response buffer read by Fiddler. Note that this isn't useful for the vast majority of
             *  // applications because the raw buffer is nearly useless; it's not decompressed, it includes both headers and body bytes, etc.
             *  //
             *  // This event is only useful for a handful of applications which need access to a raw, unprocessed byte-stream
             *  Fiddler.FiddlerApplication.OnReadResponseBuffer += new EventHandler<RawReadEventArgs>(FiddlerApplication_OnReadResponseBuffer);
             */

            /*
             * Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS) {
             *  // Console.WriteLine("{0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl);
             *
             *  // Uncomment the following two statements to decompress/unchunk the
             *  // HTTP response and subsequently modify any HTTP responses to replace
             *  // instances of the word "Microsoft" with "Bayden". You MUST also
             *  // set bBufferResponse = true inside the beforeREQUEST method above.
             *  //
             *  //oS.utilDecodeResponse(); oS.utilReplaceInResponse("Microsoft", "Bayden");
             * };*/

            FiddlerApplication.AfterSessionComplete += (Session oS) =>
            {
                Console.Title = ($"Session list contains: {oAllSessions.Count.ToString()} sessions.");
            };

            // Tell the system console to handle CTRL+C by calling our method that
            // gracefully shuts down the FiddlerCore.
            //
            // Note, this doesn't handle the case where the user closes the window with the close button.
            // See http://geekswithblogs.net/mrnat/archive/2004/09/23/11594.aspx for info on that...
            //
            Console.CancelKeyPress += new ConsoleCancelEventHandler(Console_CancelKeyPress);
            #endregion AttachEventListeners

            string sSAZInfo = "NoSAZ";

            Console.WriteLine(String.Format("Starting {0} ({1})...", FiddlerApplication.GetVersionString(), sSAZInfo));

            // For the purposes of this demo, we'll forbid connections to HTTPS
            // sites that use invalid certificates. Change this from the default only
            // if you know EXACTLY what that implies.
            CONFIG.IgnoreServerCertErrors = false;

            // ... but you can allow a specific (even invalid) certificate by implementing and assigning a callback...
            // FiddlerApplication.OnValidateServerCertificate += new System.EventHandler<ValidateServerCertificateEventArgs>(CheckCert);

            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            // NOTE: In the next line, you can pass 0 for the port (instead of 8877) to have FiddlerCore auto-select an available port
            ushort iPort = 8877;

            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(iPort)
                .RegisterAsSystemProxy()
                .DecryptSSL()
                //.AllowRemoteClients()
                //.ChainToUpstreamGateway()
                //.MonitorAllConnections()
                //.HookUsingPACFile()
                .CaptureLocalhostTraffic()
                //.CaptureFTP()
                .OptimizeThreadPool()
                //.SetUpstreamGatewayTo("http=CorpProxy:80;https=SecureProxy:443;ftp=ftpGW:20")
                .Build();

            // *******************************
            // Important HTTPS Decryption Info
            // *******************************
            // When FiddlerCoreStartupSettingsBuilder.DecryptSSL() is called, you must include either
            //
            //     MakeCert.exe
            //
            // *or*
            //
            //     CertMaker.dll
            //     BCMakeCert.dll
            //
            // ... in the folder where your executable and FiddlerCore.dll live. These files
            // are needed to generate the self-signed certificates used to man-in-the-middle
            // secure traffic. MakeCert.exe uses Windows APIs to generate certificates which
            // are stored in the user's \Personal\ Certificates store. These certificates are
            // NOT compatible with iOS devices which require specific fields in the certificate
            // which are not set by MakeCert.exe.
            //
            // In contrast, CertMaker.dll uses the BouncyCastle C# library (BCMakeCert.dll) to
            // generate new certificates from scratch. These certificates are stored in memory
            // only, and are compatible with iOS devices.

            FiddlerApplication.Startup(startupSettings);

            FiddlerApplication.Log.LogFormat("Created endpoint listening on port {0}", iPort);

            FiddlerApplication.Log.LogFormat("Gateway: {0}", CONFIG.UpstreamGateway.ToString());

            Console.WriteLine("Hit CTRL+C to end session.");

            // We'll also create a HTTPS listener, useful for when FiddlerCore is masquerading as a HTTPS server
            // instead of acting as a normal CERN-style proxy server.
            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat("Created secure endpoint listening on port {0}, using a HTTPS certificate for '{1}'", iSecureEndpointPort, sSecureEndpointHostname);
            }

            bool bDone = false;
            do
            {
                Console.WriteLine("\nEnter a command [C=Clear; L=List; G=Collect Garbage; W=write SAZ; R=read SAZ;\n\tS=Toggle Forgetful Streaming; T=Trust Root Certificate; Q=Quit]:");
                Console.Write(">");
                ConsoleKeyInfo cki = Console.ReadKey();
                Console.WriteLine();
                switch (Char.ToLower(cki.KeyChar))
                {
                case 'c':
                    Monitor.Enter(oAllSessions);
                    oAllSessions.Clear();
                    Monitor.Exit(oAllSessions);
                    WriteCommandResponse("Clear...");
                    FiddlerApplication.Log.LogString("Cleared session list.");
                    break;

                case 'd':
                    FiddlerApplication.Log.LogString("FiddlerApplication::Shutdown.");
                    FiddlerApplication.Shutdown();
                    break;

                case 'l':
                    WriteSessionList(oAllSessions);
                    break;

                case 'g':
                    Console.WriteLine("Working Set:\t" + Environment.WorkingSet.ToString("n0"));
                    Console.WriteLine("Begin GC...");
                    GC.Collect();
                    Console.WriteLine("GC Done.\nWorking Set:\t" + Environment.WorkingSet.ToString("n0"));
                    break;

                case 'q':
                    bDone = true;
                    DoQuit();
                    break;

                case 'r':

                    WriteCommandResponse("This demo was compiled without SAZ_SUPPORT defined");
                    break;

                case 'w':

                    WriteCommandResponse("This demo was compiled without SAZ_SUPPORT defined");
                    break;

                case 't':
                    try
                    {
                        WriteCommandResponse("Result: " + Fiddler.CertMaker.trustRootCert().ToString());
                    }
                    catch (Exception eX)
                    {
                        WriteCommandResponse("Failed: " + eX.ToString());
                    }
                    break;

                // Forgetful streaming
                case 's':
                    bool bForgetful = !FiddlerApplication.Prefs.GetBoolPref("fiddler.network.streaming.ForgetStreamedData", false);
                    FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.ForgetStreamedData", bForgetful);
                    Console.WriteLine(bForgetful ? "FiddlerCore will immediately dump streaming response data." : "FiddlerCore will keep a copy of streamed response data.");
                    break;
                }
            } while (!bDone);
        }
Example #13
0
File: Form1.cs Project: XEonAX/DaX
        private void button1_Click(object btnsender, EventArgs e)
        {
            List <Fiddler.Session> oAllSessions = new List <Fiddler.Session>();

            // <-- Personalize for your Application, 64 chars or fewer
            FiddlerApplication.SetAppDisplayName("FiddlerDaX");

            #region AttachEventListeners
            FiddlerApplication.OnNotification += (sender, oNEA) =>
            {
                Console.WriteLine("** NotifyUser: "******"** LogString: " + oLEA.LogString);
            };

            FiddlerApplication.BeforeRequest += (oS) =>
            {
                oS["X-OverrideGateway"] = "127.0.0.1:8888";
                oS.bBufferResponse      = false;
                Monitor.Enter(oAllSessions);
                oAllSessions.Add(oS);
                Monitor.Exit(oAllSessions);

                // Set this property if you want FiddlerCore to automatically authenticate by
                // answering Digest/Negotiate/NTLM/Kerberos challenges itself
                // oS["X-AutoAuth"] = "(default)";

                /* If the request is going to our secure endpoint, we'll echo back the response.
                 *
                 * Note: This BeforeRequest is getting called for both our main proxy tunnel AND our secure endpoint,
                 * so we have to look at which Fiddler port the client connected to (pipeClient.LocalPort) to determine whether this request
                 * was sent to secure endpoint, or was merely sent to the main proxy tunnel (e.g. a CONNECT) in order to *reach* the secure endpoint.
                 *
                 * As a result of this, if you run the demo and visit https://localhost:7777 in your browser, you'll see
                 *
                 * Session list contains...
                 *
                 *  1 CONNECT http://localhost:7777
                 *  200                                         <-- CONNECT tunnel sent to the main proxy tunnel, port 8877
                 *
                 *  2 GET https://localhost:7777/
                 *  200 text/html                               <-- GET request decrypted on the main proxy tunnel, port 8877
                 *
                 *  3 GET https://localhost:7777/
                 *  200 text/html                               <-- GET request received by the secure endpoint, port 7777
                 */

                //if ((oS.oRequest.pipeClient.LocalPort == iSecureEndpointPort) && (oS.hostname == sSecureEndpointHostname))
                //{
                //    oS.utilCreateResponseAndBypassServer();
                //    oS.oResponse.headers.SetStatus(200, "Ok");
                //    oS.oResponse["Content-Type"] = "text/html; charset=UTF-8";
                //    oS.oResponse["Cache-Control"] = "private, max-age=0";
                //    oS.utilSetResponseBody("<html><body>Request for httpS://" + sSecureEndpointHostname + ":" + iSecureEndpointPort.ToString() + " received. Your request was:<br /><plaintext>" + oS.oRequest.headers.ToString());
                //}
            };

            Fiddler.FiddlerApplication.OnReadResponseBuffer += FiddlerApplication_OnReadResponseBuffer;



            FiddlerApplication.ResponseHeadersAvailable += oS =>
            {
                Console.WriteLine("{0}:HTTP {1} for {2}", oS.id, oS.responseCode, oS.fullUrl);
                var contentlength = oS.ResponseHeaders["Content-Length"];
                if (!string.IsNullOrWhiteSpace(contentlength) && int.Parse(contentlength) > 100000)
                {
                    dgv.BeginInvoke((Action)(() =>
                    {
                        sessionDS.SessionTable.AddSessionTableRow(oS.url, int.Parse(contentlength), oS);
                    }));
                }
                else
                {
                    dgv.BeginInvoke((Action)(() =>
                    {
                        sessionDS.SessionTable.AddSessionTableRow(oS.url, -1, oS);
                    }));
                }
            };
            FiddlerApplication.BeforeResponse += (oS) =>
            {
                if (oS.oFlags.ContainsKey("dax_id"))
                {
                    oS.utilDecodeResponse();
                    oS.SaveResponseBody(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DaXCaps", oS.oFlags["dax_id"] + "_DaX_" + oS.RequestHeaders["Range"].Substring("bytes=".Length) + "_XaD_" + oS.SuggestedFilename));
                }
            };

            FiddlerApplication.AfterSessionComplete += (oS) =>
            {
                Console.WriteLine("Finished session:\t" + oS.fullUrl);
            };

            #endregion AttachEventListeners



            string sSAZInfo = "NoSAZ";
            Console.WriteLine(String.Format("Starting {0} ({1})...", FiddlerApplication.GetVersionString(), sSAZInfo));

            CONFIG.IgnoreServerCertErrors = false;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.Default;
            int iPort = 7777;
            oFCSF = FiddlerCoreStartupFlags.Default & ~FiddlerCoreStartupFlags.RegisterAsSystemProxy;
            FiddlerApplication.Startup(iPort, oFCSF);

            FiddlerApplication.Log.LogFormat("Created endpoint listening on port {0}", iPort);

            FiddlerApplication.Log.LogFormat("Starting with settings: [{0}]", oFCSF);
            FiddlerApplication.Log.LogFormat("Gateway: {0}", CONFIG.UpstreamGateway.ToString());

            oSecureEndpoint = FiddlerApplication.CreateProxyEndpoint(iSecureEndpointPort, true, sSecureEndpointHostname);
            if (null != oSecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat("Created secure endpoint listening on port {0}, using a HTTPS certificate for '{1}'", iSecureEndpointPort, sSecureEndpointHostname);
            }
        }