diff --git a/docs/changes.txt b/docs/changes.txt index 2ae77b251..4161e3b9a 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -164,6 +164,8 @@ - Metal Backend: improved compute workloads calculation - Modules: Check UnpackSize to raise false positive with hc_decompress_rar - User Options: added --metal-compiler-runtime option +- User Options: assigned -H to --hash-info +- Hash-Info: show more details using -HH - Hardware Monitor: avoid sprintf in src/ext_iokit.c - Hardware Monitor: Splitting hwmon_ctx_init function into smaller library-specific functions - Help: show supported hash-modes only with -hh diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index f1d01e0f5..c415bcb48 100755 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -425,7 +425,7 @@ _hashcat () local HIDDEN_FILES_AGGRESSIVE="${HIDDEN_FILES}|hcmask|hcchr" 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 -M -Y -R" + local SHORT_OPTS="-m -a -V -h -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 -M -Y -R" 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-inverse --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-json --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --deprecated-check-disable --left --username --dynamic-x --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-ignore-hip --backend-ignore-metal --backend-info --backend-devices --backend-devices-virtmulti --backend-devices-virthost --backend-devices-keepfree --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-func-sel --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 --multiply-accel-disable --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 --bridge-parameter1 --bridge-parameter2 --bridge-parameter3 --bridge-parameter4" 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 --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 --backend-devices-virtmulti --backend-devices-virthost --backend-devices-keepfree --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-func-sel --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 --bridge-parameter1 --bridge-parameter2 --bridge-parameter3 --bridge-parameter4" @@ -729,11 +729,11 @@ _hashcat () while [ ${h} -le ${COMP_CWORD} ]; do - if [[ "${COMP_WORDS[h]}" == "-a" ]]; then + if [[ "${COMP_WORDS[h]}" == "-a" ]]; then attack_mode=${COMP_WORDS[$((h + 1))]} - elif [[ "${COMP_WORDS[h]}" == -a* ]]; then + elif [[ "${COMP_WORDS[h]}" == -a* ]]; then attack_mode=${COMP_WORDS[h]:2} diff --git a/include/types.h b/include/types.h index b15821b17..c72232906 100644 --- a/include/types.h +++ b/include/types.h @@ -706,7 +706,7 @@ typedef enum user_options_defaults #else HWMON_TEMP_ABORT = 90, #endif - HASH_INFO = false, + HASH_INFO = 0, HASH_MODE = 0, HCCAPX_MESSAGE_PAIR = 0, HEX_CHARSET = false, @@ -830,7 +830,7 @@ typedef enum user_options_map IDX_DYNAMIC_X = 0xff55, IDX_ENCODING_FROM = 0xff15, IDX_ENCODING_TO = 0xff16, - IDX_HASH_INFO = 0xff17, + IDX_HASH_INFO = 'H', // 0xff17 IDX_FORCE = 0xff18, IDX_HWMON_DISABLE = 0xff19, IDX_HWMON_TEMP_ABORT = 0xff1a, @@ -2434,7 +2434,6 @@ typedef struct user_options bool deprecated_check; bool dynamic_x; bool hwmon; - bool hash_info; bool hex_charset; bool hex_salt; bool hex_wordlist; @@ -2528,6 +2527,7 @@ typedef struct user_options #endif u32 debug_mode; u32 hwmon_temp_abort; + u32 hash_info; int hash_mode; u32 hccapx_message_pair; u32 hook_threads; diff --git a/src/backend.c b/src/backend.c index 6e84eed34..e9e7a5572 100644 --- a/src/backend.c +++ b/src/backend.c @@ -4786,8 +4786,8 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx) backend_ctx->enabled = false; if (user_options->usage > 0) return 0; + if (user_options->hash_info > 0) 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; diff --git a/src/bitmap.c b/src/bitmap.c index 367b16a7c..1652b7cb9 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -81,8 +81,8 @@ int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 0) 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; diff --git a/src/bridges.c b/src/bridges.c index 9b37aa25a..3df210f80 100644 --- a/src/bridges.c +++ b/src/bridges.c @@ -87,12 +87,12 @@ bool bridges_init (hashcat_ctx_t *hashcat_ctx) user_options_t *user_options = hashcat_ctx->user_options; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; - if (user_options->hash_info == true) return true; + if (user_options->backend_info > 0) return true; + if (user_options->hash_info > 0) return true; + if (user_options->usage > 0) return true; if (user_options->left == true) return true; if (user_options->show == true) return true; - if (user_options->usage > 0) return true; if (user_options->version == true) return true; - if (user_options->backend_info > 0) return true; // There is a problem here. At this point, hashconfig is not yet initialized. // This is because initializing hashconfig requires the module to be loaded, @@ -241,12 +241,12 @@ bool bridges_salt_prepare (hashcat_ctx_t *hashcat_ctx) hashes_t *hashes = hashcat_ctx->hashes; user_options_t *user_options = hashcat_ctx->user_options; - if (user_options->hash_info == true) return true; + if (user_options->backend_info > 0) return true; + if (user_options->hash_info > 0) return true; + if (user_options->usage > 0) return true; if (user_options->left == true) return true; if (user_options->show == true) return true; - if (user_options->usage > 0) return true; if (user_options->version == true) return true; - if (user_options->backend_info > 0) return true; if (bridge_ctx->enabled == false) return true; diff --git a/src/combinator.c b/src/combinator.c index 654ada03f..47715ff5e 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -21,8 +21,8 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 0) return 0; - if (user_options->hash_info == true) return 0; if (user_options->left == true) return 0; if (user_options->show == true) return 0; if (user_options->version == true) return 0; diff --git a/src/cpt.c b/src/cpt.c index 8dc393c3a..97627b8c0 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -17,8 +17,8 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 0) 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; diff --git a/src/debugfile.c b/src/debugfile.c index 20ee3ad1f..25b0a6033 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -118,9 +118,9 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 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->show == true) return 0; diff --git a/src/dictstat.c b/src/dictstat.c index a607cf7d6..416eb90b3 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -58,9 +58,9 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 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->show == true) return 0; diff --git a/src/hashes.c b/src/hashes.c index 40d94941f..767c30824 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -1133,7 +1133,7 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx) hashes_cnt = 1; } - else if (user_options->hash_info == true) + else if (user_options->hash_info > 0) { } else if (user_options->keyspace == true) diff --git a/src/hwmon.c b/src/hwmon.c index e32b261fd..7408056ca 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -1638,9 +1638,9 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) //#endif // WITH_HWMON if (user_options->usage > 0) return 0; + if (user_options->hash_info > 0) return 0; //if (user_options->backend_info > 0) 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; diff --git a/src/induct.c b/src/induct.c index 3d9755034..476abe958 100644 --- a/src/induct.c +++ b/src/induct.c @@ -41,9 +41,9 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 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->show == true) return 0; diff --git a/src/interface.c b/src/interface.c index 3c9c7ed2d..129c054f8 100644 --- a/src/interface.c +++ b/src/interface.c @@ -363,7 +363,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->has_optimized_kernel = hc_path_read (source_file); - if (user_options->hash_info == false) + if (user_options->hash_info == 0 || user_options->hash_info > 1) { if (user_options->optimized_kernel == true) { diff --git a/src/loopback.c b/src/loopback.c index 28dcff0d0..b5799a435 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -62,9 +62,9 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 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->show == true) return 0; diff --git a/src/main.c b/src/main.c index 69d89e81b..0f32b4369 100644 --- a/src/main.c +++ b/src/main.c @@ -192,12 +192,13 @@ static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA status_ctx->shutdown_outer = false; - if (user_options->hash_info == true) return; + if (user_options->backend_info > 0) return; + if (user_options->hash_info > 0) return; + if (user_options->keyspace == true) return; if (user_options->stdout_flag == true) return; if (user_options->speed_only == true) return; if (user_options->identify == true) return; - if (user_options->backend_info > 0) return; if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { @@ -269,10 +270,11 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB const user_options_t *user_options = hashcat_ctx->user_options; const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - if (user_options->hash_info == true) return; + if (user_options->backend_info > 0) return; + if (user_options->hash_info > 0) return; + if (user_options->keyspace == true) return; if (user_options->stdout_flag == true) return; - if (user_options->backend_info > 0) return; // if we had a prompt, clear it @@ -1431,7 +1433,7 @@ int main (int argc, char **argv) rc_final = 0; } - else if (user_options->hash_info == true) + else if (user_options->hash_info > 0) { hash_info (hashcat_ctx); diff --git a/src/mpsp.c b/src/mpsp.c index 3efe345d7..0d2ae9ae0 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -1403,8 +1403,8 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 0) return 0; - if (user_options->hash_info == true) return 0; if (user_options->left == true) return 0; if (user_options->show == true) return 0; if (user_options->version == true) return 0; diff --git a/src/outfile_check.c b/src/outfile_check.c index e681b7263..afee8ddb8 100644 --- a/src/outfile_check.c +++ b/src/outfile_check.c @@ -343,13 +343,13 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx) outcheck_ctx->enabled = false; + if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 0) 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->identify == true) return 0; - if (user_options->backend_info > 0) return 0; if (hashconfig->outfile_check_disable == true) return 0; if (user_options->outfile_check_timer == 0) return 0; diff --git a/src/potfile.c b/src/potfile.c index afafca2f1..9a87ed027 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -115,9 +115,9 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 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->stdout_flag == true) return 0; if (user_options->speed_only == true) return 0; diff --git a/src/restore.c b/src/restore.c index 2ca95ba92..e5c141bfc 100644 --- a/src/restore.c +++ b/src/restore.c @@ -312,9 +312,9 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 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->show == true) return 0; diff --git a/src/straight.c b/src/straight.c index 36d3a8eb8..58212be52 100644 --- a/src/straight.c +++ b/src/straight.c @@ -264,11 +264,11 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 0) return 0; if (user_options->left == true) return 0; if (user_options->show == true) return 0; if (user_options->version == true) return 0; - if (user_options->hash_info == true) return 0; if (user_options->attack_mode == ATTACK_MODE_BF) return 0; diff --git a/src/terminal.c b/src/terminal.c index 6a54eb142..74e8009ae 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -97,7 +97,7 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag) event_log_info (hashcat_ctx, "%s (%s) starting in autodetect mode", PROGNAME, version_tag); event_log_info (hashcat_ctx, NULL); } - else if (user_options->hash_info == true) + else if (user_options->hash_info > 0) { event_log_info (hashcat_ctx, "%s (%s) starting in hash-info mode", PROGNAME, version_tag); event_log_info (hashcat_ctx, NULL); @@ -649,7 +649,7 @@ void compress_terminal_line_length (char *out_buf, const size_t keep_from_beginn *ptr1 = 0; } -void json_encode (char *text, char *escaped) +void json_encode (const char *text, char *escaped) { /* * Based on https://www.freeformatter.com/json-escape.html, below these 7 different chars @@ -682,6 +682,8 @@ void json_encode (char *text, char *escaped) void hash_info_single_json (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *user_options_extra) { + const user_options_t *user_options = hashcat_ctx->user_options; + if (hashconfig_init (hashcat_ctx) == 0) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -692,25 +694,70 @@ void hash_info_single_json (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *us printf ("\"category\": \"%s\", ", strhashcategory (hashconfig->hash_category)); printf ("\"slow_hash\": %s, ", (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) ? "false" : "true"); - printf ("\"password_len_min\": %u, ", hashconfig->pw_min); - printf ("\"password_len_max\": %u, ", hashconfig->pw_max); - printf ("\"is_deprecated\": %s, ", (module_ctx->module_deprecated_notice != MODULE_DEFAULT) ? "true" : "false"); - if (module_ctx->module_deprecated_notice != MODULE_DEFAULT) { - const char *deprecated_notice = module_ctx->module_deprecated_notice (hashconfig, hashcat_ctx->user_options, user_options_extra); - printf ("\"deprecated_notice\": \"%s\", ", deprecated_notice); + if (module_ctx->module_deprecated_notice != MODULE_DEFAULT) + { + const char *t_deprecated_notice = module_ctx->module_deprecated_notice (hashconfig, hashcat_ctx->user_options, user_options_extra); + + char *t_deprecated_notice_json_encoded = (char *) hcmalloc (strlen (t_deprecated_notice) * 2); + + json_encode (t_deprecated_notice, t_deprecated_notice_json_encoded); + + printf ("\"deprecated_notice\": \"%s\", ", t_deprecated_notice_json_encoded); + + hcfree (t_deprecated_notice_json_encoded); } + else + { + printf ("\"deprecated_notice\": \"%s\", ", "N/A"); + } + + const char *t_pw_desc = (hashconfig->opts_type & OPTS_TYPE_PT_HEX) ? "HEX" : "plain"; + + u32 t_pw_min = hashconfig->pw_min; + u32 t_pw_max = hashconfig->pw_max; + + if (user_options->hash_info > 1) + { + if (hashconfig->opts_type & OPTS_TYPE_PT_HEX) + { + t_pw_min *= 2; + t_pw_max *= 2; + } + } + + printf ("\"password_type\": \"%s\", ", t_pw_desc); + printf ("\"password_len_min\": %u, ", t_pw_min); + printf ("\"password_len_max\": %u, ", t_pw_max); printf ("\"is_salted\": %s, ", (hashconfig->is_salted == true) ? "true" : "false"); if (hashconfig->is_salted == true) { u32 t = hashconfig->salt_type; - const char *t_desc = (t == SALT_TYPE_EMBEDDED) ? "embedded" : (t == SALT_TYPE_GENERIC) ? "generic" : "virtual"; - printf ("\"salt_type\": \"%s\", ", t_desc); - printf ("\"salt_len_min\": %u, ", hashconfig->salt_min); - printf ("\"salt_len_max\": %u, ", hashconfig->salt_max); + + const char *t_salt_desc = (t == SALT_TYPE_EMBEDDED) ? "embedded" : (t == SALT_TYPE_GENERIC) ? "generic" : "virtual"; + + printf ("\"salt_type\": \"%s\", ", t_salt_desc); + + if (hashconfig->salt_type == SALT_TYPE_GENERIC || hashconfig->salt_type == SALT_TYPE_EMBEDDED) + { + u32 t_salt_min = hashconfig->salt_min; + u32 t_salt_max = hashconfig->salt_max; + + if (user_options->hash_info > 1) + { + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + t_salt_min *= 2; + t_salt_max *= 2; + } + } + + printf ("\"salt_len_min\": %u, ", t_salt_min); + printf ("\"salt_len_max\": %u, ", t_salt_max); + } } if ((hashconfig->has_pure_kernel) && (hashconfig->has_optimized_kernel)) @@ -726,6 +773,39 @@ void hash_info_single_json (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *us printf ("\"kernel_type\": %s, ", "[ \"optimized\" ]"); } + if (user_options->hash_info > 1) + { + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + printf ("\"kernel_type_filter\": %s, ", "[ \"optimized\" ]"); + } + else + { + printf ("\"kernel_type_filter\": %s, ", "[ \"pure\" ]"); + } + + printf ("\"attack_mode_filter\": %d, ", user_options->attack_mode); + + // almost always 1 and -1 + printf ("\"hashes_count_min\": %d, ", hashconfig->hashes_count_min); + printf ("\"hashes_count_max\": %d, ", hashconfig->hashes_count_max); + + if (hashconfig->salt_type == SALT_TYPE_GENERIC || hashconfig->salt_type == SALT_TYPE_EMBEDDED) + { + bool multi_hash_same_salt = true; + + if ((hashconfig->opts_type & OPTS_TYPE_DEEP_COMP_KERNEL) == 0) + { + if (hashconfig->attack_exec == ATTACK_EXEC_OUTSIDE_KERNEL) + { + multi_hash_same_salt = false; + } + } + + printf ("\"hashes_with_same_salt\": %s, ", (multi_hash_same_salt == true) ? "true" : "false"); + } + } + if ((hashconfig->st_hash != NULL) && (hashconfig->st_pass != NULL)) { if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) @@ -746,7 +826,7 @@ void hash_info_single_json (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *us char *example_hash_json_encoded = (char *) hcmalloc (strlen (hashconfig->st_hash) * 2); - json_encode ((char *)hashconfig->st_hash, example_hash_json_encoded); + json_encode (hashconfig->st_hash, example_hash_json_encoded); printf ("\"example_hash\": \"%s\", ", example_hash_json_encoded); @@ -822,6 +902,7 @@ void hash_info_single_json (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *us printf ("\"autodetect_enabled\": %s, ", (hashconfig->opts_type & OPTS_TYPE_AUTODETECT_DISABLE) ? "false" : "true"); printf ("\"self_test_enabled\": %s, ", (hashconfig->opts_type & OPTS_TYPE_SELF_TEST_DISABLE) ? "false" : "true"); printf ("\"potfile_enabled\": %s, ", (hashconfig->opts_type & OPTS_TYPE_POTFILE_NOPASS) ? "false" : "true"); + printf ("\"keep_guessing\": %s, ", (hashconfig->opts_type & OPTS_TYPE_SUGGEST_KG) ? "true" : "false"); printf ("\"custom_plugin\": %s, ", (hashconfig->opts_type & OPTS_TYPE_STOCK_MODULE) ? "false" : "true"); if (hashconfig->opts_type & OPTS_TYPE_PT_ALWAYS_ASCII) @@ -836,8 +917,6 @@ void hash_info_single_json (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *us { printf ("\"plaintext_encoding\": %s", "[ \"ASCII\", \"HEX\" ]"); } - - event_log_info (hashcat_ctx, NULL); } printf (" }"); @@ -847,30 +926,73 @@ void hash_info_single_json (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *us void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *user_options_extra) { + const user_options_t *user_options = hashcat_ctx->user_options; + if (hashconfig_init (hashcat_ctx) == 0) { hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + module_ctx_t *module_ctx = hashcat_ctx->module_ctx; event_log_info (hashcat_ctx, "Hash mode #%u", hashconfig->hash_mode); event_log_info (hashcat_ctx, " Name................: %s", hashconfig->hash_name); event_log_info (hashcat_ctx, " Category............: %s", strhashcategory (hashconfig->hash_category)); event_log_info (hashcat_ctx, " Slow.Hash...........: %s", (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) ? "No" : "Yes"); - event_log_info (hashcat_ctx, " Password.Len.Min....: %u", hashconfig->pw_min); - event_log_info (hashcat_ctx, " Password.Len.Max....: %u", hashconfig->pw_max); + event_log_info (hashcat_ctx, " Deprecated..........: %s", (module_ctx->module_deprecated_notice != MODULE_DEFAULT) ? "Yes" : "No"); + + char *t_deprecated_notice = "N/A\0"; + + if (module_ctx->module_deprecated_notice != MODULE_DEFAULT) + { + t_deprecated_notice = (char *) module_ctx->module_deprecated_notice (hashconfig, hashcat_ctx->user_options, user_options_extra); + } + + event_log_info (hashcat_ctx, " Deprecated.Notice...: %s", t_deprecated_notice); + + const char *t_pw_desc = (hashconfig->opts_type & OPTS_TYPE_PT_HEX) ? "HEX\0" : "plain\0"; + + u32 t_pw_min = hashconfig->pw_min; + u32 t_pw_max = hashconfig->pw_max; + + if (user_options->hash_info > 1) + { + if (hashconfig->opts_type & OPTS_TYPE_PT_HEX) + { + t_pw_min *= 2; + t_pw_max *= 2; + } + } + + event_log_info (hashcat_ctx, " Password.Type.......: %s", t_pw_desc); + event_log_info (hashcat_ctx, " Password.Len.Min....: %u", t_pw_min); + event_log_info (hashcat_ctx, " Password.Len.Max....: %u", t_pw_max); if (hashconfig->is_salted == true) { u32 t = hashconfig->salt_type; - const char *t_desc = (t == SALT_TYPE_EMBEDDED) ? "Embedded\0" : (t == SALT_TYPE_GENERIC) ? "Generic\0" : "Virtual\0"; - event_log_info (hashcat_ctx, " Salt.Type...........: %s", t_desc); - event_log_info (hashcat_ctx, " Salt.Len.Min........: %u", hashconfig->salt_min); - event_log_info (hashcat_ctx, " Salt.Len.Max........: %u", hashconfig->salt_max); - } - // almost always 1 and -1 - //event_log_info (hashcat_ctx, " Hashes.Count.Min....: %d", hashconfig->hashes_count_min); - //event_log_info (hashcat_ctx, " Hashes.Count.Max....: %u", hashconfig->hashes_count_max); + const char *t_salt_desc = (t == SALT_TYPE_EMBEDDED) ? "Embedded\0" : (t == SALT_TYPE_GENERIC) ? "Generic\0" : "Virtual\0"; + + event_log_info (hashcat_ctx, " Salt.Type...........: %s", t_salt_desc); + + if (hashconfig->salt_type == SALT_TYPE_GENERIC || hashconfig->salt_type == SALT_TYPE_EMBEDDED) + { + u32 t_salt_min = hashconfig->salt_min; + u32 t_salt_max = hashconfig->salt_max; + + if (user_options->hash_info > 1) + { + if (hashconfig->opts_type & OPTS_TYPE_ST_HEX) + { + t_salt_min *= 2; + t_salt_max *= 2; + } + } + + event_log_info (hashcat_ctx, " Salt.Len.Min........: %u", t_salt_min); + event_log_info (hashcat_ctx, " Salt.Len.Max........: %u", t_salt_max); + } + } if ((hashconfig->has_pure_kernel) && (hashconfig->has_optimized_kernel)) { @@ -885,6 +1007,39 @@ void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *user_op event_log_info (hashcat_ctx, " Kernel.Type(s)......: optimized"); } + if (user_options->hash_info > 1) + { + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + event_log_info (hashcat_ctx, " Kernel.Type.Filter..: optimized"); + } + else + { + event_log_info (hashcat_ctx, " Kernel.Type.Filter..: pure"); + } + + event_log_info (hashcat_ctx, " Attack.Mode.Filter..: %u", user_options->attack_mode); + + // almost always 1 and -1 + event_log_info (hashcat_ctx, " Hashes.Count.Min....: %d", hashconfig->hashes_count_min); + event_log_info (hashcat_ctx, " Hashes.Count.Max....: %d", hashconfig->hashes_count_max); + + if (hashconfig->salt_type == SALT_TYPE_GENERIC || hashconfig->salt_type == SALT_TYPE_EMBEDDED) + { + bool multi_hash_same_salt = true; + + if ((hashconfig->opts_type & OPTS_TYPE_DEEP_COMP_KERNEL) == 0) + { + if (hashconfig->attack_exec == ATTACK_EXEC_OUTSIDE_KERNEL) + { + multi_hash_same_salt = false; + } + } + + event_log_info (hashcat_ctx, " Hashes.w/.Same.Salt.: %s", (multi_hash_same_salt == true) ? "Allowed" : "Not allowed"); + } + } + if ((hashconfig->st_hash != NULL) && (hashconfig->st_pass != NULL)) { if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) @@ -988,6 +1143,7 @@ void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *user_op event_log_info (hashcat_ctx, " Autodetect.Enabled..: %s", (hashconfig->opts_type & OPTS_TYPE_AUTODETECT_DISABLE) ? "No" : "Yes"); event_log_info (hashcat_ctx, " Self.Test.Enabled...: %s", (hashconfig->opts_type & OPTS_TYPE_SELF_TEST_DISABLE) ? "No" : "Yes"); event_log_info (hashcat_ctx, " Potfile.Enabled.....: %s", (hashconfig->opts_type & OPTS_TYPE_POTFILE_NOPASS) ? "No" : "Yes"); + event_log_info (hashcat_ctx, " Keep.Guessing.......: %s", (hashconfig->opts_type & OPTS_TYPE_SUGGEST_KG) ? "Yes" : "No"); event_log_info (hashcat_ctx, " Custom.Plugin.......: %s", (hashconfig->opts_type & OPTS_TYPE_STOCK_MODULE) ? "No" : "Yes"); if (hashconfig->opts_type & OPTS_TYPE_PT_ALWAYS_ASCII) @@ -3156,15 +3312,10 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else { - event_log_info (hashcat_ctx, - "Remaining........: %u (%.2f%%) Digests", - digests_remain, - digests_remain_percent); + event_log_info (hashcat_ctx, "Remaining........: %u (%.2f%%) Digests", digests_remain, digests_remain_percent); } - event_log_info (hashcat_ctx, - "Recovered/Time...: %s", - hashcat_status->cpt); + event_log_info (hashcat_ctx, "Recovered/Time...: %s", hashcat_status->cpt); } switch (hashcat_status->progress_mode) @@ -3539,7 +3690,7 @@ void status_speed_json (hashcat_ctx_t *hashcat_ctx) printf (","); } - printf (" { \"device_id\": %u,", device_id + 1); + printf (" { \"device_id\": %d,", device_id + 1); printf (" \"speed\": %" PRIu64 " }", (u64) (device_info->hashes_msec_dev_benchmark * 1000)); device_num++; } @@ -3656,7 +3807,7 @@ void status_progress_json (hashcat_ctx_t *hashcat_ctx) printf (","); } - printf (" { \"device_id\": %u,", device_id + 1); + printf (" { \"device_id\": %d,", device_id + 1); printf (" \"progress\": %" PRIu64 ",", device_info->progress_dev); printf (" \"runtime\": %0.2f }", device_info->runtime_msec_dev); device_num++; diff --git a/src/tuningdb.c b/src/tuningdb.c index 41d3795aa..2c507feb7 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -56,8 +56,8 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 0) 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; diff --git a/src/usage.c b/src/usage.c index ba1f95094..94a8a0cff 100644 --- a/src/usage.c +++ b/src/usage.c @@ -100,7 +100,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --bridge-parameter4 | Str | Sets the generic parameter 4 for a Bridge |", " --cpu-affinity | Str | Locks to CPU devices, separated with commas | --cpu-affinity=1,2,3", " --hook-threads | Num | Sets number of threads for a hook (per compute unit) | --hook-threads=8", - " --hash-info | | Show information for each hash-mode |", + " -H, --hash-info | | Show information for each hash-mode | -H or -HH", " --example-hashes | | Alias of --hash-info |", " --backend-ignore-cuda | | Do not try to open CUDA interface on startup |", " --backend-ignore-hip | | Do not try to open HIP interface on startup |", diff --git a/src/user_options.c b/src/user_options.c index 2588746d9..cb27a9b47 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -21,9 +21,9 @@ #endif #ifdef WITH_BRAIN -static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSY:R:z"; +static const char *const short_options = "hHVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSY:R:z"; #else -static const char *const short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSY:R:"; +static const char *const short_options = "hHVvm:a:r:j:k:g:o:t:d:D:n:u:T:c:p:s:l:1:2:3:4:iIbw:OMSY:R:"; #endif static char *const SEPARATOR = ":"; @@ -442,7 +442,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_ENCODING_TO: user_options->encoding_to = optarg; break; case IDX_INDUCTION_DIR: user_options->induction_dir = optarg; break; case IDX_OUTFILE_CHECK_DIR: user_options->outfile_check_dir = optarg; break; - case IDX_HASH_INFO: user_options->hash_info = true; break; + case IDX_HASH_INFO: user_options->hash_info++; break; case IDX_FORCE: user_options->force = true; break; case IDX_SELF_TEST_DISABLE: user_options->self_test = false; break; case IDX_SKIP: user_options->skip = hc_strtoull (optarg, NULL, 10); @@ -1362,7 +1362,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } - if (user_options->hash_info == true) + if (user_options->hash_info > 0) { event_log_error (hashcat_ctx, "Use of --hash-info is not allowed in benchmark mode."); @@ -1554,6 +1554,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + if (user_options->hash_info > 2) + { + event_log_error (hashcat_ctx, "Invalid --hash-info/-H value, must have a value greater or equal to 0 and lower than 3."); + + return -1; + } + #ifdef WITH_BRAIN if ((user_options->brain_client == true) && (user_options->remove == true)) { @@ -1648,7 +1655,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) show_error = false; } } - else if (user_options->hash_info == true) + else if (user_options->hash_info > 0) { if (user_options->hc_argc == 0) { @@ -1846,7 +1853,7 @@ void user_options_session_auto (hashcat_ctx_t *hashcat_ctx) user_options->session = "benchmark"; } - if (user_options->hash_info == true) + if (user_options->hash_info > 0) { user_options->session = "hash_info"; } @@ -1942,13 +1949,13 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->bitmap_max = 1; } - if (user_options->hash_info == true - || user_options->keyspace == true + if (user_options->keyspace == true || user_options->total_candidates == true || user_options->speed_only == true || user_options->progress_only == true || user_options->identify == true || user_options->usage > 0 + || user_options->hash_info > 0 || user_options->backend_info > 0) { user_options->hwmon = false; @@ -2000,7 +2007,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) } } - if (user_options->hash_info == true) + if (user_options->hash_info > 0) { user_options->quiet = true; } @@ -2124,7 +2131,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) if (user_options->attack_mode == ATTACK_MODE_BF) { - if (user_options->hash_info == true) + if (user_options->hash_info > 0) { } @@ -2413,7 +2420,7 @@ void user_options_extra_init (hashcat_ctx_t *hashcat_ctx) { } - else if (user_options->hash_info == true) + else if (user_options->hash_info > 0) { } diff --git a/src/wordlist.c b/src/wordlist.c index 1776b4885..bfe09de89 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -697,9 +697,9 @@ int wl_data_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage > 0) return 0; if (user_options->backend_info > 0) return 0; + if (user_options->hash_info > 0) return 0; if (user_options->benchmark == true) return 0; - if (user_options->hash_info == true) return 0; if (user_options->left == true) return 0; if (user_options->version == true) return 0;