1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-01-03 12:21:07 +00:00

Move pw_min and pw_max to hashconfig_t and bring back data.shutdown_*

This commit is contained in:
jsteube 2016-09-28 13:51:00 +02:00
parent 171bfbbb8b
commit f8d538413e
11 changed files with 60 additions and 77 deletions

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 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 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 hashes_t *hashes, const outfile_ctx_t *outfile_ctx, const uint highest_pw_len, const uint pws_cnt, const uint fast_iteration, const uint salt_pos);
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);
@ -34,7 +34,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 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 combinator_ctx_t *combinator_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 outfile_ctx_t *outfile_ctx, const uint pws_cnt);
int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options);
void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx);

View File

@ -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 combinator_ctx_t *combinator_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 hashconfig_t *hashconfig, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx, const outfile_ctx_t *outfile_ctx, const uint pws_cnt);
#endif // _STDOUT_H

View File

@ -435,6 +435,9 @@ struct _hashconfig
u32 tmp_size;
u32 hook_size;
u32 pw_min;
u32 pw_max;
int (*parse_func) (char *, u32, hash_t *, const struct _hashconfig *);
};
@ -1216,6 +1219,13 @@ typedef struct
user_options_extra_t *user_options_extra;
user_options_t *user_options;
/**
* threads
*/
u32 shutdown_inner;
u32 shutdown_outer;
/**
* hardware watchdog
*/
@ -1241,8 +1251,6 @@ typedef struct
char *dictfile;
char *dictfile2;
u32 pw_min;
u32 pw_max;
/**
* status, timer

View File

@ -123,6 +123,7 @@ void *thread_calc_stdin (void *p)
combinator_ctx_t *combinator_ctx = data.combinator_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
outfile_ctx_t *outfile_ctx = data.outfile_ctx;
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE);
@ -179,7 +180,7 @@ void *thread_calc_stdin (void *p)
if (attack_kern == ATTACK_KERN_STRAIGHT)
{
if ((line_len < data.pw_min) || (line_len > data.pw_max))
if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max))
{
hc_thread_mutex_lock (opencl_ctx->mux_counter);
@ -213,7 +214,7 @@ void *thread_calc_stdin (void *p)
{
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, combinator_ctx, mask_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, pws_cnt);
device_param->pws_cnt = 0;
@ -253,6 +254,7 @@ void *thread_calc (void *p)
combinator_ctx_t *combinator_ctx = data.combinator_ctx;
mask_ctx_t *mask_ctx = data.mask_ctx;
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
outfile_ctx_t *outfile_ctx = data.outfile_ctx;
const uint attack_mode = user_options->attack_mode;
const uint attack_kern = user_options_extra->attack_kern;
@ -276,7 +278,7 @@ void *thread_calc (void *p)
{
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, combinator_ctx, mask_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, pws_cnt);
device_param->pws_cnt = 0;
@ -410,7 +412,7 @@ void *thread_calc (void *p)
if (attack_kern == ATTACK_KERN_STRAIGHT)
{
if ((line_len < data.pw_min) || (line_len > data.pw_max))
if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max))
{
max++;
@ -428,10 +430,10 @@ void *thread_calc (void *p)
}
else if (attack_kern == ATTACK_KERN_COMBI)
{
// do not check if minimum restriction is satisfied (line_len >= data.pw_min) here
// do not check if minimum restriction is satisfied (line_len >= hashconfig->pw_min) here
// since we still need to combine the plains
if (line_len > data.pw_max)
if (line_len > hashconfig->pw_max)
{
max++;
@ -468,7 +470,7 @@ void *thread_calc (void *p)
{
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, combinator_ctx, mask_ctx, pws_cnt);
run_cracker (opencl_ctx, device_param, hashconfig, hashes, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, pws_cnt);
device_param->pws_cnt = 0;

View File

@ -310,7 +310,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
crackpos *= straight_ctx->kernel_rules_cnt;
crackpos += device_param->innerloop_pos + il_pos;
if (plain_len > data.pw_max) plain_len = data.pw_max;
if (plain_len > hashconfig->pw_max) plain_len = hashconfig->pw_max;
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
@ -345,9 +345,9 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
crackpos *= combinator_ctx->combs_cnt;
crackpos += device_param->innerloop_pos + il_pos;
if (data.pw_max != PW_DICTMAX1)
if (hashconfig->pw_max != PW_DICTMAX1)
{
if (plain_len > data.pw_max) plain_len = data.pw_max;
if (plain_len > hashconfig->pw_max) plain_len = hashconfig->pw_max;
}
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
@ -396,9 +396,9 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
crackpos *= combinator_ctx->combs_cnt;
crackpos += device_param->innerloop_pos + il_pos;
if (data.pw_max != PW_DICTMAX1)
if (hashconfig->pw_max != PW_DICTMAX1)
{
if (plain_len > data.pw_max) plain_len = data.pw_max;
if (plain_len > hashconfig->pw_max) plain_len = hashconfig->pw_max;
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
@ -429,9 +429,9 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
crackpos *= combinator_ctx->combs_cnt;
crackpos += device_param->innerloop_pos + il_pos;
if (data.pw_max != PW_DICTMAX1)
if (hashconfig->pw_max != PW_DICTMAX1)
{
if (plain_len > data.pw_max) plain_len = data.pw_max;
if (plain_len > hashconfig->pw_max) plain_len = hashconfig->pw_max;
}
}

View File

@ -925,8 +925,8 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
if (rc_update_combinator == -1) return -1;
}
data.pw_min = pw_min;
data.pw_max = pw_max;
hashconfig->pw_min = pw_min;
hashconfig->pw_max = pw_max;
/**
* prevent the user from using --skip/--limit together w/ maskfile and or dictfile
@ -1284,15 +1284,6 @@ static int inner1_loop (user_options_t *user_options, user_options_extra_t *user
* create cracker threads
*/
/* still needed ?
if (initial_restore_done == false)
{
if (user_options->restore_disable == false) cycle_restore (restore_ctx, opencl_ctx);
initial_restore_done = true;
}
*/
opencl_ctx->devices_status = STATUS_RUNNING;
hc_timer_set (&data.timer_running);
@ -1772,6 +1763,8 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
hc_thread_t *inner_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t));
data.shutdown_inner = 0;
/**
* Outfile remove
*/
@ -1811,9 +1804,6 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
}
}
// still needed?
// bool initial_restore_done = false;
// still needed?
// mask_ctx->masks_cnt = maskcnt;
@ -1892,6 +1882,8 @@ static int outer_loop (user_options_t *user_options, user_options_extra_t *user_
// wait for inner threads
data.shutdown_inner = 1;
for (uint thread_idx = 0; thread_idx < inner_threads_cnt; thread_idx++)
{
hc_thread_wait (1, &inner_threads[thread_idx]);
@ -2709,6 +2701,8 @@ int main (int argc, char **argv)
hc_thread_t *outer_threads = (hc_thread_t *) mycalloc (10, sizeof (hc_thread_t));
data.shutdown_outer = 0;
if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false)
{
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
@ -2756,6 +2750,8 @@ int main (int argc, char **argv)
// wait for outer threads
data.shutdown_outer = 1;
for (uint thread_idx = 0; thread_idx < outer_threads_cnt; thread_idx++)
{
hc_thread_wait (1, &outer_threads[thread_idx]);

View File

@ -109,7 +109,7 @@ void *thread_monitor (void *p)
u32 remove_left = user_options->remove_timer;
u32 status_left = user_options->status_timer;
while (opencl_ctx->run_main_level2 == true)
while (data.shutdown_inner == 0)
{
hc_sleep (sleep_time);

View File

@ -295,22 +295,23 @@ 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 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 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 hashes_t *hashes, const outfile_ctx_t *outfile_ctx, const uint highest_pw_len, const uint pws_cnt, const uint fast_iteration, const uint salt_pos)
{
cl_int CL_err = CL_SUCCESS;
if (hashconfig->hash_mode == 2000)
{
process_stdout (opencl_ctx, device_param, user_options, straight_ctx, combinator_ctx, mask_ctx, pws_cnt);
process_stdout (opencl_ctx, device_param, user_options, hashconfig, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, pws_cnt);
return 0;
}
if (attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
if (attack_mode == ATTACK_MODE_BF)
if (user_options->attack_mode == ATTACK_MODE_BF)
{
if (opts_type & OPTS_TYPE_PT_BITSLICE)
if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE)
{
const uint size_tm = 32 * sizeof (bs_word_t);
@ -348,7 +349,7 @@ int choose_kernel (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, co
run_kernel (KERN_RUN_1, opencl_ctx, device_param, pws_cnt, false, 0, hashconfig, user_options);
if (opts_type & OPTS_TYPE_HOOK12)
if (hashconfig->opts_type & OPTS_TYPE_HOOK12)
{
run_kernel (KERN_RUN_12, opencl_ctx, device_param, pws_cnt, false, 0, hashconfig, user_options);
@ -373,7 +374,7 @@ int choose_kernel (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, co
}
}
uint iter = salt_buf->salt_iter;
uint iter = hashes->salts_buf[salt_pos].salt_iter;
uint loop_step = device_param->kernel_loops;
@ -414,7 +415,7 @@ int choose_kernel (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, co
}
}
if (opts_type & OPTS_TYPE_HOOK23)
if (hashconfig->opts_type & OPTS_TYPE_HOOK23)
{
run_kernel (KERN_RUN_23, opencl_ctx, device_param, pws_cnt, false, 0, hashconfig, user_options);
@ -1005,7 +1006,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 combinator_ctx_t *combinator_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 outfile_ctx_t *outfile_ctx, const uint pws_cnt)
{
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
@ -1282,7 +1283,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, combinator_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, hashes, outfile_ctx, highest_pw_len, pws_cnt, fast_iteration, salt_pos);
if (rc == -1) return -1;

View File

@ -323,7 +323,7 @@ void status_display (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, c
}
// in this case some required buffers are free'd, ascii_digest() would run into segfault
if (opencl_ctx->run_main_level2 == false) return;
if (data.shutdown_inner == 1) return;
if (user_options->machine_readable == true)
{
@ -1158,7 +1158,7 @@ void status_benchmark (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig,
return;
}
if (opencl_ctx->run_main_level2 == false) return;
if (data.shutdown_inner == 1) return;
if (user_options->machine_readable == true)
{

View File

@ -5,37 +5,13 @@
#include "common.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "memory.h"
#include "convert.h"
#include "logging.h"
#include "logfile.h"
#include "ext_OpenCL.h"
#include "ext_ADL.h"
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "tuningdb.h"
#include "thread.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "hash_management.h"
#include "locking.h"
#include "rp_cpu.h"
#include "rp_kernel_on_cpu.h"
#include "shared.h"
#include "mpsp.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
#include "loopback.h"
#include "data.h"
#include "opencl.h"
#include "stdout.h"
extern hc_global_data_t data;
static void out_flush (out_t *out)
{
fwrite (out->buf, 1, out->len, out->fp);
@ -59,7 +35,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 combinator_ctx_t *combinator_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 hashconfig_t *hashconfig, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx, const outfile_ctx_t *outfile_ctx, const uint pws_cnt)
{
out_t out;
@ -67,7 +43,7 @@ void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
// i think this section can be optimized now that we have outfile_ctx
char *filename = data.outfile_ctx->filename;
char *filename = outfile_ctx->filename;
if (filename != NULL)
{
@ -114,7 +90,7 @@ void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
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;
if (plain_len > hashconfig->pw_max) plain_len = hashconfig->pw_max;
out_push (&out, plain_ptr, plain_len);
}
@ -153,9 +129,9 @@ void process_stdout (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
plain_len += comb_len;
if (data.pw_max != PW_DICTMAX1)
if (hashconfig->pw_max != PW_DICTMAX1)
{
if (plain_len > data.pw_max) plain_len = data.pw_max;
if (plain_len > hashconfig->pw_max) plain_len = hashconfig->pw_max;
}
out_push (&out, plain_ptr, plain_len);

View File

@ -76,7 +76,7 @@ void *thread_keypress (void *p)
tty_break ();
while (opencl_ctx->run_main_level1 == true)
while (data.shutdown_outer == 0)
{
int ch = tty_getchar ();