From 340e8d1033a55ace1832aa3d641e045b54951d49 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Fri, 11 Jun 2021 19:25:39 +0200 Subject: [PATCH] fix identify functionality --- include/types.h | 102 ++++++++++++++++++++++----------------------- src/hashcat.c | 4 +- src/usage.c | 1 + src/user_options.c | 6 +-- 4 files changed, 57 insertions(+), 56 deletions(-) diff --git a/include/types.h b/include/types.h index 9760aa931..2b240ba59 100644 --- a/include/types.h +++ b/include/types.h @@ -597,7 +597,6 @@ 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, @@ -620,6 +619,7 @@ typedef enum user_options_defaults HEX_SALT = false, HEX_WORDLIST = false, HOOK_THREADS = 0, + IDENTIFY = false, INCREMENT = false, INCREMENT_MAX = PW_MAX, INCREMENT_MIN = 1, @@ -686,7 +686,6 @@ 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, @@ -727,73 +726,74 @@ typedef enum user_options_map IDX_HEX_SALT = 0xff1a, IDX_HEX_WORDLIST = 0xff1b, IDX_HOOK_THREADS = 0xff1c, + IDX_IDENTIFY = 0xff1d, IDX_INCREMENT = 'i', - IDX_INCREMENT_MAX = 0xff1d, - IDX_INCREMENT_MIN = 0xff1e, - IDX_INDUCTION_DIR = 0xff1f, - IDX_KEEP_GUESSING = 0xff20, + IDX_INCREMENT_MAX = 0xff1e, + IDX_INCREMENT_MIN = 0xff1f, + IDX_INDUCTION_DIR = 0xff20, + IDX_KEEP_GUESSING = 0xff21, IDX_KERNEL_ACCEL = 'n', IDX_KERNEL_LOOPS = 'u', IDX_KERNEL_THREADS = 'T', - IDX_KEYBOARD_LAYOUT_MAPPING = 0xff21, - IDX_KEYSPACE = 0xff22, - IDX_LEFT = 0xff23, + IDX_KEYBOARD_LAYOUT_MAPPING = 0xff22, + IDX_KEYSPACE = 0xff23, + IDX_LEFT = 0xff24, IDX_LIMIT = 'l', - IDX_LOGFILE_DISABLE = 0xff24, - IDX_LOOPBACK = 0xff25, - IDX_MACHINE_READABLE = 0xff26, - IDX_MARKOV_CLASSIC = 0xff27, - IDX_MARKOV_DISABLE = 0xff28, - IDX_MARKOV_HCSTAT2 = 0xff29, + IDX_LOGFILE_DISABLE = 0xff25, + IDX_LOOPBACK = 0xff26, + IDX_MACHINE_READABLE = 0xff27, + IDX_MARKOV_CLASSIC = 0xff28, + IDX_MARKOV_DISABLE = 0xff29, + IDX_MARKOV_HCSTAT2 = 0xff2a, IDX_MARKOV_THRESHOLD = 't', - IDX_NONCE_ERROR_CORRECTIONS = 0xff2a, + IDX_NONCE_ERROR_CORRECTIONS = 0xff2b, IDX_OPENCL_DEVICE_TYPES = 'D', IDX_OPTIMIZED_KERNEL_ENABLE = 'O', - IDX_OUTFILE_AUTOHEX_DISABLE = 0xff2b, - IDX_OUTFILE_CHECK_DIR = 0xff2c, - IDX_OUTFILE_CHECK_TIMER = 0xff2d, - IDX_OUTFILE_FORMAT = 0xff2e, + IDX_OUTFILE_AUTOHEX_DISABLE = 0xff2c, + IDX_OUTFILE_CHECK_DIR = 0xff2d, + IDX_OUTFILE_CHECK_TIMER = 0xff2e, + IDX_OUTFILE_FORMAT = 0xff2f, IDX_OUTFILE = 'o', - IDX_POTFILE_DISABLE = 0xff2f, - IDX_POTFILE_PATH = 0xff30, - IDX_PROGRESS_ONLY = 0xff31, - IDX_QUIET = 0xff32, - IDX_REMOVE = 0xff33, - IDX_REMOVE_TIMER = 0xff34, - IDX_RESTORE = 0xff35, - IDX_RESTORE_DISABLE = 0xff36, - IDX_RESTORE_FILE_PATH = 0xff37, + IDX_POTFILE_DISABLE = 0xff30, + IDX_POTFILE_PATH = 0xff31, + IDX_PROGRESS_ONLY = 0xff32, + IDX_QUIET = 0xff33, + IDX_REMOVE = 0xff34, + IDX_REMOVE_TIMER = 0xff35, + IDX_RESTORE = 0xff36, + IDX_RESTORE_DISABLE = 0xff37, + IDX_RESTORE_FILE_PATH = 0xff38, IDX_RP_FILE = 'r', - IDX_RP_GEN_FUNC_MAX = 0xff38, - IDX_RP_GEN_FUNC_MIN = 0xff39, + IDX_RP_GEN_FUNC_MAX = 0xff39, + IDX_RP_GEN_FUNC_MIN = 0xff3a, IDX_RP_GEN = 'g', - IDX_RP_GEN_SEED = 0xff3a, + IDX_RP_GEN_SEED = 0xff3b, IDX_RULE_BUF_L = 'j', IDX_RULE_BUF_R = 'k', - IDX_RUNTIME = 0xff3b, - IDX_SCRYPT_TMTO = 0xff3c, + IDX_RUNTIME = 0xff3c, + IDX_SCRYPT_TMTO = 0xff3d, IDX_SEGMENT_SIZE = 'c', - IDX_SELF_TEST_DISABLE = 0xff3d, + IDX_SELF_TEST_DISABLE = 0xff3e, IDX_SEPARATOR = 'p', - IDX_SESSION = 0xff3e, - IDX_SHOW = 0xff3f, + IDX_SESSION = 0xff3f, + IDX_SHOW = 0xff40, IDX_SKIP = 's', IDX_SLOW_CANDIDATES = 'S', - IDX_SPEED_ONLY = 0xff40, - IDX_SPIN_DAMP = 0xff41, - IDX_STATUS = 0xff42, - IDX_STATUS_JSON = 0xff43, - IDX_STATUS_TIMER = 0xff44, - IDX_STDOUT_FLAG = 0xff45, - IDX_STDIN_TIMEOUT_ABORT = 0xff46, - IDX_TRUECRYPT_KEYFILES = 0xff47, - IDX_USERNAME = 0xff48, - IDX_VERACRYPT_KEYFILES = 0xff49, - IDX_VERACRYPT_PIM_START = 0xff4a, - IDX_VERACRYPT_PIM_STOP = 0xff4b, + IDX_SPEED_ONLY = 0xff41, + IDX_SPIN_DAMP = 0xff42, + IDX_STATUS = 0xff43, + IDX_STATUS_JSON = 0xff44, + IDX_STATUS_TIMER = 0xff45, + IDX_STDOUT_FLAG = 0xff46, + IDX_STDIN_TIMEOUT_ABORT = 0xff47, + IDX_TRUECRYPT_KEYFILES = 0xff48, + IDX_USERNAME = 0xff49, + IDX_VERACRYPT_KEYFILES = 0xff4a, + IDX_VERACRYPT_PIM_START = 0xff4b, + IDX_VERACRYPT_PIM_STOP = 0xff4c, IDX_VERSION_LOWER = 'v', IDX_VERSION = 'V', - IDX_WORDLIST_AUTOHEX_DISABLE = 0xff4c, + IDX_WORDLIST_AUTOHEX_DISABLE = 0xff4d, IDX_WORKLOAD_PROFILE = 'w', } user_options_map_t; @@ -1945,7 +1945,6 @@ typedef struct user_options bool attack_mode_chgd; bool autodetect; - bool autodetect_only; #ifdef WITH_BRAIN bool brain_host_chgd; bool brain_port_chgd; @@ -1954,6 +1953,7 @@ typedef struct user_options #endif bool hash_mode_chgd; bool hccapx_message_pair_chgd; + bool identify; bool increment_max_chgd; bool increment_min_chgd; bool kernel_accel_chgd; diff --git a/src/hashcat.c b/src/hashcat.c index d367ef1d2..7d309dff8 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1480,7 +1480,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, NULL); - if (user_options->autodetect_only == false) + if (user_options->identify == false) { event_log_error (hashcat_ctx, "Please specify the hash-mode with -m [hash-mode]."); @@ -1504,7 +1504,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) hcfree (usage_sort_buf[0].hash_name); hcfree (usage_sort_buf); - if (user_options->autodetect_only == true) return 0; + if (user_options->identify == true) return 0; user_options->autodetect = false; } diff --git a/src/usage.c b/src/usage.c index b63e417c2..3ea1397ba 100644 --- a/src/usage.c +++ b/src/usage.c @@ -120,6 +120,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " -2, --custom-charset2 | CS | User-defined charset ?2 | -2 ?l?d?s", " -3, --custom-charset3 | CS | User-defined charset ?3 |", " -4, --custom-charset4 | CS | User-defined charset ?4 |", + " --identify | | Shows all supported algorithms for input hashes | --identify my.hash", " -i, --increment | | Enable mask increment mode |", " --increment-min | Num | Start mask incrementing at X | --increment-min=4", " --increment-max | Num | Stop mask incrementing at X | --increment-max=8", diff --git a/src/user_options.c b/src/user_options.c index 2ab1c632f..cb2c73379 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -63,7 +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}, + {"identify", no_argument, NULL, IDX_IDENTIFY}, {"increment-max", required_argument, NULL, IDX_INCREMENT_MAX}, {"increment-min", required_argument, NULL, IDX_INCREMENT_MIN}, {"increment", no_argument, NULL, IDX_INCREMENT}, @@ -159,7 +159,6 @@ 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; @@ -198,6 +197,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->hex_salt = HEX_SALT; user_options->hex_wordlist = HEX_WORDLIST; user_options->hook_threads = HOOK_THREADS; + user_options->identify = IDENTIFY; user_options->increment = INCREMENT; user_options->increment_max = INCREMENT_MAX; user_options->increment_min = INCREMENT_MIN; @@ -398,7 +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_IDENTIFY: user_options->identify = 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;