Робот класс java не пишет - PullRequest
       39

Робот класс java не пишет

0 голосов
/ 22 февраля 2020

Итак, я пытался запрограммировать взломщик паролей. Для этого я использовал класс java .awt.robot, но он не работает должным образом, и я не могу понять, почему.

Я уверен, что это не так лучший код, который я мог бы сделать для этого, но я не мог понять, как еще это сделать. Я надеюсь, вы даже понимаете код ^^: Основной класс:

import java.awt.event.KeyEvent;
import java.lang.Thread;


public class AutoClickerMain {

    public static void main(String[] args) {

        try {
            Thread.sleep(3000);
        } catch(Exception e)
        {
            e.printStackTrace();
        }
        AutoClicker clicker=new AutoClicker();

        clicker.bruteForce();
        System.out.println("Autoclicker complete");
        }
    }

Класс, используемый для атаки методом грубой силы:

import java.awt.Robot; 

public class AutoClicker
{
    private Robot robot;
    private int[] check=new int[8];
    private boolean[] check1=new boolean[8];

    liner []line=new liner[8];

    public AutoClicker()
    {
     for(int i=0; i<check1.length; i++)
     {
         check1[i]=false;
     }
     try {
        robot=new Robot(); 
    } catch(Exception e)
     {
        e.printStackTrace();
     }
     try {
         for(int i=0; i<line.length; i++)
         {
             line[i]=new liner();
         }
     } catch(Exception e)
     {
         e.printStackTrace();
     }
    }

    public void bruteForce()
    {
        line[0].check=true;

        for(int i=0; i<line[0].keycode.length*2; i++)
        {
            if(line[0].mode=false)
            {
                line[0].line();
                robot.keyPress(line[0].realkeycode);
                robot.delay(10);
                robot.keyRelease(line[0].realkeycode);
                robot.delay(10);
                line[0].counter=line[0].counter+1;
                line[0].arrayposition=line[0].arrayposition+1;
                robot.keyPress(10);
                robot.delay(10);
                robot.keyPress(10);
            }
            else
            {
                line[0].line();
                robot.keyPress(16);
                robot.delay(10);
                robot.keyPress(line[0].realkeycode);
                robot.delay(10);
                robot.keyRelease(line[0].realkeycode);
                robot.keyRelease(16);
                robot.delay(10);
                line[0].counter=line[0].counter+1;
                line[0].arrayposition=line[0].arrayposition+1;
                robot.keyPress(10);
                robot.delay(10);
                robot.keyRelease(10);
            }
        }
    }
}

И линия класса, которая используется написать одну из изменяющихся букв:


public class liner {
public int [] keycode= {32, 44, 45, 46, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 110};
public boolean check=false;    //used to see if the line is activated
public boolean check2;
public int realkeycode=0;       //actual keycode (easier to use)
public int arrayposition=0; //used to change the number real keycode has
public int counter;
boolean mode=false;

public void line()
{   
    if(check==false)   //presses tab until activated
    {
        realkeycode=9;
    }
    else        //line gets activated
    {
        while(arrayposition<=keycode.length)
        {
            realkeycode=keycode[arrayposition];//presses every sign/number/letter
        }
        if(arrayposition>=keycode.length)
        {
            arrayposition=0;
        }
    }

    for(int i=0; i<keycode.length; i++)
    {
        if(counter==keycode.length)
        {
            mode=true;
        }
        if(counter==keycode.length*2)
        {
            counter=0;
            check2=true;
            arrayposition=0;
            mode=false;
        }
    }
}
}

Что должно произойти при компиляции и запуске этого кода, так это то, что робот должен написать каждую букву / число / знак один раз, затем написать их снова, нажимая Shift, а затем стоп. Но робот, похоже, ничего не пишет, и я понятия не имею, почему. Любая помощь будет оценена :)

...