private void training_thread_function() { //First disabling all the buttons allowing to launch the training checkBox_ascii.Invoke((MethodInvoker) delegate { checkBox_ascii.Enabled = false; }); checkBox_uni1k.Invoke((MethodInvoker) delegate { checkBox_uni1k.Enabled = false; }); button_import_training_file.Invoke((MethodInvoker) delegate { button_import_training_file.Enabled = false; }); button_file_train.Invoke((MethodInvoker) delegate { button_file_train.Enabled = false; }); try { if (checkBox_ascii.Checked) { console_textbox.Invoke((MethodInvoker) delegate { console_textbox.AppendText("\r\n[-] Starting the CFHMM training for ASCII"); }); TrainingForPasswordStrength.SimpleHMM_trainTotalsAndProbs_V2(training_file_textbox.Text, 0, "SimpleHMM_ascii", Dll_Callback); TrainingForPasswordStrength.CFHMM_trainTotalsAndProbs_V2(training_file_textbox.Text, 0, "CFHMM_ascii", Dll_Callback); //console_textbox.AppendText("\n [-] Starting the MMmem training for unicode\n"); console_textbox.Invoke((MethodInvoker) delegate { console_textbox.AppendText("\r\n[-] Starting the MMmem training for ASCII"); }); TrainingForPasswordStrength.TrainMMmem_Hashlist_Ascii(training_file_textbox.Text, MM_memsize, "MMmem_ascii.bin", Dll_Callback); //Re-enabling all the buttons as the training is complete checkBox_ascii.Invoke((MethodInvoker) delegate { checkBox_ascii.Enabled = true; }); button_import_training_file.Invoke((MethodInvoker) delegate { button_import_training_file.Enabled = true; }); checkBox_uni1k.Invoke((MethodInvoker) delegate { checkBox_uni1k.Enabled = true; }); button_file_train.Invoke((MethodInvoker) delegate { button_file_train.Enabled = true; }); console_textbox.Invoke((MethodInvoker) delegate { console_textbox.AppendText("\r\n[-] ASCII training complete"); }); if (char_encoding == 0) { console_textbox.Invoke((MethodInvoker) delegate { console_textbox.AppendText("\r\n[-] Reloading the new matrix - it may take a while"); }); initialize_matrix(adapt_matrix_path); console_textbox.Invoke((MethodInvoker) delegate { console_textbox.AppendText("\r\n[-] Matrix loaded"); }); } } if (checkBox_uni1k.Checked) { //console_textbox.AppendText("\n [-] Starting the CFHMM training for unicode\n"); console_textbox.Invoke((MethodInvoker) delegate { console_textbox.AppendText("\r\n[-] Starting the CFHMM training for Uni1K"); }); TrainingForPasswordStrength.SimpleHMM_trainTotalsAndProbs_V2(training_file_textbox.Text, 1, "SimpleHMM_uni1k", Dll_Callback); TrainingForPasswordStrength.CFHMM_trainTotalsAndProbs_V2(training_file_textbox.Text, 1, "CFHMM_uni1k", Dll_Callback); //console_textbox.AppendText("\n [-] Starting the MMmem training for unicode\n"); console_textbox.Invoke((MethodInvoker) delegate { console_textbox.AppendText("\r\n[-] Starting the MMmem training for Uni1K"); }); TrainingForPasswordStrength.TrainMMmem_Hashlist_Uni1K(training_file_textbox.Text, MM_memsize, "MMmem_uni1k.bin", Dll_Callback); checkBox_ascii.Invoke((MethodInvoker) delegate { checkBox_ascii.Enabled = true; }); checkBox_uni1k.Invoke((MethodInvoker) delegate { checkBox_uni1k.Enabled = true; }); button_import_training_file.Invoke((MethodInvoker) delegate { button_import_training_file.Enabled = true; }); button_file_train.Invoke((MethodInvoker) delegate { button_file_train.Enabled = true; }); console_textbox.Invoke((MethodInvoker) delegate { console_textbox.AppendText("\r\n[-] Uni1K Training complete"); }); if (char_encoding == 1) { console_textbox.Invoke((MethodInvoker) delegate { console_textbox.AppendText("\r\n[-] Reloading the new matrix - it may take a while"); }); initialize_matrix(adapt_matrix_path); console_textbox.Invoke((MethodInvoker) delegate { console_textbox.AppendText("\r\n[-] Matrix loaded"); }); } } } catch (Exception err) { string err_msg = "\r\n[!] An error occur while loading the training file \n" + err; //console_textbox.AppendText(err_msg); console_textbox.Invoke((MethodInvoker) delegate { console_textbox.AppendText(err_msg); }); //As it failed, we reenable everything checkBox_ascii.Invoke((MethodInvoker) delegate { checkBox_ascii.Enabled = true; }); checkBox_uni1k.Invoke((MethodInvoker) delegate { checkBox_uni1k.Enabled = true; }); button_import_training_file.Invoke((MethodInvoker) delegate { button_import_training_file.Enabled = true; }); button_file_train.Invoke((MethodInvoker) delegate { button_file_train.Enabled = true; }); } }
private void pwd_textbox_TextChanged(object sender, EventArgs e) { if (pwd_textbox.Text == "") { pwd_score_label.Text = "Password score: N/A"; } else { double score; // We first check if the entered password match the set encoding int CodePointInitial; int CodePointFinal; if (ConfigurationManager.AppSettings["char_encoding"] == "0") { CodePointInitial = 32; CodePointFinal = 126; } else { CodePointInitial = 32; CodePointFinal = 1023; } int LengthOfCurrentPwd = pwd_textbox.Text.Length; int[] CurrentLineInCodingNumbers = new int[LengthOfCurrentPwd]; for (int Index = 0; Index < LengthOfCurrentPwd; Index++) { CurrentLineInCodingNumbers[Index] = pwd_textbox.Text[Index]; } if (TrainingForPasswordStrength.CheckIfEveryIntOfArrayIsInsideARange(CurrentLineInCodingNumbers, CodePointInitial, CodePointFinal)) { console_textbox.Text = ""; score = Math.Round(evaluate_pwd(pwd_textbox.Text), 3); progressBar1.Value = Convert.ToInt32(score * 10); pwd_score_label.Text = "Password score: " + score.ToString(); int normalized_color_score = Convert.ToInt32(score * 512 / 10); // normalize the score in the range 0-512 progressBar1.ForeColor = System.Drawing.Color.FromArgb(Math.Min(512 - normalized_color_score, 255), Math.Min(normalized_color_score, 255), 0); canvas.BringToFront(); this.Refresh(); } else { if (checkbox_advanced_view.Checked) { if (ConfigurationManager.AppSettings["char_encoding"] == "0") { console_textbox.AppendText("\r\n [!] Encoding issue, the password is not in ASCII and cannot be evaluated!\n"); } else { console_textbox.AppendText("\r\n [!] Encoding issue, the password is not in the range of accepted characters and cannot be evaluated!\n"); } } else { if (ConfigurationManager.AppSettings["char_encoding"] == "0") { MessageBox.Show("Encoding issue, the password is not in ASCII and cannot be evaluated!", " Encoding issue", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Encoding issue, the password is not in the range of accepted characters and cannot be evaluated!", " Encoding issue", MessageBoxButtons.OK, MessageBoxIcon.Error); } } pwd_score_label.Text = "Password score: N/A"; progressBar1.Value = 0; } } }