using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace md5dic { public partial class Form1 : Form { TextWriter writer; TextReader reader; int numChecked=0; public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { loadList(); txtHash.Text = HashString("password"); } public string HashString(string Value) { System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] data = System.Text.Encoding.ASCII.GetBytes(Value); data = x.ComputeHash(data); string ret = ""; for (int i = 0; i < data.Length; i++) ret += data[i].ToString("x2").ToLower(); return ret; } private void button1_Click(object sender, EventArgs e) { try { openFileDialog1.ShowDialog(); if (openFileDialog1.FileName != null && openFileDialog1.FileName != "openFileDialog1") { lstDict.Items.Add(openFileDialog1.FileName); } } catch (Exception ex) { MessageBox.Show("error: " + ex.Message.ToString(),"md5Dic error"); } } private void button2_Click(object sender, EventArgs e) { if (lstDict.SelectedItem != null) { lstDict.Items.Remove(lstDict.SelectedItem); } } private void button3_Click(object sender, EventArgs e) { saveList(); Application.Exit(); } public void saveList() { //save the list if (lstDict.Items.Count >= 0) { int counter = lstDict.Items.Count - 1; try { writer = new StreamWriter(Application.StartupPath + "\\dics.hs"); while (counter >= 0) { writer.WriteLine(lstDict.Items[counter]); lstDict.Items.Remove(counter); counter--; } } catch (Exception exc) { MessageBox.Show("error: " + exc.Message.ToString()); } finally { writer.Close(); } } } public void loadList() { //loadlist int counter = 0; try { reader = new StreamReader("dics.hs"); while (reader.Read() != null) { lstDict.Items.Add(reader.ReadLine().ToString()); counter++; } } catch (Exception exce) { MessageBox.Show("error: " + exce.Message.ToString()); } finally { reader.Close(); } } public void scan() { numChecked = 0; if (lstDict.SelectedItem != null) { try { reader = new StreamReader(lstDict.SelectedValue.ToString()); while (reader.Read() != null) { string wordListHash = reader.ReadLine(); if (HashString(wordListHash) == txtHash.Text) { txtFound.Text += "found hash! --" + wordListHash + ":" + HashString(wordListHash); } else { lblNumChecked.Text = numChecked.ToString(); numChecked++; } } } catch (Exception excep) { MessageBox.Show("error: " + excep.Message.ToString()); } finally { reader.Close(); } } } private void button4_Click(object sender, EventArgs e) { scan(); } private void lstDict_SelectedIndexChanged(object sender, EventArgs e) { } } }