Make more use of new user_options_t*

pull/518/head
jsteube 8 years ago
parent cb1375bcd7
commit c008b11de3

@ -6,6 +6,8 @@
#ifndef _COMMON_H
#define _COMMON_H
#define PROGNAME "hashcat"
#if defined (__linux__)
#define _POSIX
#elif defined (__APPLE__)

@ -17,8 +17,8 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, plai
int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos);
int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfile_ctx_t *potfile_ctx, outfile_ctx_t *outfile_ctx, char *hash_or_file, const uint keyspace, const uint quiet, const uint benchmark, const bool opencl_info, const uint stdout_flag, const uint username, const uint remove, const uint show, const uint left);
int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl_ctx_t *opencl_ctx, const uint username, const uint remove, const uint show);
int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfile_ctx_t *potfile_ctx, outfile_ctx_t *outfile_ctx, user_options_t *user_options, char *hash_or_file);
int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl_ctx_t *opencl_ctx, user_options_t *user_options);
void hashes_destroy (hashes_t *hashes);

@ -85,13 +85,13 @@ int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashcon
int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, const uint pws_cnt);
int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, const char *opencl_devices, const char *opencl_device_types, const uint opencl_vector_width, const uint opencl_vector_width_chgd, const uint nvidia_spin_damp, const uint nvidia_spin_damp_chgd, const uint workload_profile, const uint kernel_accel, const uint kernel_accel_chgd, const uint kernel_loops, const uint kernel_loops_chgd, const uint keyspace, const uint stdout_flag);
int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options);
void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx);
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const tuning_db_t *tuning_db, const uint attack_mode, const bool quiet, const bool force, const bool benchmark, const bool opencl_info, const bool machine_readable, const uint algorithm_pos);
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const tuning_db_t *tuning_db, const user_options_t *user_options, const uint algorithm_pos);
void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx);
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx);
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra);
int opencl_session_destroy (opencl_ctx_t *opencl_ctx);
#endif // _OPENCL_H

@ -6,7 +6,7 @@
#ifndef _SESSION_H
#define _SESSION_H
void session_ctx_init (session_ctx_t *session_ctx, const bool quiet, const bool force, const bool benchmark, const u32 scrypt_tmto, char *cwd, char *install_dir, char *profile_dir, char *session_dir, char *shared_dir, char *cpath_real, const u32 wordlist_mode, char *rule_buf_l, char *rule_buf_r, const int rule_len_l, const int rule_len_r, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf, const u32 attack_mode, const u32 attack_kern, const u32 bitmap_size, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, u32 *bitmap_s1_a, u32 *bitmap_s1_b, u32 *bitmap_s1_c, u32 *bitmap_s1_d, u32 *bitmap_s2_a, u32 *bitmap_s2_b, u32 *bitmap_s2_c, u32 *bitmap_s2_d);
void session_ctx_init (session_ctx_t *session_ctx, char *cwd, char *install_dir, char *profile_dir, char *session_dir, char *shared_dir, char *cpath_real, const u32 wordlist_mode, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf,const u32 bitmap_size, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, u32 *bitmap_s1_a, u32 *bitmap_s1_b, u32 *bitmap_s1_c, u32 *bitmap_s1_d, u32 *bitmap_s2_a, u32 *bitmap_s2_b, u32 *bitmap_s2_c, u32 *bitmap_s2_d);
void session_ctx_destroy (session_ctx_t *session_ctx);

@ -513,19 +513,7 @@ typedef struct
u32 devices_filter;
cl_device_type device_types_filter;
u32 opencl_vector_width;
u32 opencl_vector_width_chgd;
u32 nvidia_spin_damp;
u32 nvidia_spin_damp_chgd;
u32 kernel_loops;
u32 kernel_loops_chgd;
u32 kernel_accel;
u32 kernel_accel_chgd;
u32 workload_profile;
double target_ms;
int need_adl;
int need_nvml;
@ -856,18 +844,16 @@ typedef struct
typedef struct
{
u32 attack_kern;
u32 rule_len_r;
u32 rule_len_l;
int optind;
} user_options_extra_t;
typedef struct
{
bool quiet;
bool force;
bool benchmark;
u32 scrypt_tmto;
char *cwd;
char *install_dir;
char *profile_dir;
@ -877,17 +863,9 @@ typedef struct
u32 wordlist_mode;
char *rule_buf_l;
char *rule_buf_r;
int rule_len_l;
int rule_len_r;
u32 kernel_rules_cnt;
kernel_rule_t *kernel_rules_buf;
u32 attack_mode;
u32 attack_kern;
u32 bitmap_size;
u32 bitmap_mask;
u32 bitmap_shift1;

@ -32,8 +32,6 @@
extern hc_global_data_t data;
static double TARGET_MS_PROFILE[4] = { 2, 12, 96, 480 };
static double try_run (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const u32 kernel_accel, const u32 kernel_loops)
{
const u32 kernel_power_try = device_param->device_processors * device_param->kernel_threads * kernel_accel;
@ -58,7 +56,7 @@ static double try_run (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param
int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig)
{
const double target_ms = TARGET_MS_PROFILE[opencl_ctx->workload_profile - 1];
const double target_ms = opencl_ctx->target_ms;
const u32 kernel_accel_min = device_param->kernel_accel_min;
const u32 kernel_accel_max = device_param->kernel_accel_max;
@ -296,7 +294,7 @@ int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashcon
#if defined (DEBUG)
if (data.quiet == 0)
if (data.quiet == false)
{
clear_prompt ();

@ -40,7 +40,7 @@ extern hc_global_data_t data;
static void set_kernel_power_final (const u64 kernel_power_final)
{
if (data.quiet == 0)
if (data.quiet == false)
{
clear_prompt ();
@ -280,7 +280,7 @@ void *thread_calc (void *p)
if (opencl_ctx->run_thread_level1 == false) break;
if (data.benchmark == 1) break;
if (data.benchmark == true) break;
device_param->words_done = words_fin;
}

@ -28,7 +28,7 @@ int adl_init (ADL_PTR *adl)
if (!adl->lib)
{
//if (data.quiet == 0)
//if (data.quiet == false)
// log_info ("WARNING: load ADL library failed, proceed without ADL HWMon enabled.");
return -1;

@ -27,7 +27,7 @@ int nvapi_init (NVAPI_PTR *nvapi)
if (!nvapi->lib)
{
//if (data.quiet == 0)
//if (data.quiet == false)
// log_info ("WARNING: load NVAPI library failed, proceed without NVAPI HWMon enabled.");
return -1;

@ -36,7 +36,7 @@ int nvml_init (NVML_PTR *nvml)
}
else
{
//if (data.quiet == 0)
//if (data.quiet == false)
// log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled.");
return -1;
@ -46,7 +46,7 @@ int nvml_init (NVML_PTR *nvml)
}
else
{
//if (data.quiet == 0)
//if (data.quiet == false)
// log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled.");
return -1;
@ -65,7 +65,7 @@ int nvml_init (NVML_PTR *nvml)
if (!nvml->lib)
{
//if (data.quiet == 0)
//if (data.quiet == false)
// log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled.");
return -1;

@ -26,9 +26,9 @@ int xnvctrl_init (XNVCTRL_PTR *xnvctrl)
if (xnvctrl->lib_x11 == NULL)
{
//if (data.quiet == 0) log_info ("WARNING: Failed loading the X11 library: %s", dlerror());
//if (data.quiet == 0) log_info (" Please install libx11-dev package.");
//if (data.quiet == 0) log_info ("");
//if (data.quiet == false) log_info ("WARNING: Failed loading the X11 library: %s", dlerror());
//if (data.quiet == false) log_info (" Please install libx11-dev package.");
//if (data.quiet == false) log_info ("");
return -1;
}
@ -37,9 +37,9 @@ int xnvctrl_init (XNVCTRL_PTR *xnvctrl)
if (xnvctrl->lib_xnvctrl == NULL)
{
//if (data.quiet == 0) log_info ("WARNING: Failed loading the XNVCTRL library: %s", dlerror());
//if (data.quiet == 0) log_info (" Please install libxnvctrl-dev package.");
//if (data.quiet == 0) log_info ("");
//if (data.quiet == false) log_info ("WARNING: Failed loading the XNVCTRL library: %s", dlerror());
//if (data.quiet == false) log_info (" Please install libxnvctrl-dev package.");
//if (data.quiet == false) log_info ("");
return -1;
}

@ -469,7 +469,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, plai
outfile_write_open (outfile_ctx);
if (outfile_ctx->filename == NULL) if (quiet == 0) clear_prompt ();
if (outfile_ctx->filename == NULL) if (quiet == false) clear_prompt ();
outfile_write (outfile_ctx, out_buf, plain_ptr, plain_len, crackpos, NULL, 0, hashconfig);
@ -479,7 +479,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, plai
{
if ((opencl_ctx->devices_status != STATUS_CRACKED) && (data.status != 1))
{
if (outfile_ctx->filename == NULL) if (quiet == 0) send_prompt ();
if (outfile_ctx->filename == NULL) if (quiet == false) send_prompt ();
}
}
@ -626,7 +626,7 @@ int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, ha
return 0;
}
int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfile_ctx_t *potfile_ctx, outfile_ctx_t *outfile_ctx, char *hash_or_file, const uint keyspace, const uint quiet, const uint benchmark, const bool opencl_info, const uint stdout_flag, const uint username, const uint remove, const uint show, const uint left)
int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfile_ctx_t *potfile_ctx, outfile_ctx_t *outfile_ctx, user_options_t *user_options, char *hash_or_file)
{
/**
* load hashes, part I: find input mode, count hashes
@ -637,7 +637,7 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
uint hashes_avail = 0;
if ((benchmark == 0) && (stdout_flag == 0))
if ((user_options->benchmark == false) && (user_options->stdout_flag == false))
{
struct stat f;
@ -691,7 +691,7 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
return -1;
}
if (quiet == 0) log_info_nn ("Counting lines in %s", hashfile);
if (user_options->quiet == false) log_info_nn ("Counting lines in %s", hashfile);
hashes_avail = count_lines (fp);
@ -708,7 +708,7 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
hashlist_format = hlfmt_detect (fp, 100, hashconfig); // 100 = max numbers to "scan". could be hashes_avail, too
if ((remove == 1) && (hashlist_format != HLFMT_HASHCAT))
if ((user_options->remove == 1) && (hashlist_format != HLFMT_HASHCAT))
{
log_error ("ERROR: remove not supported in native hashfile-format mode");
@ -745,7 +745,7 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
digests_buf = (void *) mycalloc (hashes_avail, hashconfig->dgst_size);
if ((username && (remove || show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY))
if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY))
{
u32 hash_pos;
@ -755,12 +755,12 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
hashes_buf[hash_pos].hash_info = hash_info;
if (username && (remove || show || left))
if (user_options->username && (user_options->remove || user_options->show || user_options->left))
{
hash_info->user = (user_t*) mymalloc (sizeof (user_t));
}
if (benchmark)
if (user_options->benchmark)
{
hash_info->orighash = (char *) mymalloc (256);
}
@ -811,18 +811,28 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
uint hashes_cnt = 0;
if (benchmark == 0 && !opencl_info)
if (user_options->benchmark == true)
{
if (keyspace == 1)
{
// useless to read hash file for keyspace, cheat a little bit w/ optind
}
else if (stdout_flag == 1)
{
// useless to read hash file for stdout, cheat a little bit w/ optind
}
else if (hashes_avail == 0)
hashconfig_benchmark_defaults ((hashconfig_t *) hashconfig, hashes_buf[0].salt, hashes_buf[0].esalt);
hashes->hashfile = "-";
hashes_cnt = 1;
}
else if (user_options->keyspace == true)
{
}
else if (user_options->stdout_flag == true)
{
}
else if (user_options->opencl_info == true)
{
}
else
{
if (hashes_avail == 0)
{
// ???
}
else if (hashlist_mode == HL_MODE_ARG)
{
@ -917,7 +927,7 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
// hack: append MAC1 and MAC2 s.t. in --show and --left the line matches with the .pot file format (i.e. ESSID:MAC1:MAC2)
if ((show == 1) || (left == 1))
if ((user_options->show == true) || (user_options->left == true))
{
salt_t *tmp_salt = hashes_buf[hashes_cnt].salt;
@ -956,8 +966,8 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
tmp_salt->salt_len += 1 + 12 + 1 + 12;
}
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf);
if (user_options->show == true) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf);
if (user_options->left == true) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf);
hashes_cnt++;
}
@ -1004,8 +1014,8 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
if ((lm_hash_left != NULL) && (lm_hash_right != NULL))
{
if (show == 1) potfile_show_request_lm (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot);
if (left == 1) potfile_left_request_lm (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot);
if (user_options->show == true) potfile_show_request_lm (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot);
if (user_options->left == true) potfile_left_request_lm (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot);
}
}
else
@ -1014,8 +1024,8 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
if (parser_status == PARSER_OK)
{
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (user_options->show == true) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (user_options->left == true) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
}
if (parser_status == PARSER_OK)
@ -1034,8 +1044,8 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
if (parser_status == PARSER_OK)
{
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (user_options->show == true) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (user_options->left == true) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
}
if (parser_status == PARSER_OK)
@ -1091,14 +1101,14 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
continue;
}
if (username)
if (user_options->username)
{
char *user_buf = NULL;
int user_len = 0;
hlfmt_user (hashlist_format, line_buf, line_len, &user_buf, &user_len, hashconfig);
if (remove || show)
if (user_options->remove || user_options->show)
{
user_t **user = &hashes_buf[hashes_cnt].hash_info->user;
@ -1159,14 +1169,14 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
hash_t *lm_hash_right = &hashes_buf[hashes_cnt];
if (data.quiet == 0) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
hashes_cnt++;
// show / left
if (show == 1) potfile_show_request_lm (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot);
if (left == 1) potfile_left_request_lm (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot);
if (user_options->show == true) potfile_show_request_lm (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot);
if (user_options->left == true) potfile_left_request_lm (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot);
}
else
{
@ -1179,10 +1189,10 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
continue;
}
if (data.quiet == 0) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (user_options->show == true) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (user_options->left == true) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
hashes_cnt++;
}
@ -1198,10 +1208,10 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
continue;
}
if (data.quiet == 0) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
if (show == 1) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (left == 1) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (user_options->show == true) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (user_options->left == true) potfile_left_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
hashes_cnt++;
}
@ -1211,17 +1221,9 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
fclose (fp);
if (data.quiet == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_avail, hashes_avail, 100.00);
if (user_options->quiet == false) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_avail, hashes_avail, 100.00);
}
}
else
{
hashconfig_benchmark_defaults ((hashconfig_t *) hashconfig, hashes_buf[0].salt, hashes_buf[0].esalt);
hashes->hashfile = "-";
hashes_cnt = 1;
}
hashes->hashes_cnt = hashes_cnt;
@ -1237,7 +1239,7 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
return 0;
}
int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl_ctx_t *opencl_ctx, const uint username, const uint remove, const uint show)
int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl_ctx_t *opencl_ctx, user_options_t *user_options)
{
hash_t *hashes_buf = hashes->hashes_buf;
uint hashes_cnt = hashes->hashes_cnt;
@ -1246,7 +1248,7 @@ int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl
* Remove duplicates
*/
if (data.quiet == 0) log_info_nn ("Removing duplicate hashes...");
if (user_options->quiet == false) log_info_nn ("Removing duplicate hashes...");
hashes_cnt = 1;
@ -1296,7 +1298,7 @@ int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl
salts_buf_new = (salt_t *) mycalloc (1, sizeof (salt_t));
}
if (data.quiet == 0) log_info_nn ("Structuring salts for cracking task...");
if (user_options->quiet == false) log_info_nn ("Structuring salts for cracking task...");
uint digests_cnt = hashes_cnt;
uint digests_done = 0;
@ -1309,11 +1311,11 @@ int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl
hashinfo_t **hash_info = NULL;
if ((username && (remove || show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY))
if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY))
{
hash_info = (hashinfo_t **) mycalloc (hashes_cnt, sizeof (hashinfo_t *));
if (username && (remove || show))
if (user_options->username && (user_options->remove || user_options->show))
{
uint user_pos;
@ -1362,7 +1364,7 @@ int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl
memcpy (((char *) digests_buf_new) + (0 * hashconfig->dgst_size), hashes_buf[0].digest, hashconfig->dgst_size);
if ((username && (remove || show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY))
if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY))
{
hash_info[0] = hashes_buf[0].hash_info;
}
@ -1405,7 +1407,7 @@ int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl
memcpy (((char *) digests_buf_new) + (hashes_pos * hashconfig->dgst_size), hashes_buf[hashes_pos].digest, hashconfig->dgst_size);
if ((username && (remove || show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY))
if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY))
{
hash_info[hashes_pos] = hashes_buf[hashes_pos].hash_info;
}

File diff suppressed because it is too large Load Diff

@ -154,7 +154,7 @@ void *thread_monitor (void *p)
{
if (slowdown_warnings < 3)
{
if (data.quiet == 0) clear_prompt ();
if (data.quiet == false) clear_prompt ();
log_info ("WARNING: Drivers temperature threshold hit on GPU #%d, expect performance to drop...", device_id + 1);
@ -163,7 +163,7 @@ void *thread_monitor (void *p)
log_info ("");
}
if (data.quiet == 0) send_prompt ();
if (data.quiet == false) send_prompt ();
slowdown_warnings++;
}
@ -287,7 +287,7 @@ void *thread_monitor (void *p)
{
restore_left--;
if (restore_left == 0)
if (restore_left == false)
{
if (data.restore_disable == 0) cycle_restore (opencl_ctx);
@ -316,9 +316,9 @@ void *thread_monitor (void *p)
if (runtime_left <= 0)
{
if (data.benchmark == 0)
if (data.benchmark == false)
{
if (data.quiet == 0) log_info ("\nNOTE: Runtime limit reached, aborting...\n");
if (data.quiet == false) log_info ("\nNOTE: Runtime limit reached, aborting...\n");
}
myabort (opencl_ctx);
@ -329,7 +329,7 @@ void *thread_monitor (void *p)
{
remove_left--;
if (remove_left == 0)
if (remove_left == false)
{
if (hashes->digests_saved != hashes->digests_done)
{
@ -346,17 +346,17 @@ void *thread_monitor (void *p)
{
status_left--;
if (status_left == 0)
if (status_left == false)
{
hc_thread_mutex_lock (mux_display);
if (data.quiet == 0) clear_prompt ();
if (data.quiet == false) clear_prompt ();
if (data.quiet == 0) log_info ("");
if (data.quiet == false) log_info ("");
status_display (opencl_ctx, hashconfig, hashes);
if (data.quiet == 0) log_info ("");
if (data.quiet == false) log_info ("");
hc_thread_mutex_unlock (mux_display);

@ -44,6 +44,8 @@ extern hc_thread_mutex_t mux_hwmon;
extern const int comptime;
static double TARGET_MS_PROFILE[4] = { 2, 12, 96, 480 };
char *strstatus (const uint devices_status)
{
switch (devices_status)
@ -355,7 +357,7 @@ int choose_kernel (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, ha
device_param->speed_ms[speed_pos] = speed_ms;
if (data.benchmark == 1)
if (data.benchmark == true)
{
if (speed_ms > 4096) myabort (opencl_ctx);
}
@ -1047,7 +1049,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
device_param->kernel_params_buf32[30] = innerloop_left;
// i think we can get rid of this
if (innerloop_left == 0)
if (innerloop_left == false)
{
puts ("bug, how should this happen????\n");
@ -1227,7 +1229,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
}
}
if (data.benchmark == 1)
if (data.benchmark == true)
{
hc_timer_set (&device_param->timer_speed);
}
@ -1240,7 +1242,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
* result
*/
if (data.benchmark == 0)
if (data.benchmark == false)
{
check_cracked (opencl_ctx, device_param, hashconfig, hashes, salt_pos);
}
@ -1288,7 +1290,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
* benchmark
*/
if (data.benchmark == 1) break;
if (data.benchmark == true) break;
if (opencl_ctx->run_thread_level2 == false) break;
}
@ -1303,11 +1305,11 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
return 0;
}
int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, const char *opencl_devices, const char *opencl_device_types, const uint opencl_vector_width, const uint opencl_vector_width_chgd, const uint nvidia_spin_damp, const uint nvidia_spin_damp_chgd, const uint workload_profile, const uint kernel_accel, const uint kernel_accel_chgd, const uint kernel_loops, const uint kernel_loops_chgd, const uint keyspace, const uint stdout_flag)
int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options)
{
if (keyspace == 1)
if (user_options->keyspace == true)
{
opencl_ctx->disable = 1;
opencl_ctx->disable = true;
return 0;
}
@ -1315,21 +1317,12 @@ int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, con
hc_thread_mutex_init (opencl_ctx->mux_dispatcher);
hc_thread_mutex_init (opencl_ctx->mux_counter);
opencl_ctx->devices_status = STATUS_INIT;
opencl_ctx->run_main_level1 = true;
opencl_ctx->run_main_level2 = true;
opencl_ctx->run_main_level3 = true;
opencl_ctx->run_thread_level1 = true;
opencl_ctx->run_thread_level2 = true;
opencl_ctx->opencl_vector_width_chgd = opencl_vector_width_chgd;
opencl_ctx->opencl_vector_width = opencl_vector_width;
opencl_ctx->nvidia_spin_damp_chgd = nvidia_spin_damp_chgd;
opencl_ctx->nvidia_spin_damp = nvidia_spin_damp;
opencl_ctx->kernel_accel_chgd = kernel_accel_chgd;
opencl_ctx->kernel_accel = kernel_accel;
opencl_ctx->kernel_loops_chgd = kernel_loops_chgd;
opencl_ctx->kernel_loops = kernel_loops;
opencl_ctx->workload_profile = workload_profile;
opencl_ctx->devices_status = STATUS_INIT;
opencl_ctx->run_main_level1 = true;
opencl_ctx->run_main_level2 = true;
opencl_ctx->run_main_level3 = true;
opencl_ctx->run_thread_level1 = true;
opencl_ctx->run_thread_level2 = true;
opencl_ctx->ocl = (OCL_PTR *) mymalloc (sizeof (OCL_PTR));
@ -1348,7 +1341,7 @@ int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, con
* OpenCL platform selection
*/
u32 opencl_platforms_filter = setup_opencl_platforms_filter (opencl_platforms);
u32 opencl_platforms_filter = setup_opencl_platforms_filter (user_options->opencl_platforms);
opencl_ctx->opencl_platforms_filter = opencl_platforms_filter;
@ -1356,7 +1349,7 @@ int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, con
* OpenCL device selection
*/
u32 devices_filter = setup_devices_filter (opencl_devices);
u32 devices_filter = setup_devices_filter (user_options->opencl_devices);
opencl_ctx->devices_filter = devices_filter;
@ -1364,7 +1357,7 @@ int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, con
* OpenCL device type selection
*/
cl_device_type device_types_filter = setup_device_types_filter (opencl_device_types);
cl_device_type device_types_filter = setup_device_types_filter (user_options->opencl_device_types);
opencl_ctx->device_types_filter = device_types_filter;
@ -1412,7 +1405,7 @@ int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, con
}
}
if (opencl_device_types == NULL)
if (user_options->opencl_device_types == NULL)
{
/**
* OpenCL device types:
@ -1469,7 +1462,7 @@ int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, con
// In another case, when the user uses --stdout, using CPU devices is much faster to setup
// If we have a CPU device, force it to be used
if (stdout_flag == 1)
if (user_options->stdout_flag == true)
{
if (device_types_all & CL_DEVICE_TYPE_CPU)
{
@ -1506,7 +1499,7 @@ void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx)
myfree (opencl_ctx);
}
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const tuning_db_t *tuning_db, const uint attack_mode, const bool quiet, const bool force, const bool benchmark, const bool opencl_info, const bool machine_readable, const uint algorithm_pos)
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const tuning_db_t *tuning_db, const user_options_t *user_options, const uint algorithm_pos)
{
if (opencl_ctx->disable == 1) return 0;
@ -1528,7 +1521,7 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
u32 devices_active = 0;
if (opencl_info)
if (user_options->opencl_info == true)
{
fprintf (stdout, "OpenCL Info:\n");
}
@ -1606,7 +1599,7 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
platform_skipped = 2;
}
if (opencl_info)
if (user_options->opencl_info == true)
{
char platform_name[HCBUFSIZ_TINY] = { 0 };
@ -1633,9 +1626,9 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
fprintf (stdout, "\nPlatform ID #%u\n Vendor : %s\n Name : %s\n Version : %s\n\n", platform_id, platform_vendor, platform_name, platform_version);
}
if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
if ((user_options->benchmark == true || user_options->quiet == false) && (algorithm_pos == 0))
{
if (machine_readable == 0)
if (user_options->machine_readable == false)
{
if (platform_skipped == 0)
{
@ -1841,11 +1834,11 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
cl_uint vector_width;
if (opencl_ctx->opencl_vector_width_chgd == 0)
if (user_options->opencl_vector_width_chgd == false)
{
// tuning db
tuning_db_entry_t *tuningdb_entry = tuning_db_search (tuning_db, device_param->device_name, device_param->device_type, attack_mode, hashconfig->hash_mode);
tuning_db_entry_t *tuningdb_entry = tuning_db_search (tuning_db, device_param->device_name, device_param->device_type, user_options->attack_mode, hashconfig->hash_mode);
if (tuningdb_entry == NULL || tuningdb_entry->vector_width == -1)
{
@ -1879,7 +1872,7 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
}
else
{
vector_width = opencl_ctx->opencl_vector_width;
vector_width = user_options->opencl_vector_width;
}
if (vector_width > 16) vector_width = 16;
@ -2112,7 +2105,7 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
{
if (device_param->device_vendor_id == VENDOR_ID_AMD_USE_INTEL)
{
if (force == 0)
if (user_options->force == 0)
{
if (algorithm_pos == 0)
{
@ -2245,11 +2238,11 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
// Value is given as number between 0-100
// By default 100%
device_param->nvidia_spin_damp = (double) opencl_ctx->nvidia_spin_damp;
device_param->nvidia_spin_damp = (double) user_options->nvidia_spin_damp;
if (opencl_ctx->nvidia_spin_damp_chgd == 0)
if (user_options->nvidia_spin_damp_chgd == false)
{
if (attack_mode == ATTACK_MODE_STRAIGHT)
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
/**
* the workaround is not a friend of rule based attacks
@ -2268,7 +2261,7 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
// display results
if (opencl_info)
if (user_options->opencl_info == true)
{
char *format = " Device ID #%u\n Type : %s\n Vendor ID : %u\n Vendor : %s\n Name : %s\n Processor(s) : %u\n Clock : %u\n Memory : %lu/%lu MB allocatable\n OpenCL Version : %s\n\n";
@ -2283,9 +2276,9 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
myfree (device_opencl_version);
if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
if ((user_options->benchmark == true || user_options->quiet == false) && (algorithm_pos == 0))
{
if (machine_readable == 0)
if (user_options->machine_readable == false)
{
if (device_param->skipped == 0)
{
@ -2313,7 +2306,7 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
{
if (platform_vendor_id == VENDOR_ID_AMD)
{
int catalyst_check = (force == 1) ? 0 : 1;
int catalyst_check = (user_options->force == 1) ? 0 : 1;
int catalyst_warn = 0;
@ -2363,8 +2356,8 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
{
if (device_param->kernel_exec_timeout != 0)
{
if (quiet == 0) log_info ("- Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1);
if (quiet == 0) log_info (" See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch");
if (user_options->quiet == false) log_info ("- Device #%u: WARNING! Kernel exec timeout is not disabled, it might cause you errors of code 702", device_id + 1);
if (user_options->quiet == false) log_info (" See the wiki on how to disable it: https://hashcat.net/wiki/doku.php?id=timeout_patch");
}
}
}
@ -2374,7 +2367,7 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
{
if (platform_vendor_id == VENDOR_ID_AMD)
{
if (force == 0)
if (user_options->force == 0)
{
log_info ("");
log_info ("ATTENTION! OpenCL support for CPU of catalyst driver is not reliable.");
@ -2399,7 +2392,7 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
device_param->kernel_loops_min = 1;
device_param->kernel_loops_max = 1024;
tuning_db_entry_t *tuningdb_entry = tuning_db_search (tuning_db, device_param->device_name, device_param->device_type, attack_mode, hashconfig->hash_mode);
tuning_db_entry_t *tuningdb_entry = tuning_db_search (tuning_db, device_param->device_name, device_param->device_type, user_options->attack_mode, hashconfig->hash_mode);
if (tuningdb_entry != NULL)
{
@ -2414,11 +2407,11 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
if (_kernel_loops)
{
if (opencl_ctx->workload_profile == 1)
if (user_options->workload_profile == 1)
{
_kernel_loops = (_kernel_loops > 8) ? _kernel_loops / 8 : 1;
}
else if (opencl_ctx->workload_profile == 2)
else if (user_options->workload_profile == 2)
{
_kernel_loops = (_kernel_loops > 4) ? _kernel_loops / 4 : 1;
}
@ -2430,16 +2423,16 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
// commandline parameters overwrite tuningdb entries
if (opencl_ctx->kernel_accel_chgd == 1)
if (user_options->kernel_accel_chgd == true)
{
device_param->kernel_accel_min = opencl_ctx->kernel_accel;
device_param->kernel_accel_max = opencl_ctx->kernel_accel;
device_param->kernel_accel_min = user_options->kernel_accel;
device_param->kernel_accel_max = user_options->kernel_accel;
}
if (opencl_ctx->kernel_loops_chgd == 1)
if (user_options->kernel_loops_chgd == true)
{
device_param->kernel_loops_min = opencl_ctx->kernel_loops;
device_param->kernel_loops_max = opencl_ctx->kernel_loops;
device_param->kernel_loops_min = user_options->kernel_loops;
device_param->kernel_loops_max = user_options->kernel_loops;
}
/**
@ -2454,18 +2447,18 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
devices_cnt++;
}
if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
if ((user_options->benchmark == true || user_options->quiet == false) && (algorithm_pos == 0))
{
if (machine_readable == 0)
if (user_options->machine_readable == false)
{
log_info ("");
}
}
}
if (opencl_info)
if (user_options->opencl_info == true)
{
exit(0);
exit (0);
}
if (devices_active == 0)
@ -2489,6 +2482,8 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
}
}
opencl_ctx->target_ms = TARGET_MS_PROFILE[user_options->workload_profile - 1];
opencl_ctx->devices_cnt = devices_cnt;
opencl_ctx->devices_active = devices_active;
@ -2523,7 +2518,7 @@ void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx)
opencl_ctx->need_xnvctrl = 0;
}
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx)
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra)
{
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
@ -2681,9 +2676,9 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
uint tmto_start = 0;
uint tmto_stop = 10;
if (session_ctx->scrypt_tmto)
if (user_options->scrypt_tmto)
{
tmto_start = session_ctx->scrypt_tmto;
tmto_start = user_options->scrypt_tmto;
}
else
{
@ -2729,14 +2724,14 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
if ((size_scrypt / 4) > device_param->device_maxmem_alloc)
{
if (session_ctx->quiet == 0) log_info ("WARNING: Not enough single-block device memory allocatable to use --scrypt-tmto %d, increasing...", tmto);
if (user_options->quiet == false) log_info ("WARNING: Not enough single-block device memory allocatable to use --scrypt-tmto %d, increasing...", tmto);
continue;
}
if (size_scrypt > device_param->device_global_mem)
{
if (session_ctx->quiet == 0) log_info ("WARNING: Not enough total device memory allocatable to use --scrypt-tmto %d, increasing...", tmto);
if (user_options->quiet == false) log_info ("WARNING: Not enough total device memory allocatable to use --scrypt-tmto %d, increasing...", tmto);
continue;
}
@ -2756,7 +2751,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
return -1;
}
if (session_ctx->quiet == 0) log_info ("SCRYPT tmto optimizer value set to: %u, mem: %" PRIu64 "\n", scrypt_tmto_final, size_scrypt);
if (user_options->quiet == false) log_info ("SCRYPT tmto optimizer value set to: %u, mem: %" PRIu64 "\n", scrypt_tmto_final, size_scrypt);
}
size_t size_scrypt4 = size_scrypt / 4;
@ -2765,7 +2760,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
* some algorithms need a fixed kernel-loops count
*/
if (hashconfig->hash_mode == 1500 && session_ctx->attack_mode == ATTACK_MODE_BF)
if (hashconfig->hash_mode == 1500 && user_options->attack_mode == ATTACK_MODE_BF)
{
const u32 kernel_loops_fixed = 1024;
@ -2773,7 +2768,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
device_param->kernel_loops_max = kernel_loops_fixed;
}
if (hashconfig->hash_mode == 3000 && session_ctx->attack_mode == ATTACK_MODE_BF)
if (hashconfig->hash_mode == 3000 && user_options->attack_mode == ATTACK_MODE_BF)
{
const u32 kernel_loops_fixed = 1024;
@ -2805,7 +2800,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
device_param->kernel_loops_max = kernel_loops_fixed;
}
if (hashconfig->hash_mode == 14000 && session_ctx->attack_mode == ATTACK_MODE_BF)
if (hashconfig->hash_mode == 14000 && user_options->attack_mode == ATTACK_MODE_BF)
{
const u32 kernel_loops_fixed = 1024;
@ -2813,7 +2808,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
device_param->kernel_loops_max = kernel_loops_fixed;
}
if (hashconfig->hash_mode == 14100 && session_ctx->attack_mode == ATTACK_MODE_BF)
if (hashconfig->hash_mode == 14100 && user_options->attack_mode == ATTACK_MODE_BF)
{
const u32 kernel_loops_fixed = 1024;
@ -3000,7 +2995,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
/*
if (kernel_accel_max < kernel_accel)
{
if (session_ctx->quiet == 0) log_info ("- Device #%u: Reduced maximum kernel-accel to %u", device_id + 1, kernel_accel_max);
if (user_options->quiet == false) log_info ("- Device #%u: Reduced maximum kernel-accel to %u", device_id + 1, kernel_accel_max);
device_param->kernel_accel = kernel_accel_max;
}
@ -3110,7 +3105,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
char source_file[256] = { 0 };
generate_source_kernel_filename (hashconfig->attack_exec, session_ctx->attack_kern, hashconfig->kern_type, session_ctx->shared_dir, source_file);
generate_source_kernel_filename (hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, session_ctx->shared_dir, source_file);
struct stat sst;
@ -3127,7 +3122,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
char cached_file[256] = { 0 };
generate_cached_kernel_filename (hashconfig->attack_exec, session_ctx->attack_kern, hashconfig->kern_type, session_ctx->profile_dir, device_name_chksum, cached_file);
generate_cached_kernel_filename (hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, session_ctx->profile_dir, device_name_chksum, cached_file);
int cached = 1;
@ -3150,7 +3145,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
{
if (cached == 0)
{
if (session_ctx->quiet == 0) log_info ("- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file));
if (user_options->quiet == false) log_info ("- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file));
load_kernel (source_file, 1, kernel_lengths, kernel_sources);
@ -3366,7 +3361,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
* word generator kernel
*/
if (session_ctx->attack_mode != ATTACK_MODE_STRAIGHT)
if (user_options->attack_mode != ATTACK_MODE_STRAIGHT)
{
/**
* kernel mp source filename
@ -3412,8 +3407,8 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
if (cached == 0)
{
if (session_ctx->quiet == 0) log_info ("- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file));
if (session_ctx->quiet == 0) log_info ("");
if (user_options->quiet == false) log_info ("- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file));
if (user_options->quiet == false) log_info ("");
load_kernel (source_file, 1, kernel_lengths, kernel_sources);
@ -3555,7 +3550,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
char source_file[256] = { 0 };
generate_source_kernel_amp_filename (session_ctx->attack_kern, session_ctx->shared_dir, source_file);
generate_source_kernel_amp_filename (user_options_extra->attack_kern, session_ctx->shared_dir, source_file);
struct stat sst;
@ -3572,7 +3567,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
char cached_file[256] = { 0 };
generate_cached_kernel_amp_filename (session_ctx->attack_kern, session_ctx->profile_dir, device_name_chksum, cached_file);
generate_cached_kernel_amp_filename (user_options_extra->attack_kern, session_ctx->profile_dir, device_name_chksum, cached_file);
int cached = 1;
@ -3593,8 +3588,8 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
if (cached == 0)
{
if (session_ctx->quiet == 0) log_info ("- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file));
if (session_ctx->quiet == 0) log_info ("");
if (user_options->quiet == false) log_info ("- Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file));
if (user_options->quiet == false) log_info ("");
load_kernel (source_file, 1, kernel_lengths, kernel_sources);
@ -3691,7 +3686,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
else
{
#if defined (DEBUG)
if (session_ctx->quiet == 0) log_info ("- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size);
if (user_options->quiet == false) log_info ("- Device #%u: Kernel %s (%ld bytes)", device_id + 1, cached_file, cst.st_size);
#endif
load_kernel (cached_file, 1, kernel_lengths, kernel_sources);
@ -3731,7 +3726,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
// some algorithm collide too fast, make that impossible
if (session_ctx->benchmark == 1)
if (user_options->benchmark == true)
{
((uint *) hashes->digests_buf)[0] = -1u;
((uint *) hashes->digests_buf)[1] = -1u;
@ -3795,7 +3790,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
* special buffers
*/
if (session_ctx->attack_kern == ATTACK_KERN_STRAIGHT)
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
{
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_rules, NULL, &device_param->d_rules);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_rules_c, NULL, &device_param->d_rules_c);
@ -3816,7 +3811,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
return -1;
}
}
else if (session_ctx->attack_kern == ATTACK_KERN_COMBI)
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs_c);
@ -3830,7 +3825,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
return -1;
}
}
else if (session_ctx->attack_kern == ATTACK_KERN_BF)
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
{
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs);
CL_err |= hc_clCreateBuffer (opencl_ctx->ocl, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs_c);
@ -4092,7 +4087,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
}
}
if (session_ctx->attack_mode == ATTACK_MODE_BF)
if (user_options->attack_mode == ATTACK_MODE_BF)
{
if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE)
{
@ -4278,7 +4273,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
// MP start
if (session_ctx->attack_mode == ATTACK_MODE_BF)
if (user_options->attack_mode == ATTACK_MODE_BF)
{
CL_err |= hc_clCreateKernel (opencl_ctx->ocl, device_param->program_mp, "l_markov", &device_param->kernel_mp_l);
CL_err |= hc_clCreateKernel (opencl_ctx->ocl, device_param->program_mp, "r_markov", &device_param->kernel_mp_r);
@ -4313,7 +4308,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
}
}
}
else if (session_ctx->attack_mode == ATTACK_MODE_HYBRID1)
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program_mp, "C_markov", &device_param->kernel_mp);
@ -4333,7 +4328,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
return -1;
}
}
else if (session_ctx->attack_mode == ATTACK_MODE_HYBRID2)
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
CL_err = hc_clCreateKernel (opencl_ctx->ocl, device_param->program_mp, "C_markov", &device_param->kernel_mp);
@ -4428,18 +4423,18 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
* special buffers
*/
if (session_ctx->attack_kern == ATTACK_KERN_STRAIGHT)
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
{
run_kernel_bzero (opencl_ctx, device_param, device_param->d_rules_c, size_rules_c);
}
else if (session_ctx->attack_kern == ATTACK_KERN_COMBI)
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
run_kernel_bzero (opencl_ctx, device_param, device_param->d_combs, size_combs);
run_kernel_bzero (opencl_ctx, device_param, device_param->d_combs_c, size_combs);
run_kernel_bzero (opencl_ctx, device_param, device_param->d_root_css_buf, size_root_css);
run_kernel_bzero (opencl_ctx, device_param, device_param->d_markov_css_buf, size_markov_css);
}
else if (session_ctx->attack_kern == ATTACK_KERN_BF)
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
{
run_kernel_bzero (opencl_ctx, device_param, device_param->d_bfs, size_bfs);
run_kernel_bzero (opencl_ctx, device_param, device_param->d_bfs_c, size_bfs);

@ -79,7 +79,7 @@ void *thread_outfile_remove (void *p)
check_left--;
if (check_left == 0)
if (check_left == false)
{
struct stat outfile_check_stat;

@ -7,14 +7,8 @@
#include "types.h"
#include "session.h"
void session_ctx_init (session_ctx_t *session_ctx, const bool quiet, const bool force, const bool benchmark, const u32 scrypt_tmto, char *cwd, char *install_dir, char *profile_dir, char *session_dir, char *shared_dir, char *cpath_real, const u32 wordlist_mode, char *rule_buf_l, char *rule_buf_r, const int rule_len_l, const int rule_len_r, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf, const u32 attack_mode, const u32 attack_kern, const u32 bitmap_size, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, u32 *bitmap_s1_a, u32 *bitmap_s1_b, u32 *bitmap_s1_c, u32 *bitmap_s1_d, u32 *bitmap_s2_a, u32 *bitmap_s2_b, u32 *bitmap_s2_c, u32 *bitmap_s2_d)
void session_ctx_init (session_ctx_t *session_ctx, char *cwd, char *install_dir, char *profile_dir, char *session_dir, char *shared_dir, char *cpath_real, const u32 wordlist_mode, const u32 kernel_rules_cnt, kernel_rule_t *kernel_rules_buf,const u32 bitmap_size, const u32 bitmap_mask, const u32 bitmap_shift1, const u32 bitmap_shift2, u32 *bitmap_s1_a, u32 *bitmap_s1_b, u32 *bitmap_s1_c, u32 *bitmap_s1_d, u32 *bitmap_s2_a, u32 *bitmap_s2_b, u32 *bitmap_s2_c, u32 *bitmap_s2_d)
{
session_ctx->quiet = quiet;
session_ctx->force = force;
session_ctx->benchmark = benchmark;
session_ctx->scrypt_tmto = scrypt_tmto;
session_ctx->cwd = cwd;
session_ctx->install_dir = install_dir;
session_ctx->profile_dir = profile_dir;
@ -24,17 +18,9 @@ void session_ctx_init (session_ctx_t *session_ctx, const bool quiet, const bool
session_ctx->wordlist_mode = wordlist_mode;
session_ctx->rule_buf_l = rule_buf_l;
session_ctx->rule_buf_r = rule_buf_r;
session_ctx->rule_len_l = rule_len_l;
session_ctx->rule_len_r = rule_len_r;
session_ctx->kernel_rules_cnt = kernel_rules_cnt;
session_ctx->kernel_rules_buf = kernel_rules_buf;
session_ctx->attack_mode = attack_mode;
session_ctx->attack_kern = attack_kern;
session_ctx->bitmap_size = bitmap_size;
session_ctx->bitmap_mask = bitmap_mask;
session_ctx->bitmap_shift1 = bitmap_shift1;
@ -52,12 +38,6 @@ void session_ctx_init (session_ctx_t *session_ctx, const bool quiet, const bool
void session_ctx_destroy (session_ctx_t *session_ctx)
{
session_ctx->quiet = false;
session_ctx->force = false;
session_ctx->benchmark = false;
session_ctx->scrypt_tmto = 0;
session_ctx->cwd = NULL;
session_ctx->install_dir = NULL;
session_ctx->profile_dir = NULL;
@ -67,17 +47,9 @@ void session_ctx_destroy (session_ctx_t *session_ctx)
session_ctx->wordlist_mode = 0;
session_ctx->rule_buf_l = NULL;
session_ctx->rule_buf_r = NULL;
session_ctx->rule_len_l = 0;
session_ctx->rule_len_r = 0;
session_ctx->kernel_rules_buf = NULL;
session_ctx->kernel_rules_cnt = 0;
session_ctx->attack_mode = 0;
session_ctx->attack_kern = 0;
session_ctx->bitmap_size = 0;
session_ctx->bitmap_mask = 0;
session_ctx->bitmap_shift1 = 0;

@ -300,7 +300,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
// in this case some required buffers are free'd, ascii_digest() would run into segfault
if (data.shutdown_inner == 1) return;
if (data.machine_readable == 1)
if (data.machine_readable == true)
{
status_display_machine_readable (opencl_ctx, hashes);
@ -1144,7 +1144,7 @@ void status_benchmark_automate (opencl_ctx_t *opencl_ctx, const hashconfig_t *ha
speed_ms[device_id] = device_param->speed_ms[0];
}
double hashes_dev_ms[DEVICES_MAX] = { 0 };
u64 hashes_dev_ms[DEVICES_MAX] = { 0 };
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
@ -1181,7 +1181,7 @@ void status_benchmark (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig)
if (data.shutdown_inner == 1) return;
if (data.machine_readable == 1)
if (data.machine_readable == true)
{
status_benchmark_automate (opencl_ctx, hashconfig);

@ -99,7 +99,7 @@ void *thread_keypress (void *p)
log_info ("");
if (quiet == 0) send_prompt ();
if (quiet == false) send_prompt ();
break;
@ -111,7 +111,7 @@ void *thread_keypress (void *p)
log_info ("");
if (quiet == 0) send_prompt ();
if (quiet == false) send_prompt ();
break;
@ -123,7 +123,7 @@ void *thread_keypress (void *p)
log_info ("");
if (quiet == 0) send_prompt ();
if (quiet == false) send_prompt ();
break;
@ -135,7 +135,7 @@ void *thread_keypress (void *p)
log_info ("");
if (quiet == 0) send_prompt ();
if (quiet == false) send_prompt ();
break;
@ -147,7 +147,7 @@ void *thread_keypress (void *p)
log_info ("");
if (quiet == 0) send_prompt ();
if (quiet == false) send_prompt ();
break;

@ -239,49 +239,42 @@ int user_options_parse (user_options_t *user_options, int myargc, char **myargv)
{
user_options->show = false;
user_options->left = false;
user_options->quiet = true;
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->markov_disable = true;
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->opencl_info == true)
{
user_options->session = "opencl_info";
}
if (user_options->keyspace == true)
{
user_options->session = "keyspace";
}
if (user_options->benchmark == true)
{
user_options->session = "benchmark";
}
user_options->attack_mode = ATTACK_MODE_BF;
user_options->session = "benchmark";
if (user_options->stdout_flag == true)
{
user_options->session = "stdout";
if (user_options->workload_profile_chgd == false)
{
user_options->workload_profile = 3;
}
}
if (user_options->opencl_info == true)
if (user_options->keyspace == true)
{
user_options->opencl_platforms = NULL;
user_options->opencl_devices = NULL;
user_options->opencl_device_types = mystrdup ("1,2,3");
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;
@ -290,6 +283,15 @@ int user_options_parse (user_options_t *user_options, int myargc, char **myargv)
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;
@ -310,12 +312,40 @@ int user_options_parse (user_options_t *user_options, int myargc, char **myargv)
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->session == NULL)
{
user_options->session = (char *) PROGNAME;
}
return 0;
}
int user_options_sanity (user_options_t *user_options, int myargc, char **myargv, user_options_extra_t *user_options_extra)
{
if (user_options->attack_mode > 7)
if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT)
&& (user_options->attack_mode != ATTACK_MODE_COMBI)
&& (user_options->attack_mode != ATTACK_MODE_BF)
&& (user_options->attack_mode != ATTACK_MODE_HYBRID1)
&& (user_options->attack_mode != ATTACK_MODE_HYBRID2)
&& (user_options->attack_mode != ATTACK_MODE_NONE))
{
log_error ("ERROR: Invalid attack-mode specified");
@ -336,7 +366,7 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
return -1;
}
if (user_options->username == 1)
if (user_options->username == true)
{
if ((user_options->hash_mode == 2500)
|| (user_options->hash_mode == 5200)
@ -356,7 +386,7 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
return -1;
}
if (user_options->left == 1)
if (user_options->left == true)
{
if (user_options->outfile_format_chgd == true)
{
@ -366,7 +396,7 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
}
}
if (user_options->show == 1)
if (user_options->show == true)
{
if (user_options->outfile_format_chgd == true)
{
@ -397,35 +427,35 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
return -1;
}
if ((user_options->increment == 1) && (user_options->attack_mode == ATTACK_MODE_STRAIGHT))
if ((user_options->increment == true) && (user_options->attack_mode == ATTACK_MODE_STRAIGHT))
{
log_error ("ERROR: Increment is not allowed in attack-mode 0");
return -1;
}
if ((user_options->increment == 0) && (user_options->increment_min_chgd == true))
if ((user_options->increment == true) && (user_options->increment_min_chgd == true))
{
log_error ("ERROR: Increment-min is only supported combined with increment switch");
return -1;
}
if ((user_options->increment == 0) && (user_options->increment_max_chgd == true))
if ((user_options->increment == true) && (user_options->increment_max_chgd == true))
{
log_error ("ERROR: Increment-max is only supported combined with increment switch");
return -1;
}
if (user_options->rp_files_cnt && user_options->rp_gen)
if (user_options->rp_files_cnt > 0 && user_options->rp_gen == true)
{
log_error ("ERROR: Use of both rules-file and rules-generate is not supported");
return -1;
}
if (user_options->rp_files_cnt || user_options->rp_gen)
if (user_options->rp_files_cnt > 0 || user_options->rp_gen == true)
{
if (user_options->attack_mode != ATTACK_MODE_STRAIGHT)
{
@ -444,7 +474,7 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
if (user_options->kernel_accel_chgd == true)
{
if (user_options->force == 0)
if (user_options->force == false)
{
log_info ("The manual use of the -n option (or --kernel-accel) is outdated");
log_info ("Please consider using the -w option instead");
@ -471,7 +501,7 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
if (user_options->kernel_loops_chgd == true)
{
if (user_options->force == 0)
if (user_options->force == false)
{
log_info ("The manual use of the -u option (or --kernel-loops) is outdated");
log_info ("Please consider using the -w option instead");
@ -503,23 +533,26 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
return -1;
}
if (user_options->opencl_vector_width_chgd == true && (!is_power_of_2 (user_options->opencl_vector_width) || user_options->opencl_vector_width > 16))
if (user_options->opencl_vector_width_chgd == true)
{
log_error ("ERROR: opencl-vector-width %i not allowed", user_options->opencl_vector_width);
if (is_power_of_2 (user_options->opencl_vector_width) == false || user_options->opencl_vector_width > 16)
{
log_error ("ERROR: opencl-vector-width %i not allowed", user_options->opencl_vector_width);
return -1;
return -1;
}
}
if (user_options->show == 1 || user_options->left == 1)
if (user_options->show == true || user_options->left == true)
{
if (user_options->remove == 1)
if (user_options->remove == true)
{
log_error ("ERROR: Mixing remove parameter not allowed with show parameter or left parameter");
return -1;
}
if (user_options->potfile_disable == 1)
if (user_options->potfile_disable == true)
{
log_error ("ERROR: Mixing potfile-disable parameter not allowed with show parameter or left parameter");
@ -527,9 +560,9 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
}
}
if (user_options->show == 1)
if (user_options->show == true)
{
if (user_options->outfile_autohex == 0)
if (user_options->outfile_autohex == false)
{
log_error ("ERROR: Mixing outfile-autohex-disable parameter not allowed with show parameter");
@ -537,15 +570,15 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
}
}
if (user_options->keyspace == 1)
if (user_options->keyspace == true)
{
if (user_options->show == 1)
if (user_options->show == true)
{
log_error ("ERROR: Combining show parameter with keyspace parameter is not allowed");
return -1;
}
else if (user_options->left == 1)
else if (user_options->left == true)
{
log_error ("ERROR: Combining left parameter with keyspace parameter is not allowed");
@ -555,7 +588,7 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
if (user_options->remove_timer_chgd == true)
{
if (user_options->remove == 0)
if (user_options->remove == false)
{
log_error ("ERROR: Parameter remove-timer require parameter remove enabled");
@ -570,7 +603,7 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
}
}
if (user_options->loopback == 1)
if (user_options->loopback == true)
{
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
@ -651,9 +684,9 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
return -1;
}
if (user_options->benchmark == 1)
if (user_options->benchmark == true)
{
if (myargv[optind] != 0)
if (myargv[optind] != NULL)
{
log_error ("ERROR: Invalid argument for benchmark mode specified");
@ -670,6 +703,15 @@ int user_options_sanity (user_options_t *user_options, int myargc, char **myargv
}
}
}
else if (user_options->opencl_info == true)
{
if (user_options_extra->optind != myargc)
{
usage_mini_print (myargv[0]);
return -1;
}
}
else
{
if (user_options_extra->attack_kern == ATTACK_KERN_NONE)
@ -734,18 +776,18 @@ int user_options_extra_init (user_options_t *user_options, int myargc, char **my
user_options_extra->optind = optind;
if (user_options->benchmark == 1)
if (user_options->benchmark == true)
{
}
else
{
if (user_options->stdout_flag == 1) // no hash here
if (user_options->stdout_flag == true) // no hash here
{
user_options_extra->optind--;
}
if (user_options->keyspace == 1)
if (user_options->keyspace == true)
{
int num_additional_params = 1;
@ -760,5 +802,27 @@ int user_options_extra_init (user_options_t *user_options, int myargc, char **my
}
}
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) < myargc) ? WL_MODE_FILE : WL_MODE_STDIN;
if (user_options->attack_mode == ATTACK_MODE_BF)
{
user_options_extra->wordlist_mode = WL_MODE_MASK;
}
*/
/* 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;
}

@ -334,8 +334,8 @@ u64 count_words (wl_data_t *wl_data, FILE *fd, const char *dictfile, dictstat_ct
keyspace *= data.combs_cnt;
}
if (data.quiet == 0) log_info ("Cache-hit dictionary stats %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, d.stat.st_size, cached_cnt, keyspace);
if (data.quiet == 0) log_info ("");
if (data.quiet == false) log_info ("Cache-hit dictionary stats %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, d.stat.st_size, cached_cnt, keyspace);
if (data.quiet == false) log_info ("");
hc_signal (sigHandler_default);
@ -411,13 +411,13 @@ u64 count_words (wl_data_t *wl_data, FILE *fd, const char *dictfile, dictstat_ct
double percent = (double) comp / (double) d.stat.st_size;
if (data.quiet == 0) log_info_nn ("Generating dictionary stats for %s: %" PRIu64 " bytes (%.2f%%), %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, percent * 100, cnt2, cnt);
if (data.quiet == false) log_info_nn ("Generating dictionary stats for %s: %" PRIu64 " bytes (%.2f%%), %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, percent * 100, cnt2, cnt);
time (&prev);
}
if (data.quiet == 0) log_info ("Generated dictionary stats for %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, cnt2, cnt);
if (data.quiet == 0) log_info ("");
if (data.quiet == false) log_info ("Generated dictionary stats for %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, cnt2, cnt);
if (data.quiet == false) log_info ("");
dictstat_append (dictstat_ctx, &d);

Loading…
Cancel
Save