diff --git a/docs/changes.txt b/docs/changes.txt index beb3a04e2..084d3033b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -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 diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index feac5c7e1..fac85172a 100644 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -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=() diff --git a/src/backend.c b/src/backend.c index 0cc123ed4..bc3e00c0c 100644 --- a/src/backend.c +++ b/src/backend.c @@ -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)); diff --git a/src/bitmap.c b/src/bitmap.c index f161d3027..fb7367631 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -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; diff --git a/src/cpt.c b/src/cpt.c index dc40d612c..d60e30bf6 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -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; diff --git a/src/debugfile.c b/src/debugfile.c index 041b46f28..28eeb59f8 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -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; diff --git a/src/dictstat.c b/src/dictstat.c index 66d49ccce..97fcdd92d 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -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; diff --git a/src/hashcat.c b/src/hashcat.c index 61b6cb68f..97ee1c725 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -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); } diff --git a/src/hwmon.c b/src/hwmon.c index de6dafd5f..845f4c674 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -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)); diff --git a/src/induct.c b/src/induct.c index b11befb79..536bec8ff 100644 --- a/src/induct.c +++ b/src/induct.c @@ -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; diff --git a/src/loopback.c b/src/loopback.c index 694ef1a87..269f8cd2d 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -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; diff --git a/src/main.c b/src/main.c index f98673bd8..03f804915 100644 --- a/src/main.c +++ b/src/main.c @@ -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)) { diff --git a/src/outfile_check.c b/src/outfile_check.c index c7c670c47..359806985 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -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; diff --git a/src/potfile.c b/src/potfile.c index 6e86984b1..18a2883b5 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -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; diff --git a/src/restore.c b/src/restore.c index 7d3c41ff4..03b7d3125 100644 --- a/src/restore.c +++ b/src/restore.c @@ -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; diff --git a/src/terminal.c b/src/terminal.c index 6809ca8cd..848ef20dc 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -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)); diff --git a/src/tuningdb.c b/src/tuningdb.c index eae22ed1e..74caf7f7a 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -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; diff --git a/src/user_options.c b/src/user_options.c index cb2c73379..9acef8d3e 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -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);