示例#1
0
 public void WriteConsole(string Text, int WarnType)
 {
     if (WarnType == (int)WarningType.LOG)
     {
         Console_RTB.SelectionColor = Color.White;
         Console_RTB.AppendText("[" + DateTime.Now + "]" + "[LOG] " + Text);
         Console_RTB.AppendText(Environment.NewLine);
     }
     else if (WarnType == (int)WarningType.STRING)
     {
         Console_RTB.SelectionColor = Color.Yellow;
         Console_RTB.AppendText("[" + DateTime.Now + "]" + "[INFO] " + Text);
         Console_RTB.AppendText(Environment.NewLine);
     }
 }
示例#2
0
        private void StopProxy()
        {
            FiddlerApplication.Log.LogFormat("Shutting down. You need to restart the application before restart the proxy", Port);

            Fiddler.FiddlerApplication.OnNotification -= delegate(object sender, NotificationEventArgs oNEA)
            {
                if (Console_RTB.InvokeRequired)
                {
                    Console_RTB.Invoke((MethodInvoker) delegate()
                    {
                        WriteConsole(oNEA.NotifyString, 0);
                    });
                }
                else
                {
                    WriteConsole(oNEA.NotifyString, 0);
                }
            };

            Fiddler.FiddlerApplication.Log.OnLogString -= delegate(object sender, LogEventArgs oLEA)
            {
                if (Console_RTB.InvokeRequired)
                {
                    Console_RTB.Invoke((MethodInvoker) delegate()
                    {
                        WriteConsole(oLEA.LogString, 1);
                    });
                }
                else
                {
                    WriteConsole(oLEA.LogString, 1);
                }
            };

            FiddlerApplication.Shutdown();

            Thread.Sleep(100);


            this.Text              = "Main Menu | " + Version + " | Port: " + Port + " | Server Proxy: OFF";
            SrvProxy_LB.Text       = "Server Proxy: OFF";
            SrvProxy_LB.ForeColor  = Color.White;
            Proxy_Btn.Text         = "Restart";
            Proxy_TxtBox.ForeColor = Color.White;
            Proxy_TxtBox.Text      = "OFF";
            isProxyOpened          = false;
        }
示例#3
0
        private void StartProxy()
        {
            Fiddler.FiddlerApplication.SetAppDisplayName("Proxy Registry Editor");
            Fiddler.FiddlerApplication.OnNotification += delegate(object sender, NotificationEventArgs oNEA) {
                if (Console_RTB.InvokeRequired)
                {
                    Console_RTB.Invoke((MethodInvoker) delegate()
                    {
                        WriteConsole(oNEA.NotifyString, 0);
                    });
                }
                else
                {
                    WriteConsole(oNEA.NotifyString, 0);
                }
            };

            Fiddler.FiddlerApplication.Log.OnLogString += delegate(object sender, LogEventArgs oLEA) {
                if (Console_RTB.InvokeRequired)
                {
                    Console_RTB.Invoke((MethodInvoker) delegate()
                    {
                        WriteConsole(oLEA.LogString, 1);
                    });
                }
                else
                {
                    WriteConsole(oLEA.LogString, 1);
                }
            };
            //string path = "C:\\Users\\ADeltaX\\Documents\\Visual Studio 2013\\Projects\\ProxyRegistryEditor\\ProxyRegistryEditor\\bin\\Debug\\Certificate\\wpflights.trafficmanager.net.cer";
            //Fiddler.FiddlerApplication.oDefaultClientCertificate = new X509Certificate(path);

            Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.Session oS)

            {
                oS.bBufferResponse = false;
                if (oS.fullUrl.StartsWith("https://wpflights.trafficmanager.net/RestUpdateProvisioningService.svc/UpdateChoices?"))
                {
                    oS.utilCreateResponseAndBypassServer();

                    oS.oResponse.headers.SetStatus(200, "Ok");

                    //oS.oResponse["https-Client-Certificate"] = path;
                    oS.utilDecodeResponse(true);
                    FiddlerApplication.Log.LogFormat("Injecting certificate");
                    oS.oResponse["Content-Type"]  = "application/xml; charset=utf-8";
                    oS.oResponse["Cache-Control"] = "private, max-age=0";
                    StartString  = WPFlightsInit_TB.Text;
                    EndingString = EndingString_TB.Text;
                    KeysToAdd    = KeysToAdd_TB.Text;
                    KeysToDelete = KeysToDelete_TB.Text;

                    WPFlight = StartString + "<KeysToAdd>" + KeysToAdd + "</KeysToAdd>" + "<KeysToDelete>" + KeysToDelete + "</KeysToDelete>" + EndingString;
                    oS.utilSetResponseBody(WPFlight);
                    FiddlerApplication.Log.LogFormat("Sending custom Flighting Response");
                }
            };

            Fiddler.CONFIG.IgnoreServerCertErrors = false;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);
            FiddlerCoreStartupFlags oFCSF = FiddlerCoreStartupFlags.DecryptSSL | FiddlerCoreStartupFlags.AllowRemoteClients | FiddlerCoreStartupFlags.ChainToUpstreamGateway | FiddlerCoreStartupFlags.OptimizeThreadPool;

            try
            {
                Fiddler.FiddlerApplication.Startup(Port, oFCSF);
            }
            catch (Exception e)
            {
                WriteConsole(e.Message, 1);
                return;
            }

            WriteConsole(String.Format("Starting {0} ({1})", Fiddler.FiddlerApplication.GetVersionString(), "NoSAZ"), 0);
            FiddlerApplication.Log.LogFormat("Created endpoint listening on port {0}", Port);
            FiddlerApplication.Log.LogFormat("Starting with settings: [{0}]", oFCSF);
            FiddlerApplication.Log.LogFormat("Gateway: {0}", CONFIG.UpstreamGateway.ToString());


            this.Text              = "Main Menu | " + Version + " | Port: " + Port + " | Server Proxy: ON";
            SrvProxy_LB.Text       = "Server Proxy: ON";
            SrvProxy_LB.ForeColor  = Color.LimeGreen;
            Proxy_Btn.Text         = "Stop Proxy";
            Proxy_TxtBox.ForeColor = Color.LimeGreen;
            Proxy_TxtBox.Text      = "ON";
            isProxyOpened          = true;
        }