1
mirror of https://github.com/hashcat/hashcat synced 2024-11-24 14:27:14 +01:00

Introduct combinator_ctx_t

This commit is contained in:
jsteube 2016-09-27 18:32:09 +02:00
parent 8dea3d2eb9
commit c71f1bfb0c
21 changed files with 315 additions and 215 deletions

View File

@ -13,9 +13,9 @@ int sort_by_hash_no_salt (const void *v1, const void *v2);
void save_hash (const user_options_t *user_options, const hashconfig_t *hashconfig, const hashes_t *hashes);
void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, plain_t *plain);
void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, plain_t *plain);
int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos);
int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, 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, 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);

View File

@ -41,4 +41,6 @@ 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);
void mask_ctx_parse_maskfile (mask_ctx_t *mask_ctx, user_options_t *user_options, const hashconfig_t *hashconfig);
#endif // _MPSP_H

View File

@ -23,7 +23,8 @@ void writeProgramBin (char *dst, char *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 straight_ctx_t *straight_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 choose_kernel (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_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);
@ -31,9 +32,9 @@ int run_kernel_amp (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, c
int run_kernel_memset (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cl_mem buf, const uint value, const uint num);
int run_kernel_bzero (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cl_mem buf, const size_t size);
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_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 combinator_ctx_t *combinator_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 straight_ctx_t *straight_ctx, const mask_ctx_t *mask_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 straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_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);
@ -41,10 +42,11 @@ void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx);
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options);
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 straight_ctx_t *straight_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx, const tuning_db_t *tuning_db);
void opencl_session_destroy (opencl_ctx_t *opencl_ctx);
void opencl_session_reset (opencl_ctx_t *opencl_ctx);
int opencl_session_update_mp (opencl_ctx_t *opencl_ctx, const mask_ctx_t *mask_ctx);
int opencl_session_update_mp_rl (opencl_ctx_t *opencl_ctx, const mask_ctx_t *mask_ctx, const u32 css_cnt_l, const u32 css_cnt_r);
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const straight_ctx_t *straight_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const folder_config_t *folder_config, const bitmap_ctx_t *bitmap_ctx, const tuning_db_t *tuning_db);
void opencl_session_destroy (opencl_ctx_t *opencl_ctx);
void opencl_session_reset (opencl_ctx_t *opencl_ctx);
int opencl_session_update_combinator (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const combinator_ctx_t *combinator_ctx);
int opencl_session_update_mp (opencl_ctx_t *opencl_ctx, const mask_ctx_t *mask_ctx);
int opencl_session_update_mp_rl (opencl_ctx_t *opencl_ctx, const mask_ctx_t *mask_ctx, const u32 css_cnt_l, const u32 css_cnt_r);
#endif // _OPENCL_H

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 straight_ctx_t *straight_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 straight_ctx_t *straight_ctx, const mask_ctx_t *mask_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 straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_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 straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_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 straight_ctx_t *straight_ctx, const mask_ctx_t *mask_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 straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx, const uint pws_cnt);
#endif // _STDOUT_H

View File

@ -1133,6 +1133,18 @@ typedef struct
} straight_ctx_t;
typedef struct
{
bool enabled;
char *dictfile1;
char *dictfile2;
u32 combs_mode;
u32 combs_cnt;
} combinator_ctx_t;
typedef struct
{
bool enabled;
@ -1179,13 +1191,6 @@ typedef struct
u32 kernel_power_all;
u64 kernel_power_final; // we save that so that all divisions are done from the same base
/**
* attack specific
*/
u32 combs_mode;
u32 combs_cnt;
/**
* hardware watchdog
*/
@ -1230,6 +1235,7 @@ typedef struct
logfile_ctx_t *logfile_ctx;
restore_ctx_t *restore_ctx;
straight_ctx_t *straight_ctx;
combinator_ctx_t *combinator_ctx;
mask_ctx_t *mask_ctx;
/**

View File

@ -6,6 +6,6 @@
#ifndef _WEAK_HASH_H
#define _WEAK_HASH_H
void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos);
void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos);
#endif // _WEAK_HASH_H

View File

@ -18,7 +18,7 @@ void get_next_word (wl_data_t *wl_data, const user_options_t *user_options, cons
void pw_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len);
u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, FILE *fd, const char *dictfile, dictstat_ctx_t *dictstat_ctx);
u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, FILE *fd, const char *dictfile, dictstat_ctx_t *dictstat_ctx);
void wl_data_init (wl_data_t *wl_data, const user_options_t *user_options, const hashconfig_t *hashconfig);
void wl_data_destroy (wl_data_t *wl_data);

View File

@ -163,7 +163,7 @@ LFLAGS_CROSS_WIN := -lpsapi
## Objects
##
OBJS_ALL := affinity attack_mode autotune benchmark bitmap bitops common convert cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 data debugfile dictstat dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hash_management hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile powertune remove restore rp rp_cpu rp_kernel_on_cpu runtime shared status stdout straight terminal thread timer tuningdb usage user_options version weak_hash wordlist
OBJS_ALL := affinity attack_mode autotune benchmark bitmap bitops combinator common convert cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 data debugfile dictstat dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hash_management hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile powertune remove restore rp rp_cpu rp_kernel_on_cpu runtime shared status stdout straight terminal thread timer tuningdb usage user_options version weak_hash wordlist
NATIVE_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.o)

View File

@ -119,9 +119,10 @@ void *thread_calc_stdin (void *p)
user_options_extra_t *user_options_extra = data.user_options_extra;
hashconfig_t *hashconfig = data.hashconfig;
hashes_t *hashes = data.hashes;
straight_ctx_t *straight_ctx = data.straight_ctx;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
straight_ctx_t *straight_ctx = data.straight_ctx;
combinator_ctx_t *combinator_ctx = data.combinator_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE);
@ -210,9 +211,9 @@ void *thread_calc_stdin (void *p)
if (pws_cnt)
{
run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, pws_cnt);
run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, combinator_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, mask_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, pws_cnt);
device_param->pws_cnt = 0;
@ -248,9 +249,10 @@ 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;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
straight_ctx_t *straight_ctx = data.straight_ctx;
straight_ctx_t *straight_ctx = data.straight_ctx;
combinator_ctx_t *combinator_ctx = data.combinator_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
const uint attack_mode = user_options->attack_mode;
const uint attack_kern = user_options_extra->attack_kern;
@ -272,9 +274,9 @@ void *thread_calc (void *p)
if (pws_cnt)
{
run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, pws_cnt);
run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, combinator_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, mask_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, pws_cnt);
device_param->pws_cnt = 0;
@ -297,7 +299,7 @@ void *thread_calc (void *p)
if (attack_mode == ATTACK_MODE_COMBI)
{
if (data.combs_mode == COMBINATOR_MODE_BASE_RIGHT)
if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_RIGHT)
{
dictfile = data.dictfile2;
}
@ -314,7 +316,7 @@ void *thread_calc (void *p)
if (attack_mode == ATTACK_MODE_COMBI)
{
const uint combs_mode = data.combs_mode;
const uint combs_mode = combinator_ctx->combs_mode;
if (combs_mode == COMBINATOR_MODE_BASE_LEFT)
{
@ -437,7 +439,7 @@ void *thread_calc (void *p)
for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{
data.words_progress_rejected[salt_pos] += data.combs_cnt;
data.words_progress_rejected[salt_pos] += combinator_ctx->combs_cnt;
}
hc_thread_mutex_unlock (opencl_ctx->mux_counter);
@ -464,9 +466,9 @@ void *thread_calc (void *p)
if (pws_cnt)
{
run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, pws_cnt);
run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, combinator_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, mask_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, pws_cnt);
device_param->pws_cnt = 0;

View File

@ -222,7 +222,7 @@ void save_hash (const user_options_t *user_options, const hashconfig_t *hashconf
unlink (old_hashfile);
}
void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, plain_t *plain)
void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, plain_t *plain)
{
debugfile_ctx_t *debugfile_ctx = data.debugfile_ctx;
loopback_ctx_t *loopback_ctx = data.loopback_ctx;
@ -328,7 +328,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
char *comb_buf = (char *) device_param->combs_buf[il_pos].i;
uint comb_len = device_param->combs_buf[il_pos].pw_len;
if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT)
{
memcpy (plain_ptr + plain_len, comb_buf, comb_len);
}
@ -342,7 +342,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
plain_len += comb_len;
crackpos += gidvid;
crackpos *= data.combs_cnt;
crackpos *= combinator_ctx->combs_cnt;
crackpos += device_param->innerloop_pos + il_pos;
if (data.pw_max != PW_DICTMAX1)
@ -393,7 +393,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
plain_len += start + stop;
crackpos += gidvid;
crackpos *= data.combs_cnt;
crackpos *= combinator_ctx->combs_cnt;
crackpos += device_param->innerloop_pos + il_pos;
if (data.pw_max != PW_DICTMAX1)
@ -426,7 +426,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
plain_len += start + stop;
crackpos += gidvid;
crackpos *= data.combs_cnt;
crackpos *= combinator_ctx->combs_cnt;
crackpos += device_param->innerloop_pos + il_pos;
if (data.pw_max != PW_DICTMAX1)
@ -507,7 +507,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
}
}
int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos)
int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos)
{
salt_t *salt_buf = &hashes->salts_buf[salt_pos];
@ -571,7 +571,7 @@ int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, co
if (hashes->salts_done == hashes->salts_cnt) mycracked (opencl_ctx);
check_hash (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, &cracked[i]);
check_hash (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, &cracked[i]);
}
hc_thread_mutex_unlock (mux_display);

View File

@ -85,6 +85,7 @@
#include "weak_hash.h"
#include "wordlist.h"
#include "straight.h"
#include "combinator.h"
extern hc_global_data_t data;
@ -223,7 +224,7 @@ static void goodbye_screen (const user_options_t *user_options, const time_t *pr
log_info_nn ("Stopped: %s", ctime (proc_stop));
}
static int inner1_loop (user_options_t *user_options, user_options_extra_t *user_options_extra, restore_ctx_t *restore_ctx, logfile_ctx_t *logfile_ctx, induct_ctx_t *induct_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx, hashconfig_t *hashconfig, hashes_t *hashes, wl_data_t *wl_data, straight_ctx_t *straight_ctx, mask_ctx_t *mask_ctx)
static int inner1_loop (user_options_t *user_options, user_options_extra_t *user_options_extra, restore_ctx_t *restore_ctx, logfile_ctx_t *logfile_ctx, induct_ctx_t *induct_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx, hashconfig_t *hashconfig, hashes_t *hashes, wl_data_t *wl_data, straight_ctx_t *straight_ctx, combinator_ctx_t *combinator_ctx, mask_ctx_t *mask_ctx)
{
//opencl_ctx->run_main_level1 = true;
//opencl_ctx->run_main_level2 = true;
@ -273,123 +274,21 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
}
/**
* Init mask stuff
* Update attack-mode specific stuff
*/
if (user_options->attack_mode == ATTACK_MODE_HYBRID1 || user_options->attack_mode == ATTACK_MODE_HYBRID2 || user_options->attack_mode == ATTACK_MODE_BF)
if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
mask_ctx->mask = mask_ctx->masks[mask_ctx->masks_pos];
if (mask_ctx->mask_from_file == true)
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
if (mask_ctx->mask[0] == '\\' && mask_ctx->mask[1] == '#') mask_ctx->mask++; // escaped comment sign (sharp) "\#"
char *str_ptr;
uint str_pos;
uint mask_offset = 0;
uint separator_cnt;
for (separator_cnt = 0; separator_cnt < 4; separator_cnt++)
{
str_ptr = strstr (mask_ctx->mask + mask_offset, ",");
if (str_ptr == NULL) break;
str_pos = str_ptr - mask_ctx->mask;
// escaped separator, i.e. "\,"
if (str_pos > 0)
{
if (mask_ctx->mask[str_pos - 1] == '\\')
{
separator_cnt --;
mask_offset = str_pos + 1;
continue;
}
}
// reset the offset
mask_offset = 0;
mask_ctx->mask[str_pos] = 0;
switch (separator_cnt)
{
case 0:
mp_reset_usr (mask_ctx->mp_usr, 0);
user_options->custom_charset_1 = mask_ctx->mask;
mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_1, 0, hashconfig, user_options);
break;
case 1:
mp_reset_usr (mask_ctx->mp_usr, 1);
user_options->custom_charset_2 = mask_ctx->mask;
mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_2, 1, hashconfig, user_options);
break;
case 2:
mp_reset_usr (mask_ctx->mp_usr, 2);
user_options->custom_charset_3 = mask_ctx->mask;
mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_3, 2, hashconfig, user_options);
break;
case 3:
mp_reset_usr (mask_ctx->mp_usr, 3);
user_options->custom_charset_4 = mask_ctx->mask;
mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3, hashconfig, user_options);
break;
}
mask_ctx->mask += str_pos + 1;
}
/**
* What follows is a very special case where "\," is within the mask field of a line in a .hcmask file only because otherwise (without the "\")
* it would be interpreted as a custom charset definition.
*
* We need to replace all "\," with just "," within the mask (but allow the special case "\\," which means "\" followed by ",")
* Note: "\\" is not needed to replace all "\" within the mask! The meaning of "\\" within a line containing the string "\\," is just to allow "\" followed by ","
*/
uint mask_len_cur = strlen (mask_ctx->mask);
uint mask_out_pos = 0;
char mask_prev = 0;
for (uint mask_iter = 0; mask_iter < mask_len_cur; mask_iter++, mask_out_pos++)
{
if (mask_ctx->mask[mask_iter] == ',')
{
if (mask_prev == '\\')
{
mask_out_pos -= 1; // this means: skip the previous "\"
}
}
mask_prev = mask_ctx->mask[mask_iter];
mask_ctx->mask[mask_out_pos] = mask_ctx->mask[mask_iter];
}
mask_ctx->mask[mask_out_pos] = 0;
// nothing yet
}
if ((user_options->attack_mode == ATTACK_MODE_HYBRID1) || (user_options->attack_mode == ATTACK_MODE_HYBRID2))
{
mask_ctx->mask = mask_ctx->masks[mask_ctx->masks_pos];
mask_ctx_parse_maskfile (mask_ctx, user_options, hashconfig);
mask_ctx->css_buf = mp_gen_css (mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, &mask_ctx->css_cnt, hashconfig, user_options);
uint uniq_tbls[SP_PW_MAX][CHARSIZ] = { { 0 } };
@ -398,13 +297,24 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
sp_tbl_to_css (mask_ctx->root_table_buf, mask_ctx->markov_table_buf, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, user_options->markov_threshold, uniq_tbls);
data.combs_cnt = sp_get_sum (0, mask_ctx->css_cnt, mask_ctx->root_css_buf);
combinator_ctx->combs_cnt = sp_get_sum (0, mask_ctx->css_cnt, mask_ctx->root_css_buf);
const int rc_update_mp = opencl_session_update_mp (opencl_ctx, mask_ctx);
if (rc_update_mp == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
//const int rc_update_combinator = opencl_session_update_combinator (opencl_ctx, hashconfig, combinator_ctx);
//if (rc_update_combinator == -1) return -1;
}
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
{
mask_ctx->mask = mask_ctx->masks[mask_ctx->masks_pos];
mask_ctx_parse_maskfile (mask_ctx, user_options, hashconfig);
if (user_options->attack_mode == ATTACK_MODE_BF) // always true
{
mask_ctx->css_buf = mp_gen_css (mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, &mask_ctx->css_cnt, hashconfig, user_options);
@ -738,9 +648,9 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
return -1;
}
data.combs_cnt = 1;
combinator_ctx->combs_cnt = 1;
const u64 words1_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, fp1, dictfile1, dictstat_ctx);
const u64 words1_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fp1, dictfile1, dictstat_ctx);
if (words1_cnt == 0)
{
@ -752,9 +662,9 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
return -1;
}
data.combs_cnt = 1;
combinator_ctx->combs_cnt = 1;
const u64 words2_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, fp2, dictfile2, dictstat_ctx);
const u64 words2_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fp2, dictfile2, dictstat_ctx);
if (words2_cnt == 0)
{
@ -774,8 +684,8 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
if (words1_cnt >= words2_cnt)
{
data.combs_cnt = words2_cnt;
data.combs_mode = COMBINATOR_MODE_BASE_LEFT;
combinator_ctx->combs_cnt = words2_cnt;
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT;
dictfiles = &data.dictfile;
@ -783,8 +693,8 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
}
else
{
data.combs_cnt = words1_cnt;
data.combs_mode = COMBINATOR_MODE_BASE_RIGHT;
combinator_ctx->combs_cnt = words1_cnt;
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_RIGHT;
dictfiles = &data.dictfile2;
@ -802,6 +712,10 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
user_options_extra->rule_len_l = user_options_extra->rule_len_r;
user_options_extra->rule_len_r = tmpi;
}
const int rc_update_combinator = opencl_session_update_combinator (opencl_ctx, hashconfig, combinator_ctx);
if (rc_update_combinator == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
@ -826,7 +740,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
data.combs_mode = COMBINATOR_MODE_BASE_LEFT;
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT;
// mod -- moved to mpsp.c
@ -910,10 +824,14 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
return -1;
}
const int rc_update_combinator = opencl_session_update_combinator (opencl_ctx, hashconfig, combinator_ctx);
if (rc_update_combinator == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
data.combs_mode = COMBINATOR_MODE_BASE_RIGHT;
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_RIGHT;
// mod -- moved to mpsp.c
@ -997,6 +915,10 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
return -1;
}
const int rc_update_combinator = opencl_session_update_combinator (opencl_ctx, hashconfig, combinator_ctx);
if (rc_update_combinator == -1) return -1;
}
data.pw_min = pw_min;
@ -1121,7 +1043,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
return -1;
}
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, fd2, dictfile, dictstat_ctx);
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, dictfile, dictstat_ctx);
fclose (fd2);
@ -1141,7 +1063,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
logfile_sub_string (dictfile);
logfile_sub_string (dictfile2);
if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT)
{
FILE *fd2 = fopen (dictfile, "rb");
@ -1152,11 +1074,11 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
return -1;
}
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, fd2, dictfile, dictstat_ctx);
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, dictfile, dictstat_ctx);
fclose (fd2);
}
else if (data.combs_mode == COMBINATOR_MODE_BASE_RIGHT)
else if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_RIGHT)
{
FILE *fd2 = fopen (dictfile2, "rb");
@ -1167,7 +1089,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
return -1;
}
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, fd2, dictfile2, dictstat_ctx);
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, dictfile2, dictstat_ctx);
fclose (fd2);
}
@ -1206,7 +1128,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
return -1;
}
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, fd2, dictfile, dictstat_ctx);
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, dictfile, dictstat_ctx);
fclose (fd2);
@ -1233,9 +1155,9 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
if (data.combs_cnt)
if (combinator_ctx->combs_cnt)
{
words_base /= data.combs_cnt;
words_base /= combinator_ctx->combs_cnt;
}
}
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
@ -1275,7 +1197,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
{
for (uint i = 0; i < hashes->salts_cnt; i++)
{
data.words_progress_restored[i] = data.words_cur * data.combs_cnt;
data.words_progress_restored[i] = data.words_cur * combinator_ctx->combs_cnt;
}
}
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
@ -1319,7 +1241,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = straight_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_COMBI) innerloop_cnt = combinator_ctx->combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) innerloop_cnt = mask_ctx->bfs_cnt;
}
else
@ -1485,7 +1407,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
if (hashes->digests_saved != hashes->digests_done) log_info ("");
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, mask_ctx);
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx);
log_info ("");
}
@ -1493,7 +1415,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
{
if (user_options->status == true)
{
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, mask_ctx);
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx);
log_info ("");
}
@ -1705,6 +1627,18 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
if (rc_straight_init == -1) return -1;
/**
* straight mode init
*/
combinator_ctx_t *combinator_ctx = (combinator_ctx_t *) mymalloc (sizeof (combinator_ctx_t));
data.combinator_ctx = combinator_ctx;
const int rc_combinator_init = combinator_ctx_init (combinator_ctx, user_options);
if (rc_combinator_init == -1) return -1;
/**
* charsets : keep them together for more easy maintainnce
*/
@ -1859,7 +1793,7 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{
weak_hash_check (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, hashconfig, hashes, salt_pos);
weak_hash_check (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, hashconfig, hashes, salt_pos);
}
}
@ -1933,7 +1867,7 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
mask_ctx->masks_pos = masks_pos;
const int rc_inner1_loop = inner1_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hashconfig, hashes, wl_data, straight_ctx, mask_ctx);
const int rc_inner1_loop = inner1_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hashconfig, hashes, wl_data, straight_ctx, combinator_ctx, mask_ctx);
if (rc_inner1_loop == -1) return -1;
@ -1942,7 +1876,7 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
}
else
{
const int rc_inner1_loop = inner1_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hashconfig, hashes, wl_data, straight_ctx, mask_ctx);
const int rc_inner1_loop = inner1_loop (user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hashconfig, hashes, wl_data, straight_ctx, combinator_ctx, mask_ctx);
if (rc_inner1_loop == -1) return -1;
}
@ -2045,6 +1979,8 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
mask_ctx_destroy (mask_ctx);
combinator_ctx_destroy (combinator_ctx);
straight_ctx_destroy (straight_ctx);
hashes_destroy (hashes);

View File

@ -44,9 +44,10 @@ void *thread_monitor (void *p)
user_options_extra_t *user_options_extra = data.user_options_extra;
hashconfig_t *hashconfig = data.hashconfig;
hashes_t *hashes = data.hashes;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
straight_ctx_t *straight_ctx = data.straight_ctx;
straight_ctx_t *straight_ctx = data.straight_ctx;
combinator_ctx_t *combinator_ctx = data.combinator_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
bool runtime_check = false;
bool remove_check = false;
@ -346,7 +347,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, straight_ctx, mask_ctx);
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx);
if (user_options->quiet == false) log_info ("");

View File

@ -1112,3 +1112,110 @@ void mask_ctx_destroy (mask_ctx_t *mask_ctx)
myfree (mask_ctx);
}
void mask_ctx_parse_maskfile (mask_ctx_t *mask_ctx, user_options_t *user_options, const hashconfig_t *hashconfig)
{
if (mask_ctx->enabled == false) return;
if (mask_ctx->mask_from_file == false) return;
if (mask_ctx->mask[0] == '\\' && mask_ctx->mask[1] == '#') mask_ctx->mask++; // escaped comment sign (sharp) "\#"
char *str_ptr;
uint str_pos;
uint mask_offset = 0;
uint separator_cnt;
for (separator_cnt = 0; separator_cnt < 4; separator_cnt++)
{
str_ptr = strstr (mask_ctx->mask + mask_offset, ",");
if (str_ptr == NULL) break;
str_pos = str_ptr - mask_ctx->mask;
// escaped separator, i.e. "\,"
if (str_pos > 0)
{
if (mask_ctx->mask[str_pos - 1] == '\\')
{
separator_cnt--;
mask_offset = str_pos + 1;
continue;
}
}
// reset the offset
mask_offset = 0;
mask_ctx->mask[str_pos] = 0;
switch (separator_cnt)
{
case 0:
user_options->custom_charset_1 = mask_ctx->mask;
mp_reset_usr (mask_ctx->mp_usr, 0);
mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_1, 0, hashconfig, user_options);
break;
case 1:
user_options->custom_charset_2 = mask_ctx->mask;
mp_reset_usr (mask_ctx->mp_usr, 1);
mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_2, 1, hashconfig, user_options);
break;
case 2:
user_options->custom_charset_3 = mask_ctx->mask;
mp_reset_usr (mask_ctx->mp_usr, 2);
mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_3, 2, hashconfig, user_options);
break;
case 3:
user_options->custom_charset_4 = mask_ctx->mask;
mp_reset_usr (mask_ctx->mp_usr, 3);
mp_setup_usr (mask_ctx->mp_sys, mask_ctx->mp_usr, user_options->custom_charset_4, 3, hashconfig, user_options);
break;
}
mask_ctx->mask += str_pos + 1;
}
/**
* What follows is a very special case where "\," is within the mask field of a line in a .hcmask file only because otherwise (without the "\")
* it would be interpreted as a custom charset definition.
*
* We need to replace all "\," with just "," within the mask (but allow the special case "\\," which means "\" followed by ",")
* Note: "\\" is not needed to replace all "\" within the mask! The meaning of "\\" within a line containing the string "\\," is just to allow "\" followed by ","
*/
if (separator_cnt == 0) return;
uint mask_len_cur = strlen (mask_ctx->mask);
uint mask_out_pos = 0;
char mask_prev = 0;
for (uint mask_iter = 0; mask_iter < mask_len_cur; mask_iter++, mask_out_pos++)
{
if (mask_ctx->mask[mask_iter] == ',')
{
if (mask_prev == '\\')
{
mask_out_pos -= 1; // this means: skip the previous "\"
}
}
mask_prev = mask_ctx->mask[mask_iter];
mask_ctx->mask[mask_out_pos] = mask_ctx->mask[mask_iter];
}
mask_ctx->mask[mask_out_pos] = 0;
}

View File

@ -294,13 +294,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 straight_ctx_t *straight_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 choose_kernel (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_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, straight_ctx, mask_ctx, pws_cnt);
process_stdout (opencl_ctx, device_param, user_options, straight_ctx, combinator_ctx, mask_ctx, pws_cnt);
return 0;
}
@ -450,7 +450,6 @@ int run_kernel (const uint kern_run, opencl_ctx_t *opencl_ctx, hc_device_param_t
uint num_elements = num;
device_param->kernel_params_buf32[33] = data.combs_mode;
device_param->kernel_params_buf32[34] = num;
uint kernel_threads = device_param->kernel_threads;
@ -771,7 +770,6 @@ int run_kernel_amp (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, c
uint num_elements = num;
device_param->kernel_params_amp_buf32[5] = data.combs_mode;
device_param->kernel_params_amp_buf32[6] = num_elements;
// causes problems with special threads like in bcrypt
@ -783,7 +781,6 @@ int run_kernel_amp (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, c
cl_kernel kernel = device_param->kernel_amp;
CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 5, sizeof (cl_uint), device_param->kernel_params_amp[5]);
CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, kernel, 6, sizeof (cl_uint), device_param->kernel_params_amp[6]);
if (CL_err != CL_SUCCESS)
@ -915,7 +912,7 @@ int run_kernel_bzero (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
return run_kernel_memset (opencl_ctx, device_param, buf, 0, size);
}
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_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 combinator_ctx_t *combinator_ctx, const uint pws_cnt)
{
cl_int CL_err = CL_SUCCESS;
@ -934,7 +931,7 @@ int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashcon
{
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
if (data.combs_mode == COMBINATOR_MODE_BASE_RIGHT)
if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_RIGHT)
{
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01)
{
@ -1007,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 straight_ctx_t *straight_ctx, const mask_ctx_t *mask_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 straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx, const uint pws_cnt)
{
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
@ -1073,7 +1070,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
else innerloop_step = 1;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = straight_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_COMBI) innerloop_cnt = combinator_ctx->combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) innerloop_cnt = mask_ctx->bfs_cnt;
// innerloops
@ -1162,7 +1159,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
uppercase (ptr, line_len);
}
if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT)
{
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80)
{
@ -1284,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, straight_ctx, mask_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, straight_ctx, combinator_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;
@ -1294,7 +1291,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
if (user_options->benchmark == false)
{
check_cracked (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, hashconfig, hashes, salt_pos);
check_cracked (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, hashconfig, hashes, salt_pos);
}
/**
@ -4728,6 +4725,54 @@ void opencl_session_reset (opencl_ctx_t *opencl_ctx)
}
}
int opencl_session_update_combinator (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const combinator_ctx_t *combinator_ctx)
{
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
// kernel_params
device_param->kernel_params_buf32[33] = combinator_ctx->combs_mode;
cl_int CL_err = CL_SUCCESS;
CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel1, 33, sizeof (cl_uint), device_param->kernel_params[33]);
CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel2, 33, sizeof (cl_uint), device_param->kernel_params[33]);
CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel3, 33, sizeof (cl_uint), device_param->kernel_params[33]);
if (hashconfig->opts_type & OPTS_TYPE_HOOK12) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel12, 33, sizeof (cl_uint), device_param->kernel_params[33]);
if (hashconfig->opts_type & OPTS_TYPE_HOOK23) CL_err |= hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel23, 33, sizeof (cl_uint), device_param->kernel_params[33]);
if (CL_err != CL_SUCCESS)
{
log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err));
return -1;
}
// kernel_params_amp
device_param->kernel_params_amp_buf32[5] = combinator_ctx->combs_mode;
if (hashconfig->attack_exec == ATTACK_EXEC_OUTSIDE_KERNEL)
{
CL_err = hc_clSetKernelArg (opencl_ctx->ocl, device_param->kernel_amp, 5, sizeof (cl_mem), device_param->kernel_params_amp[5]);
if (CL_err != CL_SUCCESS)
{
log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err));
return -1;
}
}
}
return 0;
}
int opencl_session_update_mp (opencl_ctx_t *opencl_ctx, const mask_ctx_t *mask_ctx)
{
for (uint device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)

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 straight_ctx_t *straight_ctx, const mask_ctx_t *mask_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 straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx)
{
if (opencl_ctx->devices_status == STATUS_INIT)
{
@ -256,7 +256,7 @@ void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *
progress_skip = MIN (user_options->skip, data.words_base) * hashes->salts_cnt;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_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_COMBI) progress_skip *= combinator_ctx->combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= mask_ctx->bfs_cnt;
}
@ -265,7 +265,7 @@ void status_display_machine_readable (opencl_ctx_t *opencl_ctx, const hashes_t *
progress_end = MIN (user_options->limit, data.words_base) * hashes->salts_cnt;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_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_COMBI) progress_end *= combinator_ctx->combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= mask_ctx->bfs_cnt;
}
@ -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 straight_ctx_t *straight_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 straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_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, straight_ctx, mask_ctx);
status_display_machine_readable (opencl_ctx, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx);
return;
}
@ -731,7 +731,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
progress_skip = MIN (user_options->skip, data.words_base) * hashes->salts_cnt;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_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_COMBI) progress_skip *= combinator_ctx->combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= mask_ctx->bfs_cnt;
}
@ -740,7 +740,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
progress_end = MIN (user_options->limit, data.words_base) * hashes->salts_cnt;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_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_COMBI) progress_end *= combinator_ctx->combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= mask_ctx->bfs_cnt;
}

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 straight_ctx_t *straight_ctx, const mask_ctx_t *mask_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 straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx, const uint pws_cnt)
{
out_t out;
@ -140,7 +140,7 @@ void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
char *comb_buf = (char *) device_param->combs_buf[il_pos].i;
uint comb_len = device_param->combs_buf[il_pos].pw_len;
if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT)
{
memcpy (plain_ptr + plain_len, comb_buf, comb_len);
}

View File

@ -19,9 +19,7 @@
int straight_ctx_init (straight_ctx_t *straight_ctx, const user_options_t *user_options)
{
/**
* rules
*/
memset (straight_ctx, 0, sizeof (straight_ctx_t));
straight_ctx->enabled = false;

View File

@ -68,7 +68,8 @@ void *thread_keypress (void *p)
user_options_extra_t *user_options_extra = data.user_options_extra;
hashconfig_t *hashconfig = data.hashconfig;
hashes_t *hashes = data.hashes;
straight_ctx_t *straight_ctx = data.straight_ctx;
straight_ctx_t *straight_ctx = data.straight_ctx;
combinator_ctx_t *combinator_ctx = data.combinator_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
const bool quiet = user_options->quiet;
@ -100,7 +101,7 @@ void *thread_keypress (void *p)
log_info ("");
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, mask_ctx);
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx);
log_info ("");

View File

@ -30,7 +30,7 @@
extern hc_global_data_t data;
void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos)
void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos)
{
if (device_param == NULL)
{
@ -93,7 +93,7 @@ void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
* result
*/
check_cracked (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, hashconfig, hashes, salt_pos);
check_cracked (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, hashconfig, hashes, salt_pos);
/**
* cleanup

View File

@ -285,7 +285,7 @@ void pw_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len
//}
}
u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, FILE *fd, const char *dictfile, dictstat_ctx_t *dictstat_ctx)
u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, FILE *fd, const char *dictfile, dictstat_ctx_t *dictstat_ctx)
{
hc_signal (NULL);
@ -329,7 +329,7 @@ u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const u
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
keyspace *= data.combs_cnt;
keyspace *= combinator_ctx->combs_cnt;
}
if (user_options->quiet == false) log_info ("Cache-hit dictionary stats %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, d.stat.st_size, cached_cnt, keyspace);
@ -392,7 +392,7 @@ u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const u
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
cnt += data.combs_cnt;
cnt += combinator_ctx->combs_cnt;
}
d.cnt++;