Esempio n. 1
0
        internal static void BeforeResponse(Fiddler.Session Sess)
        {
            if (Sess.HTTPMethodIs("Connect")) return;
            if (Sess.oFlags.ContainsKey("IronFlag-BuiltBy"))
            {
                if (Sess.oFlags["IronFlag-BuiltBy"].Equals("Stealth")) return;
            }
            Session IrSe;
            try
            {
                Sess.utilDecodeResponse();
                IrSe = new Session(Sess);
            }
            catch(Exception Exp)
            {
                IronException.Report("Error reading Response", Exp.Message, Exp.StackTrace);
                return;
            }
            if (IrSe == null)
            {
                IronException.Report("Error reading Response", "", "");
                return;
            }
            if (IrSe.Response == null)
            {
                IronException.Report("Error reading Response", "", "");
                return;
            }
            if (IrSe.FiddlerSession == null)
            {
                IronException.Report("Error reading Response", "", "");
                return;
            }
            long TTL = DateTime.Now.Ticks - IrSe.Request.TimeObject.Ticks;
            IrSe.Response.TTL = (int)(TTL / 10000);
            if (Sess.oFlags.ContainsKey("IronFlag-TTL"))
            {
                IrSe.FiddlerSession.oFlags["IronFlag-TTL"] = IrSe.Response.TTL.ToString();
            }
            else
            {
                IrSe.FiddlerSession.oFlags.Add("IronFlag-TTL", IrSe.Response.TTL.ToString());
            }
            try
            {
                Session ClonedIronSessionWithResponse = IrSe.GetClone();
                if (ClonedIronSessionWithResponse != null && ClonedIronSessionWithResponse.Response != null)
                {
                    PassiveChecker.AddToCheckResponse(ClonedIronSessionWithResponse);
                }
                else
                    IronException.Report("IronSession with Response Couldn't be cloned at ID - " + IrSe.ID.ToString(), "", "");
            }
            catch (Exception Exp)
            {
                IronException.Report("Error Cloning IronSession in BeforeRequest", Exp.Message, Exp.StackTrace);
            }

            if (!IrSe.FiddlerSession.isFlagSet(Fiddler.SessionFlags.RequestGeneratedByFiddler))
            {
                //IronUpdater.AddProxyResponse(IrSe.Response);
            }

            if (!IrSe.FiddlerSession.isFlagSet(Fiddler.SessionFlags.RequestGeneratedByFiddler))
            {
                IrSe.Response.Host = IrSe.Request.Host;
                IrSe.OriginalResponse = IrSe.Response.GetClone(true);
                if(CanInterceptResponse(IrSe))
                {
                    IrSe.MSR = new ManualResetEvent(false);
                    IrSe.FiddlerSession.state = Fiddler.SessionStates.HandTamperResponse;
                    InterceptedSessions.Add(IrSe.ID + "-Response", IrSe);
                    IronUI.SendSessionToProxy(IrSe);
                    InterceptedSessions[IrSe.ID + "-Response"].MSR.WaitOne();
                    InterceptedSessions.Remove(IrSe.ID + "-Response");

                    IrSe.UpdateFiddlerSessionFromIronSession();
                }
                else if (ScriptedInterceptionEnabled)
                {
                    IrSe.UpdateFiddlerSessionFromIronSession();
                }
                else
                {
                    IrSe.FiddlerSession.state = Fiddler.SessionStates.AutoTamperResponseBefore;
                }

                if (ScriptedInterceptionEnabled && ScInt.CallAfterInterception)
                {
                    try
                    {
                        ScInt.AfterInterception = true;
                        ScInt.ShouldIntercept(IrSe);
                    }
                    catch (Exception Exp)
                    {
                        IronUI.ShowProxyException("Error in Scripted Interception Script");
                        IronException.Report("Error in Scripted Interception Script", Exp);
                    }
                    ScInt.AfterInterception = false;
                    IrSe.UpdateFiddlerSessionFromIronSession();
                }

                if (IronProxy.WasResponseChanged(IrSe))
                {
                    Response ClonedResponse = IrSe.Response.GetClone(true);
                    //IronUpdater.AddProxyResponsesAfterEdit(IrSe.OriginalResponse.GetClone(true), ClonedResponse);
                    //IronUI.UpdateEditedProxyLogResponseEntry(ClonedResponse);
                    IronUpdater.AddProxyResponses(new Response[] { IrSe.OriginalResponse, IrSe.Response });
                }
                else
                {
                    IronUpdater.AddProxyResponses(new Response[] { null, IrSe.Response });
                }
            }

            if (PluginEngine.ShouldRunResponseBasedPassivePlugins())
            {
                try
                {
                    PluginEngine.RunAllResponseBasedInlinePassivePlugins(IrSe);
                    IrSe.UpdateFiddlerSessionFromIronSession();
                }
                catch (Exception Exp)
                {
                    IronException.Report("Error running 'BeforeInterception' Passive plugins on Response", Exp.Message, Exp.StackTrace);
                }
            }
        }
Esempio n. 2
0
        internal static void BeforeResponse(Fiddler.Session Sess)
        {
            if (Sess.HTTPMethodIs("Connect")) return;
            if (Sess.oFlags.ContainsKey("IronFlag-BuiltBy"))
            {
                if (Sess.oFlags["IronFlag-BuiltBy"].Equals("Stealth")) return;
            }
            Session IrSe;
            try
            {
                Sess.utilDecodeResponse();
                IrSe = new Session(Sess);
            }
            catch(Exception Exp)
            {
                IronException.Report("Error reading Response", Exp.Message, Exp.StackTrace);
                return;
            }
            if (IrSe == null)
            {
                IronException.Report("Error reading Response", "", "");
                return;
            }
            if (IrSe.Response == null)
            {
                IronException.Report("Error reading Response", "", "");
                return;
            }
            if (IrSe.FiddlerSession == null)
            {
                IronException.Report("Error reading Response", "", "");
                return;
            }
            long TTL = DateTime.Now.Ticks - IrSe.Request.TimeObject.Ticks;
            IrSe.Response.TTL = (int)(TTL / 10000);
            if (Sess.oFlags.ContainsKey("IronFlag-TTL"))
            {
                IrSe.FiddlerSession.oFlags["IronFlag-TTL"] = IrSe.Response.TTL.ToString();
            }
            else
            {
                IrSe.FiddlerSession.oFlags.Add("IronFlag-TTL", IrSe.Response.TTL.ToString());
            }
            try
            {
                Session ClonedIronSessionWithResponse = IrSe.GetClone();
                if (ClonedIronSessionWithResponse != null && ClonedIronSessionWithResponse.Response != null)
                {
                    PassiveChecker.AddToCheckResponse(ClonedIronSessionWithResponse);
                }
                else
                    IronException.Report("IronSession with Response Couldn't be cloned at ID - " + IrSe.ID.ToString(), "", "");
            }
            catch (Exception Exp)
            {
                IronException.Report("Error Cloning IronSession in BeforeRequest", Exp.Message, Exp.StackTrace);
            }

            if (!IrSe.FiddlerSession.isFlagSet(Fiddler.SessionFlags.RequestGeneratedByFiddler))
            {
                IronUpdater.AddProxyResponse(IrSe.Response);
            }

            try
            {
                PluginStore.RunAllPassivePluginsBeforeResponseInterception(IrSe);
            }
            catch(Exception Exp)
            {
                IronException.Report("Error running 'BeforeInterception' Passive plugins on Response", Exp.Message, Exp.StackTrace);
            }

            if (!IrSe.FiddlerSession.isFlagSet(Fiddler.SessionFlags.RequestGeneratedByFiddler))
            {
                IrSe.Response.Host = IrSe.Request.Host;
                if(CanIntercept(IrSe.Response, IrSe.Request))
                {
                    IrSe.MSR = new ManualResetEvent(false);
                    IrSe.FiddlerSession.state = Fiddler.SessionStates.HandTamperResponse;
                    InterceptedSessions.Add(IrSe.ID + "-Response", IrSe);
                    IronUI.SendSessionToProxy(IrSe);
                    InterceptedSessions[IrSe.ID + "-Response"].MSR.WaitOne();
                    InterceptedSessions.Remove(IrSe.ID + "-Response");
                }
                else
                {
                    IrSe.FiddlerSession.state = Fiddler.SessionStates.AutoTamperResponseBefore;
                }
            }

            try
            {
                PluginStore.RunAllPassivePluginsAfterResponseInterception(IrSe);
            }
            catch(Exception Exp)
            {
                IronException.Report("Error running 'AfterInterception' Passive plugins on Response", Exp.Message, Exp.StackTrace);
            }
        }
Esempio n. 3
0
        public static Session FiddlerSessionToSession(Fiddler.Session fSession)
        {
            Session s = new Session();
            //Set the host.
            s.Host = fSession.host;
            //Setup the request.
            s.Request.HttpMethod = fSession.oRequest.headers.HTTPMethod;
            s.UriScheme = fSession.oRequest.headers.UriScheme;
            s.Request.Path = fSession.oRequest.headers.RequestPath;
            s.Id = fSession.id;
            foreach (Fiddler.HTTPHeaderItem header in fSession.oRequest.headers) {
                s.Request.Headers.Add(header.Name, header.Value);
            }
            s.Request.BodyBytes = fSession.requestBodyBytes;

            //Setup up the resposne.
            if (fSession.oResponse != null && fSession.oResponse.headers != null && fSession.responseBodyBytes != null && fSession.responseBodyBytes.Length > 0) {
                foreach (Fiddler.HTTPHeaderItem header in fSession.oResponse.headers) {
                    s.Response.Headers.Add(header.Name, header.Value);
                }
                fSession.utilDecodeResponse();
                s.Response.BodyBytes = fSession.responseBodyBytes;
            }

            if (fSession.oFlags[UASettings.casabaFlag] != null && fSession.oFlags[UASettings.casabaFlag].Length > 0)
            {
                s.ContainsCodePoint = true;
                s.Chr = new UAUnicodeChar(fSession.oFlags[UASettings.casabaFlag][0]);
                s.Flags[UASettings.casabaFlag] = fSession.oFlags[UASettings.casabaFlag];
            }
            //MessageBox.Show(fSession.fullUrl);
            //s.Fsession= fSession;
            return s;
        }
Esempio n. 4
0
        private static void QualityScript_BeforeResponse(Fiddler.Session oSession)
        {
            if (!oSession.url.Contains("osapi.dmm.com/gadgets/ifr?")) return;

            var q = Models.Settings.Current.FlashQuality;
            var m = Models.Settings.Current.FlashRenderMode;
            oSession.utilDecodeResponse();
            oSession.utilReplaceInResponse("</head>", string.Format(Properties.Settings.Default.TagQualityShim, q, m) + "</head>");
        }
Esempio n. 5
0
 private static void OverrideStylesheet_BeforeResponse(Fiddler.Session oSession)
 {
     if (oSession.fullUrl != Properties.Settings.Default.KanColleGamePage.AbsoluteUri) return;
     oSession.utilDecodeResponse();
     oSession.utilReplaceInResponse("</head>", Properties.Settings.Default.TagOverrideStylesheet + "</head>");
 }
Esempio n. 6
0
 private static void NoTouchActionStylesheet_BeforeResponse(Fiddler.Session oSession)
 {
     if (!Models.Settings.Current.DisableBrowserTouchAction) return;
     if (oSession.fullUrl != uri) return;
     oSession.utilDecodeResponse();
     oSession.utilReplaceInResponse("</head>", Properties.Settings.Default.TagNoTouchAction + "</head>");
 }