diff --git a/docs/changes.txt b/docs/changes.txt index a61dbe080..2c1a213d9 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -87,6 +87,7 @@ - SecureCRT MasterPassphrase v2: update module, pure kernels and test unit. Add optimized kernels. - Metal Backend: added workaround to prevent 'Infinite Loop' bug when build kernels - User Options: added --metal-compiler-runtime option +- Help: show supported hash-modes only with -hh * changes v6.2.5 -> v6.2.6 diff --git a/include/types.h b/include/types.h index c34ae9eb4..6fd4c4553 100644 --- a/include/types.h +++ b/include/types.h @@ -715,7 +715,7 @@ typedef enum user_options_defaults STATUS_TIMER = 10, STDIN_TIMEOUT_ABORT = 120, STDOUT_FLAG = false, - USAGE = false, + USAGE = 0, USERNAME = false, VERSION = false, VERACRYPT_PIM_START = 485, @@ -2366,7 +2366,6 @@ typedef struct user_options bool status_json; bool stdout_flag; bool stdin_timeout_abort_chgd; - bool usage; bool username; bool veracrypt_pim_start_chgd; bool veracrypt_pim_stop_chgd; @@ -2443,6 +2442,7 @@ typedef struct user_options u32 segment_size; u32 status_timer; u32 stdin_timeout_abort; + u32 usage; u32 veracrypt_pim_start; u32 veracrypt_pim_stop; u32 workload_profile; diff --git a/src/backend.c b/src/backend.c index 506312f07..ea6fa7acd 100644 --- a/src/backend.c +++ b/src/backend.c @@ -4254,11 +4254,12 @@ 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 == 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; diff --git a/src/bitmap.c b/src/bitmap.c index 8fb30ddb4..367b16a7c 100644 --- a/src/bitmap.c +++ b/src/bitmap.c @@ -79,14 +79,15 @@ int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx) bitmap_ctx->enabled = false; + if (user_options->usage > 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; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; - if (user_options->backend_info > 0) return 0; bitmap_ctx->enabled = true; diff --git a/src/combinator.c b/src/combinator.c index c56d21440..654ada03f 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -19,12 +19,13 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) combinator_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_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->usage == true) return 0; if (user_options->version == true) return 0; - if (user_options->backend_info > 0) return 0; if ((user_options->attack_mode != ATTACK_MODE_COMBI) && (user_options->attack_mode != ATTACK_MODE_HYBRID1) diff --git a/src/cpt.c b/src/cpt.c index 235dafe27..8dc393c3a 100644 --- a/src/cpt.c +++ b/src/cpt.c @@ -15,14 +15,15 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx) cpt_ctx->enabled = false; + if (user_options->usage > 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; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; - if (user_options->backend_info > 0) return 0; cpt_ctx->enabled = true; diff --git a/src/debugfile.c b/src/debugfile.c index 21cd4e17f..cf943f3aa 100644 --- a/src/debugfile.c +++ b/src/debugfile.c @@ -114,6 +114,11 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx) debugfile_ctx->enabled = false; + if (user_options->debug_mode == 0) return 0; + + if (user_options->usage > 0) return 0; + if (user_options->backend_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; @@ -122,11 +127,8 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx) 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; - if (user_options->backend_info > 0) return 0; debugfile_ctx->enabled = true; diff --git a/src/dictstat.c b/src/dictstat.c index 6ae52b9de..02bb86b5f 100644 --- a/src/dictstat.c +++ b/src/dictstat.c @@ -56,21 +56,22 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx) dictstat_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_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; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; - if (user_options->backend_info > 0) return 0; if (user_options->attack_mode == ATTACK_MODE_BF) return 0; - dictstat_ctx->enabled = true; - dictstat_ctx->base = (dictstat_t *) hccalloc (MAX_DICTSTAT, sizeof (dictstat_t)); - dictstat_ctx->cnt = 0; + dictstat_ctx->enabled = true; + dictstat_ctx->base = (dictstat_t *) hccalloc (MAX_DICTSTAT, sizeof (dictstat_t)); + dictstat_ctx->cnt = 0; hc_asprintf (&dictstat_ctx->filename, "%s/%s", folder_config->profile_dir, DICTSTAT_FILENAME); diff --git a/src/hwmon.c b/src/hwmon.c index b1cf2d56e..5ef2e4a9c 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -1226,16 +1226,17 @@ int hwmon_ctx_init (hashcat_ctx_t *hashcat_ctx) return 0; #endif // WITH_HWMON + if (user_options->usage > 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; 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; - if (user_options->backend_info > 0) 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 ff5ca0fbb..3d9755034 100644 --- a/src/induct.c +++ b/src/induct.c @@ -39,6 +39,9 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) induct_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_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; @@ -47,10 +50,8 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) 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->backend_info > 0) 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 3f09cd87a..c20c88ea5 100644 --- a/src/loopback.c +++ b/src/loopback.c @@ -60,6 +60,9 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx) loopback_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_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; @@ -68,10 +71,8 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx) 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->backend_info > 0) return 0; loopback_ctx->enabled = true; loopback_ctx->fp.pfp = NULL; diff --git a/src/main.c b/src/main.c index 8c35fa8b4..69cc64fa5 100644 --- a/src/main.c +++ b/src/main.c @@ -1312,7 +1312,7 @@ int main (int argc, char **argv) if (hashcat_session_init (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME) == 0) { - if (user_options->usage == true) + if (user_options->usage > 0) { usage_big_print (hashcat_ctx); diff --git a/src/mpsp.c b/src/mpsp.c index 05c7c3eb3..ba5511616 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -1401,12 +1401,13 @@ int mask_ctx_init (hashcat_ctx_t *hashcat_ctx) mask_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_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->usage == true) return 0; if (user_options->version == true) return 0; - if (user_options->backend_info > 0) return 0; if (user_options->attack_mode == ATTACK_MODE_ASSOCIATION) return 0; if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) return 0; diff --git a/src/potfile.c b/src/potfile.c index 3945d3c55..78d4468bc 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -110,17 +110,18 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx) potfile_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_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; 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 (user_options->backend_info > 0) return 0; if (hashconfig->potfile_disable == true) return 0; diff --git a/src/restore.c b/src/restore.c index 8f0547313..0b6906fff 100644 --- a/src/restore.c +++ b/src/restore.c @@ -302,6 +302,9 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) restore_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_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; @@ -310,11 +313,9 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) 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->restore_disable == true) return 0; - if (user_options->backend_info > 0) return 0; if (argc == 0) return 0; if (argv == NULL) return 0; diff --git a/src/straight.c b/src/straight.c index 2cf5ff714..36d3a8eb8 100644 --- a/src/straight.c +++ b/src/straight.c @@ -262,12 +262,13 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx) straight_ctx->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_info > 0) 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->backend_info > 0) return 0; if (user_options->attack_mode == ATTACK_MODE_BF) return 0; diff --git a/src/terminal.c b/src/terminal.c index d141cdad2..5519eb060 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -35,7 +35,7 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag) if (user_options->left == true) return; if (user_options->identify == true) return; - if (user_options->usage == true) + if (user_options->usage > 0) { event_log_info (hashcat_ctx, "%s (%s) starting in help mode", PROGNAME, version_tag); event_log_info (hashcat_ctx, NULL); diff --git a/src/tuningdb.c b/src/tuningdb.c index 4a92db0a4..2f983b31e 100644 --- a/src/tuningdb.c +++ b/src/tuningdb.c @@ -54,14 +54,15 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx) tuning_db->enabled = false; + if (user_options->usage > 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; - if (user_options->usage == true) return 0; if (user_options->version == true) return 0; if (user_options->identify == true) return 0; - if (user_options->backend_info > 0) return 0; tuning_db->enabled = true; diff --git a/src/usage.c b/src/usage.c index 003a6eea6..c79a8c6ac 100644 --- a/src/usage.c +++ b/src/usage.c @@ -29,7 +29,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " -m, --hash-type | Num | Hash-type, references below (otherwise autodetect) | -m 1000", " -a, --attack-mode | Num | Attack-mode, see references below | -a 3", " -V, --version | | Print version |", - " -h, --help | | Print help |", + " -h, --help | | Print help. Use -hh to show all supported hash-modes | -h or -hh", " --quiet | | Suppress output |", " --hex-charset | | Assume charset is given in hex |", " --hex-salt | | Assume salt is given in hex |", @@ -145,13 +145,28 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --brain-session-whitelist | Hex | Allow given sessions only, separated with commas | --brain-session-whitelist=0x2ae611db", #endif "", - "- [ Hash modes ] -", + NULL +}; + +static const char *const USAGE_BIG_HEADER_HASHMODES[] = +{ + "- [ Hash Modes ] -", "", " # | Name | Category", " ======+============================================================+======================================", NULL }; +static const char *const USAGE_BIG_NO_HASHMODES[] = +{ + "- [ Hash Modes ] -", + "", + " please use -hh to show all supported Hash Modes" + "", + "", + NULL +}; + static const char *const USAGE_BIG_POST_HASHMODES[] = { #ifdef WITH_BRAIN @@ -306,37 +321,42 @@ void usage_big_print (hashcat_ctx_t *hashcat_ctx) const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; user_options_t *user_options = hashcat_ctx->user_options; - char *modulefile = (char *) hcmalloc (HCBUFSIZ_TINY); - - usage_sort_t *usage_sort_buf = (usage_sort_t *) hccalloc (MODULE_HASH_MODES_MAXIMUM, sizeof (usage_sort_t)); - int usage_sort_cnt = 0; - for (int i = 0; i < MODULE_HASH_MODES_MAXIMUM; i++) + usage_sort_t *usage_sort_buf = NULL; + + if (user_options->usage > 1) { - user_options->hash_mode = i; + char *modulefile = (char *) hcmalloc (HCBUFSIZ_TINY); - module_filename (folder_config, i, modulefile, HCBUFSIZ_TINY); + usage_sort_buf = (usage_sort_t *) hccalloc (MODULE_HASH_MODES_MAXIMUM, sizeof (usage_sort_t)); - if (hc_path_exist (modulefile) == false) continue; + for (int i = 0; i < MODULE_HASH_MODES_MAXIMUM; i++) + { + user_options->hash_mode = i; - const int rc = hashconfig_init (hashcat_ctx); + module_filename (folder_config, i, modulefile, HCBUFSIZ_TINY); - if (rc == 0) - { - usage_sort_buf[usage_sort_cnt].hash_mode = hashconfig->hash_mode; - usage_sort_buf[usage_sort_cnt].hash_name = hcstrdup (hashconfig->hash_name); - usage_sort_buf[usage_sort_cnt].hash_category = hashconfig->hash_category; + if (hc_path_exist (modulefile) == false) continue; - usage_sort_cnt++; - } + const int rc = hashconfig_init (hashcat_ctx); - hashconfig_destroy (hashcat_ctx); - } + if (rc == 0) + { + usage_sort_buf[usage_sort_cnt].hash_mode = hashconfig->hash_mode; + usage_sort_buf[usage_sort_cnt].hash_name = hcstrdup (hashconfig->hash_name); + usage_sort_buf[usage_sort_cnt].hash_category = hashconfig->hash_category; + + usage_sort_cnt++; + } - hcfree (modulefile); + hashconfig_destroy (hashcat_ctx); + } + + hcfree (modulefile); - qsort (usage_sort_buf, usage_sort_cnt, sizeof (usage_sort_t), sort_by_usage); + qsort (usage_sort_buf, usage_sort_cnt, sizeof (usage_sort_t), sort_by_usage); + } for (int i = 0; USAGE_BIG_PRE_HASHMODES[i] != NULL; i++) { @@ -347,21 +367,40 @@ void usage_big_print (hashcat_ctx_t *hashcat_ctx) //hc_fwrite (EOL, strlen (EOL), 1, stdout); - for (int i = 0; i < usage_sort_cnt; i++) + if (user_options->usage > 1) { - printf ("%7u | %-58s | %s", usage_sort_buf[i].hash_mode, usage_sort_buf[i].hash_name, strhashcategory (usage_sort_buf[i].hash_category)); + for (int i = 0; USAGE_BIG_HEADER_HASHMODES[i] != NULL; i++) + { + printf ("%s", USAGE_BIG_HEADER_HASHMODES[i]); + + fwrite (EOL, strlen (EOL), 1, stdout); + } + + for (int i = 0; i < usage_sort_cnt; i++) + { + printf ("%7u | %-58s | %s", usage_sort_buf[i].hash_mode, usage_sort_buf[i].hash_name, strhashcategory (usage_sort_buf[i].hash_category)); + + fwrite (EOL, strlen (EOL), 1, stdout); + } fwrite (EOL, strlen (EOL), 1, stdout); - } - fwrite (EOL, strlen (EOL), 1, stdout); + for (int i = 0; i < usage_sort_cnt; i++) + { + hcfree (usage_sort_buf[i].hash_name); + } - for (int i = 0; i < usage_sort_cnt; i++) - { - hcfree (usage_sort_buf[i].hash_name); + hcfree (usage_sort_buf); } + else + { + for (int i = 0; USAGE_BIG_NO_HASHMODES[i] != NULL; i++) + { + printf ("%s", USAGE_BIG_NO_HASHMODES[i]); - hcfree (usage_sort_buf); + fwrite (EOL, strlen (EOL), 1, stdout); + } + } for (int i = 0; USAGE_BIG_POST_HASHMODES[i] != NULL; i++) { diff --git a/src/user_options.c b/src/user_options.c index 50da0dbd7..a510c1d69 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -390,7 +390,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) { switch (c) { - case IDX_HELP: user_options->usage = true; break; + case IDX_HELP: user_options->usage++; break; case IDX_VERSION: user_options->version = true; break; case IDX_RESTORE: user_options->restore = true; break; case IDX_QUIET: user_options->quiet = true; break; @@ -568,6 +568,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + if (user_options->usage > 2) + { + event_log_error (hashcat_ctx, "Invalid --help/-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->brain_server == true)) { @@ -1514,7 +1521,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) { show_error = false; } - else if (user_options->usage == true) + else if (user_options->usage > 0) { show_error = false; } @@ -1734,7 +1741,7 @@ void user_options_session_auto (hashcat_ctx_t *hashcat_ctx) user_options->session = "hash_info"; } - if (user_options->usage == true) + if (user_options->usage > 0) { user_options->session = "usage"; } @@ -1817,7 +1824,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) || user_options->speed_only == true || user_options->progress_only == true || user_options->identify == true - || user_options->usage == true + || user_options->usage > 0 || user_options->backend_info > 0) { user_options->hwmon_disable = true; @@ -1874,7 +1881,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->quiet = true; } - if (user_options->usage == true) + if (user_options->usage > 0) { user_options->quiet = true; } diff --git a/src/wordlist.c b/src/wordlist.c index bc413396c..62941295f 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -695,20 +695,21 @@ int wl_data_init (hashcat_ctx_t *hashcat_ctx) wl_data->enabled = false; + if (user_options->usage > 0) return 0; + if (user_options->backend_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->usage == true) return 0; if (user_options->version == true) return 0; - if (user_options->backend_info > 0) return 0; wl_data->enabled = true; - wl_data->buf = (char *) hcmalloc (user_options->segment_size); - wl_data->avail = user_options->segment_size; - wl_data->incr = user_options->segment_size; - wl_data->cnt = 0; - wl_data->pos = 0; + wl_data->buf = (char *) hcmalloc (user_options->segment_size); + wl_data->avail = user_options->segment_size; + wl_data->incr = user_options->segment_size; + wl_data->cnt = 0; + wl_data->pos = 0; /** * choose dictionary parser