From 4f80d31ca2b32f784d8106ed07fa29fb33348d77 Mon Sep 17 00:00:00 2001 From: Abhisha Nirmalathas <a.nirmalathas1@student.unimelb.edu.au> Date: Thu, 23 May 2019 21:33:37 +1000 Subject: [PATCH] chnaged to print all guesses for 1 arg --- common_password_frequency.txt | 46 +++++++++++++++++++++++++++++++++++ common_password_statistics.py | 4 +-- four_password_strategy.c | 15 +++++++++--- passwords.c | 10 ++++++-- six_password_strategy.c | 17 ++++++++++--- 5 files changed, 81 insertions(+), 11 deletions(-) create mode 100644 common_password_frequency.txt diff --git a/common_password_frequency.txt b/common_password_frequency.txt new file mode 100644 index 0000000..a802016 --- /dev/null +++ b/common_password_frequency.txt @@ -0,0 +1,46 @@ +e +a +r +o +n +i +s +t +l +c +d +m +h +g +b +u +p +1 +y +k +f +w +2 +v +j +3 +z +0 +4 +5 +9 +6 +x +7 +8 +q +* +? +. +- ++ +& +\ +' +; +! diff --git a/common_password_statistics.py b/common_password_statistics.py index 140f6e5..19a8e18 100644 --- a/common_password_statistics.py +++ b/common_password_statistics.py @@ -100,7 +100,7 @@ def get_character_frequencies(): f.close() # create_common_password_substitutions() -# get_character_frequencies() +get_character_frequencies() def write_out_common_substitutions(): f = open("common_subs.txt", "w") @@ -114,4 +114,4 @@ def write_out_common_substitutions(): f.write("\n") f.close() -write_out_common_substitutions() \ No newline at end of file +# write_out_common_substitutions() \ No newline at end of file diff --git a/four_password_strategy.c b/four_password_strategy.c index 82245c3..30c622a 100644 --- a/four_password_strategy.c +++ b/four_password_strategy.c @@ -32,7 +32,7 @@ void brute_force_four(HashTable *ht, Passwords* solved){ BYTE guess[32]; sha256_final(&ctx, guess); char* hex_guess = sha256_byteToHexString(guess); - if ((hash = hash_table_get(ht, hex_guess))>0){ + if ((hash = hash_table_get(ht, hex_guess))>0 && get_remaining_guesses(solved) <=-1){ printf("%s %d\n", brute_guess, hash); add_new_cracked(solved, brute_guess); // Tries generating guesses with common substituions for guessed password @@ -41,6 +41,9 @@ void brute_force_four(HashTable *ht, Passwords* solved){ return; } } + else if (get_remaining_guesses(solved) >0){ + printf("%s\n", brute_guess); + } free(hex_guess); made_guess(solved); if (remaining_hashes(ht) == 0 || get_remaining_guesses(solved) == 0){ @@ -93,7 +96,7 @@ int popular_character_guess_four(HashTable *ht, Passwords* solved){ sha256_final(&ctx, guess); char* hex_guess = sha256_byteToHexString(guess); // Checks if guess matched password hash - if ((hash = hash_table_get(ht, hex_guess))>0){ + if ((hash = hash_table_get(ht, hex_guess))>0 && get_remaining_guesses(solved) <=-1){ printf("%s %d\n", brute_guess, hash); add_new_cracked(solved, brute_guess); //Finds common substituion guesses @@ -102,6 +105,9 @@ int popular_character_guess_four(HashTable *ht, Passwords* solved){ return 0; } } + else if (get_remaining_guesses(solved) >0){ + printf("%s\n", brute_guess); + } free(hex_guess); made_guess(solved); if (remaining_hashes(ht) == 0 || get_remaining_guesses(solved) == 0){ @@ -128,7 +134,7 @@ int generate_guesses_four(HashTable *ht, Passwords* solved){ sha256_final(&ctx, guess); char* hex_guess = sha256_byteToHexString(guess); // Checks for matching password - if ((hash = hash_table_get(ht, hex_guess))>0){ + if ((hash = hash_table_get(ht, hex_guess))>0 && get_remaining_guesses(solved) <=-1){ printf("%s %d\n", line, hash); add_new_cracked(solved, line); // Checks for common substituion with guessed password @@ -137,6 +143,9 @@ int generate_guesses_four(HashTable *ht, Passwords* solved){ return 0; } } + else if (get_remaining_guesses(solved) >0){ + printf("%s\n", line); + } made_guess(solved); free(hex_guess); } diff --git a/passwords.c b/passwords.c index 144b3e6..59d8276 100644 --- a/passwords.c +++ b/passwords.c @@ -129,10 +129,13 @@ int generate_common_subs_four(Passwords* solved, HashTable *ht){ sha256_final(&ctx, guess); char* hex_guess = sha256_byteToHexString(guess); // Checks if password cracked - if ((hash = hash_table_get(ht, hex_guess))>0){ + if ((hash = hash_table_get(ht, hex_guess))>0 && get_remaining_guesses(solved) <=-1){ printf("%s %d\n", sub_guess, hash); add_new_cracked(solved, sub_guess); } + else if (get_remaining_guesses(solved) >0){ + printf("%s\n", sub_guess); + } free(hex_guess); made_guess(solved); if (remaining_hashes(ht) == 0 || get_remaining_guesses(solved) == 0){ @@ -215,10 +218,13 @@ int generate_common_subs_six(Passwords* solved, HashTable *ht){ sha256_final(&ctx, guess); char* hex_guess = sha256_byteToHexString(guess); // Checks if found a password - if ((hash = hash_table_get(ht, hex_guess))>0){ + if ((hash = hash_table_get(ht, hex_guess))>0 && get_remaining_guesses(solved) <=-1){ printf("%s %d\n", sub_guess, hash); add_new_cracked(solved, sub_guess); } + else if (get_remaining_guesses(solved) >0){ + printf("%s\n", sub_guess); + } free(hex_guess); made_guess(solved); if (remaining_hashes(ht) == 0 || get_remaining_guesses(solved) == 0){ diff --git a/six_password_strategy.c b/six_password_strategy.c index 38b949c..8aa28ab 100644 --- a/six_password_strategy.c +++ b/six_password_strategy.c @@ -37,7 +37,7 @@ void brute_force_six(HashTable *ht, Passwords *solved){ BYTE guess[32]; sha256_final(&ctx, guess); char* hex_guess = sha256_byteToHexString(guess); - if ((hash = hash_table_get(ht, hex_guess))>0){ + if ((hash = hash_table_get(ht, hex_guess))>0 && get_remaining_guesses(solved) <= -1){ printf("%s %d\n", brute_guess, hash); add_new_cracked(solved, brute_guess); // Tries generating guesses with common substituions for guessed password @@ -46,6 +46,9 @@ void brute_force_six(HashTable *ht, Passwords *solved){ return; } } + else if (get_remaining_guesses(solved) >0){ + printf("%s\n", brute_guess); + } free(hex_guess); made_guess(solved); if (remaining_hashes(ht) == 0 || get_remaining_guesses(solved) == 0){ @@ -100,8 +103,8 @@ int popular_character_guess_six(HashTable *ht, Passwords *solved){ BYTE guess[32]; sha256_final(&ctx, guess); char* hex_guess = sha256_byteToHexString(guess); - // Checks if guess matched password hash - if ((hash = hash_table_get(ht, hex_guess))>0){ + // Checks if guess matched password hash get_remaining_guesses(solved) <=-1 + if ((hash = hash_table_get(ht, hex_guess))>0 && get_remaining_guesses(solved) <=-1){ printf("%s %d\n", brute_guess, hash); add_new_cracked(solved, brute_guess); //Finds common substituion guesses @@ -110,6 +113,9 @@ int popular_character_guess_six(HashTable *ht, Passwords *solved){ return 0; } } + else if (get_remaining_guesses(solved) >0){ + printf("%s\n", brute_guess); + } free(hex_guess); made_guess(solved); if (remaining_hashes(ht) == 0 || get_remaining_guesses(solved) == 0){ @@ -142,7 +148,7 @@ int generate_guesses_six(char* file_name, HashTable *ht, Passwords *solved){ sha256_final(&ctx, guess); char* hex_guess = sha256_byteToHexString(guess); // Checks for matching password - if ((hash = hash_table_get(ht, hex_guess))>0){ + if ((hash = hash_table_get(ht, hex_guess))>0 && get_remaining_guesses(solved) <=-1){ printf("%s %d\n", line, hash); add_new_cracked(solved, line); // Checks for common substituion with guessed password @@ -151,6 +157,9 @@ int generate_guesses_six(char* file_name, HashTable *ht, Passwords *solved){ return 0; } } + else if (get_remaining_guesses(solved) >0){ + printf("%s\n", line); + } made_guess(solved); free(hex_guess); } -- GitLab