1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 16:18:09 +00:00

Make use of argc/argv easier

This commit is contained in:
jsteube 2016-10-02 23:30:31 +02:00
parent 9413ed8f56
commit 667a8b1d3d
7 changed files with 401 additions and 279 deletions

View File

@ -38,7 +38,7 @@ void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_tabl
void sp_stretch_markov (hcstat_table_t *in, hcstat_table_t *out);
void sp_stretch_root (hcstat_table_t *in, hcstat_table_t *out);
int mask_ctx_init (mask_ctx_t *mask_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const restore_ctx_t *restore_ctx, const hashconfig_t *hashconfig);
int mask_ctx_init (mask_ctx_t *mask_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const hashconfig_t *hashconfig);
void mask_ctx_destroy (mask_ctx_t *mask_ctx);
int mask_ctx_parse_maskfile (mask_ctx_t *mask_ctx, user_options_t *user_options, const hashconfig_t *hashconfig);

View File

@ -123,6 +123,7 @@ typedef enum status_rc
typedef enum wl_mode
{
WL_MODE_NONE = 0,
WL_MODE_STDIN = 1,
WL_MODE_FILE = 2,
WL_MODE_MASK = 3
@ -1124,6 +1125,11 @@ typedef struct user_options
bool workload_profile_chgd;
bool segment_size_chgd;
char *hc_bin;
int hc_argc;
char **hc_argv;
} user_options_t;
typedef struct user_options_extra
@ -1135,7 +1141,10 @@ typedef struct user_options_extra
u32 wordlist_mode;
int optind;
char *hc_hash; // can be filename or string
int hc_workc; // can be 0 in bf-mode = default mask
char **hc_workv;
} user_options_extra_t;

View File

@ -160,11 +160,13 @@ void user_options_init (user_options_t *user_options);
void user_options_destroy (user_options_t *user_options);
int user_options_parse (user_options_t *user_options, int argc, char **argv);
int user_options_getopt (user_options_t *user_options, int argc, char **argv);
int user_options_sanity (user_options_t *user_options, restore_ctx_t *restore_ctx, user_options_extra_t *user_options_extra);
int user_options_sanity (const user_options_t *user_options);
int user_options_extra_init (user_options_t *user_options, restore_ctx_t *restore_ctx, user_options_extra_t *user_options_extra);
void user_options_preprocess (user_options_t *user_options);
void user_options_extra_init (const user_options_t *user_options, user_options_extra_t *user_options_extra);
void user_options_extra_destroy (user_options_extra_t *user_options_extra);

View File

@ -857,11 +857,9 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
{
if (user_options_extra->wordlist_mode == WL_MODE_FILE)
{
int wls_left = restore_ctx->argc - (user_options_extra->optind + 1);
for (int i = 0; i < wls_left; i++)
for (int i = 0; i < user_options_extra->hc_workc; i++)
{
char *l0_filename = restore_ctx->argv[user_options_extra->optind + 1 + i];
char *l0_filename = user_options_extra->hc_workv[i];
struct stat l0_stat;
@ -922,8 +920,8 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
{
// display
char *dictfile1 = restore_ctx->argv[user_options_extra->optind + 1 + 0];
char *dictfile2 = restore_ctx->argv[user_options_extra->optind + 1 + 1];
char *dictfile1 = user_options_extra->hc_workv[0];
char *dictfile2 = user_options_extra->hc_workv[1];
// find the bigger dictionary and use as base
@ -1063,11 +1061,9 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
// base
int wls_left = restore_ctx->argc - (user_options_extra->optind + 2);
for (int i = 0; i < wls_left; i++)
for (int i = 0; i < user_options_extra->hc_workc - 1; i++)
{
char *l0_filename = restore_ctx->argv[user_options_extra->optind + 1 + i];
char *l0_filename = user_options_extra->hc_workv[i];
struct stat l0_stat;
@ -1135,11 +1131,9 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
// base
int wls_left = restore_ctx->argc - (user_options_extra->optind + 2);
for (int i = 0; i < wls_left; i++)
for (int i = 1; i < user_options_extra->hc_workc; i++)
{
char *l0_filename = restore_ctx->argv[user_options_extra->optind + 2 + i];
char *l0_filename = user_options_extra->hc_workv[i];
struct stat l0_stat;
@ -1328,7 +1322,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
* load hashes, stage 1
*/
const int rc_hashes_init_stage1 = hashes_init_stage1 (hashes, hashconfig, potfile_ctx, outfile_ctx, user_options, restore_ctx->argv[user_options_extra->optind]);
const int rc_hashes_init_stage1 = hashes_init_stage1 (hashes, hashconfig, potfile_ctx, outfile_ctx, user_options, user_options_extra->hc_hash);
if (rc_hashes_init_stage1 == -1) return -1;
@ -1426,7 +1420,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
* charsets : keep them together for more easy maintainnce
*/
const int rc_mask_init = mask_ctx_init (mask_ctx, user_options, user_options_extra, folder_config, restore_ctx, hashconfig);
const int rc_mask_init = mask_ctx_init (mask_ctx, user_options, user_options_extra, folder_config, hashconfig);
if (rc_mask_init == -1) return -1;
@ -1787,9 +1781,13 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
user_options_init (user_options);
const int rc_user_options_parse = user_options_parse (user_options, argc, argv);
const int rc_options_getopt = user_options_getopt (user_options, argc, argv);
if (rc_user_options_parse == -1) return -1;
if (rc_options_getopt == -1) return -1;
const int rc_options_sanity = user_options_sanity (user_options);
if (rc_options_sanity == -1) return -1;
/**
* some early exits
@ -1821,13 +1819,9 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
* process user input
*/
const int rc_user_options_extra_init = user_options_extra_init (user_options, restore_ctx, user_options_extra);
user_options_preprocess (user_options);
if (rc_user_options_extra_init == -1) return -1;
const int rc_user_options_sanity = user_options_sanity (user_options, restore_ctx, user_options_extra);
if (rc_user_options_sanity == -1) return -1;
user_options_extra_init (user_options, user_options_extra);
/**
* prepare seeding for random number generator, required by logfile and rules generator
@ -1888,7 +1882,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
* Sanity check for hashfile vs outfile (should not point to the same physical file)
*/
const int rc_outfile_and_hashfile = outfile_and_hashfile (outfile_ctx, restore_ctx->argv[user_options_extra->optind]);
const int rc_outfile_and_hashfile = outfile_and_hashfile (outfile_ctx, user_options_extra->hc_hash);
if (rc_outfile_and_hashfile == -1) return -1;

View File

@ -16,6 +16,8 @@
#include "interface.h"
#include "mpsp.h"
static const char DEF_MASK[] = "?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d";
#define MAX_MFS 5 // 4*charset, 1*mask
void mp_css_to_uniq_tbl (uint css_cnt, cs_t *css, uint uniq_tbls[SP_PW_MAX][CHARSIZ])
@ -854,7 +856,7 @@ static void mask_append (mask_ctx_t *mask_ctx, const user_options_t *user_option
}
}
int mask_ctx_init (mask_ctx_t *mask_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const restore_ctx_t *restore_ctx, const hashconfig_t *hashconfig)
int mask_ctx_init (mask_ctx_t *mask_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const hashconfig_t *hashconfig)
{
mask_ctx->enabled = false;
@ -899,9 +901,9 @@ int mask_ctx_init (mask_ctx_t *mask_ctx, const user_options_t *user_options, con
{
if (user_options->benchmark == false)
{
if ((user_options_extra->optind + 2) <= restore_ctx->argc)
if (user_options_extra->hc_workc)
{
char *arg = restore_ctx->argv[user_options_extra->optind + 1];
char *arg = user_options_extra->hc_workv[0];
struct stat file_stat;
@ -913,11 +915,9 @@ int mask_ctx_init (mask_ctx_t *mask_ctx, const user_options_t *user_options, con
{
mask_ctx->mask_from_file = true;
int arg_left = restore_ctx->argc - (user_options_extra->optind + 1);
for (int i = 0; i < arg_left; i++)
for (int i = 0; i < user_options_extra->hc_workc; i++)
{
arg = restore_ctx->argv[user_options_extra->optind + 1 + i];
arg = user_options_extra->hc_workv[i];
if (stat (arg, &file_stat) == -1)
{
@ -965,7 +965,7 @@ int mask_ctx_init (mask_ctx_t *mask_ctx, const user_options_t *user_options, con
}
else
{
const char *mask = "?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d";
const char *mask = DEF_MASK;
mask_append (mask_ctx, user_options, mask);
}
@ -981,7 +981,7 @@ int mask_ctx_init (mask_ctx_t *mask_ctx, const user_options_t *user_options, con
{
// display
char *arg = restore_ctx->argv[restore_ctx->argc - 1];
char *arg = user_options_extra->hc_workv[user_options_extra->hc_workc - 1];
// mod
@ -1035,7 +1035,7 @@ int mask_ctx_init (mask_ctx_t *mask_ctx, const user_options_t *user_options, con
{
// display
char *arg = restore_ctx->argv[user_options_extra->optind + 1];
char *arg = user_options_extra->hc_workv[0];
// mod

View File

@ -360,7 +360,7 @@ int restore_ctx_init (restore_ctx_t *restore_ctx, user_options_t *user_options,
if (user_options->benchmark == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->opencl_info == true) return 0;
if (user_options->opencl_info == 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;
@ -388,14 +388,15 @@ int restore_ctx_init (restore_ctx_t *restore_ctx, user_options_t *user_options,
rd->pid = GetCurrentProcessId ();
#endif
restore_ctx->argc = rd->argc;
restore_ctx->argv = rd->argv;
user_options_init (user_options);
const int rc_user_options_parse = user_options_parse (user_options, rd->argc, rd->argv);
const int rc_options_getopt = user_options_getopt (user_options, rd->argc, rd->argv);
if (rc_user_options_parse == -1) return -1;
if (rc_options_getopt == -1) return -1;
const int rc_options_sanity = user_options_sanity (user_options);
if (rc_options_sanity == -1) return -1;
}
return 0;

View File

@ -104,6 +104,10 @@ static const struct option long_options[] =
static char RULE_BUF_R[] = ":";
static char RULE_BUF_L[] = ":";
static char DEF_MASK_CS_1[] = "?l?d?u";
static char DEF_MASK_CS_2[] = "?l?d";
static char DEF_MASK_CS_3[] = "?l?d*!$@_";
void user_options_init (user_options_t *user_options)
{
user_options->attack_mode = ATTACK_MODE;
@ -187,6 +191,9 @@ void user_options_init (user_options_t *user_options)
user_options->workload_profile = WORKLOAD_PROFILE;
user_options->rp_files_cnt = 0;
user_options->rp_files = (char **) mycalloc (256, sizeof (char *));
user_options->hc_bin = PROGNAME;
user_options->hc_argc = 0;
user_options->hc_argv = NULL;
}
void user_options_destroy (user_options_t *user_options)
@ -196,7 +203,7 @@ void user_options_destroy (user_options_t *user_options)
memset (user_options, 0, sizeof (user_options_t));
}
int user_options_parse (user_options_t *user_options, int argc, char **argv)
int user_options_getopt (user_options_t *user_options, int argc, char **argv)
{
int c = -1;
@ -320,142 +327,30 @@ int user_options_parse (user_options_t *user_options, int argc, char **argv)
return -1;
}
#if !defined (WITH_HWMON)
user_options->powertune_enable = false;
user_options->gpu_temp_disable = true;
user_options->gpu_temp_abort = 0;
user_options->gpu_temp_retain = 0;
#endif // WITH_HWMON
user_options->hc_bin = argv[0];
// some options can influence or overwrite other options
if (user_options->opencl_info == true
|| user_options->keyspace == true
|| user_options->benchmark == true
|| user_options->stdout_flag == true)
{
user_options->show = false;
user_options->left = false;
user_options->gpu_temp_disable = true;
user_options->potfile_disable = true;
user_options->powertune_enable = false;
user_options->restore = false;
user_options->restore_disable = true;
user_options->restore_timer = 0;
user_options->logfile_disable = true;
user_options->weak_hash_threshold = 0;
user_options->nvidia_spin_damp = 0;
user_options->status = false;
user_options->status_timer = 0;
user_options->outfile_check_timer = 0;
}
if (user_options->benchmark == true)
{
user_options->session = "benchmark";
user_options->attack_mode = ATTACK_MODE_BF;
user_options->increment = false;
if (user_options->workload_profile_chgd == false)
{
user_options->workload_profile = 3;
}
if (user_options->powertune_enable == true)
{
user_options->gpu_temp_disable = false;
}
}
if (user_options->keyspace == true)
{
user_options->session = "keyspace";
user_options->quiet = true;
}
if (user_options->stdout_flag == true)
{
user_options->session = "stdout";
user_options->quiet = true;
user_options->hash_mode = 2000;
user_options->outfile_format = OUTFILE_FMT_PLAIN;
user_options->force = true;
user_options->kernel_accel = 1024;
user_options->kernel_loops = 1024;
user_options->opencl_vector_width = 1;
}
if (user_options->opencl_info == true)
{
user_options->session = "opencl_info";
user_options->quiet = true;
user_options->opencl_platforms = NULL;
user_options->opencl_devices = NULL;
user_options->opencl_device_types = mystrdup ("1,2,3");
}
if (user_options->left == true)
{
user_options->outfile_format = OUTFILE_FMT_HASH;
}
if (user_options->show == true || user_options->left == true)
{
user_options->attack_mode = ATTACK_MODE_NONE;
user_options->quiet = true;
}
// this allows the user to use --show and --left while cracking (i.e. while another instance of hashcat is running)
if (user_options->show == true || user_options->left == true)
{
user_options->restore_disable = true;
user_options->restore = false;
}
if (user_options->skip != 0 && user_options->limit != 0)
{
user_options->limit += user_options->skip;
}
if (user_options->attack_mode != ATTACK_MODE_STRAIGHT)
{
user_options->weak_hash_threshold = 0;
}
if (user_options->hash_mode == 9710)
{
user_options->outfile_format = 5;
user_options->outfile_format_chgd = 1;
}
if (user_options->hash_mode == 9810)
{
user_options->outfile_format = 5;
user_options->outfile_format_chgd = 1;
}
if (user_options->hash_mode == 10410)
{
user_options->outfile_format = 5;
user_options->outfile_format_chgd = 1;
}
if (user_options->markov_threshold == 0)
{
user_options->markov_threshold = 0x100;
}
if (user_options->segment_size_chgd == true)
{
user_options->segment_size *= (1024 * 1024);
}
user_options->hc_argc = argc - optind;
user_options->hc_argv = argv + optind;
return 0;
}
int user_options_sanity (user_options_t *user_options, restore_ctx_t *restore_ctx, user_options_extra_t *user_options_extra)
int user_options_sanity (const user_options_t *user_options)
{
if (user_options->hc_argc < 0)
{
log_error ("ERROR: hc_argc %d is invalid", user_options->hc_argc);
return -1;
}
if (user_options->hc_argv == NULL)
{
log_error ("ERROR: hc_argv is NULL");
return -1;
}
if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT)
&& (user_options->attack_mode != ATTACK_MODE_COMBI)
&& (user_options->attack_mode != ATTACK_MODE_BF)
@ -807,12 +702,6 @@ int user_options_sanity (user_options_t *user_options, restore_ctx_t *restore_ct
return -1;
}
if (user_options->gpu_temp_disable == true)
{
user_options->gpu_temp_abort = 0;
user_options->gpu_temp_retain = 0;
}
if ((user_options->gpu_temp_abort != 0) && (user_options->gpu_temp_retain != 0))
{
if (user_options->gpu_temp_abort < user_options->gpu_temp_retain)
@ -825,13 +714,6 @@ int user_options_sanity (user_options_t *user_options, restore_ctx_t *restore_ct
if (user_options->benchmark == true)
{
if (restore_ctx->argv[optind] != NULL)
{
log_error ("ERROR: Invalid argument for benchmark mode specified");
return -1;
}
if (user_options->attack_mode_chgd == true)
{
if (user_options->attack_mode != ATTACK_MODE_BF)
@ -842,66 +724,317 @@ int user_options_sanity (user_options_t *user_options, restore_ctx_t *restore_ct
}
}
}
// argc / argv checks
bool show_error = true;
if (user_options->benchmark == true)
{
if (user_options->hc_argc == 0)
{
show_error = false;
}
}
else if (user_options->opencl_info == true)
{
if (user_options_extra->optind != restore_ctx->argc)
if (user_options->hc_argc == 0)
{
usage_mini_print (restore_ctx->argv[0]);
show_error = false;
}
}
else if (user_options->restore == true)
{
if (user_options->hc_argc == 0)
{
show_error = false;
}
}
else if (user_options->keyspace == true)
{
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
if (user_options->hc_argc == 1)
{
show_error = false;
}
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
if (user_options->hc_argc == 2)
{
show_error = false;
}
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
if (user_options->hc_argc == 1)
{
show_error = false;
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
if (user_options->hc_argc == 2)
{
show_error = false;
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
if (user_options->hc_argc == 2)
{
show_error = false;
}
}
}
else if (user_options->stdout_flag == true)
{
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
// all argc possible because of stdin mode
return -1;
show_error = false;
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
if (user_options->hc_argc == 2)
{
show_error = false;
}
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
if (user_options->hc_argc >= 1)
{
show_error = false;
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
if (user_options->hc_argc >= 1)
{
show_error = false;
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
if (user_options->hc_argc >= 1)
{
show_error = false;
}
}
}
else
{
if (user_options_extra->attack_kern == ATTACK_KERN_NONE)
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
if ((user_options_extra->optind + 1) != restore_ctx->argc)
if (user_options->hc_argc >= 1)
{
usage_mini_print (restore_ctx->argv[0]);
return -1;
show_error = false;
}
}
else if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
if ((user_options_extra->optind + 1) > restore_ctx->argc)
if (user_options->hc_argc == 3)
{
usage_mini_print (restore_ctx->argv[0]);
return -1;
show_error = false;
}
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
if ((user_options_extra->optind + 3) != restore_ctx->argc)
if (user_options->hc_argc >= 2)
{
usage_mini_print (restore_ctx->argv[0]);
return -1;
show_error = false;
}
}
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
if ((user_options_extra->optind + 1) > restore_ctx->argc)
if (user_options->hc_argc >= 2)
{
usage_mini_print (restore_ctx->argv[0]);
return -1;
show_error = false;
}
}
else
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
usage_mini_print (restore_ctx->argv[0]);
return -1;
if (user_options->hc_argc >= 2)
{
show_error = false;
}
}
}
if (show_error == true)
{
usage_mini_print (user_options->hc_bin);
return -1;
}
return 0;
}
int user_options_extra_init (user_options_t *user_options, restore_ctx_t *restore_ctx, user_options_extra_t *user_options_extra)
void user_options_preprocess (user_options_t *user_options)
{
#if !defined (WITH_HWMON)
user_options->powertune_enable = false;
user_options->gpu_temp_disable = true;
user_options->gpu_temp_abort = 0;
user_options->gpu_temp_retain = 0;
#endif // WITH_HWMON
// some options can influence or overwrite other options
if (user_options->opencl_info == true
|| user_options->keyspace == true
|| user_options->benchmark == true
|| user_options->stdout_flag == true)
{
user_options->show = false;
user_options->left = false;
user_options->gpu_temp_disable = true;
user_options->potfile_disable = true;
user_options->powertune_enable = false;
user_options->restore = false;
user_options->restore_disable = true;
user_options->restore_timer = 0;
user_options->logfile_disable = true;
user_options->weak_hash_threshold = 0;
user_options->nvidia_spin_damp = 0;
user_options->status = false;
user_options->status_timer = 0;
user_options->outfile_check_timer = 0;
}
if (user_options->benchmark == true)
{
user_options->session = "benchmark";
user_options->attack_mode = ATTACK_MODE_BF;
user_options->increment = false;
if (user_options->workload_profile_chgd == false)
{
user_options->workload_profile = 3;
}
if (user_options->powertune_enable == true)
{
user_options->gpu_temp_disable = false;
}
}
if (user_options->keyspace == true)
{
user_options->session = "keyspace";
user_options->quiet = true;
}
if (user_options->stdout_flag == true)
{
user_options->session = "stdout";
user_options->quiet = true;
user_options->hash_mode = 2000;
user_options->outfile_format = OUTFILE_FMT_PLAIN;
user_options->force = true;
user_options->kernel_accel = 1024;
user_options->kernel_loops = 1024;
user_options->opencl_vector_width = 1;
}
if (user_options->opencl_info == true)
{
user_options->session = "opencl_info";
user_options->quiet = true;
user_options->opencl_platforms = NULL;
user_options->opencl_devices = NULL;
user_options->opencl_device_types = mystrdup ("1,2,3");
}
if (user_options->left == true)
{
user_options->outfile_format = OUTFILE_FMT_HASH;
}
if (user_options->show == true || user_options->left == true)
{
user_options->attack_mode = ATTACK_MODE_NONE;
user_options->quiet = true;
}
// this allows the user to use --show and --left while cracking (i.e. while another instance of hashcat is running)
if (user_options->show == true || user_options->left == true)
{
user_options->restore_disable = true;
user_options->restore = false;
}
if (user_options->skip != 0 && user_options->limit != 0)
{
user_options->limit += user_options->skip;
}
if (user_options->attack_mode != ATTACK_MODE_STRAIGHT)
{
user_options->weak_hash_threshold = 0;
}
if (user_options->hash_mode == 9710)
{
user_options->outfile_format = 5;
user_options->outfile_format_chgd = 1;
}
if (user_options->hash_mode == 9810)
{
user_options->outfile_format = 5;
user_options->outfile_format_chgd = 1;
}
if (user_options->hash_mode == 10410)
{
user_options->outfile_format = 5;
user_options->outfile_format_chgd = 1;
}
if (user_options->markov_threshold == 0)
{
user_options->markov_threshold = 0x100;
}
if (user_options->segment_size_chgd == true)
{
user_options->segment_size *= (1024 * 1024);
}
if (user_options->gpu_temp_disable == true)
{
user_options->gpu_temp_abort = 0;
user_options->gpu_temp_retain = 0;
}
// default mask
if (user_options->attack_mode == ATTACK_MODE_BF)
{
if (user_options->benchmark == false)
{
if (user_options->hc_argc == 1)
{
user_options->custom_charset_1 = DEF_MASK_CS_1;
user_options->custom_charset_2 = DEF_MASK_CS_2;
user_options->custom_charset_3 = DEF_MASK_CS_3;
user_options->increment = true;
}
}
}
}
void user_options_extra_init (const user_options_t *user_options, user_options_extra_t *user_options_extra)
{
// attack-kern
user_options_extra->attack_kern = ATTACK_KERN_NONE;
switch (user_options->attack_mode)
@ -913,75 +1046,58 @@ int user_options_extra_init (user_options_t *user_options, restore_ctx_t *restor
case ATTACK_MODE_HYBRID2: user_options_extra->attack_kern = ATTACK_KERN_COMBI; break;
}
user_options_extra->optind = optind;
// rules
user_options_extra->rule_len_l = (int) strlen (user_options->rule_buf_l);
user_options_extra->rule_len_r = (int) strlen (user_options->rule_buf_r);
// wordlist_mode
user_options_extra->wordlist_mode = WL_MODE_NONE;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
{
user_options_extra->wordlist_mode = (user_options->hc_argc >= 2) ? WL_MODE_FILE : WL_MODE_STDIN;
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
user_options_extra->wordlist_mode = WL_MODE_FILE;
}
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
{
user_options_extra->wordlist_mode = WL_MODE_MASK;
}
// hc_hash and hc_work*
user_options_extra->hc_hash = NULL;
user_options_extra->hc_workv = NULL;
user_options_extra->hc_workc = 0;
if (user_options->benchmark == true)
{
}
else if (user_options->opencl_info == true)
{
}
else if (user_options->keyspace == true)
{
user_options_extra->hc_workc = user_options->hc_argc;
user_options_extra->hc_workv = user_options->hc_argv;
}
else if (user_options->stdout_flag == true)
{
user_options_extra->hc_workc = user_options->hc_argc;
user_options_extra->hc_workv = user_options->hc_argv;
}
else
{
if (user_options->stdout_flag == true) // no hash here
{
user_options_extra->optind--;
}
if (user_options->keyspace == true)
{
int num_additional_params = 1;
if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
num_additional_params = 2;
}
int keyspace_wordlist_specified = restore_ctx->argc - user_options_extra->optind - num_additional_params;
if (keyspace_wordlist_specified == 0) user_options_extra->optind--;
}
user_options_extra->hc_hash = user_options->hc_argv[0];
user_options_extra->hc_workc = user_options->hc_argc - 1;
user_options_extra->hc_workv = user_options->hc_argv + 1;
}
user_options_extra->rule_len_l = (int) strlen (user_options->rule_buf_l);
user_options_extra->rule_len_r = (int) strlen (user_options->rule_buf_r);
user_options_extra->wordlist_mode = ((user_options_extra->optind + 1) < restore_ctx->argc) ? WL_MODE_FILE : WL_MODE_STDIN;
if (user_options->attack_mode == ATTACK_MODE_BF)
{
user_options_extra->wordlist_mode = WL_MODE_MASK;
// default mask
if (user_options->benchmark == false)
{
if ((user_options_extra->optind + 2) <= restore_ctx->argc)
{
// user provides mask
}
else
{
// prepare default mask charset
user_options->custom_charset_1 = (char *) "?l?d?u";
user_options->custom_charset_2 = (char *) "?l?d";
user_options->custom_charset_3 = (char *) "?l?d*!$@_";
user_options->increment = true;
}
}
}
/* still needed?
if (user_options_extra->wordlist_mode == WL_MODE_STDIN)
{
// enable status (in stdin mode) whenever we do not use --stdout together with an outfile
if (user_options->stdout_flag == true) user_options->status = true;
else if (user_options->outfile) user_options->status = true;
}
*/
return 0;
}
void user_options_extra_destroy (user_options_extra_t *user_options_extra)