1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-22 14:48:12 +00:00

Do not initialize backend devices in case --id is used and some bug fixes

This commit is contained in:
Jens Steube 2021-06-12 10:47:48 +02:00
parent 2b68d4bec1
commit 7fc0ac4ef1
18 changed files with 123 additions and 90 deletions

View File

@ -26,7 +26,8 @@
## Features
##
- Autodetect hash-type: performs an automatic analysis of the input hash(es), associating compatible algorithms, or executing the attack if only one compatible format is found.
- Autodetect hash-type: performs an automatic analysis of the input hash(es), associating compatible algorithms, or executing the attack if only one compatible format is found
- Autodetect hash-type: Added option --identify to limit hashcat to perform only autodetection of hash-type and to skip the backend device initialization
##
## Bugs

View File

@ -426,7 +426,7 @@ _hashcat ()
local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s ?h ?H'
local SHORT_OPTS="-m -a -V -h -b -t -T -o -p -c -d -D -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l -O -S -z"
local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-json --status-timer --stdin-timeout-abort --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --hash-info --backend-ignore-cuda --backend-ignore-opencl --backend-info --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-server-timer --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password"
local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-json --status-timer --stdin-timeout-abort --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --hash-info --backend-ignore-cuda --backend-ignore-opencl --backend-info --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-server-timer --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password --identify"
local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --stdin-timeout-abort --markov-hcstat2 --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-server-timer --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-session-whitelist"
COMPREPLY=()

View File

@ -5157,12 +5157,13 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx)
backend_ctx->enabled = false;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->show == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->show == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->identify == true) return 0;
hc_device_param_t *devices_param = (hc_device_param_t *) hccalloc (DEVICES_MAX, sizeof (hc_device_param_t));

View File

@ -79,13 +79,14 @@ int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx)
bitmap_ctx->enabled = false;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->identify == true) return 0;
bitmap_ctx->enabled = true;

View File

@ -15,13 +15,14 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx)
cpt_ctx->enabled = false;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->identify == true) return 0;
cpt_ctx->enabled = true;

View File

@ -86,18 +86,19 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx)
debugfile_ctx->enabled = false;
if (user_options->benchmark == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->progress_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->debug_mode == 0) return 0;
if (user_options->benchmark == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->progress_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->identify == true) return 0;
if (user_options->debug_mode == 0) return 0;
debugfile_ctx->enabled = true;

View File

@ -56,14 +56,15 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx)
dictstat_ctx->enabled = false;
if (user_options->benchmark == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->benchmark == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->identify == true) return 0;
if (user_options->attack_mode == ATTACK_MODE_BF) return 0;

View File

@ -1464,7 +1464,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx)
if (modes_cnt > 1)
{
if (user_options->quiet == false)
if (user_options->machine_readable == 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);
@ -1474,7 +1474,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx)
for (int i = 0; i < modes_cnt; i++)
{
if (user_options->quiet == false)
if (user_options->machine_readable == 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));
}
@ -1488,7 +1488,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx)
hcfree (usage_sort_buf);
if (user_options->quiet == false) event_log_info (hashcat_ctx, NULL);
if (user_options->machine_readable == false) event_log_info (hashcat_ctx, NULL);
if (user_options->identify == false)
{
@ -1510,7 +1510,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx)
if (user_options->identify == true)
{
if (user_options->quiet == true)
if (user_options->machine_readable == true)
{
event_log_info (hashcat_ctx, "%u", usage_sort_buf[0].hash_mode);
}

View File

@ -966,15 +966,16 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx)
return 0;
#endif // WITH_HWMON
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->hwmon_disable == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->identify == true) return 0;
if (user_options->hwmon_disable == true) return 0;
hwmon_ctx->hm_device = (hm_attrs_t *) hccalloc (DEVICES_MAX, sizeof (hm_attrs_t));

View File

@ -39,17 +39,18 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx)
induct_ctx->enabled = false;
if (user_options->benchmark == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->progress_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->benchmark == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->progress_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->identify == true) return 0;
if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT)
&& (user_options->attack_mode != ATTACK_MODE_ASSOCIATION)) return 0;

View File

@ -60,17 +60,18 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx)
loopback_ctx->enabled = false;
if (user_options->benchmark == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->progress_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->benchmark == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->progress_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->identify == true) return 0;
loopback_ctx->enabled = true;
loopback_ctx->fp.pfp = NULL;

View File

@ -189,6 +189,7 @@ static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA
if (user_options->stdout_flag == true) return;
if (user_options->backend_info == true) return;
if (user_options->speed_only == true) return;
if (user_options->identify == true) return;
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{

View File

@ -343,12 +343,13 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx)
outcheck_ctx->enabled = false;
if (user_options->keyspace == true) return 0;
if (user_options->benchmark == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->progress_only == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->benchmark == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->progress_only == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->identify == true) return 0;
if (hashconfig->outfile_check_disable == true) return 0;

View File

@ -119,6 +119,7 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->progress_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->identify == true) return 0;
if (user_options->potfile_disable == true) return 0;
if (hashconfig->potfile_disable == true) return 0;

View File

@ -309,6 +309,7 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
if (user_options->progress_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->identify == true) return 0;
if (user_options->restore_disable == true) return 0;
if (argc == 0) return 0;

View File

@ -30,6 +30,7 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag)
if (user_options->stdout_flag == true) return;
if (user_options->show == true) return;
if (user_options->left == true) return;
if (user_options->identify == true) return;
if (user_options->benchmark == true)
{
@ -101,6 +102,7 @@ void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const
if (user_options->stdout_flag == true) return;
if (user_options->show == true) return;
if (user_options->left == true) return;
if (user_options->identify == true) return;
char start_buf[32]; memset (start_buf, 0, sizeof (start_buf));
char stop_buf[32]; memset (start_buf, 0, sizeof (stop_buf));

View File

@ -54,13 +54,14 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
tuning_db->enabled = false;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->hash_info == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->backend_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->identify == true) return 0;
tuning_db->enabled = true;

View File

@ -1085,6 +1085,16 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
return -1;
}
if (user_options->identify == true)
{
if (user_options->hash_mode_chgd == true)
{
event_log_error (hashcat_ctx, "Can't change --hash-type (-m) in identify mode.");
return -1;
}
}
if (user_options->benchmark == true)
{
// sanity checks based on automatically overwritten configuration variables by
@ -1639,6 +1649,11 @@ void user_options_session_auto (hashcat_ctx_t *hashcat_ctx)
{
user_options->session = "left";
}
if (user_options->identify == true)
{
user_options->session = "identify";
}
}
}
@ -1678,6 +1693,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
|| user_options->keyspace == true
|| user_options->speed_only == true
|| user_options->progress_only == true
|| user_options->identify == true
|| user_options->usage == true)
{
user_options->hwmon_disable = true;
@ -3032,6 +3048,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx)
logfile_top_uint (user_options->hex_salt);
logfile_top_uint (user_options->hex_wordlist);
logfile_top_uint (user_options->hook_threads);
logfile_top_uint (user_options->identify);
logfile_top_uint (user_options->increment);
logfile_top_uint (user_options->increment_max);
logfile_top_uint (user_options->increment_min);