示例#1
0
 /// <summary>
 /// Updates the display with users hash list and if they have been found
 /// </summary>
 private void updatePasswordAndHint()
 {
     passwordAndHints_LB.Items.Clear();
     foreach (KeyValuePair <string, hashCount> kvp in userHashes)
     {
         hashCount hc = kvp.Value;
         string    s  = "";
         if (hc.hashFound)
         {
             s = "found " + hc.count.ToString() + " times";
         }
         else
         {
             s = "not found";
         }
         passwordAndHints_LB.Items.Add(kvp.Key + " - " + hc.hint + " - " + s);
     }
 }
示例#2
0
        /// <summary>
        /// Adds a hash of the currently entered password and a hint to the list of passwords to check
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void addHash_Btn_Click(object sender, EventArgs e)
        {
            if (password_TB.Text != "")
            {
                if (passwordRetype_TB.Text == password_TB.Text)
                {
                    string passwd        = password_TB.Text;
                    byte[] passwordArray = Encoding.UTF8.GetBytes(passwd);
                    byte[] hashArray     = hashFunction.ComputeHash(passwordArray);

                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (byte b in hashArray)
                    {
                        stringBuilder.AppendFormat("{0:X2}", b);
                    }
                    if (!userHashes.ContainsKey(stringBuilder.ToString()))
                    {
                        hashCount hc = new hashCount();
                        hc.count     = 0;
                        hc.hashFound = false;
                        hc.hint      = hint_TB.Text;
                        userHashes.Add(stringBuilder.ToString(), hc);
                    }
                    password_TB.Text       = "";
                    passwordRetype_TB.Text = "";
                    hint_TB.Text           = "";
                }
                else
                {
                    MessageBox.Show("Passwords do not match");
                }
            }
            else
            {
                MessageBox.Show("Please enter password");
            }
            updatePasswordAndHint();
        }
示例#3
0
        /// <summary>
        /// Will check the users list of hashes againsts a file or using the Web API
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void checkHash_Btn_Click(object sender, EventArgs e)
        {
            Tuple <bool, int> returnTup = new Tuple <bool, int>(false, 0);
            Dictionary <string, hashCount> updatedHashes = new Dictionary <string, hashCount>();

            foreach (string hash in userHashes.Keys)
            {
                if (filePaths.Count > 0)
                {
                    foreach (string path in filePaths)
                    {
                        try
                        {
                            returnTup = Check(hash, path);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error reading file, does it contain non SHA1 hash values? \n" + ex.Message);
                            return;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Please select some files");
                }

                hashCount hc = userHashes[hash];
                hc.hashFound = returnTup.Item1;
                hc.count     = returnTup.Item2;
                updatedHashes.Add(hash, hc);
            }
            userHashes.Clear();
            userHashes = updatedHashes;
            updatePasswordAndHint();
        }