Un simple programa en Java para crackear un hash MD5 mediante 3 servicios online.

Una imagen :

Imagen


El codigo :
// MD5 Cracker 0.2
// (C) Doddy Hackman 2015
// Credits : Based in the services ...
// http://md5online.net/index.php
// http://md5.my-addr.com/md5_decrypt-md5_cracker_online/md5_decoder_tool.php
// http://md5decryption.com/index.php
package MD5_Cracker;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import org.jvnet.substance.SubstanceLookAndFeel;

/**
 *
 * @author Doddy
 */
public class Home extends javax.swing.JFrame {

    /**
     * Creates new form Home
     */
    public Home() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jPanel3 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        txtMD5 = new javax.swing.JTextField();
        btnCrack = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        txtPassword1 = new javax.swing.JTextField();
        txtPassword2 = new javax.swing.JTextField();
        txtPassword3 = new javax.swing.JTextField();
        jPanel4 = new javax.swing.JPanel();
        status = new javax.swing.JLabel();

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("MD5 Cracker 0.2 (C) Doddy Hackman 2015");
        setResizable(false);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Enter MD5", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.TOP));

        btnCrack.setText("Crack");
        btnCrack.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCrackActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txtMD5, javax.swing.GroupLayout.PREFERRED_SIZE, 280, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(btnCrack, javax.swing.GroupLayout.DEFAULT_SIZE, 75, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtMD5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnCrack))
                .addContainerGap())
        );

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Result", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.TOP));

        jLabel1.setText("md5online.net ->");

        jLabel2.setText("md5.my-addr.co ->");

        jLabel3.setText("md5decryption.com ->");

        txtPassword1.setEditable(false);

        txtPassword2.setEditable(false);

        txtPassword3.setEditable(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtPassword3))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtPassword2))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(txtPassword1, javax.swing.GroupLayout.PREFERRED_SIZE, 229, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtPassword1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtPassword2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtPassword3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(15, Short.MAX_VALUE))
        );

        jPanel4.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

        status.setText("[+] Program Ready");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addComponent(status)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(status))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
            .addComponent(jPanel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0))
        );

        pack();
    }// </editor-fold>                        

    private void btnCrackActionPerformed(java.awt.event.ActionEvent evt) {                                         

        DH_Tools tools = new DH_Tools();

        if ("".equals(txtMD5.getText())) {
            JOptionPane.showMessageDialog(null, "Write MD5");
        } else {

            SwingUtilities.updateComponentTreeUI(this);
            status.setText("[+] Cracking ...");

            String md5 = txtMD5.getText();

            String code1 = tools.tomar("http://md5online.net/index.php", "pass=" + md5 + "&option=hash2text&send=Submit");

            Pattern search = null;
            Matcher regex = null;

            search = Pattern.compile("pass : <b>(.*?)<\\/b>");
            regex = search.matcher(code1);
            if (regex.find()) {
                txtPassword1.setText(regex.group(1));
            } else {
                txtPassword1.setText("Not Found");
            }

            String code2 = tools.tomar("http://md5.my-addr.com/md5_decrypt-md5_cracker_online/md5_decoder_tool.php", "md5=" + md5);

            search = Pattern.compile("<span class='middle_title'>Hashed string<\\/span>: (.*?)<\\/div>");
            regex = search.matcher(code2);
            if (regex.find()) {
                txtPassword2.setText(regex.group(1));
            } else {
                txtPassword2.setText("Not Found");
            }

            String code3 = tools.tomar("http://md5decryption.com/index.php", "hash=" + md5 + "&submit=Decrypt It!");

            search = Pattern.compile("Decrypted Text: <\\/b>(.*?)<\\/font>");
            regex = search.matcher(code3);
            if (regex.find()) {
                txtPassword3.setText(regex.group(1));
            } else {
                txtPassword3.setText("Not Found");
            }

            SwingUtilities.updateComponentTreeUI(this);
            status.setText("[+] Finished");

        }


    }                                        

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Home.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        Home.setDefaultLookAndFeelDecorated(true);
        String skin = "org.jvnet.substance.skin.RavenGraphiteGlassSkin";
        SubstanceLookAndFeel.setSkin(skin);
        SubstanceLookAndFeel.setCurrentWatermark("org.jvnet.substance.watermark.SubstanceMetalWallWatermark");

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Home().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton btnCrack;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JLabel status;
    private javax.swing.JTextField txtMD5;
    private javax.swing.JTextField txtPassword1;
    private javax.swing.JTextField txtPassword2;
    private javax.swing.JTextField txtPassword3;
    // End of variables declaration                   
}

// The End ?
Si quieren bajar el programa lo pueden hacer de [Enlace externo eliminado para invitados].
Usas netbeans o eclipse?, deberias separar el proyecto en paquetes, logica y gui al menos para no meter la lógica dentro del propio código swing.
Y en cuanto al código swing autogenerado suele quedar muy "código spaghetti", separa cada componente en un método getter, por legibilidad y mantenibilidad(que tu eres de los que suele sacar más versiones siempre). Si usas eclipse puedes ahorrarte esto usando el lazy mode en las preferencias de la generación de código
Bueno, recien llegue a casa y me he tomado la libertad y unos minutos para programarte un ejemplo de lo que yo veo como algo mantenible por ejemplo.
Estar usando java o cualquier lenguaje que soporte POO y no hacer uso de conceptos como la polimorfia es casi un delito.

La manera que planteo es la siguiente:
Imagen

Partes de una clase abstracta que será la encargada de almacenar URL, HASH y en este caso le añadi tan bien un booleano para distinguir Web Services que usen POST/GET.
En dicha clase abstracta se crean 2 métodos sin cuerpo(abstractos), getParameters() define los parámetros para el web service que estes usando, y getCrackedHash() se encargaria de parsear el HTML y devolver la palabra.

Cada "MD5WebService_N" será una clase que extenderá/heredará de la clase Cracker y ahi es donde tan solo tendremos que redefinir "getParameters()" y "getCrackedHash()", de esta forma para cada servicio web como md5decryptor.com se creara una clase, donde definiremos como va a parsear el HTML y cuales son los parámetros que tenemos que enviar.
Con esto logramos que si el dia de mañana queremos añadir 50 páginas web más para desencriptar MD5 no te pases dia y medio editando código y te pases solo 10 minutos escribiendo las nuevas 50 clases.


Bueno, entonces el proyecto quedaría dividido tal que asi:
Imagen


Logic:
-Cracker:

Mostrar/Ocultar

MD5WebService1, 2, ... , MD5WebServiceN:

Mostrar/Ocultar


En cuanto a la GUI, carece de dinamismo, lo que supone que sacar una nueva versión de tu cracker donde por ejemplo añadirias 50 web services más, llevaría mucho tiempo editando todos los componentes del panel de la GUI.

Yo te propongo que uses generación dinámica de componentes, de esta forma el panel de resultados
Imagen


Si te fijas en el botón de añadir veras que creo un array con JPanels y en cada JPanel meto un WebService, esto haría que tu aplicación quedará tal que asi:
Imagen


GUI:

-MainWindow(JFrame):

Mostrar/Ocultar

- ResultPane (JPanel):

Mostrar/Ocultar

Espero que no te tomes esto a mal, ya que solo estoy intentando darte un consejo para que empieces a hacer aplicaciones más robustas y mantenibles, y asi en el futuro todas las versiones de aplicaciones que vayas mejorando te llevaran bastante menos de la mitad del tiempo que te estaría robando hasta ahora.

No hace falta aprender 20 lenguajes distintos, pero si hace falta aprender a programar en general.
PD: Aqui te dejo el .zip con el proyecto exportado de eclipse para que puedas estudiarlo y trastocarlo cuanto te de la gana. -> [Enlace externo eliminado para invitados]

Un saludo.
El SuperRatón decía.- Hay que vitaminarse y mineralizarse y yo digo es una ciencia la OOP modularidad,encapsulamiento,polimorfismo a todo esto hay que añadir pruebas de código, refactorización cada día me gusta más pero soy consciente de lo que todavía no sé.

Viviendo y aprendiendo all the days in my life Sr Stbn.
Imagen
Neutrox escribió:El SuperRatón decía.- Hay que vitaminarse y mineralizarse y yo digo es una ciencia la OOP modularidad,encapsulamiento,polimorfismo a todo esto hay que añadir pruebas de código, refactorización cada día me gusta más pero soy consciente de lo que todavía no sé.

Viviendo y aprendiendo all the days in my life Sr Stbn.
True!
Responder

Volver a “Nuestros Programas”