This forum is in archive mode. You will not be able to post new content.

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - WizZ

Pages: [1]
1
Scripting Languages / [Java] MD5 BruteForcer
« on: October 23, 2010, 07:27:50 PM »
I Do Not Take Any Responsibility For The Effects Of This Source.
Code: [Select]
import java.security.*;
import java.util.*;

public class BruteForcer implements Runnable{

    public static String currentCombo;
    public static String encryptedCombo;
    public static String encryptedWord;
    public static int wordLength;
    public static int char1, char2, char3, char4, char5;

    public static char Char[] = { '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', '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', '0', '1', '2', '3',
                '4', '5', '6', '7', '8', '9'
    };

    public BruteForcer() {}

    public void run() {
        Scanner sc = new Scanner(System.in);
        System.out.println("Encrypted Word:");
        encryptedWord = sc.nextLine();
        resetChars();
        wordLength = 1;
        Decrypt(encryptedWord);
    }

    public static boolean compareDigestedMsg(String s1, String s2) {
        if(s1.contains(s2))
            return true;
        else
            return false;
    }

    public static void resetChars() {
        char1 = 0;
        char2 = 0;
        char3 = 0;
        char4 = 0;
        char5 = 0;
    }

    public static String DigestMsg(String s) {
        byte[] defaultBytes = s.getBytes();
        try {
            MessageDigest algorithm = MessageDigest.getInstance("MD5");
            algorithm.reset();
            algorithm.update(defaultBytes);
            byte messageDigest[] = algorithm.digest();
           
            StringBuffer hexString = new StringBuffer();

            for (int i = 0; i < messageDigest.length; i++) {
                hexString.append(Integer.toHexString(0xFF & messageDigest[i]));
            }

            s = hexString + "";
        } catch(NoSuchAlgorithmException e) {
                    e.printStackTrace();
        }
        return s;
    }

    public static void Decrypt(String s) {
        int i = 0;
        switch(wordLength) {
            case 1:
                for(i = 0; i < 62; i++) {
                    currentCombo = "" + Char[i];

                    if(compareDigestedMsg(s, DigestMsg(currentCombo))) {
                        System.out.println("[MATCH FOUND!] Combonation: " + currentCombo);                        wordLength = 1;
                        break;
                    }
                }
                if(!compareDigestedMsg(s, DigestMsg(currentCombo))) {
                    System.out.println("[WORD LENGTH: " + wordLength + "] has been processed: NO MATCHES!");
                    wordLength++;
                    Decrypt(encryptedWord);
                }
            break;

            case 2:
                resetChars();
                for(i = 0; i < 3844; i++) {

                    char2 = i % 62;

                    if(char2 == 0) {
                        if(i > 0)
                            char1++;
                    }

                    currentCombo = "" + Char[char1] + Char[char2];

                    if(compareDigestedMsg(s, DigestMsg(currentCombo))) {
                        System.out.println("[MATCH FOUND!] Combonation: " + currentCombo);
                        wordLength = 1;
                        break;
                    }
                }
                if(!compareDigestedMsg(s, DigestMsg(currentCombo))) {
                    System.out.println("[WORD LENGTH: " + wordLength + "] has been processed: NO MATCHES!");
                    wordLength++;
                    Decrypt(encryptedWord);
                }   
            break;

            case 3:
                resetChars();
               
                for(i = 0; i < 238328; i++) {
                    char3 = i % 62;

                    if(char3 == 0) {
                        if(i > 0) {
                            if(char2 < 61){
                                char2++;
                                if(Char[char2] == '9' && Char[char1] != '9')
                                    char1++;
                            } else {
                                char2 = 0;
                            }
                        }
                    }

                    currentCombo = "" + Char[char1] + Char[char2] + Char[char3];

                    if(compareDigestedMsg(s, DigestMsg(currentCombo))) {
                        System.out.println("[MATCH FOUND!] Combonation: " + currentCombo);
                        wordLength = 1;
                        break;
                    }
                }
                if(!compareDigestedMsg(s, DigestMsg(currentCombo))) {
                    System.out.println("[WORD LENGTH: " + wordLength + "] has been processed: NO MATCHES!");
                    wordLength++;
                    Decrypt(encryptedWord);
                }
            break;

            case 4:
                resetChars();
               
                for(i = 0; i < 14776336; i++) {
                    char4 = i % 62;

                    if(char4 == 0) {
                        if(i > 0) {
                            if(char3 < 61) {
                                char3++;
                                if(Char[char2] == '9')
                                    char2 = 0;
                                if(Char[char3] == '9' && Char[char2] != '9')
                                    char2++;
                                if(Char[char2] == '9' && Char[char1] != '9')
                                    char1++;
                            } else {
                                char3 = 0;
                            }
                        }
                    }

                    currentCombo = "" + Char[char1] + Char[char2] + Char[char3] + Char[char4];

                    if(compareDigestedMsg(s, DigestMsg(currentCombo))) {
                        System.out.println("[MATCH FOUND!] Combonation: " + currentCombo);
                        wordLength = 1;
                        break;
                    }
                }
                if(!compareDigestedMsg(s, DigestMsg(currentCombo))) {
                    System.out.println("[WORD LENGTH: " + wordLength + "] has been processed: NO MATCHES!");
                    wordLength++;
                    Decrypt(encryptedWord);
                }
            break;

            case 5:
                resetChars();
               
                for(i = 0; i < 916132832; i++) {
                    char5 = i % 62;

                    if(char5 == 0) {
                        if(i > 0) {
                            if(char4 < 61) {
                                char4++;
                                if(Char[char2] == '9')
                                    char2 = 0;
                                if(Char[char3] == '9')
                                    char3 = 0;
                                if(Char[char4] == '9' && Char[char3] != '9')
                                    char3++;
                                if(Char[char3] == '9' && Char[char2] != '9')
                                    char2++;
                                if(Char[char2] == '9' && Char[char1] != '9')
                                    char1++;
                            } else {
                                char4 = 0;
                            }
                        }
                    }

                    currentCombo = "" + Char[char1] + Char[char2] + Char[char3] + Char[char4];

                    if(compareDigestedMsg(s, DigestMsg(currentCombo))) {
                        System.out.println("[MATCH FOUND!] Combonation: " + currentCombo);
                        wordLength = 1;
                        break;
                    }
                }
                if(!compareDigestedMsg(s, DigestMsg(currentCombo))) {
                    System.out.println("[WORD LENGTH: " + wordLength + "] has been processed: NO MATCHES!");
                    wordLength++;
                    Decrypt(encryptedWord);
                }
            break;
        }
    }
    public static void main(String[] args) {
        BruteForcer bf = new BruteForcer();
        new Thread(bf).start();
        while(true) {}
    }
}

Pages: [1]


Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.