1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-14 03:39:09 +00:00

add identify/autodetect-only option

This commit is contained in:
Gabriele Gristina 2021-06-10 20:44:21 +02:00
parent a80ad1030e
commit 3c6f4b0e69
3 changed files with 20 additions and 7 deletions

View File

@ -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;

View File

@ -1476,13 +1476,18 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx)
hcfree (usage_sort_buf[i].hash_name);
}
event_log_info (hashcat_ctx, NULL);
event_log_error (hashcat_ctx, "Please specify the hash-mode with -m [hash-mode].");
hcfree (usage_sort_buf);
return -1;
event_log_info (hashcat_ctx, NULL);
if (user_options->autodetect_only == false)
{
event_log_error (hashcat_ctx, "Please specify the hash-mode with -m [hash-mode].");
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;
}
/**

View File

@ -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;