public void SetUp()
 {
     _driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
     _driver.Manage().Window.Maximize();
     pageHTML           = new PageHTML(_driver);
     pageRuby           = new PageRuby(_driver);
     shoppingBasketPage = new ShoppingBasket(_driver);
     pageJavaScript     = new PageJavaScript(_driver);
     practiceHomePage   = new PracticeHomePage(_driver);
     practiceHomePage.NavigateTo("http://practice.automationtesting.in/");
     javaScript = (IJavaScriptExecutor)_driver;
 }
예제 #2
0
        private void WriteFragmented(Report report, IScanRunner Sender)
        {
            if (report.Events.Count > 0)
            {
                string output = "";

                //Found a malicious string
                foreach (Event ev in report.Events)
                {
                    output += "<div class=\"result\"><h3>found fragmented injection: </h3></div>";
                    //output += "<div class=\"value\">value: " + Server.HtmlEncode(ev.Value) + "</div>";
                    int impact = 0;

                    foreach (Filter f in ev.Filters)
                    {
                        impact += f.Impact;

                        if (f.Rule.Length > 60)
                        {
                            output += "<div class=\"result\">rule: " + Server.HtmlEncode(f.Rule.Substring(0, 60)) + "...<br />rule-description: <i>" + Server.HtmlEncode(f.Description) + "</i><br />impact: " + f.Impact + "</div>";
                        }
                        else
                        {
                            output += "<div class=\"result\">rule: " + Server.HtmlEncode(f.Rule) + "<br />rule-description: <i>" + Server.HtmlEncode(f.Description) + "</i><br />impact: " + f.Impact + "</div>";
                        }
                    }

                    output += "<div class=\"result\"><h3>Overall impact: <strong style=\"color:red;\">" + ev.Impact + "</strong></h3></div>";
                }

                if (_replace != string.Empty)
                {
                    string newoutput = PageHTML.Replace(_replace, output);
                    Sender.WriteResponse(newoutput);
                }
                else
                {
                    Sender.WriteResponse();
                }
            }
        }
예제 #3
0
        public static object Request(webTask task)
        {
            String Host     = task.URL;
            String Referer  = task.URL;
            String POSTData = null;

            if (!task.retainCookies)
            {
                Cookies = new CookieContainer();
            }

            if (task.POSTData == null)
            {
                _Method = "GET";
            }
            else
            {
                _Method  = "POST";
                POSTData = (String)task.POSTData;
            }

            try
            {
                HttpWebRequest WebR = (HttpWebRequest)WebRequest.Create(Host);

                WebR.Method            = _Method;
                WebR.CookieContainer   = Cookies;
                WebR.AllowAutoRedirect = _AllowAutoRedirect;
                WebR.KeepAlive         = _KeepAlive;
                WebR.UserAgent         = _UserAgent;
                WebR.ContentType       = "application/x-www-form-urlencoded";
                WebR.Referer           = Referer;

                if ((_Method == "POST"))
                {
                    byte[] _PostData = null;
                    _PostData          = System.Text.Encoding.Default.GetBytes(POSTData);
                    WebR.ContentLength = _PostData.Length;

                    System.IO.Stream StreamWriter = WebR.GetRequestStream();
                    StreamWriter.Write(_PostData, 0, POSTData.Length);
                    StreamWriter.Dispose();
                }

                HttpWebResponse WebResponse;
                string          PageHTML;

                try
                {
                    WebResponse = (HttpWebResponse)WebR.GetResponse();
                    Cookies.Add(WebResponse.Cookies);
                    System.IO.StreamReader StreamReader = new System.IO.StreamReader(WebResponse.GetResponseStream());
                    PageHTML = StreamReader.ReadToEnd();
                }
                catch (WebException e)
                {
                    WebResponse response = e.Response;
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()))
                    {
                        PageHTML = reader.ReadToEnd();
                    }
                }

                String pageTitle = System.Text.RegularExpressions.Regex.Match(PageHTML, @"<title>(.*<)/title>").Groups[1].ToString();

                if (task.exportCookies)
                {
                    try
                    {
                        CookieCollection toExport = Cookies.GetCookies(new Uri(task.URL));
                        foreach (Cookie toOutput in toExport)
                        {
                            System.IO.File.AppendAllText(System.IO.Directory.GetCurrentDirectory() + @"\" + pageTitle + @" - Cookies.txt", toOutput.ToString() + "\r\n");
                        }
                    }catch (Exception ex)
                    {
                        System.IO.File.WriteAllText(System.IO.Directory.GetCurrentDirectory() + @"\" + pageTitle + @" - Cookies.txt", ex.Message);
                    }
                }

                if (task.outputSource)
                {
                    if (PageHTML.Contains("<title> myicard.net Select</title>"))
                    {
                        return(PageHTML);
                    }
                    else
                    {
                        return(null);
                    }
                }
                return(null);
            }
            catch (Exception ex)
            {
                Console.WriteLine(String.Format("WebRequest exited with error: {0}", ex.Message));
                return(null);
            }
        }
예제 #4
0
        // Modified version of my WebRequest Wrapper
        public static object Request(checkConfig.checkConf Config, String Name)
        {
            String Host          = Config.URL.Replace("%user%", Name);
            String Referer       = Config.URL;
            String POSTData      = null;
            String SuccessString = null;
            String FailString    = null;

            if (Config.POSTData == null)
            {
                _Method = "GET";
            }
            else
            {
                _Method  = "POST";
                POSTData = Config.POSTData.Replace("%user%", Name);
            }
            if (Config.SuccessString != null)
            {
                SuccessString = Config.SuccessString.Replace("%user%", Name);
            }
            if (Config.FailString != null)
            {
                FailString = Config.FailString.Replace("%user%", Name);
            }

            try
            {
                HttpWebRequest WebR = (HttpWebRequest)WebRequest.Create(Host);

                WebR.Method            = _Method;
                WebR.CookieContainer   = Cookies;
                WebR.AllowAutoRedirect = _AllowAutoRedirect;
                WebR.KeepAlive         = _KeepAlive;
                WebR.UserAgent         = _UserAgent;
                WebR.ContentType       = "application/x-www-form-urlencoded";
                WebR.Referer           = Referer;

                if ((_Method == "POST"))
                {
                    byte[] _PostData = null;
                    _PostData          = System.Text.Encoding.Default.GetBytes(POSTData);
                    WebR.ContentLength = _PostData.Length;

                    System.IO.Stream StreamWriter = WebR.GetRequestStream();
                    StreamWriter.Write(_PostData, 0, POSTData.Length);
                    StreamWriter.Dispose();
                }

                HttpWebResponse WebResponse;
                string          PageHTML;

                try
                {
                    WebResponse = (HttpWebResponse)WebR.GetResponse();
                    Cookies.Add(WebResponse.Cookies);
                    System.IO.StreamReader StreamReader = new System.IO.StreamReader(WebResponse.GetResponseStream());
                    PageHTML = StreamReader.ReadToEnd();
                }
                catch (WebException e)
                {
                    if (Config.successOn404)
                    {
                        return(true);
                    }
                    WebResponse response = e.Response;
                    using (System.IO.StreamReader reader = new System.IO.StreamReader(response.GetResponseStream()))
                    {
                        PageHTML = reader.ReadToEnd();
                    }
                }

                if (SuccessString != null)
                {
                    if (PageHTML.ToLower().Contains(SuccessString.ToLower()))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else if (FailString != null)
                {
                    if (!PageHTML.ToLower().Contains(FailString.ToLower()))
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                return(false);
            }
            catch (Exception ex)
            {
                eventLogger.logEvent(String.Format("{0} - {1} [{2}] | {3}", ex.Message, "WebRequest Wrapper", ex.StackTrace, ex.TargetSite));
                return(Config.successOn404);
            }
        }