Hack Forums
[Java] Bot Automation Example using Selenium - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Java] Bot Automation Example using Selenium (/showthread.php?tid=4853435)



Bot Automation Example using Selenium - jarvur - Jun 6, 2015

Inspired by Tizen's DTG bot.

Code
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class Main {

    private static final String _URL = "http://ddosthegame.com/index.php", _USERNAME = "/*username*/", _PASSWORD = "/*password*/";

    static WebDriver driver;
    static WebElement element;

    public static final void print(final String s)
    {
        System.out.println(s);
    }

    public static void main(String[] args)
    {
        print("Connecting...");
        connect(_URL);
    }

    public static void connect(String url)
    {
        driver = new HtmlUnitDriver();
        driver.get(url);

        String userEl = "username", passEl = "password";

        print("Setting username data... (" + _USERNAME + ")");

        element = driver.findElement(By.name(userEl));
        element.sendKeys(_USERNAME);

        print("Setting password data... (" + _PASSWORD + ")");

        element = driver.findElement(By.name(passEl));
        element.sendKeys(_PASSWORD);

        print("Logging in");

        driver.findElement(By.name("login_today")).click();

        if (driver.getTitle().contains("- index"))
        {
            print("Successfully logged in!");
        }

        driver.get("http://ddosthegame.com/index.php?page=resolve");

        print(driver.getTitle());

        driver.close();
    }

    public static void resolveBot(String username, int amount)
    {
        print("Resolving " + username + " for " + amount + "times");
        for (int i = 0; i < 100; i++)
        {
            element = driver.findElement(By.name("userid"));    
            element.sendKeys(username);
            driver.findElement(By.name("resolve_user")).click();
        }
    }



* - Fractal - Jun 7, 2015

Nice, never thought of using Selenium for anything other than testing. Which is stupid really considering we're on a Hacking related forum, lol.


RE: Bot Automation Example using Selenium - Nemo2478 - Aug 2, 2019

Hello jarvur,

resolveBot never seems to be used.

Regards