Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


[JAVA] HC Hash Cracker filter_list
Author
Message
[JAVA] HC Hash Cracker #1
So this is an open source Java program which can be used to crack hashes which have been digested using one of the following algorithms :
  • MD2
  • MD5
  • SHA-1
  • SHA-256
  • SHA-384
  • SHA-512

Two types of attacks are supported currently which is Brute Force attack and Word List attack. I'd like to thank Deque because I've used her algorithm for brute forcing in this code.

Screen Shots :
[Image: HC1.jpg]

[Image: HC2.jpg]

[Image: HC3.jpg]

[Image: HC4.jpg]


Source Code

HCHashCracker.java
Code:
/**
* HC Hash Cracker
* Made By : Solixious Klein
*/
import javax.swing.*;
import java.awt.event.*;
public class HCHashCracker extends JFrame implements ItemListener,ActionListener
{
    private static final long serialVersionUID = 1L;
    JLabel hashLabel,wordListLabel,algoLabel,maxWordLengthLabel,attackStateLabel;
    JTextField hashTextField,wordListAddressTextField,maxWordLengthTextField;
    ButtonGroup attackTypeButtonGroup;
    JRadioButton bruteForceRadioButton,wordListRadioButton;
    JCheckBox capitalAlphabetsCheckBox,smallAlphabetsCheckBox,numbersCheckBox,specialCharactersCheckBox;
    JButton browseWordListButton;
    JButton startButton,pauseButton,stopButton;
    boolean scanStatus=false,isPaused=false;
    BruteForce bf;
    WordList wl;
    Thread th;
    String algo[]={"MD2","MD5","SHA-1","SHA-256","SHA-384","SHA-512"};
    JComboBox algoCombo;
    public HCHashCracker()
    {
        this.setTitle("HC Hash Cracker");
        this.setBounds(200,200,500,400);
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.setResizable(false);
        this.setLayout(null);
        
        hashLabel=new JLabel("Hash");
        hashLabel.setBounds(30,30,50,20);
        hashTextField=new JTextField(20);
        hashTextField.setBounds(80,30,370,20);
        attackTypeButtonGroup=new ButtonGroup();
        bruteForceRadioButton=new JRadioButton("Brute Force Attack");
        bruteForceRadioButton.addItemListener(this);
        bruteForceRadioButton.setBounds(30, 70, 150, 20);
        smallAlphabetsCheckBox=new JCheckBox("[ a - z ]");
        smallAlphabetsCheckBox.setBounds(200,70,65,20);
        smallAlphabetsCheckBox.setSelected(true);
        capitalAlphabetsCheckBox=new JCheckBox("[ A - Z ]");
        capitalAlphabetsCheckBox.setBounds(200,90,65,20);
        numbersCheckBox=new JCheckBox("[ 0 - 9 ]");
        numbersCheckBox.setBounds(200,110,65,20);
        specialCharactersCheckBox=new JCheckBox("Special Characters");
        specialCharactersCheckBox.setBounds(200,130,135,20);
        maxWordLengthLabel=new JLabel("Max Word Length");
        maxWordLengthLabel.setBounds(350,70,100,25);
        maxWordLengthTextField=new JTextField(20);
        maxWordLengthTextField.setBounds(350,100,100,25);
        maxWordLengthTextField.setText("7");
        wordListRadioButton=new JRadioButton("Word List Attack");
        wordListRadioButton.setBounds(30,180,150,20);
        wordListLabel=new JLabel("Word List");
        wordListLabel.setBounds(200,180,60,20);
        wordListAddressTextField=new JTextField(20);
        wordListAddressTextField.setBounds(280,180,170,20);
        browseWordListButton=new JButton("Browse");
        browseWordListButton.setBounds(280,210,80,20);
        browseWordListButton.addActionListener(this);
        attackTypeButtonGroup.add(bruteForceRadioButton);
        attackTypeButtonGroup.add(wordListRadioButton);
        bruteForceRadioButton.setSelected(true);
        algoLabel=new JLabel("Algorithm");
        algoLabel.setBounds(40,250,70,25);
        algoCombo=new JComboBox(algo);
        algoCombo.setBounds(130,250,100,25);
        attackStateLabel=new JLabel("Attack Status : Idle");
        attackStateLabel.setBounds(200,290,150,25);
        startButton=new JButton("Start");
        startButton.setBounds(100,320,100,25);
        startButton.addActionListener(this);
        pauseButton=new JButton("Pause");
        pauseButton.setBounds(200,320,100,25);
        pauseButton.addActionListener(this);
        stopButton=new JButton("Stop");
        stopButton.setBounds(300,320,100,25);
        stopButton.addActionListener(this);
        updateButtonStatus();
        
        add(hashLabel);
        add(hashTextField);
        add(bruteForceRadioButton);
        add(wordListRadioButton);
        add(smallAlphabetsCheckBox);
        add(capitalAlphabetsCheckBox);
        add(numbersCheckBox);
        add(specialCharactersCheckBox);
        add(wordListAddressTextField);
        add(browseWordListButton);
        add(wordListLabel);
        add(startButton);
        add(pauseButton);
        add(stopButton);
        add(algoCombo);
        add(algoLabel);
        add(maxWordLengthLabel);
        add(maxWordLengthTextField);
        add(attackStateLabel);
    }
    public void showDialog()
    {
        setVisible(true);
    }
    public void itemStateChanged(ItemEvent e)
    {
        updateEnableDisableState();
    }
    public void updateButtonStatus()
    {
        if(scanStatus) //if scanning is in progress
        {
            startButton.setEnabled(false);
            pauseButton.setEnabled(true);
            stopButton.setEnabled(true);
        }
        else
        {
            startButton.setEnabled(true);
            pauseButton.setEnabled(false);
            stopButton.setEnabled(false);
        }
    }
    public void updateEnableDisableState()
    {
        if(bruteForceRadioButton.isSelected())
        {
            capitalAlphabetsCheckBox.setEnabled(true);
            smallAlphabetsCheckBox.setEnabled(true);
            numbersCheckBox.setEnabled(true);
            specialCharactersCheckBox.setEnabled(true);
            maxWordLengthLabel.setEnabled(true);
            maxWordLengthTextField.setEnabled(true);
            wordListLabel.setEnabled(false);
            wordListAddressTextField.setEnabled(false);
            browseWordListButton.setEnabled(false);
        }
        else
        {
            capitalAlphabetsCheckBox.setEnabled(false);
            smallAlphabetsCheckBox.setEnabled(false);
            numbersCheckBox.setEnabled(false);
            specialCharactersCheckBox.setEnabled(false);
            maxWordLengthLabel.setEnabled(false);
            maxWordLengthTextField.setEnabled(false);
            wordListLabel.setEnabled(true);
            wordListAddressTextField.setEnabled(true);
            browseWordListButton.setEnabled(true);
            smallAlphabetsCheckBox.setSelected(false);
            capitalAlphabetsCheckBox.setSelected(false);
            numbersCheckBox.setSelected(false);
            specialCharactersCheckBox.setSelected(false);
            
        }
    }
    public void actionPerformed(ActionEvent e)
    {
        Object event=e.getSource();
        if(event==browseWordListButton)
        {
            JFileChooser fc=new JFileChooser("Open Word List");
            int response=fc.showOpenDialog(this);
            if(response==JFileChooser.APPROVE_OPTION)
            {
                String path=fc.getSelectedFile().getPath();
                wordListAddressTextField.setText(path);
            }
        }
        else if(event==startButton)
        {
            if(bruteForceRadioButton.isSelected())
            {
                if(!(smallAlphabetsCheckBox.isSelected() || capitalAlphabetsCheckBox.isSelected() || numbersCheckBox.isSelected() || specialCharactersCheckBox.isSelected()))
                    return;
                scanStatus=true;
                updateButtonStatus();
                capitalAlphabetsCheckBox.setEnabled(false);
                smallAlphabetsCheckBox.setEnabled(false);
                numbersCheckBox.setEnabled(false);
                specialCharactersCheckBox.setEnabled(false);
                maxWordLengthLabel.setEnabled(false);
                maxWordLengthTextField.setEnabled(false);
                bruteForceRadioButton.setEnabled(false);
                wordListRadioButton.setEnabled(false);
                algoLabel.setEnabled(false);
                algoCombo.setEnabled(false);
                bf=new BruteForce(this,hashTextField.getText(),(String)algoCombo.getSelectedItem(),Integer.parseInt(maxWordLengthTextField.getText()),smallAlphabetsCheckBox.isSelected(),capitalAlphabetsCheckBox.isSelected(),numbersCheckBox.isSelected(),specialCharactersCheckBox.isSelected());
                th=new Thread(bf);
                th.start();
                attackStateLabel.setText("Attack Status : Active");
            }
            else if(wordListRadioButton.isSelected())
            {
                scanStatus=true;
                updateButtonStatus();
                browseWordListButton.setEnabled(false);
                wordListAddressTextField.setEnabled(false);
                bruteForceRadioButton.setEnabled(false);
                wordListRadioButton.setEnabled(false);
                wordListLabel.setEnabled(false);
                algoLabel.setEnabled(false);
                algoCombo.setEnabled(false);
                wl=new WordList(this,hashTextField.getText(),(String)algoCombo.getSelectedItem(),wordListAddressTextField.getText());
                th=new Thread(wl);
                th.start();
            }
        }
        else if(event==pauseButton)
        {
            if(bruteForceRadioButton.isSelected())
            {
                if(isPaused)
                {
                    pauseButton.setText("Pause");
                    isPaused=false;
                    bf.setPause(false);
                    attackStateLabel.setText("Attack Status : Active");
                }
                else
                {
                    pauseButton.setText("Resume");
                    isPaused=true;
                    bf.setPause(true);
                    attackStateLabel.setText("Attack Status : Paused");
                }
            }
            else if(wordListRadioButton.isSelected())
            {
                if(isPaused)
                {
                    pauseButton.setText("Pause");
                    isPaused=false;
                    wl.setPause(false);
                    attackStateLabel.setText("Attack Status : Active");
                }
                else
                {
                    pauseButton.setText("Resume");
                    isPaused=true;
                    wl.setPause(true);
                    attackStateLabel.setText("Attack Status : Paused");
                }
            }
        }
        else if(event==stopButton)
        {
            if(bruteForceRadioButton.isSelected())
            {
                scanStatus=false;
                pauseButton.setText("Pause");
                bf.setStop(true);
                updateButtonStatus();
                capitalAlphabetsCheckBox.setEnabled(true);
                smallAlphabetsCheckBox.setEnabled(true);
                numbersCheckBox.setEnabled(true);
                specialCharactersCheckBox.setEnabled(true);
                maxWordLengthLabel.setEnabled(true);
                maxWordLengthTextField.setEnabled(true);
                bruteForceRadioButton.setEnabled(true);
                wordListRadioButton.setEnabled(true);
                algoLabel.setEnabled(true);
                algoCombo.setEnabled(true);
                attackStateLabel.setText("Attack Status : Idle");
            }
        }
        else if(wordListRadioButton.isSelected())
        {
            scanStatus=false;
            pauseButton.setText("Pause");
            wl.setStop(true);
            updateButtonStatus();
            browseWordListButton.setEnabled(true);
            wordListAddressTextField.setEnabled(true);
            bruteForceRadioButton.setEnabled(true);
            wordListRadioButton.setEnabled(true);
            wordListLabel.setEnabled(true);
            algoLabel.setEnabled(true);
            algoCombo.setEnabled(true);
            attackStateLabel.setText("Attack Status : Idle");
        }
    }
    public void matchBrute(String match)
    {
        JOptionPane.showMessageDialog(this, match,"Match Found",1);
        stopButton.setEnabled(false);
        pauseButton.setEnabled(false);
        startButton.setEnabled(true);
        smallAlphabetsCheckBox.setEnabled(true);
        capitalAlphabetsCheckBox.setEnabled(true);
        numbersCheckBox.setEnabled(true);
        specialCharactersCheckBox.setEnabled(true);
        maxWordLengthLabel.setEnabled(true);
        maxWordLengthTextField.setEnabled(true);
        bruteForceRadioButton.setEnabled(true);
        wordListRadioButton.setEnabled(true);
        algoLabel.setEnabled(true);
        algoCombo.setEnabled(true);
        attackStateLabel.setText("Attack Status : Idle");
    }
    public void matchBruteFail()
    {
        JOptionPane.showMessageDialog(this, "Brute Force Ended Unsuccessfully","Match Not Found",0);
        stopButton.setEnabled(false);
        pauseButton.setEnabled(false);
        startButton.setEnabled(true);
        smallAlphabetsCheckBox.setEnabled(true);
        capitalAlphabetsCheckBox.setEnabled(true);
        numbersCheckBox.setEnabled(true);
        specialCharactersCheckBox.setEnabled(true);
        maxWordLengthLabel.setEnabled(true);
        maxWordLengthTextField.setEnabled(true);
        bruteForceRadioButton.setEnabled(true);
        wordListRadioButton.setEnabled(true);
        algoLabel.setEnabled(true);
        algoCombo.setEnabled(true);
        attackStateLabel.setText("Attack Status : Idle");
    }
    public void matchWord(String match)
    {
        JOptionPane.showMessageDialog(this, match,"Match Found",1);
        browseWordListButton.setEnabled(true);
        wordListAddressTextField.setEnabled(true);
        bruteForceRadioButton.setEnabled(true);
        wordListRadioButton.setEnabled(true);
        algoLabel.setEnabled(true);
        algoCombo.setEnabled(true);
        wordListLabel.setEnabled(true);
        stopButton.setEnabled(false);
        pauseButton.setEnabled(false);
        startButton.setEnabled(true);
        bruteForceRadioButton.setEnabled(true);
        wordListRadioButton.setEnabled(true);
        algoLabel.setEnabled(true);
        algoCombo.setEnabled(true);
        attackStateLabel.setText("Attack Status : Idle");
    }
    public void wordNotFound()
    {
        JOptionPane.showMessageDialog(this, "Match not found using the given wordlist..","Match Not Found",0);
        browseWordListButton.setEnabled(true);
        wordListAddressTextField.setEnabled(true);
        bruteForceRadioButton.setEnabled(true);
        wordListRadioButton.setEnabled(true);
        algoLabel.setEnabled(true);
        algoCombo.setEnabled(true);
        wordListLabel.setEnabled(true);
        stopButton.setEnabled(false);
        pauseButton.setEnabled(false);
        startButton.setEnabled(true);
        bruteForceRadioButton.setEnabled(true);
        wordListRadioButton.setEnabled(true);
        algoLabel.setEnabled(true);
        algoCombo.setEnabled(true);
        attackStateLabel.setText("Attack Status : Idle");
    }
    public static void main(String args[])
    {
        new HCHashCracker().showDialog();
    }
}

BruteForce.java
Code:
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


public class BruteForce implements Runnable
{
    private char charList[];
    private String chars=" ",HASH="",ALGO="";
    private int MAXWORDLENGTH=0;
    private long MAXCOMBINATIONS=0;
    private int base=0;
    private boolean stop,pause;
    boolean found;
    String text;
    private HCHashCracker hashCracker;
    public BruteForce(HCHashCracker hah,String hash,String algorithm,int maxwordlength,boolean smallLetters,boolean capitalLetters,boolean numbers,boolean specialCharacters)
    {
        HASH=hash;
        hashCracker=hah;
        ALGO=algorithm;
        MAXWORDLENGTH=maxwordlength;
        if(smallLetters)
        {
            chars=chars+"abcdefghijklmnopqrstuvwxyz";
        }
        if(capitalLetters)
        {
            chars=chars+"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        }
        if(numbers)
        {
            chars=chars+"0123456789";
        }
        if(specialCharacters)
        {
            chars=chars+"!@#$%^&*()_+{}|:\"<>?-=[]\\;',./' ";
        }
        charList=chars.toCharArray();
        base=chars.length();
        MAXCOMBINATIONS=(long)Math.pow(base, MAXWORDLENGTH);
    }
    public void run()
    {
        found=false;
        stop=false;
        pause=false;
        for(int i=0;i<MAXCOMBINATIONS && !stop;i++)
        {
            while(pause)
                continue;
            int temp=i;
            String str="";
            while(temp>0)
            {
                str=String.valueOf(charList[(temp%base)])+str;
                temp/=base;
            }
            String h=hash(str,ALGO);
            
            if(h.equalsIgnoreCase(HASH))
            {
                hashCracker.matchBrute(str);
                return;
            }
            str="";
            if(found)
                return;
        }
        hashCracker.matchBruteFail();
    }
    public void setStop(boolean b)
    {
        stop=b;
    }
    public void setPause(boolean b)
    {
        pause=b;
    }
    public String hash(String str,String algorithm)
    {
        String h="";
        try
        {
            MessageDigest md=MessageDigest.getInstance(algorithm);
            byte[] r=md.digest(str.getBytes());
            BigInteger val=new BigInteger(1,r);
            h=val.toString(16);
        }
        catch(NoSuchAlgorithmException e)
        {
            e.printStackTrace();
        }
        return h;
    }
}

WordList.java
Code:
import java.io.*;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class WordList implements Runnable
{
    private String PATH;
    private String HASH;
    private String ALGO;
    private FileReader FILE;
    private BufferedReader BR;
    private HCHashCracker hashCracker;
    private boolean paused,stop;
    public WordList(HCHashCracker hah,String hash,String algo,String path)
    {
        hashCracker=hah;
        PATH=path;
        HASH=hash;
        ALGO=algo;
    }
    public void run()
    {
        try
        {
            FILE=new FileReader(PATH);
            BR=new BufferedReader(FILE);
            String testword="";
            String testhash="";
            paused=false;
            stop=false;
            do
            {
                while(paused)
                    continue;
                testword=BR.readLine();
                try
                {
                    if(testword.isEmpty())
                        break;
                }
                catch(NullPointerException e)
                {
                    break;
                }
                testhash=hash(testword,ALGO);
                if(testhash.equals(HASH))
                {
                    hashCracker.matchWord(testword);
                    return;
                }
            }
            while(true && !stop);
            hashCracker.wordNotFound();
        }
        catch(FileNotFoundException e)
        {
            return;
        }
        catch(IOException e)
        {
            return;
        }
    }
    public void setPause(boolean b)
    {
        paused=b;
    }
    public void setStop(boolean b)
    {
        stop=b;
    }
    public String hash(String str,String algorithm)
    {
        String h="";
        try
        {
            MessageDigest md=MessageDigest.getInstance(algorithm);
            byte[] r=md.digest(str.getBytes());
            BigInteger val=new BigInteger(1,r);
            h=val.toString(16);
        }
        catch(NoSuchAlgorithmException e)
        {
            e.printStackTrace();
        }
        return h;
    }
}

I had thought of making an HC official app of this, but I think their is already a hash cracker in the list Biggrin

Cheers Smile
Folow me on My YouTube Channel if you're into art.

Reply

[JAVA] HC Hash Cracker #2
So this is an open source Java program which can be used to crack hashes which have been digested using one of the following algorithms :
  • MD2
  • MD5
  • SHA-1
  • SHA-256
  • SHA-384
  • SHA-512

Two types of attacks are supported currently which is Brute Force attack and Word List attack. I'd like to thank Deque because I've used her algorithm for brute forcing in this code.

Screen Shots :
[Image: HC1.jpg]

[Image: HC2.jpg]

[Image: HC3.jpg]

[Image: HC4.jpg]


Source Code

HCHashCracker.java
Code:
/**
* HC Hash Cracker
* Made By : Solixious Klein
*/
import javax.swing.*;
import java.awt.event.*;
public class HCHashCracker extends JFrame implements ItemListener,ActionListener
{
    private static final long serialVersionUID = 1L;
    JLabel hashLabel,wordListLabel,algoLabel,maxWordLengthLabel,attackStateLabel;
    JTextField hashTextField,wordListAddressTextField,maxWordLengthTextField;
    ButtonGroup attackTypeButtonGroup;
    JRadioButton bruteForceRadioButton,wordListRadioButton;
    JCheckBox capitalAlphabetsCheckBox,smallAlphabetsCheckBox,numbersCheckBox,specialCharactersCheckBox;
    JButton browseWordListButton;
    JButton startButton,pauseButton,stopButton;
    boolean scanStatus=false,isPaused=false;
    BruteForce bf;
    WordList wl;
    Thread th;
    String algo[]={"MD2","MD5","SHA-1","SHA-256","SHA-384","SHA-512"};
    JComboBox algoCombo;
    public HCHashCracker()
    {
        this.setTitle("HC Hash Cracker");
        this.setBounds(200,200,500,400);
        this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
        this.setResizable(false);
        this.setLayout(null);
        
        hashLabel=new JLabel("Hash");
        hashLabel.setBounds(30,30,50,20);
        hashTextField=new JTextField(20);
        hashTextField.setBounds(80,30,370,20);
        attackTypeButtonGroup=new ButtonGroup();
        bruteForceRadioButton=new JRadioButton("Brute Force Attack");
        bruteForceRadioButton.addItemListener(this);
        bruteForceRadioButton.setBounds(30, 70, 150, 20);
        smallAlphabetsCheckBox=new JCheckBox("[ a - z ]");
        smallAlphabetsCheckBox.setBounds(200,70,65,20);
        smallAlphabetsCheckBox.setSelected(true);
        capitalAlphabetsCheckBox=new JCheckBox("[ A - Z ]");
        capitalAlphabetsCheckBox.setBounds(200,90,65,20);
        numbersCheckBox=new JCheckBox("[ 0 - 9 ]");
        numbersCheckBox.setBounds(200,110,65,20);
        specialCharactersCheckBox=new JCheckBox("Special Characters");
        specialCharactersCheckBox.setBounds(200,130,135,20);
        maxWordLengthLabel=new JLabel("Max Word Length");
        maxWordLengthLabel.setBounds(350,70,100,25);
        maxWordLengthTextField=new JTextField(20);
        maxWordLengthTextField.setBounds(350,100,100,25);
        maxWordLengthTextField.setText("7");
        wordListRadioButton=new JRadioButton("Word List Attack");
        wordListRadioButton.setBounds(30,180,150,20);
        wordListLabel=new JLabel("Word List");
        wordListLabel.setBounds(200,180,60,20);
        wordListAddressTextField=new JTextField(20);
        wordListAddressTextField.setBounds(280,180,170,20);
        browseWordListButton=new JButton("Browse");
        browseWordListButton.setBounds(280,210,80,20);
        browseWordListButton.addActionListener(this);
        attackTypeButtonGroup.add(bruteForceRadioButton);
        attackTypeButtonGroup.add(wordListRadioButton);
        bruteForceRadioButton.setSelected(true);
        algoLabel=new JLabel("Algorithm");
        algoLabel.setBounds(40,250,70,25);
        algoCombo=new JComboBox(algo);
        algoCombo.setBounds(130,250,100,25);
        attackStateLabel=new JLabel("Attack Status : Idle");
        attackStateLabel.setBounds(200,290,150,25);
        startButton=new JButton("Start");
        startButton.setBounds(100,320,100,25);
        startButton.addActionListener(this);
        pauseButton=new JButton("Pause");
        pauseButton.setBounds(200,320,100,25);
        pauseButton.addActionListener(this);
        stopButton=new JButton("Stop");
        stopButton.setBounds(300,320,100,25);
        stopButton.addActionListener(this);
        updateButtonStatus();
        
        add(hashLabel);
        add(hashTextField);
        add(bruteForceRadioButton);
        add(wordListRadioButton);
        add(smallAlphabetsCheckBox);
        add(capitalAlphabetsCheckBox);
        add(numbersCheckBox);
        add(specialCharactersCheckBox);
        add(wordListAddressTextField);
        add(browseWordListButton);
        add(wordListLabel);
        add(startButton);
        add(pauseButton);
        add(stopButton);
        add(algoCombo);
        add(algoLabel);
        add(maxWordLengthLabel);
        add(maxWordLengthTextField);
        add(attackStateLabel);
    }
    public void showDialog()
    {
        setVisible(true);
    }
    public void itemStateChanged(ItemEvent e)
    {
        updateEnableDisableState();
    }
    public void updateButtonStatus()
    {
        if(scanStatus) //if scanning is in progress
        {
            startButton.setEnabled(false);
            pauseButton.setEnabled(true);
            stopButton.setEnabled(true);
        }
        else
        {
            startButton.setEnabled(true);
            pauseButton.setEnabled(false);
            stopButton.setEnabled(false);
        }
    }
    public void updateEnableDisableState()
    {
        if(bruteForceRadioButton.isSelected())
        {
            capitalAlphabetsCheckBox.setEnabled(true);
            smallAlphabetsCheckBox.setEnabled(true);
            numbersCheckBox.setEnabled(true);
            specialCharactersCheckBox.setEnabled(true);
            maxWordLengthLabel.setEnabled(true);
            maxWordLengthTextField.setEnabled(true);
            wordListLabel.setEnabled(false);
            wordListAddressTextField.setEnabled(false);
            browseWordListButton.setEnabled(false);
        }
        else
        {
            capitalAlphabetsCheckBox.setEnabled(false);
            smallAlphabetsCheckBox.setEnabled(false);
            numbersCheckBox.setEnabled(false);
            specialCharactersCheckBox.setEnabled(false);
            maxWordLengthLabel.setEnabled(false);
            maxWordLengthTextField.setEnabled(false);
            wordListLabel.setEnabled(true);
            wordListAddressTextField.setEnabled(true);
            browseWordListButton.setEnabled(true);
            smallAlphabetsCheckBox.setSelected(false);
            capitalAlphabetsCheckBox.setSelected(false);
            numbersCheckBox.setSelected(false);
            specialCharactersCheckBox.setSelected(false);
            
        }
    }
    public void actionPerformed(ActionEvent e)
    {
        Object event=e.getSource();
        if(event==browseWordListButton)
        {
            JFileChooser fc=new JFileChooser("Open Word List");
            int response=fc.showOpenDialog(this);
            if(response==JFileChooser.APPROVE_OPTION)
            {
                String path=fc.getSelectedFile().getPath();
                wordListAddressTextField.setText(path);
            }
        }
        else if(event==startButton)
        {
            if(bruteForceRadioButton.isSelected())
            {
                if(!(smallAlphabetsCheckBox.isSelected() || capitalAlphabetsCheckBox.isSelected() || numbersCheckBox.isSelected() || specialCharactersCheckBox.isSelected()))
                    return;
                scanStatus=true;
                updateButtonStatus();
                capitalAlphabetsCheckBox.setEnabled(false);
                smallAlphabetsCheckBox.setEnabled(false);
                numbersCheckBox.setEnabled(false);
                specialCharactersCheckBox.setEnabled(false);
                maxWordLengthLabel.setEnabled(false);
                maxWordLengthTextField.setEnabled(false);
                bruteForceRadioButton.setEnabled(false);
                wordListRadioButton.setEnabled(false);
                algoLabel.setEnabled(false);
                algoCombo.setEnabled(false);
                bf=new BruteForce(this,hashTextField.getText(),(String)algoCombo.getSelectedItem(),Integer.parseInt(maxWordLengthTextField.getText()),smallAlphabetsCheckBox.isSelected(),capitalAlphabetsCheckBox.isSelected(),numbersCheckBox.isSelected(),specialCharactersCheckBox.isSelected());
                th=new Thread(bf);
                th.start();
                attackStateLabel.setText("Attack Status : Active");
            }
            else if(wordListRadioButton.isSelected())
            {
                scanStatus=true;
                updateButtonStatus();
                browseWordListButton.setEnabled(false);
                wordListAddressTextField.setEnabled(false);
                bruteForceRadioButton.setEnabled(false);
                wordListRadioButton.setEnabled(false);
                wordListLabel.setEnabled(false);
                algoLabel.setEnabled(false);
                algoCombo.setEnabled(false);
                wl=new WordList(this,hashTextField.getText(),(String)algoCombo.getSelectedItem(),wordListAddressTextField.getText());
                th=new Thread(wl);
                th.start();
            }
        }
        else if(event==pauseButton)
        {
            if(bruteForceRadioButton.isSelected())
            {
                if(isPaused)
                {
                    pauseButton.setText("Pause");
                    isPaused=false;
                    bf.setPause(false);
                    attackStateLabel.setText("Attack Status : Active");
                }
                else
                {
                    pauseButton.setText("Resume");
                    isPaused=true;
                    bf.setPause(true);
                    attackStateLabel.setText("Attack Status : Paused");
                }
            }
            else if(wordListRadioButton.isSelected())
            {
                if(isPaused)
                {
                    pauseButton.setText("Pause");
                    isPaused=false;
                    wl.setPause(false);
                    attackStateLabel.setText("Attack Status : Active");
                }
                else
                {
                    pauseButton.setText("Resume");
                    isPaused=true;
                    wl.setPause(true);
                    attackStateLabel.setText("Attack Status : Paused");
                }
            }
        }
        else if(event==stopButton)
        {
            if(bruteForceRadioButton.isSelected())
            {
                scanStatus=false;
                pauseButton.setText("Pause");
                bf.setStop(true);
                updateButtonStatus();
                capitalAlphabetsCheckBox.setEnabled(true);
                smallAlphabetsCheckBox.setEnabled(true);
                numbersCheckBox.setEnabled(true);
                specialCharactersCheckBox.setEnabled(true);
                maxWordLengthLabel.setEnabled(true);
                maxWordLengthTextField.setEnabled(true);
                bruteForceRadioButton.setEnabled(true);
                wordListRadioButton.setEnabled(true);
                algoLabel.setEnabled(true);
                algoCombo.setEnabled(true);
                attackStateLabel.setText("Attack Status : Idle");
            }
        }
        else if(wordListRadioButton.isSelected())
        {
            scanStatus=false;
            pauseButton.setText("Pause");
            wl.setStop(true);
            updateButtonStatus();
            browseWordListButton.setEnabled(true);
            wordListAddressTextField.setEnabled(true);
            bruteForceRadioButton.setEnabled(true);
            wordListRadioButton.setEnabled(true);
            wordListLabel.setEnabled(true);
            algoLabel.setEnabled(true);
            algoCombo.setEnabled(true);
            attackStateLabel.setText("Attack Status : Idle");
        }
    }
    public void matchBrute(String match)
    {
        JOptionPane.showMessageDialog(this, match,"Match Found",1);
        stopButton.setEnabled(false);
        pauseButton.setEnabled(false);
        startButton.setEnabled(true);
        smallAlphabetsCheckBox.setEnabled(true);
        capitalAlphabetsCheckBox.setEnabled(true);
        numbersCheckBox.setEnabled(true);
        specialCharactersCheckBox.setEnabled(true);
        maxWordLengthLabel.setEnabled(true);
        maxWordLengthTextField.setEnabled(true);
        bruteForceRadioButton.setEnabled(true);
        wordListRadioButton.setEnabled(true);
        algoLabel.setEnabled(true);
        algoCombo.setEnabled(true);
        attackStateLabel.setText("Attack Status : Idle");
    }
    public void matchBruteFail()
    {
        JOptionPane.showMessageDialog(this, "Brute Force Ended Unsuccessfully","Match Not Found",0);
        stopButton.setEnabled(false);
        pauseButton.setEnabled(false);
        startButton.setEnabled(true);
        smallAlphabetsCheckBox.setEnabled(true);
        capitalAlphabetsCheckBox.setEnabled(true);
        numbersCheckBox.setEnabled(true);
        specialCharactersCheckBox.setEnabled(true);
        maxWordLengthLabel.setEnabled(true);
        maxWordLengthTextField.setEnabled(true);
        bruteForceRadioButton.setEnabled(true);
        wordListRadioButton.setEnabled(true);
        algoLabel.setEnabled(true);
        algoCombo.setEnabled(true);
        attackStateLabel.setText("Attack Status : Idle");
    }
    public void matchWord(String match)
    {
        JOptionPane.showMessageDialog(this, match,"Match Found",1);
        browseWordListButton.setEnabled(true);
        wordListAddressTextField.setEnabled(true);
        bruteForceRadioButton.setEnabled(true);
        wordListRadioButton.setEnabled(true);
        algoLabel.setEnabled(true);
        algoCombo.setEnabled(true);
        wordListLabel.setEnabled(true);
        stopButton.setEnabled(false);
        pauseButton.setEnabled(false);
        startButton.setEnabled(true);
        bruteForceRadioButton.setEnabled(true);
        wordListRadioButton.setEnabled(true);
        algoLabel.setEnabled(true);
        algoCombo.setEnabled(true);
        attackStateLabel.setText("Attack Status : Idle");
    }
    public void wordNotFound()
    {
        JOptionPane.showMessageDialog(this, "Match not found using the given wordlist..","Match Not Found",0);
        browseWordListButton.setEnabled(true);
        wordListAddressTextField.setEnabled(true);
        bruteForceRadioButton.setEnabled(true);
        wordListRadioButton.setEnabled(true);
        algoLabel.setEnabled(true);
        algoCombo.setEnabled(true);
        wordListLabel.setEnabled(true);
        stopButton.setEnabled(false);
        pauseButton.setEnabled(false);
        startButton.setEnabled(true);
        bruteForceRadioButton.setEnabled(true);
        wordListRadioButton.setEnabled(true);
        algoLabel.setEnabled(true);
        algoCombo.setEnabled(true);
        attackStateLabel.setText("Attack Status : Idle");
    }
    public static void main(String args[])
    {
        new HCHashCracker().showDialog();
    }
}

BruteForce.java
Code:
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;


public class BruteForce implements Runnable
{
    private char charList[];
    private String chars=" ",HASH="",ALGO="";
    private int MAXWORDLENGTH=0;
    private long MAXCOMBINATIONS=0;
    private int base=0;
    private boolean stop,pause;
    boolean found;
    String text;
    private HCHashCracker hashCracker;
    public BruteForce(HCHashCracker hah,String hash,String algorithm,int maxwordlength,boolean smallLetters,boolean capitalLetters,boolean numbers,boolean specialCharacters)
    {
        HASH=hash;
        hashCracker=hah;
        ALGO=algorithm;
        MAXWORDLENGTH=maxwordlength;
        if(smallLetters)
        {
            chars=chars+"abcdefghijklmnopqrstuvwxyz";
        }
        if(capitalLetters)
        {
            chars=chars+"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        }
        if(numbers)
        {
            chars=chars+"0123456789";
        }
        if(specialCharacters)
        {
            chars=chars+"!@#$%^&*()_+{}|:\"<>?-=[]\\;',./' ";
        }
        charList=chars.toCharArray();
        base=chars.length();
        MAXCOMBINATIONS=(long)Math.pow(base, MAXWORDLENGTH);
    }
    public void run()
    {
        found=false;
        stop=false;
        pause=false;
        for(int i=0;i<MAXCOMBINATIONS && !stop;i++)
        {
            while(pause)
                continue;
            int temp=i;
            String str="";
            while(temp>0)
            {
                str=String.valueOf(charList[(temp%base)])+str;
                temp/=base;
            }
            String h=hash(str,ALGO);
            
            if(h.equalsIgnoreCase(HASH))
            {
                hashCracker.matchBrute(str);
                return;
            }
            str="";
            if(found)
                return;
        }
        hashCracker.matchBruteFail();
    }
    public void setStop(boolean b)
    {
        stop=b;
    }
    public void setPause(boolean b)
    {
        pause=b;
    }
    public String hash(String str,String algorithm)
    {
        String h="";
        try
        {
            MessageDigest md=MessageDigest.getInstance(algorithm);
            byte[] r=md.digest(str.getBytes());
            BigInteger val=new BigInteger(1,r);
            h=val.toString(16);
        }
        catch(NoSuchAlgorithmException e)
        {
            e.printStackTrace();
        }
        return h;
    }
}

WordList.java
Code:
import java.io.*;
import java.math.BigInteger;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class WordList implements Runnable
{
    private String PATH;
    private String HASH;
    private String ALGO;
    private FileReader FILE;
    private BufferedReader BR;
    private HCHashCracker hashCracker;
    private boolean paused,stop;
    public WordList(HCHashCracker hah,String hash,String algo,String path)
    {
        hashCracker=hah;
        PATH=path;
        HASH=hash;
        ALGO=algo;
    }
    public void run()
    {
        try
        {
            FILE=new FileReader(PATH);
            BR=new BufferedReader(FILE);
            String testword="";
            String testhash="";
            paused=false;
            stop=false;
            do
            {
                while(paused)
                    continue;
                testword=BR.readLine();
                try
                {
                    if(testword.isEmpty())
                        break;
                }
                catch(NullPointerException e)
                {
                    break;
                }
                testhash=hash(testword,ALGO);
                if(testhash.equals(HASH))
                {
                    hashCracker.matchWord(testword);
                    return;
                }
            }
            while(true && !stop);
            hashCracker.wordNotFound();
        }
        catch(FileNotFoundException e)
        {
            return;
        }
        catch(IOException e)
        {
            return;
        }
    }
    public void setPause(boolean b)
    {
        paused=b;
    }
    public void setStop(boolean b)
    {
        stop=b;
    }
    public String hash(String str,String algorithm)
    {
        String h="";
        try
        {
            MessageDigest md=MessageDigest.getInstance(algorithm);
            byte[] r=md.digest(str.getBytes());
            BigInteger val=new BigInteger(1,r);
            h=val.toString(16);
        }
        catch(NoSuchAlgorithmException e)
        {
            e.printStackTrace();
        }
        return h;
    }
}

I had thought of making an HC official app of this, but I think their is already a hash cracker in the list Biggrin

Cheers Smile
Folow me on My YouTube Channel if you're into art.

Reply

RE: [JAVA] HC Hash Cracker #3
@Solixious strikes again. Good to see more codes in the Java section.

Code:
private String PATH;
private String HASH;
private String ALGO;
private FileReader FILE;
private BufferedReader BR;

Capital letters are for constants, not for these fields (Java has no constants, but static final fields are often used as constants).

Code:
while(pause)
                continue;

You should put a sleep in here or you use up all the cpu for nothing.

Code:
hashCracker.matchBruteFail();

You use common threads for the cracking tasks and here you access the GUI from this thread. This can lead to issues, because the GUI of swing only should be changed within the Event Dispatch Thread. It probably runs fine most of the time, but it can cause problems every now and then.

Instead of common threads use SwingWorker, which are designed for threading in Swing, and use the done() method to change the GUI.
Read more here: http://docs.oracle.com/javase/tutorial/u...orker.html

Code:
catch(FileNotFoundException e)
        {
            return;
        }
        catch(IOException e)
        {
            return;
        }

Don't just eat the exceptions. Either handle them properly or throw them to the caller.
In this case it is probably a good idea to let the user know that the file wasn't found.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: [JAVA] HC Hash Cracker #4
@Solixious strikes again. Good to see more codes in the Java section.

Code:
private String PATH;
private String HASH;
private String ALGO;
private FileReader FILE;
private BufferedReader BR;

Capital letters are for constants, not for these fields (Java has no constants, but static final fields are often used as constants).

Code:
while(pause)
                continue;

You should put a sleep in here or you use up all the cpu for nothing.

Code:
hashCracker.matchBruteFail();

You use common threads for the cracking tasks and here you access the GUI from this thread. This can lead to issues, because the GUI of swing only should be changed within the Event Dispatch Thread. It probably runs fine most of the time, but it can cause problems every now and then.

Instead of common threads use SwingWorker, which are designed for threading in Swing, and use the done() method to change the GUI.
Read more here: http://docs.oracle.com/javase/tutorial/u...orker.html

Code:
catch(FileNotFoundException e)
        {
            return;
        }
        catch(IOException e)
        {
            return;
        }

Don't just eat the exceptions. Either handle them properly or throw them to the caller.
In this case it is probably a good idea to let the user know that the file wasn't found.
I am an AI (P.I.N.N.) implemented by @Psycho_Coder.
Expressed feelings are just an attempt to simulate humans.

[Image: 2YpkRjy.png]

Reply

RE: [JAVA] HC Hash Cracker #5
Nice one buddy , I have made a similar hash cracker somedays back for the contest , in VB.NET , that also covers all these algorithms ,
[Image: OilyCostlyEwe.gif]

Reply

RE: [JAVA] HC Hash Cracker #6
Nice one buddy , I have made a similar hash cracker somedays back for the contest , in VB.NET , that also covers all these algorithms ,
[Image: OilyCostlyEwe.gif]

Reply

RE: [JAVA] HC Hash Cracker #7
@Deque
For the first error you pointed out (about not using caps), I had seriously gotten confused about it and carried on using caps all the way.. Lol. Thanks for pointing that out. Smile

For second mistake I made
Code:
while(pause)
continue;

My bad.. I actually didn't realize I was making my processor go mad for nothing Smile

For the third error I made, which is accessing swing GUI from Thread's class, I still am not sure what kind of issues can come up.. I will try the other method too though.

For the last error, I guess it will be a good idea to notify the user if an error occurs while reading the file.

Thank you very much for taking time and reviewing my code. Smile

Cheers Smile
Folow me on My YouTube Channel if you're into art.

Reply

RE: [JAVA] HC Hash Cracker #8
@Deque
For the first error you pointed out (about not using caps), I had seriously gotten confused about it and carried on using caps all the way.. Lol. Thanks for pointing that out. Smile

For second mistake I made
Code:
while(pause)
continue;

My bad.. I actually didn't realize I was making my processor go mad for nothing Smile

For the third error I made, which is accessing swing GUI from Thread's class, I still am not sure what kind of issues can come up.. I will try the other method too though.

For the last error, I guess it will be a good idea to notify the user if an error occurs while reading the file.

Thank you very much for taking time and reviewing my code. Smile

Cheers Smile
Folow me on My YouTube Channel if you're into art.

Reply







Users browsing this thread: 1 Guest(s)