FiddlerCore - How to Delay a Request

2 posts, 0 answers
  1. Harry
    Harry avatar
    2 posts
    Member since:
    Apr 2018

    Posted 22 Nov 2018 Link to this post

    I'm having an issue with an WinHTTP application I'm intercepting and modifying data for. I'm setting the WinHTTP proxy as a loopback to capture and modify the response, however the WinHTTP application checks for a loopback after the response and denies authorization if one is found.

    I've tried setting the loopback, decoding the response, and right before sending my modified response, resetting the WinHTTP settings to default. The problem i'm facing is that this WinHTTP application actually polls the server twice in a row, so if I reset the proxy once, i need to set it again and then reset it again before modifying the response a 2nd time.

    Is there a way I can delay the 2nd request so that I have enough time to reset and set the first one? I've tried using Thread.Sleep but that doesn't work. Thanks.

            void Start()
            {
                CaptureConfiguration.CaptureDomain = "https://toirplusvip.com/";

                SetWinHTTPProxy();

                FiddlerApplication.AfterSessionComplete += FiddlerApplication_AfterSessionComplete;
                FiddlerApplication.BeforeRequest += FiddlerApplication_BeforeRequest;
                FiddlerApplication.BeforeResponse += FiddlerApplication_BeforeResponse;
                FiddlerApplication.Startup(8877, false, true, true);
            }

            public void SetWinHTTPProxy()
            {
                var proc1 = new ProcessStartInfo();
                string anyCommand = "netsh winhttp set proxy 127.0.0.1:8877 \"<-loopback>\"";
                proc1.UseShellExecute = true;
                proc1.WorkingDirectory = @"C:\Windows\System32";
                proc1.FileName = @"C:\Windows\System32\cmd.exe";
                proc1.Verb = "runas";
                proc1.Arguments = "/c " + anyCommand;
                proc1.WindowStyle = ProcessWindowStyle.Hidden;
                Process.Start(proc1);
            }

            public void ResetWinHTTPProxy()
            {
                var proc1 = new ProcessStartInfo();
                string anyCommand = "netsh winhttp reset proxy";
                proc1.UseShellExecute = true;
                proc1.WorkingDirectory = @"C:\Windows\System32";
                proc1.FileName = @"C:\Windows\System32\cmd.exe";
                proc1.Verb = "runas";
                proc1.Arguments = "/c " + anyCommand;
                proc1.WindowStyle = ProcessWindowStyle.Hidden;
                Process.Start(proc1);
            }

            private void FiddlerApplication_BeforeResponse(Session oSession)
            {
                if (oSession.fullUrl.ToLower().Contains("toirplusvip.com/checklogin_vip_aimode2.php"))
                {
                    Console.WriteLine(oSession.fullUrl.ToLower());
                    Console.WriteLine("beeuty");
                    oSession.utilDecodeResponse();
                    var oBody = System.Text.Encoding.UTF8.GetString(oSession.responseBodyBytes);
                    var epoch = (int)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
                    var sessionID = "8763c665bc13e4ba56ee578c161dc1f4";
                    String input = "rnd='&ret=" + sessionID + "&token=" + epoch + "&code=0";
                    Console.WriteLine(input);
                    Cryptography c = new Cryptography();
                    String nBody = c.EncryptString(input, key, iv);

                    ResetWinHTTPProxy(); // needs to be reset in between

                    oSession.utilSetResponseBody(nBody);
                    return;
                }
            }

  2. Harry
    Harry avatar
    2 posts
    Member since:
    Apr 2018

    Posted 23 Nov 2018 in reply to Harry Link to this post

    Nvm I figured it out, if an admin can delete this topic that would be great. Thanks.
Back to Top