import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.ObjectOutputStream; import java.io.ObjectInputStream; public class Cracker { // Password variables private int[] status; // Current password pointers final int DUMP_MAX = 10000; // Max. amount of passwords in memory before clearing & dumping // NOTE: DUMP_MAX can be changed between batches! private String[] tried = new String[DUMP_MAX]; // Passwords tried. private int current = 0; // Current step private int max = 22; // Max. password length // Teriminal command variables private Process p; private int step = 0; private int batch = 0; // Streams private BufferedReader stdInput; //private BufferedReader stdError; private FileInputStream fin; private FileOutputStream fout; private ObjectOutputStream oo; private ObjectInputStream oi; private final String STATUS = "status.dat"; char[] canUse = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z', // 26 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z', // 52 '0','1','2','3','4','5','6','7','8','9', // 62 ' ','~','`','!','@','#','$','%','^','&','*','-','=','+','_' // 77 }; // Characters to use for making up a password private int maxStat = canUse.length; /** * @param args */ public static void main(String[] args) { Cracker c = new Cracker(); c.PrepareCharacters(); c.Crack(); System.exit(0); } public void Crack() { boolean result = false; String passWord = ""; while(!result) { passWord = GetPassWord(); if(current>=DUMP_MAX) { DumpTried(tried, batch); DumpStatus(); batch++; // Batch counter current=0; tried = new String[DUMP_MAX]; System.out.println(); } tried[current++] = passWord; result = TryPassword(passWord); } System.out.println(); DumpTried(tried, batch); if(result) { System.out.println("IS> " + passWord); } else { System.out.println("Huh? options depleted and no password found. That sucks...."); } System.out.println("Done!"); } private String GetPassWord() { int carry = 1; int tmp; for(int i=max-1; i>=0 && carry==1; i--) { tmp = status[i] + 1; status[i] = tmp % maxStat; carry = tmp/maxStat; } step++; String result = ""; for(int i=0;i=0) s += canUse[i]; } System.out.format("- Starting with: '%s'\n\n", s); } catch(Exception ioe) { System.err.format("Cannot restore status: %s\n%s\n", ioe.getMessage(), ioe.getStackTrace()); } finally { try { if(oo!=null) { oo.flush(); oo.close(); } if(fout!=null) { fout.flush(); fout.close(); } } catch(IOException ioe) { System.err.println("Cannot close stream: " + ioe.getMessage()); } } } }