From 3c6f4b0e695942cee30d94697ab44837598d6231 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Thu, 10 Jun 2021 20:44:21 +0200 Subject: [PATCH] add identify/autodetect-only option --- include/types.h | 3 +++ src/hashcat.c | 17 ++++++++++++----- src/user_options.c | 3 +++ 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/types.h b/include/types.h index 192c0998b..9760aa931 100644 --- a/include/types.h +++ b/include/types.h @@ -597,6 +597,7 @@ typedef enum user_options_defaults ADVICE_DISABLE = false, ATTACK_MODE = ATTACK_MODE_STRAIGHT, AUTODETECT = false, + AUTODETECT_ONLY = false, BENCHMARK_ALL = false, BENCHMARK = false, BITMAP_MAX = 18, @@ -685,6 +686,7 @@ typedef enum user_options_map { IDX_ADVICE_DISABLE = 0xff00, IDX_ATTACK_MODE = 'a', + IDX_AUTODETECT_ONLY = 0xff4d, IDX_BACKEND_DEVICES = 'd', IDX_BACKEND_IGNORE_CUDA = 0xff01, IDX_BACKEND_IGNORE_OPENCL = 0xff02, @@ -1943,6 +1945,7 @@ typedef struct user_options bool attack_mode_chgd; bool autodetect; + bool autodetect_only; #ifdef WITH_BRAIN bool brain_host_chgd; bool brain_port_chgd; diff --git a/src/hashcat.c b/src/hashcat.c index c7532f61e..d367ef1d2 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1476,13 +1476,18 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) hcfree (usage_sort_buf[i].hash_name); } + hcfree (usage_sort_buf); + event_log_info (hashcat_ctx, NULL); - event_log_error (hashcat_ctx, "Please specify the hash-mode with -m [hash-mode]."); + if (user_options->autodetect_only == false) + { + event_log_error (hashcat_ctx, "Please specify the hash-mode with -m [hash-mode]."); - hcfree (usage_sort_buf); + return -1; + } - return -1; + return 0; } // modes_cnt == 1 @@ -1494,12 +1499,14 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) 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->autodetect = false; - user_options->hash_mode = usage_sort_buf[0].hash_mode; hcfree (usage_sort_buf[0].hash_name); hcfree (usage_sort_buf); + + if (user_options->autodetect_only == true) return 0; + + user_options->autodetect = false; } /** diff --git a/src/user_options.c b/src/user_options.c index bc4465c5c..2ab1c632f 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -63,6 +63,7 @@ static const struct option long_options[] = {"hex-salt", no_argument, NULL, IDX_HEX_SALT}, {"hex-wordlist", no_argument, NULL, IDX_HEX_WORDLIST}, {"hook-threads", required_argument, NULL, IDX_HOOK_THREADS}, + {"identify", no_argument, NULL, IDX_AUTODETECT_ONLY}, {"increment-max", required_argument, NULL, IDX_INCREMENT_MAX}, {"increment-min", required_argument, NULL, IDX_INCREMENT_MIN}, {"increment", no_argument, NULL, IDX_INCREMENT}, @@ -158,6 +159,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->advice_disable = ADVICE_DISABLE; user_options->attack_mode = ATTACK_MODE; user_options->autodetect = AUTODETECT; + user_options->autodetect_only = AUTODETECT_ONLY; user_options->backend_devices = NULL; user_options->backend_ignore_cuda = BACKEND_IGNORE_CUDA; user_options->backend_ignore_opencl = BACKEND_IGNORE_OPENCL; @@ -396,6 +398,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_STDOUT_FLAG: user_options->stdout_flag = true; break; case IDX_STDIN_TIMEOUT_ABORT: user_options->stdin_timeout_abort = hc_strtoul (optarg, NULL, 10); user_options->stdin_timeout_abort_chgd = true; break; + case IDX_AUTODETECT_ONLY: user_options->autodetect_only = true; break; case IDX_SPEED_ONLY: user_options->speed_only = true; break; case IDX_PROGRESS_ONLY: user_options->progress_only = true; break; case IDX_RESTORE_DISABLE: user_options->restore_disable = true; break;