This site requires JavaScript, please enable it in your browser!
Greenfoot back
GreenAnthony
GreenAnthony wrote ...

2014/3/8

Brute-Force tool

GreenAnthony GreenAnthony

2014/3/8

#
Hi, I have kinda forgotten many of my passwords... Not only for word documents but also for websites, I mean I could get password recovery tools and I could use the "forgot passwords" button on most of the websites... However I was wondering if you could program a brute-force (or directory tool). I mean it seems like you can't as Greenfoot is a game making tool, but I'm not sure... So can you? If yes what coding would you need??
danpost danpost

2014/3/8

#
You can. However, you would have to program it so only you could use it. And you would still need to remember your Greenfoot login password.
GreenAnthony GreenAnthony

2014/3/8

#
I wrote an algorithm for it, didn't test it yet... Do you think this will work?
import java.util.Arrays;

public class BruteForce {

  final int min;
  final int max;
  final int stringLength;

  /**
   */
  private final int[] chars;

  public BruteForce(char min, char max, int len) {
    this.min = min;
    this.max = max;
    this.stringLength = len;

    chars = new int[stringLength + 1];
    Arrays.fill(chars, 1, chars.length, min);
  }

  public void run() {
    while (chars[0] == 0) {
      print();
      increment();
    }
  }

  private void increment() {
    for (int i = chars.length - 1; i >= 0; i--) {
      if (chars[i] < max) {
        chars[i]++;
        return;
      }
      chars[i] = min;
    }
  }

  private void print() {
    for (int i = 1; i < chars.length; i++) {
      System.out.print((char) chars[i]);
    }
    System.out.println();
  }

  public static void main(String[] args) {
    new BruteForce('a', 'z', 4).run();
  }

}
If not, what should I change about it?
danpost danpost

2014/3/8

#
I think I might have mis-understood what you meant by a Brute Force tool. It may be possible, but I think there would be a whole lot more to consider when programming one than just trying combintations. Also, the keystrokes will probably need to be artificially created as printing them does not input them. Java does have a Robot class that, if I am not mistaken, can simulate the keyboard input.
GreenAnthony GreenAnthony

2014/3/9

#
Anyways, I tried the code I wrote in real Java programing (not Eclipse but notepad) and it worked, however it doesn't select a file.... Meaning it runs in cmd and shows everything it tries however it doesn't recover any passwords as it doesn't know where to type everything into... How can I fix that??
You need to login to post a reply.