Merge pull request #2821 from matrix/autodetect-only

add identify/autodetect-only option
pull/2824/head
Jens Steube 3 years ago committed by GitHub
commit 2b68d4bec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -619,6 +619,7 @@ typedef enum user_options_defaults
HEX_SALT = false,
HEX_WORDLIST = false,
HOOK_THREADS = 0,
IDENTIFY = false,
INCREMENT = false,
INCREMENT_MAX = PW_MAX,
INCREMENT_MIN = 1,
@ -725,73 +726,74 @@ typedef enum user_options_map
IDX_HEX_SALT = 0xff1a,
IDX_HEX_WORDLIST = 0xff1b,
IDX_HOOK_THREADS = 0xff1c,
IDX_IDENTIFY = 0xff1d,
IDX_INCREMENT = 'i',
IDX_INCREMENT_MAX = 0xff1d,
IDX_INCREMENT_MIN = 0xff1e,
IDX_INDUCTION_DIR = 0xff1f,
IDX_KEEP_GUESSING = 0xff20,
IDX_INCREMENT_MAX = 0xff1e,
IDX_INCREMENT_MIN = 0xff1f,
IDX_INDUCTION_DIR = 0xff20,
IDX_KEEP_GUESSING = 0xff21,
IDX_KERNEL_ACCEL = 'n',
IDX_KERNEL_LOOPS = 'u',
IDX_KERNEL_THREADS = 'T',
IDX_KEYBOARD_LAYOUT_MAPPING = 0xff21,
IDX_KEYSPACE = 0xff22,
IDX_LEFT = 0xff23,
IDX_KEYBOARD_LAYOUT_MAPPING = 0xff22,
IDX_KEYSPACE = 0xff23,
IDX_LEFT = 0xff24,
IDX_LIMIT = 'l',
IDX_LOGFILE_DISABLE = 0xff24,
IDX_LOOPBACK = 0xff25,
IDX_MACHINE_READABLE = 0xff26,
IDX_MARKOV_CLASSIC = 0xff27,
IDX_MARKOV_DISABLE = 0xff28,
IDX_MARKOV_HCSTAT2 = 0xff29,
IDX_LOGFILE_DISABLE = 0xff25,
IDX_LOOPBACK = 0xff26,
IDX_MACHINE_READABLE = 0xff27,
IDX_MARKOV_CLASSIC = 0xff28,
IDX_MARKOV_DISABLE = 0xff29,
IDX_MARKOV_HCSTAT2 = 0xff2a,
IDX_MARKOV_THRESHOLD = 't',
IDX_NONCE_ERROR_CORRECTIONS = 0xff2a,
IDX_NONCE_ERROR_CORRECTIONS = 0xff2b,
IDX_OPENCL_DEVICE_TYPES = 'D',
IDX_OPTIMIZED_KERNEL_ENABLE = 'O',
IDX_OUTFILE_AUTOHEX_DISABLE = 0xff2b,
IDX_OUTFILE_CHECK_DIR = 0xff2c,
IDX_OUTFILE_CHECK_TIMER = 0xff2d,
IDX_OUTFILE_FORMAT = 0xff2e,
IDX_OUTFILE_AUTOHEX_DISABLE = 0xff2c,
IDX_OUTFILE_CHECK_DIR = 0xff2d,
IDX_OUTFILE_CHECK_TIMER = 0xff2e,
IDX_OUTFILE_FORMAT = 0xff2f,
IDX_OUTFILE = 'o',
IDX_POTFILE_DISABLE = 0xff2f,
IDX_POTFILE_PATH = 0xff30,
IDX_PROGRESS_ONLY = 0xff31,
IDX_QUIET = 0xff32,
IDX_REMOVE = 0xff33,
IDX_REMOVE_TIMER = 0xff34,
IDX_RESTORE = 0xff35,
IDX_RESTORE_DISABLE = 0xff36,
IDX_RESTORE_FILE_PATH = 0xff37,
IDX_POTFILE_DISABLE = 0xff30,
IDX_POTFILE_PATH = 0xff31,
IDX_PROGRESS_ONLY = 0xff32,
IDX_QUIET = 0xff33,
IDX_REMOVE = 0xff34,
IDX_REMOVE_TIMER = 0xff35,
IDX_RESTORE = 0xff36,
IDX_RESTORE_DISABLE = 0xff37,
IDX_RESTORE_FILE_PATH = 0xff38,
IDX_RP_FILE = 'r',
IDX_RP_GEN_FUNC_MAX = 0xff38,
IDX_RP_GEN_FUNC_MIN = 0xff39,
IDX_RP_GEN_FUNC_MAX = 0xff39,
IDX_RP_GEN_FUNC_MIN = 0xff3a,
IDX_RP_GEN = 'g',
IDX_RP_GEN_SEED = 0xff3a,
IDX_RP_GEN_SEED = 0xff3b,
IDX_RULE_BUF_L = 'j',
IDX_RULE_BUF_R = 'k',
IDX_RUNTIME = 0xff3b,
IDX_SCRYPT_TMTO = 0xff3c,
IDX_RUNTIME = 0xff3c,
IDX_SCRYPT_TMTO = 0xff3d,
IDX_SEGMENT_SIZE = 'c',
IDX_SELF_TEST_DISABLE = 0xff3d,
IDX_SELF_TEST_DISABLE = 0xff3e,
IDX_SEPARATOR = 'p',
IDX_SESSION = 0xff3e,
IDX_SHOW = 0xff3f,
IDX_SESSION = 0xff3f,
IDX_SHOW = 0xff40,
IDX_SKIP = 's',
IDX_SLOW_CANDIDATES = 'S',
IDX_SPEED_ONLY = 0xff40,
IDX_SPIN_DAMP = 0xff41,
IDX_STATUS = 0xff42,
IDX_STATUS_JSON = 0xff43,
IDX_STATUS_TIMER = 0xff44,
IDX_STDOUT_FLAG = 0xff45,
IDX_STDIN_TIMEOUT_ABORT = 0xff46,
IDX_TRUECRYPT_KEYFILES = 0xff47,
IDX_USERNAME = 0xff48,
IDX_VERACRYPT_KEYFILES = 0xff49,
IDX_VERACRYPT_PIM_START = 0xff4a,
IDX_VERACRYPT_PIM_STOP = 0xff4b,
IDX_SPEED_ONLY = 0xff41,
IDX_SPIN_DAMP = 0xff42,
IDX_STATUS = 0xff43,
IDX_STATUS_JSON = 0xff44,
IDX_STATUS_TIMER = 0xff45,
IDX_STDOUT_FLAG = 0xff46,
IDX_STDIN_TIMEOUT_ABORT = 0xff47,
IDX_TRUECRYPT_KEYFILES = 0xff48,
IDX_USERNAME = 0xff49,
IDX_VERACRYPT_KEYFILES = 0xff4a,
IDX_VERACRYPT_PIM_START = 0xff4b,
IDX_VERACRYPT_PIM_STOP = 0xff4c,
IDX_VERSION_LOWER = 'v',
IDX_VERSION = 'V',
IDX_WORDLIST_AUTOHEX_DISABLE = 0xff4c,
IDX_WORDLIST_AUTOHEX_DISABLE = 0xff4d,
IDX_WORKLOAD_PROFILE = 'w',
} user_options_map_t;
@ -1951,6 +1953,7 @@ typedef struct user_options
#endif
bool hash_mode_chgd;
bool hccapx_message_pair_chgd;
bool identify;
bool increment_max_chgd;
bool increment_min_chgd;
bool kernel_accel_chgd;

@ -1464,42 +1464,86 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx)
if (modes_cnt > 1)
{
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);
event_log_info (hashcat_ctx, " # | Name | Category");
event_log_info (hashcat_ctx, " ======+=====================================================+======================================");
if (user_options->quiet == 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);
event_log_info (hashcat_ctx, " # | Name | Category");
event_log_info (hashcat_ctx, " ======+=====================================================+======================================");
}
for (int i = 0; i < modes_cnt; i++)
{
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));
if (user_options->quiet == 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));
}
else
{
event_log_info (hashcat_ctx, "%u", usage_sort_buf[i].hash_mode);
}
hcfree (usage_sort_buf[i].hash_name);
}
event_log_info (hashcat_ctx, NULL);
hcfree (usage_sort_buf);
event_log_error (hashcat_ctx, "Please specify the hash-mode with -m [hash-mode].");
if (user_options->quiet == false) event_log_info (hashcat_ctx, NULL);
hcfree (usage_sort_buf);
if (user_options->identify == false)
{
event_log_error (hashcat_ctx, "Please specify the hash-mode with -m [hash-mode].");
return -1;
return -1;
}
return 0;
}
// modes_cnt == 1
event_log_warning (hashcat_ctx, "Hash-mode was not specified with -m. Attempting to auto-detect hash mode.");
event_log_warning (hashcat_ctx, "The following mode was auto-detected as the only one matching your input hash:");
event_log_warning (hashcat_ctx, "\n%u | %s | %s\n", usage_sort_buf[0].hash_mode, usage_sort_buf[0].hash_name, strhashcategory (usage_sort_buf[0].hash_category));
event_log_warning (hashcat_ctx, "NOTE: Auto-detect is best effort. The correct hash-mode is NOT guaranteed!");
event_log_warning (hashcat_ctx, "Do NOT report auto-detect issues unless you are certain of the hash type.");
event_log_warning (hashcat_ctx, NULL);
if (user_options->identify == false)
{
event_log_warning (hashcat_ctx, "Hash-mode was not specified with -m. Attempting to auto-detect hash mode.");
event_log_warning (hashcat_ctx, "The following mode was auto-detected as the only one matching your input hash:");
}
if (user_options->identify == true)
{
if (user_options->quiet == true)
{
event_log_info (hashcat_ctx, "%u", usage_sort_buf[0].hash_mode);
}
else
{
event_log_info (hashcat_ctx, "The following hash-mode match the structure of your input hash:");
event_log_info (hashcat_ctx, NULL);
event_log_info (hashcat_ctx, " # | Name | Category");
event_log_info (hashcat_ctx, " ======+=====================================================+======================================");
event_log_info (hashcat_ctx, "%7u | %-51s | %s", usage_sort_buf[0].hash_mode, usage_sort_buf[0].hash_name, strhashcategory (usage_sort_buf[0].hash_category));
event_log_info (hashcat_ctx, NULL);
}
}
else
{
event_log_info (hashcat_ctx, "\n%u | %s | %s\n", usage_sort_buf[0].hash_mode, usage_sort_buf[0].hash_name, strhashcategory (usage_sort_buf[0].hash_category));
}
user_options->autodetect = false;
if (user_options->identify == false)
{
event_log_warning (hashcat_ctx, "NOTE: Auto-detect is best effort. The correct hash-mode is NOT guaranteed!");
event_log_warning (hashcat_ctx, "Do NOT report auto-detect issues unless you are certain of the hash type.");
event_log_warning (hashcat_ctx, NULL);
}
user_options->hash_mode = usage_sort_buf[0].hash_mode;
hcfree (usage_sort_buf[0].hash_name);
hcfree (usage_sort_buf);
if (user_options->identify == true) return 0;
user_options->autodetect = false;
}
/**

@ -120,6 +120,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] =
" -2, --custom-charset2 | CS | User-defined charset ?2 | -2 ?l?d?s",
" -3, --custom-charset3 | CS | User-defined charset ?3 |",
" -4, --custom-charset4 | CS | User-defined charset ?4 |",
" --identify | | Shows all supported algorithms for input hashes | --identify my.hash",
" -i, --increment | | Enable mask increment mode |",
" --increment-min | Num | Start mask incrementing at X | --increment-min=4",
" --increment-max | Num | Stop mask incrementing at X | --increment-max=8",

@ -63,6 +63,7 @@ static const struct option long_options[] =
{"hex-salt", no_argument, NULL, IDX_HEX_SALT},
{"hex-wordlist", no_argument, NULL, IDX_HEX_WORDLIST},
{"hook-threads", required_argument, NULL, IDX_HOOK_THREADS},
{"identify", no_argument, NULL, IDX_IDENTIFY},
{"increment-max", required_argument, NULL, IDX_INCREMENT_MAX},
{"increment-min", required_argument, NULL, IDX_INCREMENT_MIN},
{"increment", no_argument, NULL, IDX_INCREMENT},
@ -196,6 +197,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx)
user_options->hex_salt = HEX_SALT;
user_options->hex_wordlist = HEX_WORDLIST;
user_options->hook_threads = HOOK_THREADS;
user_options->identify = IDENTIFY;
user_options->increment = INCREMENT;
user_options->increment_max = INCREMENT_MAX;
user_options->increment_min = INCREMENT_MIN;
@ -396,6 +398,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
case IDX_STDOUT_FLAG: user_options->stdout_flag = true; break;
case IDX_STDIN_TIMEOUT_ABORT: user_options->stdin_timeout_abort = hc_strtoul (optarg, NULL, 10);
user_options->stdin_timeout_abort_chgd = true; break;
case IDX_IDENTIFY: user_options->identify = true; break;
case IDX_SPEED_ONLY: user_options->speed_only = true; break;
case IDX_PROGRESS_ONLY: user_options->progress_only = true; break;
case IDX_RESTORE_DISABLE: user_options->restore_disable = true; break;

Loading…
Cancel
Save