From a25db47215b40356edb334cf0e953b84c95c68ef Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 11 Jun 2021 20:12:59 +0200 Subject: [PATCH] updated output messages for identify functionality --- src/hashcat.c | 61 +++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 12 deletions(-) diff --git a/src/hashcat.c b/src/hashcat.c index 7d309dff8..61b6cb68f 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1464,21 +1464,31 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) if (modes_cnt > 1) { - event_log_info (hashcat_ctx, "The following %d hash-modes match the structure of your input hash:", modes_cnt); - event_log_info (hashcat_ctx, NULL); - event_log_info (hashcat_ctx, " # | Name | Category"); - event_log_info (hashcat_ctx, " ======+=====================================================+======================================"); + if (user_options->quiet == false) + { + event_log_info (hashcat_ctx, "The following %d hash-modes match the structure of your input hash:", modes_cnt); + event_log_info (hashcat_ctx, NULL); + event_log_info (hashcat_ctx, " # | Name | Category"); + event_log_info (hashcat_ctx, " ======+=====================================================+======================================"); + } for (int i = 0; i < modes_cnt; i++) { - event_log_info (hashcat_ctx, "%7u | %-51s | %s", usage_sort_buf[i].hash_mode, usage_sort_buf[i].hash_name, strhashcategory (usage_sort_buf[i].hash_category)); + if (user_options->quiet == false) + { + event_log_info (hashcat_ctx, "%7u | %-51s | %s", usage_sort_buf[i].hash_mode, usage_sort_buf[i].hash_name, strhashcategory (usage_sort_buf[i].hash_category)); + } + else + { + event_log_info (hashcat_ctx, "%u", usage_sort_buf[i].hash_mode); + } hcfree (usage_sort_buf[i].hash_name); } hcfree (usage_sort_buf); - event_log_info (hashcat_ctx, NULL); + if (user_options->quiet == false) event_log_info (hashcat_ctx, NULL); if (user_options->identify == false) { @@ -1492,12 +1502,39 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) // modes_cnt == 1 - event_log_warning (hashcat_ctx, "Hash-mode was not specified with -m. Attempting to auto-detect hash mode."); - event_log_warning (hashcat_ctx, "The following mode was auto-detected as the only one matching your input hash:"); - event_log_warning (hashcat_ctx, "\n%u | %s | %s\n", usage_sort_buf[0].hash_mode, usage_sort_buf[0].hash_name, strhashcategory (usage_sort_buf[0].hash_category)); - event_log_warning (hashcat_ctx, "NOTE: Auto-detect is best effort. The correct hash-mode is NOT guaranteed!"); - event_log_warning (hashcat_ctx, "Do NOT report auto-detect issues unless you are certain of the hash type."); - event_log_warning (hashcat_ctx, NULL); + if (user_options->identify == false) + { + event_log_warning (hashcat_ctx, "Hash-mode was not specified with -m. Attempting to auto-detect hash mode."); + event_log_warning (hashcat_ctx, "The following mode was auto-detected as the only one matching your input hash:"); + } + + if (user_options->identify == true) + { + if (user_options->quiet == true) + { + event_log_info (hashcat_ctx, "%u", usage_sort_buf[0].hash_mode); + } + else + { + event_log_info (hashcat_ctx, "The following hash-mode match the structure of your input hash:"); + event_log_info (hashcat_ctx, NULL); + event_log_info (hashcat_ctx, " # | Name | Category"); + event_log_info (hashcat_ctx, " ======+=====================================================+======================================"); + event_log_info (hashcat_ctx, "%7u | %-51s | %s", usage_sort_buf[0].hash_mode, usage_sort_buf[0].hash_name, strhashcategory (usage_sort_buf[0].hash_category)); + event_log_info (hashcat_ctx, NULL); + } + } + else + { + event_log_info (hashcat_ctx, "\n%u | %s | %s\n", usage_sort_buf[0].hash_mode, usage_sort_buf[0].hash_name, strhashcategory (usage_sort_buf[0].hash_category)); + } + + if (user_options->identify == false) + { + event_log_warning (hashcat_ctx, "NOTE: Auto-detect is best effort. The correct hash-mode is NOT guaranteed!"); + event_log_warning (hashcat_ctx, "Do NOT report auto-detect issues unless you are certain of the hash type."); + event_log_warning (hashcat_ctx, NULL); + } user_options->hash_mode = usage_sort_buf[0].hash_mode;