1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-26 01:50:10 +00:00

Large but needed refactoring of mask handling, maskfiles, default mask, etc., expect smaller bugs

This commit is contained in:
jsteube 2016-09-26 01:18:00 +02:00
parent 92e263a761
commit 54a4ea3db2
17 changed files with 661 additions and 733 deletions

View File

@ -1542,7 +1542,7 @@ void hashconfig_destroy (hashconfig_t *hashconfig);
uint hashconfig_general_pw_min (hashconfig_t *hashconfig);
uint hashconfig_general_pw_max (hashconfig_t *hashconfig);
void hashconfig_general_defaults (hashconfig_t *hashconfig, hashes_t *hashes, const user_options_t *user_options);
void hashconfig_benchmark_defaults (hashconfig_t *hashconfig, salt_t *salt, void *esalt);
char *hashconfig_benchmark_mask (hashconfig_t *hashconfig);
void hashconfig_benchmark_defaults (const hashconfig_t *hashconfig, salt_t *salt, void *esalt);
char *hashconfig_benchmark_mask (const hashconfig_t *hashconfig);
#endif // _INTERFACE_H

View File

@ -24,12 +24,11 @@ void mp_css_to_uniq_tbl (uint css_cnt, cs_t *css, uint uniq_tbls[SP_PW_MAX][CHA
void mp_cut_at (char *mask, uint max);
uint mp_get_length (char *mask);
void mp_exec (u64 val, char *buf, cs_t *css, int css_cnt);
cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, uint *css_cnt, hashconfig_t *hashconfig, const user_options_t *user_options);
cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, uint *css_cnt, const hashconfig_t *hashconfig, const user_options_t *user_options);
u64 mp_get_sum (uint css_cnt, cs_t *css);
void mp_setup_sys (cs_t *mp_sys);
void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, uint index, hashconfig_t *hashconfig, const user_options_t *user_options);
void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, uint index, const hashconfig_t *hashconfig, const user_options_t *user_options);
void mp_reset_usr (cs_t *mp_usr, uint index);
char *mp_get_truncated_mask (char *mask_buf, size_t mask_len, uint len, const user_options_t *user_options);
u64 sp_get_sum (uint start, uint stop, cs_t *root_css_buf);
void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, uint start, uint stop);
@ -39,4 +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);
void mask_ctx_destroy (mask_ctx_t *mask_ctx);
#endif // _MPSP_H

View File

@ -23,7 +23,7 @@ void writeProgramBin (char *dst, u8 *binary, size_t binary_size);
int gidd_to_pw_t (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const u64 gidd, pw_t *pw);
int choose_kernel (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const rules_ctx_t *rules_ctx, hashconfig_t *hashconfig, const uint attack_exec, const uint attack_mode, const uint opts_type, const salt_t *salt_buf, const uint highest_pw_len, const uint pws_cnt, const uint fast_iteration);
int choose_kernel (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const rules_ctx_t *rules_ctx, const mask_ctx_t *mask_ctx, hashconfig_t *hashconfig, const uint attack_exec, const uint attack_mode, const uint opts_type, const salt_t *salt_buf, const uint highest_pw_len, const uint pws_cnt, const uint fast_iteration);
int run_kernel (const uint kern_run, opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const uint num, const uint event_update, const uint iteration, hashconfig_t *hashconfig, const user_options_t *user_options);
int run_kernel_mp (const uint kern_run, opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const uint num);
int run_kernel_tm (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param);
@ -33,7 +33,7 @@ int run_kernel_bzero (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const uint pws_cnt);
int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx, const uint pws_cnt);
int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx, const mask_ctx_t *mask_ctx, const uint pws_cnt);
int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options);
void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx);

View File

@ -11,8 +11,8 @@
double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries);
void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx);
void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx);
void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx, const mask_ctx_t *mask_ctx);
void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx, const mask_ctx_t *mask_ctx);
void status_benchmark_automate (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig);
void status_benchmark (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const user_options_t *user_options);

View File

@ -20,6 +20,6 @@
#include <pwd.h>
#endif // _POSIX
void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const rules_ctx_t *rules_ctx, const uint pws_cnt);
void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const rules_ctx_t *rules_ctx, const mask_ctx_t *mask_ctx, const uint pws_cnt);
#endif // _STDOUT_H

View File

@ -866,7 +866,7 @@ typedef struct
u32 pid;
u32 dictpos;
u32 maskpos;
u32 masks_pos;
u64 words_cur;
@ -1114,6 +1114,33 @@ typedef struct
} induct_ctx_t;
typedef struct
{
cs_t mp_sys[6];
cs_t mp_usr[4];
u32 bfs_cnt;
cs_t *css_buf;
u32 css_cnt;
hcstat_table_t *root_table_buf;
hcstat_table_t *markov_table_buf;
cs_t *root_css_buf;
cs_t *markov_css_buf;
bool mask_from_file;
char **masks;
u32 masks_pos;
u32 masks_cnt;
u32 masks_avail;
char *mask;
} mask_ctx_t;
typedef struct
{
bool enabled;
@ -1153,14 +1180,6 @@ typedef struct
u32 combs_mode;
u32 combs_cnt;
u32 bfs_cnt;
u32 css_cnt;
cs_t *css_buf;
cs_t *root_css_buf;
cs_t *markov_css_buf;
/**
* hardware watchdog
*/
@ -1186,9 +1205,6 @@ typedef struct
char *dictfile;
char *dictfile2;
char *mask;
u32 maskcnt;
u32 maskpos;
u32 pw_min;
u32 pw_max;
@ -1208,6 +1224,7 @@ typedef struct
logfile_ctx_t *logfile_ctx;
rules_ctx_t *rules_ctx;
restore_ctx_t *restore_ctx;
mask_ctx_t *mask_ctx;
/**
* status, timer

View File

@ -121,6 +121,7 @@ void *thread_calc_stdin (void *p)
hashes_t *hashes = data.hashes;
rules_ctx_t *rules_ctx = data.rules_ctx;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE);
@ -211,7 +212,7 @@ void *thread_calc_stdin (void *p)
{
run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, rules_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, rules_ctx, mask_ctx, pws_cnt);
device_param->pws_cnt = 0;
@ -247,8 +248,9 @@ void *thread_calc (void *p)
user_options_extra_t *user_options_extra = data.user_options_extra;
hashconfig_t *hashconfig = data.hashconfig;
hashes_t *hashes = data.hashes;
rules_ctx_t *rules_ctx = data.rules_ctx;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
rules_ctx_t *rules_ctx = data.rules_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
const uint attack_mode = user_options->attack_mode;
const uint attack_kern = user_options_extra->attack_kern;
@ -272,7 +274,7 @@ void *thread_calc (void *p)
{
run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, rules_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, rules_ctx, mask_ctx, pws_cnt);
device_param->pws_cnt = 0;
@ -464,7 +466,7 @@ void *thread_calc (void *p)
{
run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, rules_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, rules_ctx, mask_ctx, pws_cnt);
device_param->pws_cnt = 0;

View File

@ -228,6 +228,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
loopback_ctx_t *loopback_ctx = data.loopback_ctx;
outfile_ctx_t *outfile_ctx = data.outfile_ctx;
potfile_ctx_t *potfile_ctx = data.potfile_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
hashconfig_t *hashconfig = data.hashconfig;
hashes_t *hashes = data.hashes;
@ -360,13 +361,13 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
uint l_stop = device_param->kernel_params_mp_l_buf32[4];
uint r_stop = device_param->kernel_params_mp_r_buf32[4];
sp_exec (l_off, (char *) plain_ptr + l_start, data.root_css_buf, data.markov_css_buf, l_start, l_start + l_stop);
sp_exec (r_off, (char *) plain_ptr + r_start, data.root_css_buf, data.markov_css_buf, r_start, r_start + r_stop);
sp_exec (l_off, (char *) plain_ptr + l_start, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, l_start, l_start + l_stop);
sp_exec (r_off, (char *) plain_ptr + r_start, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, r_start, r_start + r_stop);
plain_len = data.css_cnt;
plain_len = mask_ctx->css_cnt;
crackpos += gidvid;
crackpos *= data.bfs_cnt;
crackpos *= mask_ctx->bfs_cnt;
crackpos += device_param->innerloop_pos + il_pos;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
@ -387,7 +388,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
uint start = 0;
uint stop = device_param->kernel_params_mp_buf32[4];
sp_exec (off, (char *) plain_ptr + plain_len, data.root_css_buf, data.markov_css_buf, start, start + stop);
sp_exec (off, (char *) plain_ptr + plain_len, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop);
plain_len += start + stop;
@ -420,7 +421,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
memmove (plain_ptr + stop, plain_ptr, plain_len);
sp_exec (off, (char *) plain_ptr, data.root_css_buf, data.markov_css_buf, start, start + stop);
sp_exec (off, (char *) plain_ptr, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop);
plain_len += start + stop;

File diff suppressed because it is too large Load Diff

View File

@ -20080,7 +20080,7 @@ void hashconfig_general_defaults (hashconfig_t *hashconfig, hashes_t *hashes, co
}
}
void hashconfig_benchmark_defaults (hashconfig_t *hashconfig, salt_t *salt, void *esalt)
void hashconfig_benchmark_defaults (const hashconfig_t *hashconfig, salt_t *salt, void *esalt)
{
if (hashconfig->is_salted)
{
@ -20393,7 +20393,7 @@ void hashconfig_benchmark_defaults (hashconfig_t *hashconfig, salt_t *salt, void
}
}
char *hashconfig_benchmark_mask (hashconfig_t *hashconfig)
char *hashconfig_benchmark_mask (const hashconfig_t *hashconfig)
{
char *mask = "?b?b?b?b?b?b?b";

View File

@ -46,6 +46,7 @@ void *thread_monitor (void *p)
hashes_t *hashes = data.hashes;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
rules_ctx_t *rules_ctx = data.rules_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
bool runtime_check = false;
bool remove_check = false;
@ -345,7 +346,7 @@ void *thread_monitor (void *p)
if (user_options->quiet == false) log_info ("");
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, rules_ctx);
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, rules_ctx, mask_ctx);
if (user_options->quiet == false) log_info ("");

View File

@ -13,6 +13,7 @@
#include "logging.h"
#include "convert.h"
#include "filehandling.h"
#include "interface.h"
#include "mpsp.h"
const unsigned int full01 = 0x01010101;
@ -45,7 +46,7 @@ void mp_css_to_uniq_tbl (uint css_cnt, cs_t *css, uint uniq_tbls[SP_PW_MAX][CHAR
}
}
static void mp_add_cs_buf (uint *in_buf, size_t in_len, cs_t *css, int css_cnt, hashconfig_t *hashconfig)
static void mp_add_cs_buf (uint *in_buf, size_t in_len, cs_t *css, int css_cnt, const hashconfig_t *hashconfig)
{
cs_t *cs = &css[css_cnt];
@ -80,7 +81,7 @@ static void mp_add_cs_buf (uint *in_buf, size_t in_len, cs_t *css, int css_cnt,
myfree (css_uniq);
}
static void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, int mp_usr_offset, int interpret, hashconfig_t *hashconfig, const user_options_t *user_options)
static void mp_expand (char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, int mp_usr_offset, int interpret, const hashconfig_t *hashconfig, const user_options_t *user_options)
{
size_t in_pos;
@ -179,7 +180,7 @@ u64 mp_get_sum (uint css_cnt, cs_t *css)
return (sum);
}
cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, uint *css_cnt, hashconfig_t *hashconfig, const user_options_t *user_options)
cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, uint *css_cnt, const hashconfig_t *hashconfig, const user_options_t *user_options)
{
cs_t *css = (cs_t *) mycalloc (256, sizeof (cs_t));
@ -357,7 +358,7 @@ void mp_setup_sys (cs_t *mp_sys)
mp_sys[5].cs_len = pos; }
}
void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, uint index, hashconfig_t *hashconfig, const user_options_t *user_options)
void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, uint index, const hashconfig_t *hashconfig, const user_options_t *user_options)
{
FILE *fp = fopen (buf, "rb");
@ -395,7 +396,7 @@ void mp_reset_usr (cs_t *mp_usr, uint index)
memset (mp_usr[index].cs_buf, 0, sizeof (mp_usr[index].cs_buf));
}
char *mp_get_truncated_mask (char *mask_buf, size_t mask_len, uint len, const user_options_t *user_options)
static char *mp_get_truncated_mask (const char *mask_buf, const size_t mask_len, const uint len, const user_options_t *user_options)
{
char *new_mask_buf = (char *) mymalloc (256);
@ -817,3 +818,287 @@ void sp_stretch_markov (hcstat_table_t *in, hcstat_table_t *out)
}
}
}
static void mask_append_final (mask_ctx_t *mask_ctx, const char *mask)
{
if (mask_ctx->masks_avail == mask_ctx->masks_cnt)
{
mask_ctx->masks = (char **) myrealloc (mask_ctx->masks, mask_ctx->masks_avail * sizeof (char *), INCR_MASKS * sizeof (char *));
mask_ctx->masks_avail += INCR_MASKS;
}
mask_ctx->masks[mask_ctx->masks_cnt] = mystrdup (mask);
mask_ctx->masks_cnt++;
}
static void mask_append (mask_ctx_t *mask_ctx, const user_options_t *user_options, const char *mask)
{
if (user_options->increment == true)
{
for (uint mask_len = user_options->increment_min; mask_len <= user_options->increment_max; mask_len++)
{
char *mask_truncated = mp_get_truncated_mask (mask, strlen (mask), mask_len, user_options);
if (mask_truncated == NULL) break;
mask_append_final (mask_ctx, mask_truncated);
}
}
else
{
mask_append_final (mask_ctx, mask);
}
}
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)
{
memset (mask_ctx, 0, sizeof (mask_ctx_t));
mask_ctx->root_table_buf = (hcstat_table_t *) mycalloc (SP_ROOT_CNT, sizeof (hcstat_table_t));
mask_ctx->markov_table_buf = (hcstat_table_t *) mycalloc (SP_MARKOV_CNT, sizeof (hcstat_table_t));
sp_setup_tbl (folder_config->shared_dir, user_options->markov_hcstat, user_options->markov_disable, user_options->markov_classic, mask_ctx->root_table_buf, mask_ctx->markov_table_buf);
mask_ctx->root_css_buf = (cs_t *) mycalloc (SP_PW_MAX, sizeof (cs_t));
mask_ctx->markov_css_buf = (cs_t *) mycalloc (SP_PW_MAX * CHARSIZ, sizeof (cs_t));
mask_ctx->css_cnt = 0;
mask_ctx->css_buf = NULL;
mask_ctx->mask_from_file = false;
mask_ctx->masks = NULL;
mask_ctx->masks_pos = 0;
mask_ctx->masks_cnt = 0;
mp_setup_sys (mask_ctx->mp_sys);
if (user_options->custom_charset_1) mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_1, 0, hashconfig, user_options);
if (user_options->custom_charset_2) mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_2, 1, hashconfig, user_options);
if (user_options->custom_charset_3) mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_3, 2, hashconfig, user_options);
if (user_options->custom_charset_4) mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3, hashconfig, user_options);
if (user_options->attack_mode == ATTACK_MODE_BF)
{
if (user_options->benchmark == false)
{
if ((user_options_extra->optind + 2) <= restore_ctx->argc)
{
char *arg = restore_ctx->argv[user_options_extra->optind + 1];
struct stat file_stat;
if (stat (arg, &file_stat) == -1)
{
mask_append (mask_ctx, user_options, arg);
}
else
{
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++)
{
arg = restore_ctx->argv[user_options_extra->optind + 1 + i];
if (stat (arg, &file_stat) == -1)
{
log_error ("ERROR: %s: %s", arg, strerror (errno));
return -1;
}
if (S_ISREG (file_stat.st_mode))
{
FILE *mask_fp = fopen (arg, "r");
if (mask_fp == NULL)
{
log_error ("ERROR: %s: %s", arg, strerror (errno));
return -1;
}
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
while (!feof (mask_fp))
{
const int line_len = fgetl (mask_fp, line_buf);
if (line_len == 0) continue;
if (line_buf[0] == '#') continue;
mask_append (mask_ctx, user_options, line_buf);
}
myfree (line_buf);
fclose (mask_fp);
}
else
{
log_error ("ERROR: %s: unsupported file-type", arg);
return -1;
}
}
}
}
else
{
const char *mask = "?1?2?2?2?2?2?2?3?3?3?3?d?d?d?d";
mask_append (mask_ctx, user_options, mask);
}
}
else
{
const char *mask = hashconfig_benchmark_mask (hashconfig);
mask_append (mask_ctx, user_options, mask);
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
// display
char *arg = restore_ctx->argv[restore_ctx->argc - 1];
// mod
struct stat file_stat;
if (stat (arg, &file_stat) == -1)
{
mask_append (mask_ctx, user_options, arg);
}
else
{
if (S_ISREG (file_stat.st_mode))
{
mask_ctx->mask_from_file = true;
FILE *mask_fp = fopen (arg, "r");
if (mask_fp == NULL)
{
log_error ("ERROR: %s: %s", arg, strerror (errno));
return -1;
}
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
while (!feof (mask_fp))
{
const int line_len = fgetl (mask_fp, line_buf);
if (line_len == 0) continue;
if (line_buf[0] == '#') continue;
mask_append (mask_ctx, user_options, line_buf);
}
myfree (line_buf);
fclose (mask_fp);
}
else
{
log_error ("ERROR: %s: unsupported file-type", arg);
return -1;
}
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
// display
char *arg = restore_ctx->argv[user_options_extra->optind + 1];
// mod
struct stat file_stat;
if (stat (arg, &file_stat) == -1)
{
mask_append (mask_ctx, user_options, arg);
}
else
{
if (S_ISREG (file_stat.st_mode))
{
mask_ctx->mask_from_file = true;
FILE *mask_fp = fopen (arg, "r");
if (mask_fp == NULL)
{
log_error ("ERROR: %s: %s", arg, strerror (errno));
return -1;
}
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
while (!feof (mask_fp))
{
const int line_len = fgetl (mask_fp, line_buf);
if (line_len == 0) continue;
if (line_buf[0] == '#') continue;
mask_append (mask_ctx, user_options, line_buf);
}
myfree (line_buf);
fclose (mask_fp);
}
else
{
log_error ("ERROR: %s: unsupported file-type", arg);
return -1;
}
}
}
if (mask_ctx->masks_cnt == 0)
{
log_error ("ERROR: Invalid mask");
return -1;
}
mask_ctx->mask = mask_ctx->masks[0];
return 0;
}
void mask_ctx_destroy (mask_ctx_t *mask_ctx)
{
myfree (mask_ctx->css_buf);
myfree (mask_ctx->root_css_buf);
myfree (mask_ctx->markov_css_buf);
myfree (mask_ctx->root_table_buf);
myfree (mask_ctx->markov_table_buf);
for (u32 mask_pos = 0; mask_pos < mask_ctx->masks_cnt; mask_pos++)
{
myfree (mask_ctx->masks[mask_pos]);
}
myfree (mask_ctx->masks);
myfree (mask_ctx);
}

View File

@ -291,13 +291,13 @@ int gidd_to_pw_t (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, con
return 0;
}
int choose_kernel (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const rules_ctx_t *rules_ctx, hashconfig_t *hashconfig, const uint attack_exec, const uint attack_mode, const uint opts_type, const salt_t *salt_buf, const uint highest_pw_len, const uint pws_cnt, const uint fast_iteration)
int choose_kernel (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const rules_ctx_t *rules_ctx, const mask_ctx_t *mask_ctx, hashconfig_t *hashconfig, const uint attack_exec, const uint attack_mode, const uint opts_type, const salt_t *salt_buf, const uint highest_pw_len, const uint pws_cnt, const uint fast_iteration)
{
cl_int CL_err = CL_SUCCESS;
if (hashconfig->hash_mode == 2000)
{
process_stdout (opencl_ctx, device_param, user_options, rules_ctx, pws_cnt);
process_stdout (opencl_ctx, device_param, user_options, rules_ctx, mask_ctx, pws_cnt);
return 0;
}
@ -1004,7 +1004,7 @@ int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashcon
return 0;
}
int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx, const uint pws_cnt)
int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx, const mask_ctx_t *mask_ctx, const uint pws_cnt)
{
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
@ -1071,7 +1071,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = rules_ctx->kernel_rules_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = data.combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) innerloop_cnt = data.bfs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) innerloop_cnt = mask_ctx->bfs_cnt;
// innerloops
@ -1281,7 +1281,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
hc_timer_set (&device_param->timer_speed);
}
int rc = choose_kernel (opencl_ctx, device_param, user_options, rules_ctx, hashconfig, hashconfig->attack_exec, user_options->attack_mode, hashconfig->opts_type, salt_buf, highest_pw_len, pws_cnt, fast_iteration);
int rc = choose_kernel (opencl_ctx, device_param, user_options, rules_ctx, mask_ctx, hashconfig, hashconfig->attack_exec, user_options->attack_mode, hashconfig->opts_type, salt_buf, highest_pw_len, pws_cnt, fast_iteration);
if (rc == -1) return -1;

View File

@ -164,7 +164,7 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_en
return exec_ms_sum / exec_ms_cnt;
}
void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx)
void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx, const mask_ctx_t *mask_ctx)
{
if (opencl_ctx->devices_status == STATUS_INIT)
{
@ -257,7 +257,7 @@ void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= rules_ctx->kernel_rules_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= data.combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= data.bfs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= mask_ctx->bfs_cnt;
}
if (user_options->limit)
@ -266,7 +266,7 @@ void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= rules_ctx->kernel_rules_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= data.combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= mask_ctx->bfs_cnt;
}
u64 progress_cur_relative_skip = progress_cur - progress_skip;
@ -313,7 +313,7 @@ void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *
fflush (out);
}
void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx)
void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const restore_ctx_t *restore_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const rules_ctx_t *rules_ctx, const mask_ctx_t *mask_ctx)
{
if (opencl_ctx->devices_status == STATUS_INIT)
{
@ -327,7 +327,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
if (user_options->machine_readable == true)
{
status_display_machine_readable (opencl_ctx, hashes, restore_ctx, user_options, user_options_extra, rules_ctx);
status_display_machine_readable (opencl_ctx, hashes, restore_ctx, user_options, user_options_extra, rules_ctx, mask_ctx);
return;
}
@ -403,11 +403,11 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
char *mask = data.mask;
char *mask = mask_ctx->mask;
if (mask != NULL)
{
uint mask_len = data.css_cnt;
uint mask_len = mask_ctx->css_cnt;
tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "Mask (%s)", mask);
@ -426,9 +426,9 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " [%i]", mask_len);
}
if (data.maskcnt > 1)
if (mask_ctx->masks_cnt > 1)
{
double mask_percentage = (double) data.maskpos / (double) data.maskcnt;
double mask_percentage = (double) mask_ctx->masks_pos / (double) mask_ctx->masks_cnt;
tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100);
}
@ -450,8 +450,8 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
if (data.dictfile != NULL) log_info ("Input.Left.....: File (%s)", data.dictfile);
if (data.mask != NULL) log_info ("Input.Right....: Mask (%s) [%i]", data.mask, data.css_cnt);
if (data.dictfile != NULL) log_info ("Input.Left.....: File (%s)", data.dictfile);
if (mask_ctx->mask != NULL) log_info ("Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt);
if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL))
{
@ -465,7 +465,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
if (data.mask != NULL) log_info ("Input.Left.....: Mask (%s) [%i]", data.mask, data.css_cnt);
if (mask_ctx->mask != NULL) log_info ("Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt);
if (data.dictfile != NULL) log_info ("Input.Right....: File (%s)", data.dictfile);
if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL))
@ -730,7 +730,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= rules_ctx->kernel_rules_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= data.combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= data.bfs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= mask_ctx->bfs_cnt;
}
if (user_options->limit)
@ -739,7 +739,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= rules_ctx->kernel_rules_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= data.combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= data.bfs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= mask_ctx->bfs_cnt;
}
u64 progress_cur_relative_skip = progress_cur - progress_skip;

View File

@ -59,7 +59,7 @@ static void out_push (out_t *out, const u8 *pw_buf, const int pw_len)
}
}
void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const rules_ctx_t *rules_ctx, const uint pws_cnt)
void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const rules_ctx_t *rules_ctx, const mask_ctx_t *mask_ctx, const uint pws_cnt)
{
out_t out;
@ -177,10 +177,10 @@ void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
uint l_stop = device_param->kernel_params_mp_l_buf32[4];
uint r_stop = device_param->kernel_params_mp_r_buf32[4];
sp_exec (l_off, (char *) plain_ptr + l_start, data.root_css_buf, data.markov_css_buf, l_start, l_start + l_stop);
sp_exec (r_off, (char *) plain_ptr + r_start, data.root_css_buf, data.markov_css_buf, r_start, r_start + r_stop);
sp_exec (l_off, (char *) plain_ptr + l_start, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, l_start, l_start + l_stop);
sp_exec (r_off, (char *) plain_ptr + r_start, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, r_start, r_start + r_stop);
plain_len = data.css_cnt;
plain_len = mask_ctx->css_cnt;
out_push (&out, plain_ptr, plain_len);
}
@ -208,7 +208,7 @@ void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
uint start = 0;
uint stop = device_param->kernel_params_mp_buf32[4];
sp_exec (off, (char *) plain_ptr + plain_len, data.root_css_buf, data.markov_css_buf, start, start + stop);
sp_exec (off, (char *) plain_ptr + plain_len, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop);
plain_len += start + stop;
@ -240,7 +240,7 @@ void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
memmove (plain_ptr + stop, plain_ptr, plain_len);
sp_exec (off, (char *) plain_ptr, data.root_css_buf, data.markov_css_buf, start, start + stop);
sp_exec (off, (char *) plain_ptr, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop);
plain_len += start + stop;

View File

@ -69,6 +69,7 @@ void *thread_keypress (void *p)
hashconfig_t *hashconfig = data.hashconfig;
hashes_t *hashes = data.hashes;
rules_ctx_t *rules_ctx = data.rules_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
const bool quiet = user_options->quiet;
@ -99,7 +100,7 @@ void *thread_keypress (void *p)
log_info ("");
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, rules_ctx);
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, rules_ctx, mask_ctx);
log_info ("");

View File

@ -255,7 +255,6 @@ int user_options_parse (user_options_t *user_options, int argc, char **argv)
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;
@ -268,6 +267,7 @@ int user_options_parse (user_options_t *user_options, int argc, char **argv)
{
user_options->session = "benchmark";
user_options->attack_mode = ATTACK_MODE_BF;
user_options->increment = false;
if (user_options->workload_profile_chgd == false)
{
@ -868,6 +868,26 @@ int user_options_extra_init (user_options_t *user_options, restore_ctx_t *restor
}
*/
// 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;
}
}
return 0;
}