示例#1
0
        public static string GetResponseTriggerHighlighting(string Trigg, Response Res)
        {
            StringBuilder SB        = new StringBuilder();
            string        ResHeader = Res.GetHeadersAsString();
            string        ResBody   = Res.BodyString;

            List <string> AllTriggerVariations = new List <string>();

            AllTriggerVariations.Add(Trigg);
            if (!AllTriggerVariations.Contains(CookieParameters.Encode(Trigg)))
            {
                AllTriggerVariations.Add(CookieParameters.Encode(Trigg));
            }
            if (!AllTriggerVariations.Contains(HeaderParameters.Encode(Trigg)))
            {
                AllTriggerVariations.Add(HeaderParameters.Encode(Trigg));
            }

            try
            {
                List <string> HeaderAdjustments = GetHeaderVariations(Trigg, Res.Headers, ResHeader);
                foreach (string HA in HeaderAdjustments)
                {
                    if (!AllTriggerVariations.Contains(HA))
                    {
                        AllTriggerVariations.Add(HA);
                    }
                }
            }
            catch { }

            List <string> HeaderTriggerVariations = new List <string>();

            foreach (string CurrentVariation in AllTriggerVariations)
            {
                if (!HeaderTriggerVariations.Contains(CurrentVariation) && ResHeader.Contains(CurrentVariation))
                {
                    HeaderTriggerVariations.Add(CurrentVariation);
                }
            }
            ResHeader = Highlighter.InsertHighlights(ResHeader, HeaderTriggerVariations);

            ResBody = GetResponseBodyHighlighting(ResBody, Trigg);
            if (!ResHeader.Contains("<i<hlg>>") && !ResBody.Contains("<i<hlg>>"))
            {
                foreach (string TriggLine in Tools.SplitLines(Trigg))
                {
                    ResBody = GetResponseBodyHighlighting(ResBody, TriggLine);
                }
            }

            SB.Append(Highlighter.SnipHeaderSection(ResHeader).TrimEnd());
            SB.AppendLine(); SB.AppendLine();
            SB.Append(Highlighter.SnipBodySection(ResBody));
            return(SB.ToString().Replace("\n", "<i<br>>"));
        }
示例#2
0
 void SetHeader(Response Res)
 {
     if (this.BaseTabs.InvokeRequired)
     {
         SetHeader_d InvokeDelegate_d = new SetHeader_d(SetHeader);
         this.BaseTabs.Invoke(InvokeDelegate_d, new object[] { Res });
     }
     else
     {
         this.HeadersTBP.SetText(Res.GetHeadersAsString());
         this.ResetHeadersChangedStatus();
     }
 }
示例#3
0
        public static string Highlight(Response Res, List<string> ToHighlight)
        {
            string ResHeader = Res.GetHeadersAsString();
            string Body = Res.BodyString;

            ResHeader = InsertHighlights(ResHeader, ToHighlight);
            Body = InsertHighlights(Body, ToHighlight);

            StringBuilder SB = new StringBuilder();
            SB.Append(SnipHeaderSection(ResHeader));
            SB.AppendLine(); SB.AppendLine();
            SB.Append(SnipBodySection(Body));

            return SB.ToString();
        }
示例#4
0
        public static string Highlight(Response Res, List <string> ToHighlight)
        {
            string ResHeader = Res.GetHeadersAsString();
            string Body      = Res.BodyString;

            ResHeader = InsertHighlights(ResHeader, ToHighlight);
            Body      = InsertHighlights(Body, ToHighlight);

            StringBuilder SB = new StringBuilder();

            SB.Append(SnipHeaderSection(ResHeader));
            SB.AppendLine(); SB.AppendLine();
            SB.Append(SnipBodySection(Body));

            return(SB.ToString());
        }
示例#5
0
 public static bool IsSame(Response A, Response B)
 {
     try
     {
         if (!A.GetHeadersAsString().Equals(B.GetHeadersAsString()))
         {
             return(false);
         }
         if (A.BodyLength != B.BodyLength)
         {
             return(false);
         }
         for (int i = 0; i < A.BodyLength; i++)
         {
             if (A.BodyArray[i] != B.BodyArray[i])
             {
                 return(false);
             }
         }
     }
     catch { return(false); }
     return(true);
 }
示例#6
0
文件: IronDB.cs 项目: 0ks3ii/IronWASP
 internal static void LogMTResponse(Response Response)
 {
     using (SQLiteConnection MT_DB = new SQLiteConnection("data source=" + TestLogFile))
     {
         MT_DB.Open();
         using (SQLiteCommand Cmd = MT_DB.CreateCommand())
         {
             Cmd.CommandText = "UPDATE TestLog SET Code=@Code, Length=@Length, MIME=@MIME, SetCookie=@SetCookie, ResponseHeaders=@ResponseHeaders, ResponseBody=@ResponseBody, BinaryResponse=@BinaryResponse, RoundTrip=@RoundTrip, Notes=@Notes WHERE ID=@ID";
             Cmd.Parameters.AddWithValue("@Code", Response.Code);
             Cmd.Parameters.AddWithValue("@Length", Response.BodyLength);
             Cmd.Parameters.AddWithValue("@MIME", Response.ContentType);
             Cmd.Parameters.AddWithValue("@SetCookie", AsInt((Response.SetCookies.Count > 0)));
             Cmd.Parameters.AddWithValue("@ResponseHeaders", Response.GetHeadersAsString());
             if (Response.IsBinary)
                 Cmd.Parameters.AddWithValue("@ResponseBody", Response.BinaryBodyString);
             else
                 Cmd.Parameters.AddWithValue("@ResponseBody", Response.BodyString);
             //Cmd.Parameters.AddWithValue("@ResponseBody", Response.BodyString);
             Cmd.Parameters.AddWithValue("@BinaryResponse", AsInt(Response.IsBinary));
             Cmd.Parameters.AddWithValue("@RoundTrip", Response.RoundTrip);
             Cmd.Parameters.AddWithValue("@Notes", "Some Notes");
             Cmd.Parameters.AddWithValue("@ID", Response.ID);
             Cmd.ExecuteNonQuery();
         }
     }
 }
示例#7
0
        internal static void Handle(Fiddler.Session Sess)
        {
            Session  IrSe = new Session(Sess);
            Response Res  = new Response("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nOK");

            Res.Headers.Set("Access-Control-Allow-Origin", "*");

            string ApiUrl     = IrSe.Request.UrlPath.Substring(14);
            bool   MatchFound = false;

            if (ApiUrl.StartsWith("core/", StringComparison.OrdinalIgnoreCase))
            {
                ApiUrl = ApiUrl.Substring(5);
                if (CoreCallHandlers.ContainsKey(ApiUrl))
                {
                    MatchFound = true;
                    try
                    {
                        CoreCallHandlers[ApiUrl](IrSe.Request, Res);
                    }
                    catch (Exception Exp)
                    {
                        Res.BodyString = string.Format("Error executing API call.\r\nError details:\r\n{0}\r\n{1}", Exp.Message, Exp.StackTrace);
                    }
                }
            }
            else if (ApiUrl.StartsWith("custom/", StringComparison.OrdinalIgnoreCase))
            {
                ApiUrl = ApiUrl.Substring(7);
                if (CustomCallHandlers.ContainsKey(ApiUrl))
                {
                    MatchFound = true;
                    try
                    {
                        CustomCallHandlers[ApiUrl](IrSe.Request, Res);
                    }
                    catch (Exception Exp)
                    {
                        Res.BodyString = string.Format("Error executing API call.\r\nError details:\r\n{0}\r\n{1}", Exp.Message, Exp.StackTrace);
                    }
                }
            }
            if (!MatchFound)
            {
                StringBuilder SB = new StringBuilder();
                SB.AppendLine("No API call handler registered for this URL");
                SB.AppendLine();
                SB.AppendLine("The following are the registered URLs:");
                foreach (string Url in CoreCallHandlers.Keys)
                {
                    SB.Append(CoreApiUrlStart); SB.AppendLine(Url);
                }
                Res.BodyString = SB.ToString();
                foreach (string Url in CustomCallHandlers.Keys)
                {
                    SB.Append(CustomApiUrlStart); SB.AppendLine(Url);
                }
                Res.BodyString = SB.ToString();
            }


            //switch (ApiUrl)
            //{
            //    case("LogRangeStart"):
            //        ProxyLogRangeStart = Config.LastProxyLogId;
            //        ProxyLogRangeEnd = 0;
            //        break;
            //    case ("LogRangeEnd"):
            //        ProxyLogRangeEnd = Config.LastProxyLogId;
            //        break;
            //    case ("ScanLogRange"):
            //        break;
            //    default:
            //        if (CustomCallHandlers.ContainsKey(ApiUrl))
            //        {
            //            CustomCallHandlers[ApiUrl](IrSe.Request, Res);
            //        }
            //        else
            //        {
            //        }
            //        break;
            //}
            Sess.utilCreateResponseAndBypassServer();
            Sess.oResponse.headers.AssignFromString(Res.GetHeadersAsString());
            Sess.responseBodyBytes = Res.BodyArray;
        }
示例#8
0
 public static bool IsSame(Response A, Response B)
 {
     try
     {
         if (!A.GetHeadersAsString().Equals(B.GetHeadersAsString())) return false;
         if (A.BodyLength != B.BodyLength) return false;
         for (int i = 0; i < A.BodyLength; i++)
         {
             if (A.BodyArray[i] != B.BodyArray[i]) return false;
         }
     }
     catch { return false; }
     return true;
 }
示例#9
0
        public static string GetResponseTriggerHighlighting(string Trigg, Response Res)
        {
            StringBuilder SB = new StringBuilder();
            string ResHeader = Res.GetHeadersAsString();
            string ResBody = Res.BodyString;

            List<string> AllTriggerVariations = new List<string>();
            AllTriggerVariations.Add(Trigg);
            if (!AllTriggerVariations.Contains(CookieParameters.Encode(Trigg))) AllTriggerVariations.Add(CookieParameters.Encode(Trigg));
            if (!AllTriggerVariations.Contains(HeaderParameters.Encode(Trigg))) AllTriggerVariations.Add(HeaderParameters.Encode(Trigg));

            try
            {
                List<string> HeaderAdjustments = GetHeaderVariations(Trigg, Res.Headers, ResHeader);
                foreach (string HA in HeaderAdjustments)
                {
                    if (!AllTriggerVariations.Contains(HA))
                    {
                        AllTriggerVariations.Add(HA);
                    }
                }
            }
            catch { }

            List<string> HeaderTriggerVariations = new List<string>();
            foreach (string CurrentVariation in AllTriggerVariations)
            {
                if (!HeaderTriggerVariations.Contains(CurrentVariation) && ResHeader.Contains(CurrentVariation))
                {
                    HeaderTriggerVariations.Add(CurrentVariation);
                }
            }
            ResHeader = Highlighter.InsertHighlights(ResHeader, HeaderTriggerVariations);

            ResBody = GetResponseBodyHighlighting(ResBody, Trigg);
            if (!ResHeader.Contains("<i<hlg>>") && !ResBody.Contains("<i<hlg>>"))
            {
                foreach (string TriggLine in Tools.SplitLines(Trigg))
                {
                    ResBody = GetResponseBodyHighlighting(ResBody, TriggLine);
                }
            }

            SB.Append(Highlighter.SnipHeaderSection(ResHeader).TrimEnd());
            SB.AppendLine(); SB.AppendLine();
            SB.Append(Highlighter.SnipBodySection(ResBody));
            return SB.ToString().Replace("\n", "<i<br>>");
        }
示例#10
0
 void SetHeader(Response Res)
 {
     if (this.BaseTabs.InvokeRequired)
     {
         SetHeader_d InvokeDelegate_d = new SetHeader_d(SetHeader);
         this.BaseTabs.Invoke(InvokeDelegate_d, new object[] { Res });
     }
     else
     {
         this.HeadersTBP.SetText(Res.GetHeadersAsString());
         this.ResetHeadersChangedStatus();
     }
 }
示例#11
0
文件: IronUI.cs 项目: welias/IronWASP
 internal static void FillProxyFields(Response Response)
 {
     UI.ProxyResponseHeadersIDV.Text = Response.GetHeadersAsString();
     UI.ProxyResponseHeadersIDV.ReadOnly = false;
     UI.ProxyResponseBodyIDV.ReadOnly = false;
     if (Response.HasBody)
     {
         if (Response.IsBinary)
         {
             UI.ProxyResponseBodyIDV.Text = Encoding.UTF8.GetString(Response.BodyArray);
             UI.ProxyResponseBodyIDV.ReadOnly = true;
         }
         else
         {
             UI.ProxyResponseBodyIDV.Text = Response.BodyString;
         }
     }
 }
示例#12
0
文件: IronUI.cs 项目: welias/IronWASP
 internal static void FillLogFields(Response Response)
 {
     UI.LogResponseHeadersIDV.Text = Response.GetHeadersAsString();
     if (Response.HasBody)
     {
         if (Response.IsBinary)
         {
             UI.LogResponseBodyIDV.Text = Encoding.UTF8.GetString(Response.BodyArray);
         }
         else
         {
             UI.LogResponseBodyIDV.Text = Response.BodyString;
         }
     }
 }