Esempio n. 1
0
 public void SetCookie(CookieStore Store)
 {
     foreach (SetCookie SC in Store.GetCookies(this))
     {
         this.Cookie.Set(SC.Name, SC.Value);
     }
 }
Esempio n. 2
0
        //public static List<IronHtml.FormSubmission> GetFormSubmissionItems(Request Req, Response Res, CookieStore Cookies)
        //{

        //}

        static List <Request> GetFormSubmissionsByType(Request Req, Response Res, CookieStore Cookies, bool LoginFormsOnly)
        {
            List <Request>  FormSubmissions = new List <Request>();
            List <HtmlNode> FormNodes       = Res.Html.GetForms();

            foreach (HtmlNode FormNode in FormNodes)
            {
                Request FormSub = GetFormSubmission(Req, FormNode, Cookies, LoginFormsOnly);
                if (FormSub != null)
                {
                    FormSubmissions.Add(FormSub);
                }
            }
            return(FormSubmissions);
        }
Esempio n. 3
0
        public static List <Request> GetLinkClicks(Request Req, Response Res, CookieStore Cookies)
        {
            List <Request> LinkClicks = new List <Request>();
            List <string>  Links      = GetLinks(Req, Res);

            foreach (string Link in Links)
            {
                try
                {
                    Request LinkReq = new Request(Link);
                    LinkReq.SetCookie(Cookies);
                    LinkClicks.Add(LinkReq);
                }
                catch { }
            }
            return(LinkClicks);
        }
Esempio n. 4
0
        public static List <Request> GetRedirects(Request Req, Response Res, CookieStore Cookies)
        {
            List <Request> Redirects    = new List <Request>();
            List <string>  RedirectUrls = GetRedirectUrls(Req, Res);

            foreach (string RedirectUrl in RedirectUrls)
            {
                try
                {
                    Request RedirectReq = new Request(RedirectUrl);
                    RedirectReq.SetCookie(Cookies);
                    Redirects.Add(RedirectReq);
                }
                catch { }
            }
            return(Redirects);
        }
Esempio n. 5
0
 internal static void UpdateCookieStoreFromResponse()
 {
     try
     {
         Session CurrentSession = GroupSessions[CurrentGroup][CurrentGroupLogId[CurrentGroup]];
         if (CurrentSession.Response == null)
         {
             IronUI.ShowMTException("No Set-Cookie headers in the Response");
         }
         else
         {
             CookieStore.AddToStore(CurrentSession.Request, CurrentSession.Response);
         }
     }
     catch (Exception Exp)
     {
         IronUI.ShowMTException("Error reading cookies from the Response");
         IronException.Report("Error reading cookies from the Manual Testing Response", Exp);
     }
 }
Esempio n. 6
0
 internal static void UpdateRequestFromCookieStore()
 {
     try
     {
         if (ManualTesting.CurrentRequest == null)
         {
             IronUI.ShowMTException("No valid Request found");
         }
         else
         {
             Request NewRequest = ManualTesting.CurrentRequest.GetClone();
             CookieStore.ReadFromStore(NewRequest);
             IronUI.ResetMTDisplayFields();
             IronUI.FillMTFields(NewRequest);
         }
     }
     catch
     {
         IronUI.ShowMTException("No valid Request found");
     }
 }
Esempio n. 7
0
        public static List <Request> GetFormSubmissions(Request Req, Response Res, CookieStore Cookies)
        {
            List <Request>  FormSubmissions = new List <Request>();
            List <HtmlNode> FormNodes       = Res.Html.GetForms();

            foreach (HtmlNode FormNode in FormNodes)
            {
                Request SubReq = Req.GetClone();
                SubReq.Method     = "GET";
                SubReq.BodyString = "";

                foreach (HtmlAttribute Attr in FormNode.Attributes)
                {
                    if (Attr.Name.Equals("method"))
                    {
                        SubReq.Method = Attr.Value.ToUpper();
                    }
                    else if (Attr.Name.Equals("action"))
                    {
                        if (Attr.Value.StartsWith("javascript:"))
                        {
                            continue;
                        }
                        string ActionUrl = NormalizeUrl(Req, Tools.HtmlDecode(Attr.Value.Trim()));
                        if (ActionUrl.Length > 0)
                        {
                            SubReq.FullUrl = ActionUrl;
                        }
                    }
                }

                if (SubReq.Method == "GET")
                {
                    SubReq.Query.RemoveAll();
                }
                else
                {
                    SubReq.Headers.Set("Content-Type", "application/x-www-form-urlencoded");
                }

                foreach (HtmlNode InputNode in FormNode.ChildNodes)
                {
                    string Name  = "";
                    string Value = "";
                    foreach (HtmlAttribute Attr in InputNode.Attributes)
                    {
                        switch (Attr.Name)
                        {
                        case ("name"):
                            Name = Attr.Value;
                            break;

                        case ("type"):
                            if (Attr.Value.Equals("submit"))
                            {
                                Name = "";
                            }
                            break;

                        case ("value"):
                            Value = Attr.Value;
                            break;
                        }
                    }
                    if (Value.Length == 0)
                    {
                        Value = Tools.GetRandomString(2, 5);
                    }
                    if (Name.Length > 0)
                    {
                        if (SubReq.Method.Equals("GET"))
                        {
                            SubReq.Query.Add(Name, Value);
                        }
                        else
                        {
                            SubReq.Body.Add(Name, Value);
                        }
                    }
                }
                SubReq.SetCookie(Cookies);
                FormSubmissions.Add(SubReq);
            }
            return(FormSubmissions);
        }
Esempio n. 8
0
        public static List<Request> GetFormSubmissions(Request Req, Response Res, CookieStore Cookies)
        {
            List<Request> FormSubmissions = new List<Request>();
            List<HtmlNode> FormNodes = Res.Html.GetForms();
            foreach (HtmlNode FormNode in FormNodes)
            {
                Request SubReq = Req.GetClone();
                SubReq.Method = "GET";
                SubReq.BodyString = "";

                foreach (HtmlAttribute Attr in FormNode.Attributes)
                {
                    if (Attr.Name.Equals("method"))
                    {
                        SubReq.Method = Attr.Value.ToUpper();
                    }
                    else if(Attr.Name.Equals("action"))
                    {
                        if (Attr.Value.StartsWith("javascript:")) continue;
                        string ActionUrl = NormalizeUrl(Req, Tools.HtmlDecode(Attr.Value.Trim()));
                        if (ActionUrl.Length > 0)
                        {
                            SubReq.FullUrl = ActionUrl;
                        }
                    }
                }

                if (SubReq.Method == "GET")
                {
                    SubReq.Query.RemoveAll();
                }
                else
                {
                    SubReq.Headers.Set("Content-Type", "application/x-www-form-urlencoded");
                }

                foreach (HtmlNode InputNode in FormNode.ChildNodes)
                {
                    string Name = "";
                    string Value = "";
                    foreach (HtmlAttribute Attr in InputNode.Attributes)
                    {
                        switch(Attr.Name)
                        {
                            case("name"):
                                Name = Attr.Value;
                                break;
                            case("type"):
                                if(Attr.Value.Equals("submit")) Name = "";
                                break;
                            case("value"):
                                Value = Attr.Value;
                                break;
                        }
                    }
                    if (Value.Length == 0)
                    {
                        Value = Tools.GetRandomString(2,5);
                    }
                    if (Name.Length > 0)
                    {
                        if (SubReq.Method.Equals("GET"))
                            SubReq.Query.Add(Name, Value);
                        else
                            SubReq.Body.Add(Name, Value);
                    }
                }
                SubReq.SetCookie(Cookies);
                FormSubmissions.Add(SubReq);
            }
            return FormSubmissions;
        }
Esempio n. 9
0
 public static List<Request> GetRedirects(Request Req, Response Res, CookieStore Cookies)
 {
     List<Request> Redirects = new List<Request>();
     List<string> RedirectUrls = GetRedirectUrls(Req, Res);
     foreach (string RedirectUrl in RedirectUrls)
     {
         try
         {
             Request RedirectReq = new Request(RedirectUrl);
             RedirectReq.SetCookie(Cookies);
             Redirects.Add(RedirectReq);
         }
         catch { }
     }
     return Redirects;
 }
Esempio n. 10
0
 static List <Request> GetFormSubmissions(Request Req, Response Res, CookieStore Cookies)
 {
     return(GetFormSubmissionsByType(Req, Res, Cookies, false));
 }
Esempio n. 11
0
        public static Request GetFormSubmission(Request Req, HtmlNode FormNode, CookieStore Cookies, bool LoginFormOnly, bool FillEmptyFields)
        {
            //Login request signatures:
            //form must have one password type input field
            //three or more parameters must be present in the request query/body

            Request SubReq = Req.GetClone();

            SubReq.Method     = "GET";
            SubReq.BodyString = "";

            foreach (HtmlAttribute Attr in FormNode.Attributes)
            {
                if (Attr.Name.Equals("method"))
                {
                    SubReq.Method = Attr.Value.ToUpper();
                }
                else if (Attr.Name.Equals("action"))
                {
                    if (Attr.Value.StartsWith("javascript:"))
                    {
                        continue;
                    }
                    string ActionUrl = NormalizeUrl(Req, Tools.HtmlDecode(Attr.Value.Trim()));
                    if (ActionUrl.Length > 0)
                    {
                        SubReq.FullUrl = ActionUrl;
                    }
                }
            }

            if (SubReq.Method == "GET")
            {
                SubReq.Query.RemoveAll();
            }
            else
            {
                SubReq.Headers.Set("Content-Type", "application/x-www-form-urlencoded");
            }

            bool PasswordFieldPresent = false;

            foreach (HtmlNode InputNode in FormNode.ChildNodes)
            {
                string Name  = "";
                string Value = "";

                foreach (HtmlAttribute Attr in InputNode.Attributes)
                {
                    switch (Attr.Name)
                    {
                    case ("name"):
                        Name = Attr.Value;
                        break;

                    case ("type"):
                        if (Attr.Value.Equals("password", StringComparison.OrdinalIgnoreCase))
                        {
                            PasswordFieldPresent = true;
                        }
                        break;

                    case ("value"):
                        Value = Attr.Value;
                        break;
                    }
                }
                if (FillEmptyFields && Value.Length == 0)
                {
                    Value = Tools.GetRandomString(2, 5);
                }
                if (Name.Length > 0)
                {
                    if (SubReq.Method.Equals("GET"))
                    {
                        SubReq.Query.Add(Name, Value);
                    }
                    else
                    {
                        SubReq.Body.Add(Name, Value);
                    }
                }
            }
            SubReq.SetCookie(Cookies);
            if (LoginFormOnly)
            {
                if (PasswordFieldPresent)
                {
                    if ((SubReq.Method.Equals("GET", StringComparison.OrdinalIgnoreCase) && SubReq.Query.Count >= 3) || (SubReq.Method.Equals("POST", StringComparison.OrdinalIgnoreCase) && SubReq.Body.Count >= 3))
                    {
                        return(SubReq);
                    }
                }
            }
            else
            {
                return(SubReq);
            }
            return(null);
        }
Esempio n. 12
0
 public static Request GetFormSubmissionWithActualValue(Request Req, HtmlNode FormNode, CookieStore Cookies)
 {
     return(GetFormSubmission(Req, FormNode, Cookies, false, false));
 }
Esempio n. 13
0
 static Request GetFormSubmission(Request Req, HtmlNode FormNode, CookieStore Cookies, bool LoginFormOnly)
 {
     return(GetFormSubmission(Req, FormNode, Cookies, LoginFormOnly, true));
 }
Esempio n. 14
0
 static Request GetFormSubmission(Request Req, HtmlNode FormNode, CookieStore Cookies)
 {
     return(GetFormSubmission(Req, FormNode, Cookies, false));
 }
Esempio n. 15
0
 public static List <Request> GetFormSubmissionsWithActualValue(Request Req, Response Res, CookieStore Cookies)
 {
     return(GetFormSubmissionsByType(Req, Res, Cookies, false));
 }
Esempio n. 16
0
 public void SetCookie(CookieStore Store)
 {
     foreach (SetCookie SC in Store.GetCookies(this))
     {
         this.Cookie.Set(SC.Name, SC.Value);
     }
 }
Esempio n. 17
0
 public static List<Request> GetLinkClicks(Request Req, Response Res, CookieStore Cookies)
 {
     List<Request> LinkClicks = new List<Request>();
     List<string> Links = GetLinks(Req, Res);
     foreach (string Link in Links)
     {
         try
         {
             Request LinkReq = new Request(Link);
             LinkReq.SetCookie(Cookies);
             LinkClicks.Add(LinkReq);
         }
         catch { }
     }
     return LinkClicks;
 }