Exemple #1
0
        public void Start()
        {
            FiddlerApplication.CreateProxyEndpoint(7777, true, "localhost");
            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(8877)
                .RegisterAsSystemProxy()
                .DecryptSSL()
                .OptimizeThreadPool()
                .Build();

            FiddlerApplication.Startup(startupSettings);
        }
Exemple #2
0
        public void Start()
        {
            FiddlerApplication.Prefs.SetBoolPref("fiddler.certmaker.CleanupServerCertsOnExit", true);
            FiddlerApplication.CreateProxyEndpoint(7777, true, "localhost");
            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(port)
                .DecryptSSL()
                .OptimizeThreadPool()
                .Build();

            FiddlerApplication.Startup(startupSettings);
        }
        public HttpMonitor()
        {
            FiddlerApplication.BeforeRequest += (Session oS) =>
            {
                oS.bBufferResponse = false;
                Monitor.Enter(oAllSessions);
                oAllSessions.Add(oS);
                OnNewSession(this, new EventArgs());
                Monitor.Exit(oAllSessions);
                if ((oS.oRequest.pipeClient.LocalPort == SecureEndpointPort) && (oS.hostname == SecureEndpointHostname))
                {
                    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://" + SecureEndpointHostname + ":" + SecureEndpointPort.ToString() + " received. Your request was:<br /><plaintext>" + oS.oRequest.headers.ToString());
                }
            };
            FiddlerApplication.AfterSessionComplete += (Session oS) => { };
            Application.ApplicationExit             += (object senser, EventArgs e) => { DoQuit(); };
            CONFIG.IgnoreServerCertErrors            = false;
            FiddlerApplication.Prefs.SetBoolPref("fiddler.network.streaming.abortifclientaborts", true);

            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();

            FiddlerApplication.Startup(startupSettings);

            FiddlerApplication.Log.LogFormat("Created endpoint listening on port {0}", iPort);
            FiddlerApplication.Log.LogFormat("Gateway: {0}", CONFIG.UpstreamGateway.ToString());
            SecureEndpoint = FiddlerApplication.CreateProxyEndpoint(SecureEndpointPort, true, SecureEndpointHostname);
            if (null != SecureEndpoint)
            {
                FiddlerApplication.Log.LogFormat($"Created secure endpoint listening on port {SecureEndpointPort}, using a HTTPS certificate for '{SecureEndpointHostname}'");
            }
        }
Exemple #4
0
        private static void StartupFiddlerCore()
        {
            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(fiddlerCoreListenPort)
                .RegisterAsSystemProxy()
                .ChainToUpstreamGateway()
                .DecryptSSL()
                .OptimizeThreadPool()
                .Build();

            FiddlerApplication.Startup(startupSettings);

            FiddlerApplication.Log.LogString($"Created endpoint listening on port {CONFIG.ListenPort}");
        }
Exemple #5
0
        public void ConfigureFiddlerCore(ProxySettings upstreamProxySettings)
        {
            this.EnsureRootCertificate();

            FiddlerApplication.BeforeRequest += this.sessionsPersister.AddSession;

            FiddlerApplication.Prefs.SetBoolPref("fiddler.ui.rules.bufferresponses", false);

            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(Settings.Default.FiddlerCoreListenPort)
                .SetUpstreamProxySettingsTo(upstreamProxySettings)
                .DecryptSSL()
                .Build();

            FiddlerApplication.Startup(startupSettings);
        }
Exemple #6
0
        static void Main(string[] args)
        {
            FiddlerApplication.Prefs.SetBoolPref("fiddler.certmaker.bc.Debug", true);

            FiddlerApplication.BeforeRequest        += FiddlerApplication_BeforeRequest;
            FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;

            var  port = Properties.Settings.Default.listenPort;
            bool certLoaded;

            LoadCert();
            if (!InstallCert())
            {
                Console.WriteLine("failed to install cert.");
                certLoaded = false;
            }
            else
            {
                certLoaded = true;
            }

            ReadHosts();
            sProxy = Properties.Settings.Default.proxy;

            var builder = new FiddlerCoreStartupSettingsBuilder()
                          .ListenOnPort(port)
                          .AllowRemoteClients()
                          .MonitorAllConnections();

            if (certLoaded)
            {
                builder.DecryptSSL();
            }

            FiddlerApplication.Startup(builder.Build());
            Console.WriteLine("start...");

            while (Console.ReadKey(true).Key != ConsoleKey.Escape)
            {
                ;
            }

            Stop();
        }
Exemple #7
0
        static void Main(string[] args)
        {
            string UrlFilter = "manuals.playstation.net";

            Console.WriteLine("PS5Prxy running on port 8080");
            FiddlerCoreStartupSettingsBuilder builder = new FiddlerCoreStartupSettingsBuilder();

            builder.ListenOnPort(8080);
            builder.AllowRemoteClients();
            FiddlerCoreStartupSettings settings = builder.Build();

            FiddlerApplication.BeforeRequest += FiddlerApplication_BeforeRequest;
            FiddlerApplication.Startup(settings);

            while (true)
            {
            }
            ;
        }
Exemple #8
0
        public void Start()
        {
            sessions = new Buffer <Session>(Settings.SessionBufferSize);
            FiddlerApplication.OnValidateServerCertificate += (sender, args) =>
            {
                var errors = args.CertificatePolicyErrors;

                // No need to re-verify
                if (errors == SslPolicyErrors.None)
                {
                    return;
                }

                if ((errors & SslPolicyErrors.RemoteCertificateNotAvailable) > 0 ||
                    (errors & SslPolicyErrors.RemoteCertificateNameMismatch) > 0)
                {
                    return;
                }

                var remoteChain = args.ServerCertificateChain;
                var chain       = new X509Chain();
                var policy      = chain.ChainPolicy;
                policy.RevocationMode    = X509RevocationMode.NoCheck;
                policy.VerificationFlags = X509VerificationFlags.AllowUnknownCertificateAuthority;
                policy.ExtraStore.AddRange(CertificateStore);
                if (chain.Build(remoteChain.ChainElements[0].Certificate))
                {
                    args.ValidityState = CertificateValidity.ForceValid;
                }
            };
            FiddlerApplication.Prefs.SetBoolPref("fiddler.certmaker.CleanupServerCertsOnExit", true);
            FiddlerApplication.CreateProxyEndpoint(7777, true, "localhost");
            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(port)
                .DecryptSSL()
                .OptimizeThreadPool()
                .Build();

            FiddlerApplication.Startup(startupSettings);
        }
Exemple #9
0
        public static void Start()
        {
            _provider.WriteMessageEvent("Starting proxy...");
            FiddlerApplication.BeforeRequest        += OnBeforeRequest;
            FiddlerApplication.AfterSessionComplete += OnAfterSessionComplete;

            var startupSettings = new FiddlerCoreStartupSettingsBuilder()
                                  .ListenOnPort(8877)
                                  .RegisterAsSystemProxy()
                                  .DecryptSSL()
                                  .ChainToUpstreamGateway()
                                  .MonitorAllConnections()
                                  //.CaptureLocalhostTraffic()
                                  .OptimizeThreadPool()
                                  .Build();

            FiddlerApplication.Startup(startupSettings);
            _proxyEndpoint = FiddlerApplication.CreateProxyEndpoint(48721, true, "localhost");

            _provider.WriteMessageEvent("Proxy started");
        }
Exemple #10
0
        public static void startProxy()
        {
            List <Fiddler.Session> oAllSessions = new List <Fiddler.Session>();

            Fiddler.FiddlerApplication.SetAppDisplayName("VaultBreaker");
            Fiddler.FiddlerApplication.AfterSessionComplete += AfterSessionComplete;
            Fiddler.FiddlerApplication.BeforeRequest        += delegate(Fiddler.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);
            };

            DebugFunctions.writeDebug(String.Format("Starting {0}...", Fiddler.FiddlerApplication.GetVersionString()), Globals.DebugMode);
            Fiddler.CONFIG.IgnoreServerCertErrors = true;
            CONFIG.bMITM_HTTPS = true;

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

            //What port you want to listen on.
            ushort iPort = 8888;

            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort(iPort)
                .DecryptSSL()
                .MonitorAllConnections()
                .OptimizeThreadPool()
                .Build();

            Fiddler.FiddlerApplication.Startup(startupSettings);

            FiddlerApplication.Log.LogFormat("Created endpoint listening on port {0}", iPort);
        }
Exemple #11
0
        public static void Start()
        {
            FiddlerApplication.Shutdown();
            FiddlerApplication.OnValidateServerCertificate += FiddlerApplication_OnValidateServerCertificate;
            SessionStateHandler _bResp;

            if ((_bResp = _beforeResponse) == null)
            {
                _bResp = (_beforeResponse = new SessionStateHandler(BeforeResponse));
                FiddlerApplication.BeforeResponse += _bResp;
            }
            SessionStateHandler _bReq;

            if ((_bReq = _beforeRequest) == null)
            {
                _bReq = (_beforeRequest = new SessionStateHandler(BeforeRequest));
                FiddlerApplication.BeforeRequest += _bReq;
            }
            InstallCert();

            ushort iPort = 7777;

            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();

            Fiddler.FiddlerApplication.Startup(startupSettings);
        }
Exemple #12
0
        static void Main(string[] args)
        {
            FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;
            var settingsBuilder = new FiddlerCoreStartupSettingsBuilder();

            settingsBuilder.ListenOnPort(8889).RegisterAsSystemProxy().DecryptSSL();
            FiddlerApplication.Startup(settingsBuilder.Build());

            while (true)
            {
                var key = Console.ReadKey(true);
                if (key.Key == ConsoleKey.LeftArrow)
                {
                    if (gameIndex > 0)
                    {
                        ShowGame(gameIndex - 1);
                    }
                }
                else if (key.Key == ConsoleKey.RightArrow)
                {
                    if (gameIndex < games.Length - 1)
                    {
                        ShowGame(gameIndex + 1);
                    }
                }
                else if (key.Key == ConsoleKey.X && key.Modifiers.HasFlag(ConsoleModifiers.Control))
                {
                    break;
                }
            }

            FiddlerApplication.AfterSessionComplete -= FiddlerApplication_AfterSessionComplete;

            if (FiddlerApplication.IsStarted())
            {
                FiddlerApplication.Shutdown();
            }
        }
Exemple #13
0
        static void Main(string[] args)
        {
            List <Fiddler.Session> oAllSessions = new List <Fiddler.Session>();

            // <-- Personalize for your Application, 64 chars or fewer
            Fiddler.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.
            Fiddler.FiddlerApplication.OnNotification  += delegate(object sender, NotificationEventArgs oNEA) { Console.WriteLine("** NotifyUser: "******"** LogString: " + oLEA.LogString); };

            Fiddler.FiddlerApplication.BeforeRequest += delegate(Fiddler.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");
             * };*/

            Fiddler.FiddlerApplication.AfterSessionComplete += delegate(Fiddler.Session oS)
            {
                //Console.WriteLine("Finished session:\t" + oS.fullUrl);
                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";
#if SAZ_SUPPORT
            sSAZInfo = Assembly.GetAssembly(typeof(Ionic.Zip.ZipFile)).FullName;

            // You can load Transcoders from any different assembly if you'd like, using the ImportTranscoders(string AssemblyPath)
            // overload.
            //
            //if (!FiddlerApplication.oTranscoders.ImportTranscoders(Assembly.GetExecutingAssembly()))
            //{
            //    Console.WriteLine("This assembly was not compiled with a SAZ-exporter");
            //}

            DNZSAZProvider.fnObtainPwd = () =>
            {
                Console.WriteLine("Enter the password (or just hit Enter to cancel):");
                string sResult = Console.ReadLine();
                Console.WriteLine();
                return(sResult);
            };

            FiddlerApplication.oSAZProvider = new DNZSAZProvider();
#endif

            Console.WriteLine(String.Format("Starting {0} ({1})...", Fiddler.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.
            Fiddler.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.

            Fiddler.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':
#if SAZ_SUPPORT
                    ReadSessions(oAllSessions);
#else
                    WriteCommandResponse("This demo was compiled without SAZ_SUPPORT defined");
#endif
                    break;

                case 'w':
#if SAZ_SUPPORT
                    if (oAllSessions.Count > 0)
                    {
                        SaveSessionsToDesktop(oAllSessions);
                    }
                    else
                    {
                        WriteCommandResponse("No sessions have been captured");
                    }
#else
                    WriteCommandResponse("This demo was compiled without SAZ_SUPPORT defined");
#endif
                    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);
        }
Exemple #14
0
        public void Start(int port, ToolManager manager)
        {
            int requestcount  = 0;
            int responsecount = 0;

            FiddlerApplication.BeforeRequest += (Session oS) =>
            {
                requestcount++;
                Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " [request] request:" + requestcount + " response:" + responsecount);
                bool isbh3url = false;
                foreach (var info in modinfos)
                {
                    if (info.Enabletouch && oS.fullUrl.Contains(info.gameserver_url))
                    {
                        Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " [request] response server info:" + info.server.ToString());
                        oS.utilCreateResponseAndBypassServer();
                        oS.oResponse.headers.SetStatus(200, "OK");
                        oS.utilSetResponseBody(info.mod_gameserver_rsp);
                        isbh3url = true;
                        break;
                    }
                }



                if (oS.fullUrl.Contains("_compressed/DataVersion.unity3d"))
                {
                    Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " [request] response dataversion");
                    oS.utilCreateResponseAndBypassServer();
                    oS.oResponse.headers.SetStatus(200, "OK");
                    if (oS.fullUrl.Contains("android_compressed"))
                    {
                        oS.ResponseBody = manager.a_dataversion;
                    }
                    if (oS.fullUrl.Contains("iphone_compressed"))
                    {
                        oS.ResponseBody = manager.i_dataversion;
                    }
                }

                if (oS.fullUrl.Contains("_compressed/data/excel_output_"))
                {
                    Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " [request] response excel_output.unity3d");
                    oS.utilCreateResponseAndBypassServer();
                    oS.oResponse.headers.SetStatus(200, "OK");
                    if (oS.fullUrl.Contains("android_compressed"))
                    {
                        oS.ResponseBody = manager.a_excel_output;
                    }
                    if (oS.fullUrl.Contains("iphone_compressed"))
                    {
                        oS.ResponseBody = manager.i_excel_output;
                    }
                }

                if (oS.fullUrl.Contains("_compressed/data/setting_"))
                {
                    Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " [request] response setting.unity3d");
                    oS.utilCreateResponseAndBypassServer();
                    oS.oResponse.headers.SetStatus(200, "OK");
                    if (oS.fullUrl.Contains("android_compressed"))
                    {
                        oS.ResponseBody = manager.a_setting;
                    }
                    if (oS.fullUrl.Contains("iphone_compressed"))
                    {
                        oS.ResponseBody = manager.i_setting;
                    }
                }

                if (bh3only && !isbh3url)
                {
                    if (!oS.uriContains("bh3.com") && !oS.uriContains("mihoyo"))
                    {
                        oS.Abort();
                    }
                }
            };

            FiddlerApplication.BeforeResponse += (Session oS) =>
            {
                responsecount++;
                Console.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " [response] request:" + requestcount + " response:" + responsecount);
            };

            CONFIG.IgnoreServerCertErrors = true;

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

            FiddlerCoreStartupSettings startupSettings =
                new FiddlerCoreStartupSettingsBuilder()
                .ListenOnPort((ushort)port)
                .OptimizeThreadPool()
                .AllowRemoteClients()
                .Build();

            FiddlerApplication.Startup(startupSettings);
        }