outfile: improved version of OUTFILE_FORMAT assignment

pull/2292/head
philsmd 4 years ago
parent 0b082e2e31
commit ebd904a179
No known key found for this signature in database
GPG Key ID: 4F25D016D9D6A8AF

@ -1925,7 +1925,6 @@ typedef struct user_options
char *opencl_device_types;
char *outfile;
char *outfile_check_dir;
char *outfile_format;
char *potfile_path;
char *restore_file_path;
char **rp_files;
@ -1965,6 +1964,7 @@ typedef struct user_options
u32 spin_damp;
u32 backend_vector_width;
u32 outfile_check_timer;
u32 outfile_format;
u32 remove_timer;
u32 restore_timer;
u32 rp_files_cnt;

@ -516,7 +516,7 @@ u32 default_kernel_threads_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY
u32 default_forced_outfile_format (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
{
const u32 forced_outfile_format = outfile_format_parse (user_options->outfile_format);
const u32 forced_outfile_format = user_options->outfile_format;
return forced_outfile_format;
}

@ -99,7 +99,7 @@ const char *module_benchmark_mask (MAYBE_UNUSED const hashconfig_t *hashconfig,
u32 module_forced_outfile_format (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
{
const u32 forced_outfile_format = 5;
const u32 forced_outfile_format = OUTFILE_FMT_HASH | OUTFILE_FMT_HEXPLAIN;
return forced_outfile_format;
}

@ -98,7 +98,7 @@ const char *module_benchmark_mask (MAYBE_UNUSED const hashconfig_t *hashconfig,
u32 module_forced_outfile_format (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
{
const u32 forced_outfile_format = 5;
const u32 forced_outfile_format = OUTFILE_FMT_HASH | OUTFILE_FMT_HEXPLAIN;
return forced_outfile_format;
}

@ -107,7 +107,7 @@ const char *module_benchmark_mask (MAYBE_UNUSED const hashconfig_t *hashconfig,
u32 module_forced_outfile_format (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
{
const u32 forced_outfile_format = 5;
const u32 forced_outfile_format = OUTFILE_FMT_HASH | OUTFILE_FMT_HEXPLAIN;
return forced_outfile_format;
}

@ -19,7 +19,7 @@
u32 outfile_format_parse (const char *format_string)
{
if (format_string == NULL) return OUTFILE_FORMAT; // default outfile format
if (format_string == NULL) return 0;
char *format = hcstrdup (format_string);
@ -29,7 +29,12 @@ u32 outfile_format_parse (const char *format_string)
char *next = strtok_r (format, ",", &saveptr);
if (next == NULL) return 0;
if (next == NULL)
{
hcfree (format);
return 0;
}
u32 outfile_format = 0;
@ -484,7 +489,7 @@ int outfile_init (hashcat_ctx_t *hashcat_ctx)
outfile_ctx->fp.pfp = NULL;
outfile_ctx->filename = user_options->outfile;
outfile_ctx->outfile_format = outfile_format_parse (user_options->outfile_format);
outfile_ctx->outfile_format = user_options->outfile_format;
outfile_ctx->outfile_autohex = user_options->outfile_autohex;
return 0;

@ -219,7 +219,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx)
user_options->outfile_autohex = OUTFILE_AUTOHEX;
user_options->outfile_check_dir = NULL;
user_options->outfile_check_timer = OUTFILE_CHECK_TIMER;
user_options->outfile_format = NULL;
user_options->outfile_format = OUTFILE_FORMAT;
user_options->outfile = NULL;
user_options->potfile_disable = POTFILE_DISABLE;
user_options->potfile_path = NULL;
@ -423,7 +423,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
case IDX_MARKOV_THRESHOLD: user_options->markov_threshold = hc_strtoul (optarg, NULL, 10); break;
case IDX_MARKOV_HCSTAT2: user_options->markov_hcstat2 = optarg; break;
case IDX_OUTFILE: user_options->outfile = optarg; break;
case IDX_OUTFILE_FORMAT: user_options->outfile_format = optarg;
case IDX_OUTFILE_FORMAT: user_options->outfile_format = outfile_format_parse (optarg);
user_options->outfile_format_chgd = true; break;
case IDX_OUTFILE_AUTOHEX_DISABLE: user_options->outfile_autohex = false; break;
case IDX_OUTFILE_CHECK_TIMER: user_options->outfile_check_timer = hc_strtoul (optarg, NULL, 10); break;
@ -659,9 +659,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
return -1;
}
const u32 outfile_format = outfile_format_parse (user_options->outfile_format);
if (outfile_format == 0)
if (user_options->outfile_format == 0)
{
event_log_error (hashcat_ctx, "Invalid --outfile-format value specified.");
@ -672,7 +670,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->outfile_format_chgd == true)
{
if (outfile_format > 1)
if (user_options->outfile_format > 1)
{
event_log_error (hashcat_ctx, "Combining --outfile-format > 1 with --left is not allowed.");
@ -685,21 +683,21 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->outfile_format_chgd == true)
{
if (outfile_format & OUTFILE_FMT_CRACKPOS)
if (user_options->outfile_format & OUTFILE_FMT_CRACKPOS)
{
event_log_error (hashcat_ctx, "Using crack_pos in --outfile-format for --show is not allowed.");
return -1;
}
if (outfile_format & OUTFILE_FMT_TIME_ABS)
if (user_options->outfile_format & OUTFILE_FMT_TIME_ABS)
{
event_log_error (hashcat_ctx, "Using the absolute timestamp in --outfile-format for --show is not allowed.");
return -1;
}
if (outfile_format & OUTFILE_FMT_TIME_REL)
if (user_options->outfile_format & OUTFILE_FMT_TIME_REL)
{
event_log_error (hashcat_ctx, "Using the relative timestamp in --outfile-format for --show is not allowed.");
@ -1704,7 +1702,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
user_options->hash_mode = 2000;
user_options->kernel_accel = 1024;
user_options->backend_vector_width = 1;
user_options->outfile_format = hcstrdup ("2");
user_options->outfile_format = OUTFILE_FMT_PLAIN;
user_options->quiet = true;
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
@ -1738,7 +1736,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
if (user_options->left == true)
{
user_options->outfile_format = hcstrdup ("1");
user_options->outfile_format = OUTFILE_FMT_HASH;
}
if (user_options->show == true || user_options->left == true)
@ -2845,7 +2843,6 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx)
logfile_top_string (user_options->opencl_device_types);
logfile_top_string (user_options->outfile);
logfile_top_string (user_options->outfile_check_dir);
logfile_top_string (user_options->outfile_format);
logfile_top_string (user_options->potfile_path);
logfile_top_string (user_options->restore_file_path);
logfile_top_string (user_options->rp_files[0]);
@ -2894,6 +2891,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx)
logfile_top_uint (user_options->optimized_kernel_enable);
logfile_top_uint (user_options->outfile_autohex);
logfile_top_uint (user_options->outfile_check_timer);
logfile_top_uint (user_options->outfile_format);
logfile_top_uint (user_options->wordlist_autohex_disable);
logfile_top_uint (user_options->potfile_disable);
logfile_top_uint (user_options->progress_only);

Loading…
Cancel
Save