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

Separate rules and straight mode from each other, remove rules_ctx_t

This commit is contained in:
jsteube 2016-09-27 13:13:07 +02:00
parent edd50de047
commit 67dd2e9b67
24 changed files with 292 additions and 235 deletions

View File

@ -6,7 +6,7 @@
#ifndef _AUTOTUNE_H
#define _AUTOTUNE_H
int autotune (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 rules_ctx_t *rules_ctx);
int autotune (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 straight_ctx_t *straight_ctx);
void *thread_autotune (void *p);

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 rules_ctx_t *rules_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, 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 rules_ctx_t *rules_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, 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

@ -23,7 +23,7 @@ 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 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 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 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 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 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,7 +41,7 @@ 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 rules_ctx_t *rules_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);
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);

View File

@ -23,14 +23,14 @@ bool class_alpha (const u8 c);
int conv_ctoi (const u8 c);
int conv_itoc (const u8 c);
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max);
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], const u32 rp_gen_func_min, const u32 rp_gen_func_max);
int cpu_rule_to_kernel_rule (char *rule_buf, uint rule_len, kernel_rule_t *rule);
int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule);
int rules_ctx_init (rules_ctx_t *rules_ctx, const user_options_t *user_options);
void rules_ctx_destroy (rules_ctx_t *rules_ctx);
bool kernel_rules_has_noop (const kernel_rule_t *kernel_rules_buf, const u32 kernel_rules_cnt);
bool rules_ctx_has_noop (rules_ctx_t *rules_ctx);
int kernel_rules_load (kernel_rule_t **out_buf, u32 *out_cnt, const user_options_t *user_options);
int kernel_rules_generate (kernel_rule_t **out_buf, u32 *out_cnt, const user_options_t *user_options);
#endif // _RP_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 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_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_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 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 mask_ctx_t *mask_ctx, const uint pws_cnt);
#endif // _STDOUT_H

14
include/straight.h Normal file
View File

@ -0,0 +1,14 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _STRAIGHT_H
#define _STRAIGHT_H
#include <string.h>
int straight_ctx_init (straight_ctx_t *straight_ctx, const user_options_t *user_options);
void straight_ctx_destroy (straight_ctx_t *straight_ctx);
#endif // _STRAIGHT_H

View File

@ -1114,6 +1114,25 @@ typedef struct
} induct_ctx_t;
typedef struct
{
bool enabled;
char *root_directory;
} outcheck_ctx_t;
typedef struct
{
bool enabled;
char *dictfile;
u32 kernel_rules_cnt;
kernel_rule_t *kernel_rules_buf;
} straight_ctx_t;
typedef struct
{
bool enabled;
@ -1143,21 +1162,6 @@ typedef struct
} mask_ctx_t;
typedef struct
{
bool enabled;
char *root_directory;
} outcheck_ctx_t;
typedef struct
{
u32 kernel_rules_cnt;
kernel_rule_t *kernel_rules_buf;
} rules_ctx_t;
typedef struct
{
/**
@ -1224,8 +1228,8 @@ typedef struct
induct_ctx_t *induct_ctx;
outcheck_ctx_t *outcheck_ctx;
logfile_ctx_t *logfile_ctx;
rules_ctx_t *rules_ctx;
restore_ctx_t *restore_ctx;
straight_ctx_t *straight_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 rules_ctx_t *rules_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, 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 rules_ctx_t *rules_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, 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 terminal thread timer tuningdb usage user_options version weak_hash wordlist
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
NATIVE_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.o)

View File

@ -36,7 +36,7 @@ static double try_run (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param
return exec_ms_prev;
}
int autotune (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 rules_ctx_t *rules_ctx)
int autotune (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 straight_ctx_t *straight_ctx)
{
const double target_ms = opencl_ctx->target_ms;
@ -103,7 +103,7 @@ int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashcon
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
if (rules_ctx->kernel_rules_cnt > 1)
if (straight_ctx->kernel_rules_cnt > 1)
{
cl_int CL_err = hc_clEnqueueCopyBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL);
@ -302,10 +302,10 @@ void *thread_autotune (void *p)
user_options_t *user_options = data.user_options;
user_options_extra_t *user_options_extra = data.user_options_extra;
hashconfig_t *hashconfig = data.hashconfig;
rules_ctx_t *rules_ctx = data.rules_ctx;
straight_ctx_t *straight_ctx = data.straight_ctx;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
autotune (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, rules_ctx);
autotune (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, straight_ctx);
return NULL;
}

View File

@ -119,7 +119,7 @@ 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;
rules_ctx_t *rules_ctx = data.rules_ctx;
straight_ctx_t *straight_ctx = data.straight_ctx;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
@ -184,7 +184,7 @@ void *thread_calc_stdin (void *p)
for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{
data.words_progress_rejected[salt_pos] += rules_ctx->kernel_rules_cnt;
data.words_progress_rejected[salt_pos] += straight_ctx->kernel_rules_cnt;
}
hc_thread_mutex_unlock (opencl_ctx->mux_counter);
@ -212,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, mask_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, mask_ctx, pws_cnt);
device_param->pws_cnt = 0;
@ -249,7 +249,7 @@ void *thread_calc (void *p)
hashconfig_t *hashconfig = data.hashconfig;
hashes_t *hashes = data.hashes;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
rules_ctx_t *rules_ctx = data.rules_ctx;
straight_ctx_t *straight_ctx = data.straight_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
const uint attack_mode = user_options->attack_mode;
@ -274,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, mask_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, mask_ctx, pws_cnt);
device_param->pws_cnt = 0;
@ -416,7 +416,7 @@ void *thread_calc (void *p)
for (uint salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{
data.words_progress_rejected[salt_pos] += rules_ctx->kernel_rules_cnt;
data.words_progress_rejected[salt_pos] += straight_ctx->kernel_rules_cnt;
}
hc_thread_mutex_unlock (opencl_ctx->mux_counter);
@ -466,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, mask_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_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 rules_ctx_t *rules_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, plain_t *plain)
{
debugfile_ctx_t *debugfile_ctx = data.debugfile_ctx;
loopback_ctx_t *loopback_ctx = data.loopback_ctx;
@ -290,7 +290,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
{
memset (debug_rule_buf, 0, sizeof (debug_rule_buf));
debug_rule_len = kernel_rule_to_cpu_rule ((char *) debug_rule_buf, &rules_ctx->kernel_rules_buf[off]);
debug_rule_len = kernel_rule_to_cpu_rule ((char *) debug_rule_buf, &straight_ctx->kernel_rules_buf[off]);
}
// save plain
@ -304,10 +304,10 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
}
}
plain_len = apply_rules (rules_ctx->kernel_rules_buf[off].cmds, &plain_buf[0], &plain_buf[4], plain_len);
plain_len = apply_rules (straight_ctx->kernel_rules_buf[off].cmds, &plain_buf[0], &plain_buf[4], plain_len);
crackpos += gidvid;
crackpos *= rules_ctx->kernel_rules_cnt;
crackpos *= straight_ctx->kernel_rules_cnt;
crackpos += device_param->innerloop_pos + il_pos;
if (plain_len > data.pw_max) plain_len = data.pw_max;
@ -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 rules_ctx_t *rules_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, 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, rules_ctx, &cracked[i]);
check_hash (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, &cracked[i]);
}
hc_thread_mutex_unlock (mux_display);

View File

@ -84,6 +84,7 @@
#include "version.h"
#include "weak_hash.h"
#include "wordlist.h"
#include "straight.h"
extern hc_global_data_t data;
@ -222,7 +223,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, rules_ctx_t *rules_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx, hashconfig_t *hashconfig, hashes_t *hashes, mask_ctx_t *mask_ctx, wl_data_t *wl_data)
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)
{
//opencl_ctx->run_main_level1 = true;
//opencl_ctx->run_main_level2 = true;
@ -241,7 +242,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
* If we have a NOOP rule then we can process words from wordlists > length 32 for slow hashes
*/
const bool has_noop = rules_ctx_has_noop (rules_ctx);
const bool has_noop = kernel_rules_has_noop (straight_ctx->kernel_rules_buf, straight_ctx->kernel_rules_cnt);
if (has_noop == false)
{
@ -739,7 +740,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
data.combs_cnt = 1;
const u64 words1_cnt = count_words (wl_data, user_options, user_options_extra, rules_ctx, fp1, dictfile1, dictstat_ctx);
const u64 words1_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, fp1, dictfile1, dictstat_ctx);
if (words1_cnt == 0)
{
@ -753,7 +754,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
data.combs_cnt = 1;
const u64 words2_cnt = count_words (wl_data, user_options, user_options_extra, rules_ctx, fp2, dictfile2, dictstat_ctx);
const u64 words2_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, fp2, dictfile2, dictstat_ctx);
if (words2_cnt == 0)
{
@ -1120,7 +1121,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, rules_ctx, fd2, dictfile, dictstat_ctx);
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, fd2, dictfile, dictstat_ctx);
fclose (fd2);
@ -1151,7 +1152,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, rules_ctx, fd2, dictfile, dictstat_ctx);
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, fd2, dictfile, dictstat_ctx);
fclose (fd2);
}
@ -1166,7 +1167,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, rules_ctx, fd2, dictfile2, dictstat_ctx);
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, fd2, dictfile2, dictstat_ctx);
fclose (fd2);
}
@ -1205,7 +1206,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, rules_ctx, fd2, dictfile, dictstat_ctx);
data.words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, fd2, dictfile, dictstat_ctx);
fclose (fd2);
@ -1225,9 +1226,9 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
{
if (rules_ctx->kernel_rules_cnt)
if (straight_ctx->kernel_rules_cnt)
{
words_base /= rules_ctx->kernel_rules_cnt;
words_base /= straight_ctx->kernel_rules_cnt;
}
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
@ -1267,7 +1268,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 * rules_ctx->kernel_rules_cnt;
data.words_progress_restored[i] = data.words_cur * straight_ctx->kernel_rules_cnt;
}
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
@ -1317,7 +1318,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 = rules_ctx->kernel_rules_cnt;
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_BF) innerloop_cnt = mask_ctx->bfs_cnt;
}
@ -1484,7 +1485,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, rules_ctx, mask_ctx);
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, mask_ctx);
log_info ("");
}
@ -1492,7 +1493,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, rules_ctx, mask_ctx);
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, mask_ctx);
log_info ("");
}
@ -1539,7 +1540,7 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
return 0;
}
static int outer_loop (user_options_t *user_options, user_options_extra_t *user_options_extra, restore_ctx_t *restore_ctx, folder_config_t *folder_config, logfile_ctx_t *logfile_ctx, tuning_db_t *tuning_db, induct_ctx_t *induct_ctx, outcheck_ctx_t *outcheck_ctx, outfile_ctx_t *outfile_ctx, potfile_ctx_t *potfile_ctx, rules_ctx_t *rules_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx)
static int outer_loop (user_options_t *user_options, user_options_extra_t *user_options_extra, restore_ctx_t *restore_ctx, folder_config_t *folder_config, logfile_ctx_t *logfile_ctx, tuning_db_t *tuning_db, induct_ctx_t *induct_ctx, outcheck_ctx_t *outcheck_ctx, outfile_ctx_t *outfile_ctx, potfile_ctx_t *potfile_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx)
{
opencl_ctx->devices_status = STATUS_INIT;
@ -1684,6 +1685,26 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
bitmap_ctx_init (bitmap_ctx, user_options, hashconfig, hashes);
/**
* Wordlist allocate buffer
*/
wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
wl_data_init (wl_data, user_options, hashconfig);
/**
* straight mode init
*/
straight_ctx_t *straight_ctx = (straight_ctx_t *) mymalloc (sizeof (straight_ctx_t));
data.straight_ctx = straight_ctx;
const int rc_straight_init = straight_ctx_init (straight_ctx, user_options);
if (rc_straight_init == -1) return -1;
/**
* charsets : keep them together for more easy maintainnce
*/
@ -1696,14 +1717,6 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
if (rc_mask_init == -1) return -1;
/**
* Wordlist allocate buffer
*/
wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
wl_data_init (wl_data, user_options, hashconfig);
/**
* enable custom signal handler(s)
*/
@ -1729,7 +1742,7 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
log_info ("Rules: %u", rules_ctx->kernel_rules_cnt);
log_info ("Rules: %u", straight_ctx->kernel_rules_cnt);
}
if (user_options->quiet == false) log_info ("");
@ -1800,7 +1813,7 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
session_ctx_init (session_ctx);
*/
opencl_session_begin (opencl_ctx, hashconfig, hashes, rules_ctx, user_options, user_options_extra, folder_config, bitmap_ctx, tuning_db);
opencl_session_begin (opencl_ctx, hashconfig, hashes, straight_ctx, user_options, user_options_extra, folder_config, bitmap_ctx, tuning_db);
if (user_options->quiet == false) log_info_nn ("");
@ -1846,7 +1859,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, rules_ctx, hashconfig, hashes, salt_pos);
weak_hash_check (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, hashconfig, hashes, salt_pos);
}
}
@ -1920,7 +1933,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, rules_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hashconfig, hashes, mask_ctx, wl_data);
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);
if (rc_inner1_loop == -1) return -1;
@ -1929,7 +1942,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, rules_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hashconfig, hashes, mask_ctx, wl_data);
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);
if (rc_inner1_loop == -1) return -1;
}
@ -2032,6 +2045,8 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
mask_ctx_destroy (mask_ctx);
straight_ctx_destroy (straight_ctx);
hashes_destroy (hashes);
hashconfig_destroy (hashconfig);
@ -2279,18 +2294,6 @@ int main (int argc, char **argv)
set_cpu_affinity (user_options->cpu_affinity);
}
/**
* rules
*/
rules_ctx_t *rules_ctx = (rules_ctx_t *) mymalloc (sizeof (rules_ctx_t));
data.rules_ctx = rules_ctx;
const int rc_rules_init = rules_ctx_init (rules_ctx, user_options);
if (rc_rules_init == -1) return -1;
/**
* Init OpenCL library loader
*/
@ -2829,7 +2832,7 @@ int main (int argc, char **argv)
if (user_options->hash_mode_chgd == true)
{
const int rc = outer_loop (user_options, user_options_extra, restore_ctx, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, rules_ctx, dictstat_ctx, loopback_ctx, opencl_ctx);
const int rc = outer_loop (user_options, user_options_extra, restore_ctx, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, dictstat_ctx, loopback_ctx, opencl_ctx);
if (rc == -1) return -1;
}
@ -2839,7 +2842,7 @@ int main (int argc, char **argv)
{
user_options->hash_mode = DEFAULT_BENCHMARK_ALGORITHMS_BUF[algorithm_pos];
const int rc = outer_loop (user_options, user_options_extra, restore_ctx, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, rules_ctx, dictstat_ctx, loopback_ctx, opencl_ctx);
const int rc = outer_loop (user_options, user_options_extra, restore_ctx, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, dictstat_ctx, loopback_ctx, opencl_ctx);
if (rc == -1) return -1;
@ -2849,7 +2852,7 @@ int main (int argc, char **argv)
}
else
{
const int rc = outer_loop (user_options, user_options_extra, restore_ctx, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, rules_ctx, dictstat_ctx, loopback_ctx, opencl_ctx);
const int rc = outer_loop (user_options, user_options_extra, restore_ctx, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, dictstat_ctx, loopback_ctx, opencl_ctx);
if (rc == -1) return -1;
}
@ -3038,8 +3041,6 @@ int main (int argc, char **argv)
debugfile_destroy (debugfile_ctx);
rules_ctx_destroy (rules_ctx);
tuning_db_destroy (tuning_db);
loopback_destroy (loopback_ctx);

View File

@ -45,7 +45,7 @@ void *thread_monitor (void *p)
hashconfig_t *hashconfig = data.hashconfig;
hashes_t *hashes = data.hashes;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
rules_ctx_t *rules_ctx = data.rules_ctx;
straight_ctx_t *straight_ctx = data.straight_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
bool runtime_check = false;
@ -346,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, mask_ctx);
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, mask_ctx);
if (user_options->quiet == false) log_info ("");

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 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 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)
{
cl_int CL_err = CL_SUCCESS;
if (hashconfig->hash_mode == 2000)
{
process_stdout (opencl_ctx, device_param, user_options, rules_ctx, mask_ctx, pws_cnt);
process_stdout (opencl_ctx, device_param, user_options, straight_ctx, mask_ctx, pws_cnt);
return 0;
}
@ -1007,7 +1007,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 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 mask_ctx_t *mask_ctx, const uint pws_cnt)
{
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
@ -1072,7 +1072,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) innerloop_step = device_param->kernel_loops;
else innerloop_step = 1;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = rules_ctx->kernel_rules_cnt;
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_BF) innerloop_cnt = mask_ctx->bfs_cnt;
@ -1284,7 +1284,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, 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, 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 +1294,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, rules_ctx, hashconfig, hashes, salt_pos);
check_cracked (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, hashconfig, hashes, salt_pos);
}
/**
@ -2460,7 +2460,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 rules_ctx_t *rules_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)
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)
{
/**
* Some algorithm, like descrypt, can benefit from JIT compilation
@ -2690,8 +2690,8 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
device_param->size_results = size_results;
size_t size_rules = rules_ctx->kernel_rules_cnt * sizeof (kernel_rule_t);
size_t size_rules_c = KERNEL_RULES * sizeof (kernel_rule_t);
size_t size_rules = straight_ctx->kernel_rules_cnt * sizeof (kernel_rule_t);
size_t size_rules_c = KERNEL_RULES * sizeof (kernel_rule_t);
size_t size_plains = hashes->digests_cnt * sizeof (plain_t);
size_t size_salts = hashes->salts_cnt * sizeof (salt_t);
@ -3866,7 +3866,7 @@ int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconf
return -1;
}
CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, rules_ctx->kernel_rules_buf, 0, NULL, NULL);
CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, straight_ctx->kernel_rules_buf, 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{

184
src/rp.c
View File

@ -147,7 +147,7 @@ int conv_itoc (const u8 c)
return -1;
}
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max)
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], const u32 rp_gen_func_min, const u32 rp_gen_func_max)
{
u32 rp_gen_num = get_random_num (rp_gen_func_min, rp_gen_func_max);
@ -701,7 +701,20 @@ int kernel_rule_to_cpu_rule (char *rule_buf, kernel_rule_t *rule)
return -1;
}
int rules_ctx_init (rules_ctx_t *rules_ctx, const user_options_t *user_options)
bool kernel_rules_has_noop (const kernel_rule_t *kernel_rules_buf, const u32 kernel_rules_cnt)
{
for (uint kernel_rules_pos = 0; kernel_rules_pos < kernel_rules_cnt; kernel_rules_pos++)
{
if (kernel_rules_buf[kernel_rules_pos].cmds[0] != RULE_OP_MANGLE_NOOP) continue;
if (kernel_rules_buf[kernel_rules_pos].cmds[1] != 0) continue;
return true;
}
return false;
}
int kernel_rules_load (kernel_rule_t **out_buf, u32 *out_cnt, const user_options_t *user_options)
{
/**
* load rules
@ -748,8 +761,6 @@ int rules_ctx_init (rules_ctx_t *rules_ctx, const user_options_t *user_options)
while (!feof (fp))
{
memset (rule_buf, 0, HCBUFSIZ_LARGE);
rule_len = fgetl (fp, rule_buf);
rule_line++;
@ -792,109 +803,58 @@ int rules_ctx_init (rules_ctx_t *rules_ctx, const user_options_t *user_options)
fclose (fp);
all_kernel_rules_cnt[i] = kernel_rules_cnt;
all_kernel_rules_buf[i] = kernel_rules_buf;
}
/**
* merge rules or automatic rule generator
*/
uint kernel_rules_cnt = 0;
kernel_rule_t *kernel_rules_buf = NULL;
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
if (user_options->rp_files_cnt)
{
kernel_rules_cnt = 1;
uint *repeats = (uint *) mycalloc (user_options->rp_files_cnt + 1, sizeof (uint));
repeats[0] = kernel_rules_cnt;
for (uint i = 0; i < user_options->rp_files_cnt; i++)
{
kernel_rules_cnt *= all_kernel_rules_cnt[i];
repeats[i + 1] = kernel_rules_cnt;
}
kernel_rules_buf = (kernel_rule_t *) mycalloc (kernel_rules_cnt, sizeof (kernel_rule_t));
memset (kernel_rules_buf, 0, kernel_rules_cnt * sizeof (kernel_rule_t));
for (uint i = 0; i < kernel_rules_cnt; i++)
{
uint out_pos = 0;
kernel_rule_t *out = &kernel_rules_buf[i];
for (uint j = 0; j < user_options->rp_files_cnt; j++)
{
uint in_off = (i / repeats[j]) % all_kernel_rules_cnt[j];
uint in_pos;
kernel_rule_t *in = &all_kernel_rules_buf[j][in_off];
for (in_pos = 0; in->cmds[in_pos]; in_pos++, out_pos++)
{
if (out_pos == RULES_MAX - 1)
{
// log_info ("WARNING: Truncating chaining of rule %d and rule %d as maximum number of function calls per rule exceeded", i, in_off);
break;
}
out->cmds[out_pos] = in->cmds[in_pos];
}
}
}
myfree (repeats);
}
else if (user_options->rp_gen)
{
uint kernel_rules_avail = 0;
while (kernel_rules_cnt < user_options->rp_gen)
{
if (kernel_rules_avail == kernel_rules_cnt)
{
kernel_rules_buf = (kernel_rule_t *) myrealloc (kernel_rules_buf, kernel_rules_avail * sizeof (kernel_rule_t), INCR_RULES * sizeof (kernel_rule_t));
kernel_rules_avail += INCR_RULES;
}
memset (rule_buf, 0, HCBUFSIZ_LARGE);
rule_len = (int) generate_random_rule (rule_buf, user_options->rp_gen_func_min, user_options->rp_gen_func_max);
if (cpu_rule_to_kernel_rule (rule_buf, rule_len, &kernel_rules_buf[kernel_rules_cnt]) == -1) continue;
kernel_rules_cnt++;
}
}
}
myfree (rule_buf);
/**
* generate NOP rules
* merge rules
*/
if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0))
uint kernel_rules_cnt = 1;
uint *repeats = (uint *) mycalloc (user_options->rp_files_cnt + 1, sizeof (uint));
repeats[0] = kernel_rules_cnt;
for (uint i = 0; i < user_options->rp_files_cnt; i++)
{
kernel_rules_buf = (kernel_rule_t *) mymalloc (sizeof (kernel_rule_t));
kernel_rules_cnt *= all_kernel_rules_cnt[i];
kernel_rules_buf[kernel_rules_cnt].cmds[0] = RULE_OP_MANGLE_NOOP;
kernel_rules_cnt++;
repeats[i + 1] = kernel_rules_cnt;
}
rules_ctx->kernel_rules_cnt = kernel_rules_cnt;
rules_ctx->kernel_rules_buf = kernel_rules_buf;
kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) mycalloc (kernel_rules_cnt, sizeof (kernel_rule_t));
for (uint i = 0; i < kernel_rules_cnt; i++)
{
uint out_pos = 0;
kernel_rule_t *out = &kernel_rules_buf[i];
for (uint j = 0; j < user_options->rp_files_cnt; j++)
{
uint in_off = (i / repeats[j]) % all_kernel_rules_cnt[j];
uint in_pos;
kernel_rule_t *in = &all_kernel_rules_buf[j][in_off];
for (in_pos = 0; in->cmds[in_pos]; in_pos++, out_pos++)
{
if (out_pos == RULES_MAX - 1)
{
// log_info ("WARNING: Truncating chaining of rule %d and rule %d as maximum number of function calls per rule exceeded", i, in_off);
break;
}
out->cmds[out_pos] = in->cmds[in_pos];
}
}
}
myfree (repeats);
if (kernel_rules_cnt == 0)
{
@ -906,28 +866,32 @@ int rules_ctx_init (rules_ctx_t *rules_ctx, const user_options_t *user_options)
myfree (all_kernel_rules_cnt);
myfree (all_kernel_rules_buf);
*out_cnt = kernel_rules_cnt;
*out_buf = kernel_rules_buf;
return 0;
}
void rules_ctx_destroy (rules_ctx_t *rules_ctx)
int kernel_rules_generate (kernel_rule_t **out_buf, u32 *out_cnt, const user_options_t *user_options)
{
myfree (rules_ctx->kernel_rules_buf);
u32 kernel_rules_cnt = 0;
kernel_rule_t *kernel_rules_buf = mycalloc (user_options->rp_gen, sizeof (kernel_rule_t));
rules_ctx->kernel_rules_buf = NULL;
rules_ctx->kernel_rules_cnt = 0;
char *rule_buf = (char *) mymalloc (RP_RULE_BUFSIZ);
myfree (rules_ctx);
}
bool rules_ctx_has_noop (rules_ctx_t *rules_ctx)
{
for (uint kernel_rules_pos = 0; kernel_rules_pos < rules_ctx->kernel_rules_cnt; kernel_rules_pos++)
for (kernel_rules_cnt = 0; kernel_rules_cnt < user_options->rp_gen; kernel_rules_cnt++)
{
if (rules_ctx->kernel_rules_buf[kernel_rules_pos].cmds[0] != RULE_OP_MANGLE_NOOP) continue;
if (rules_ctx->kernel_rules_buf[kernel_rules_pos].cmds[1] != 0) continue;
memset (rule_buf, 0, RP_RULE_BUFSIZ);
return true;
int rule_len = (int) generate_random_rule (rule_buf, user_options->rp_gen_func_min, user_options->rp_gen_func_max);
if (cpu_rule_to_kernel_rule (rule_buf, rule_len, &kernel_rules_buf[kernel_rules_cnt]) == -1) continue;
}
return false;
}
myfree (rule_buf);
*out_cnt = kernel_rules_cnt;
*out_buf = kernel_rules_buf;
return 0;
}

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, 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 mask_ctx_t *mask_ctx)
{
if (opencl_ctx->devices_status == STATUS_INIT)
{
@ -255,7 +255,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 *= rules_ctx->kernel_rules_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_BF) progress_skip *= mask_ctx->bfs_cnt;
}
@ -264,7 +264,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 *= rules_ctx->kernel_rules_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_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 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 straight_ctx_t *straight_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, mask_ctx);
status_display_machine_readable (opencl_ctx, hashes, restore_ctx, user_options, user_options_extra, straight_ctx, mask_ctx);
return;
}
@ -728,7 +728,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 *= rules_ctx->kernel_rules_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_BF) progress_skip *= mask_ctx->bfs_cnt;
}
@ -737,7 +737,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 *= rules_ctx->kernel_rules_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_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 rules_ctx_t *rules_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 mask_ctx_t *mask_ctx, const uint pws_cnt)
{
out_t out;
@ -112,7 +112,7 @@ void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
plain_len = pw.pw_len;
plain_len = apply_rules (rules_ctx->kernel_rules_buf[pos + il_pos].cmds, &plain_buf[0], &plain_buf[4], plain_len);
plain_len = apply_rules (straight_ctx->kernel_rules_buf[pos + il_pos].cmds, &plain_buf[0], &plain_buf[4], plain_len);
if (plain_len > data.pw_max) plain_len = data.pw_max;

74
src/straight.c Normal file
View File

@ -0,0 +1,74 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#if defined (__APPLE__)
#include <stdio.h>
#endif
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "shared.h"
#include "filehandling.h"
#include "rp.h"
#include "rp_cpu.h"
#include "straight.h"
int straight_ctx_init (straight_ctx_t *straight_ctx, const user_options_t *user_options)
{
/**
* rules
*/
straight_ctx->enabled = false;
if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) return 0;
straight_ctx->enabled = true;
if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0))
{
straight_ctx->kernel_rules_buf = (kernel_rule_t *) mymalloc (sizeof (kernel_rule_t));
straight_ctx->kernel_rules_buf[0].cmds[0] = RULE_OP_MANGLE_NOOP;
straight_ctx->kernel_rules_cnt = 1;
}
else
{
if (user_options->rp_files_cnt)
{
const int rc_kernel_load = kernel_rules_load (&straight_ctx->kernel_rules_buf, &straight_ctx->kernel_rules_cnt, user_options);
if (rc_kernel_load == -1) return -1;
}
else if (user_options->rp_gen)
{
const int rc_kernel_generate = kernel_rules_generate (&straight_ctx->kernel_rules_buf, &straight_ctx->kernel_rules_cnt, user_options);
if (rc_kernel_generate == -1) return -1;
}
}
/**
* generate NOP rules
*/
return 0;
}
void straight_ctx_destroy (straight_ctx_t *straight_ctx)
{
if (straight_ctx->enabled == false) return;
myfree (straight_ctx->kernel_rules_buf);
straight_ctx->kernel_rules_buf = NULL;
straight_ctx->kernel_rules_cnt = 0;
myfree (straight_ctx);
}

View File

@ -68,7 +68,7 @@ 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;
rules_ctx_t *rules_ctx = data.rules_ctx;
straight_ctx_t *straight_ctx = data.straight_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
const bool quiet = user_options->quiet;
@ -100,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, mask_ctx);
status_display (opencl_ctx, hashconfig, hashes, restore_ctx, user_options, user_options_extra, straight_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 rules_ctx_t *rules_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, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos)
{
if (device_param == NULL)
{
@ -54,9 +54,9 @@ void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
data.dictfile = (char *) weak_hash_check;
uint cmd0_rule_old = rules_ctx->kernel_rules_buf[0].cmds[0];
uint cmd0_rule_old = straight_ctx->kernel_rules_buf[0].cmds[0];
rules_ctx->kernel_rules_buf[0].cmds[0] = 0;
straight_ctx->kernel_rules_buf[0].cmds[0] = 0;
/**
* run the kernel
@ -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, rules_ctx, hashconfig, hashes, salt_pos);
check_cracked (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, hashconfig, hashes, salt_pos);
/**
* cleanup
@ -110,5 +110,5 @@ void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
data.dictfile = dictfile_old;
rules_ctx->kernel_rules_buf[0].cmds[0] = cmd0_rule_old;
straight_ctx->kernel_rules_buf[0].cmds[0] = cmd0_rule_old;
}

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 rules_ctx_t *rules_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, FILE *fd, const char *dictfile, dictstat_ctx_t *dictstat_ctx)
{
hc_signal (NULL);
@ -325,7 +325,7 @@ u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const u
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
{
keyspace *= rules_ctx->kernel_rules_cnt;
keyspace *= straight_ctx->kernel_rules_cnt;
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
@ -388,7 +388,7 @@ u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const u
{
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
{
cnt += rules_ctx->kernel_rules_cnt;
cnt += straight_ctx->kernel_rules_cnt;
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{