コード例 #1
0
ファイル: Request.cs プロジェクト: melagiri/IronWASP
 public void SetCookie(CookieStore Store)
 {
     foreach (SetCookie SC in Store.GetCookies(this))
     {
         this.Cookie.Set(SC.Name, SC.Value);
     }
 }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
     }
 }
コード例 #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");
     }
 }
コード例 #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);
        }
コード例 #8
0
ファイル: Crawler.cs プロジェクト: mskr30/IronWASP
        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;
        }
コード例 #9
0
ファイル: Crawler.cs プロジェクト: mskr30/IronWASP
 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;
 }
コード例 #10
0
 static List <Request> GetFormSubmissions(Request Req, Response Res, CookieStore Cookies)
 {
     return(GetFormSubmissionsByType(Req, Res, Cookies, false));
 }
コード例 #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);
        }
コード例 #12
0
 public static Request GetFormSubmissionWithActualValue(Request Req, HtmlNode FormNode, CookieStore Cookies)
 {
     return(GetFormSubmission(Req, FormNode, Cookies, false, false));
 }
コード例 #13
0
 static Request GetFormSubmission(Request Req, HtmlNode FormNode, CookieStore Cookies, bool LoginFormOnly)
 {
     return(GetFormSubmission(Req, FormNode, Cookies, LoginFormOnly, true));
 }
コード例 #14
0
 static Request GetFormSubmission(Request Req, HtmlNode FormNode, CookieStore Cookies)
 {
     return(GetFormSubmission(Req, FormNode, Cookies, false));
 }
コード例 #15
0
 public static List <Request> GetFormSubmissionsWithActualValue(Request Req, Response Res, CookieStore Cookies)
 {
     return(GetFormSubmissionsByType(Req, Res, Cookies, false));
 }
コード例 #16
0
ファイル: Request.cs プロジェクト: moon2l/IronWASP
 public void SetCookie(CookieStore Store)
 {
     foreach (SetCookie SC in Store.GetCookies(this))
     {
         this.Cookie.Set(SC.Name, SC.Value);
     }
 }
コード例 #17
0
ファイル: Crawler.cs プロジェクト: mskr30/IronWASP
 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;
 }