From 86f67517a0ee743e642ff866b71b69acedecffed Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 29 Aug 2017 10:28:42 +0200 Subject: [PATCH] Allow higher number of kernel_loops for -a 0 mode in case they are slow hashes --- src/hashcat.c | 1 + src/opencl.c | 42 +++++++++++++++++++++++++----------------- src/user_options.c | 26 +------------------------- 3 files changed, 27 insertions(+), 42 deletions(-) diff --git a/src/hashcat.c b/src/hashcat.c index e590a7f1a..1426b20de 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -159,6 +159,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) * limit kernel loops by the amplification count we have from: * - straight_ctx, combinator_ctx or mask_ctx for fast hashes * - hash iteration count for slow hashes + * this is required for autotune */ opencl_ctx_devices_kernel_loops (hashcat_ctx); diff --git a/src/opencl.c b/src/opencl.c index 62edf1a81..40ef7c456 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -3575,9 +3575,9 @@ void opencl_ctx_devices_kernel_loops (hashcat_ctx_t *hashcat_ctx) 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 = combinator_ctx->combs_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) innerloop_cnt = mask_ctx->bfs_cnt; + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = MIN (KERNEL_RULES, straight_ctx->kernel_rules_cnt); + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = MIN (KERNEL_COMBS, combinator_ctx->combs_cnt); + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) innerloop_cnt = MIN (KERNEL_BFS, mask_ctx->bfs_cnt); } else { @@ -3796,20 +3796,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->kernel_accel_max = 1024; device_param->kernel_loops_min = 1; - //device_param->kernel_loops_max = 1024; - - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) - { - device_param->kernel_loops_max = KERNEL_RULES; - } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) - { - device_param->kernel_loops_max = KERNEL_COMBS; - } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) - { - device_param->kernel_loops_max = KERNEL_BFS; - } + device_param->kernel_loops_max = 1024; tuning_db_entry_t *tuningdb_entry = tuning_db_search (hashcat_ctx, device_param->device_name, device_param->device_type, user_options->attack_mode, hashconfig->hash_mode); @@ -3854,6 +3841,27 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->kernel_loops_max = user_options->kernel_loops; } + // we have some absolute limits for fast hashes (because of limit constant memory), make sure not to overstep + + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + { + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + { + device_param->kernel_loops_min = MIN (device_param->kernel_loops_min, KERNEL_RULES); + device_param->kernel_loops_max = MIN (device_param->kernel_loops_max, KERNEL_RULES); + } + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + { + device_param->kernel_loops_min = MIN (device_param->kernel_loops_min, KERNEL_COMBS); + device_param->kernel_loops_max = MIN (device_param->kernel_loops_max, KERNEL_COMBS); + } + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + device_param->kernel_loops_min = MIN (device_param->kernel_loops_min, KERNEL_BFS); + device_param->kernel_loops_max = MIN (device_param->kernel_loops_max, KERNEL_BFS); + } + } + /** * device properties */ diff --git a/src/user_options.c b/src/user_options.c index e232b4728..2361265af 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -689,31 +689,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } - if ((user_options->attack_mode == ATTACK_MODE_STRAIGHT) && (user_options->kernel_loops > KERNEL_RULES)) - { - event_log_error (hashcat_ctx, "Invalid kernel-loops specified."); - - return -1; - } - else if ((user_options->attack_mode == ATTACK_MODE_COMBI) && (user_options->kernel_loops > KERNEL_COMBS)) - { - event_log_error (hashcat_ctx, "Invalid kernel-loops specified."); - - return -1; - } - else if ((user_options->attack_mode == ATTACK_MODE_BF) && (user_options->kernel_loops > KERNEL_BFS)) - { - event_log_error (hashcat_ctx, "Invalid kernel-loops specified."); - - return -1; - } - else if ((user_options->attack_mode == ATTACK_MODE_HYBRID1) && (user_options->kernel_loops > KERNEL_COMBS)) - { - event_log_error (hashcat_ctx, "Invalid kernel-loops specified."); - - return -1; - } - else if ((user_options->attack_mode == ATTACK_MODE_HYBRID2) && (user_options->kernel_loops > KERNEL_COMBS)) + if (user_options->kernel_loops > 1024) { event_log_error (hashcat_ctx, "Invalid kernel-loops specified.");