1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 08:08:10 +00:00

Help: show supported hash-modes only with -hh

This commit is contained in:
Gabriele Gristina 2023-05-01 17:38:42 +02:00
parent cdd1e050b0
commit 36606addac
21 changed files with 142 additions and 79 deletions

View File

@ -81,6 +81,7 @@
- Unicode: Update UTF-8 to UTF-16 conversion to match RFC 3629
- User Options: Added error message when mixing --username and --show to warn users of exponential delay
- MetaMask: update extraction tool to support MetaMask Mobile wallets
- Help: show supported hash-modes only with -hh
* changes v6.2.5 -> v6.2.6

View File

@ -714,7 +714,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,
@ -2363,7 +2363,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;
@ -2439,6 +2438,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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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 |",
@ -144,13 +144,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
@ -305,38 +320,43 @@ 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;
const int rc = hashconfig_init (hashcat_ctx);
if (rc == 0)
for (int i = 0; i < MODULE_HASH_MODES_MAXIMUM; i++)
{
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;
user_options->hash_mode = i;
usage_sort_cnt++;
module_filename (folder_config, i, modulefile, HCBUFSIZ_TINY);
if (hc_path_exist (modulefile) == false) continue;
const int rc = hashconfig_init (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++;
}
hashconfig_destroy (hashcat_ctx);
}
hashconfig_destroy (hashcat_ctx);
hcfree (modulefile);
qsort (usage_sort_buf, usage_sort_cnt, sizeof (usage_sort_t), sort_by_usage);
}
hcfree (modulefile);
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++)
{
printf ("%s", USAGE_BIG_PRE_HASHMODES[i]);
@ -346,21 +366,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);
for (int i = 0; i < usage_sort_cnt; i++)
{
hcfree (usage_sort_buf[i].hash_name);
}
hcfree (usage_sort_buf);
}
fwrite (EOL, strlen (EOL), 1, stdout);
for (int i = 0; i < usage_sort_cnt; i++)
else
{
hcfree (usage_sort_buf[i].hash_name);
}
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++)
{

View File

@ -387,7 +387,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;
@ -563,6 +563,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))
{
@ -1500,7 +1507,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;
}
@ -1720,7 +1727,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";
}
@ -1803,7 +1810,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;
@ -1860,7 +1867,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;
}

View File

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