diff --git a/include/opencl.h b/include/opencl.h index dc1c88de9..260a28797 100644 --- a/include/opencl.h +++ b/include/opencl.h @@ -57,17 +57,22 @@ int hc_clReleaseProgram (hashcat_ctx_t *hashcat_ctx, cl_program program int hc_clSetKernelArg (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value); int hc_clWaitForEvents (hashcat_ctx_t *hashcat_ctx, cl_uint num_events, const cl_event *event_list); -int gidd_to_pw_t (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 gidd, pw_t *pw); -int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 highest_pw_len, const u32 pws_cnt, const u32 fast_iteration, const u32 salt_pos); -int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kern_run, const u64 num, const u32 event_update, const u32 iteration); -int run_kernel_mp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kern_run, const u64 num); -int run_kernel_tm (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param); -int run_kernel_amp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 num); -int run_kernel_atinit (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_mem buf, const u64 num); -int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_mem buf, const u32 value, const u64 size); -int run_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_mem buf, const u64 size); -int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt); -int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt); +int gidd_to_pw_t (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 gidd, pw_t *pw); + +int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 highest_pw_len, const u32 pws_cnt, const u32 fast_iteration, const u32 salt_pos); + +void rebuild_pws_compressed_append (hc_device_param_t *device_param, const u32 pws_cnt, const u8 chr); + +int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kern_run, const u64 num, const u32 event_update, const u32 iteration); +int run_kernel_mp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kern_run, const u64 num); +int run_kernel_tm (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param); +int run_kernel_amp (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 num); +int run_kernel_atinit (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_mem buf, const u64 num); +int run_kernel_memset (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_mem buf, const u32 value, const u64 size); +int run_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, cl_mem buf, const u64 size); +int run_kernel_decompress (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 num); +int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt); +int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt); void generate_source_kernel_filename (const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *shared_dir, char *source_file); void generate_cached_kernel_filename (const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *profile_dir, const char *device_name_chksum, char *cached_file); diff --git a/src/opencl.c b/src/opencl.c index 84a6938c9..88b4757c1 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -1415,6 +1415,57 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, return 0; } +void rebuild_pws_compressed_append (hc_device_param_t *device_param, const u32 pws_cnt, const u8 chr) +{ + // this function is used if we have to modify the compressed pws buffer in order to + // append some data to each password candidate + + u32 *tmp_pws_comp = (u32 *) hcmalloc (device_param->size_pws_comp); + pw_idx_t *tmp_pws_idx = (pw_idx_t *) hcmalloc (device_param->size_pws_idx); + + for (u32 i = 0; i < pws_cnt; i++) + { + pw_idx_t *pw_idx_src = device_param->pws_idx + i; + pw_idx_t *pw_idx_dst = tmp_pws_idx + i; + + const u32 src_off = pw_idx_src->off; + const u32 src_len = pw_idx_src->len; + + u8 buf[256]; + + memcpy (buf, device_param->pws_comp + src_off, src_len); + + buf[src_len] = chr; + + const u32 dst_len = src_len + 1; + + const u32 dst_pw_len4 = (dst_len + 3) & ~3; // round up to multiple of 4 + + const u32 dst_pw_len4_cnt = dst_pw_len4 / 4; + + pw_idx_dst->cnt = dst_pw_len4_cnt; + pw_idx_dst->len = src_len; // this is intenionally! src_len can not be dst_len, we dont want the kernel to think 0x80 is part of the password + + u8 *dst = (u8 *) (tmp_pws_comp + pw_idx_dst->off); + + memcpy (dst, buf, dst_len); + + memset (dst + dst_len, 0, dst_pw_len4 - dst_len); + + // prepare next element + + pw_idx_t *pw_idx_dst_next = pw_idx_dst + 1; + + pw_idx_dst_next->off = pw_idx_dst->off + pw_idx_dst->cnt; + } + + memcpy (device_param->pws_comp, tmp_pws_comp, device_param->size_pws_comp); + memcpy (device_param->pws_idx, tmp_pws_idx, device_param->size_pws_idx); + + hcfree (tmp_pws_comp); + hcfree (tmp_pws_idx); +} + int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kern_run, const u64 num, const u32 event_update, const u32 iteration) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -1901,58 +1952,6 @@ int run_kernel_bzero (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para return run_kernel_memset (hashcat_ctx, device_param, buf, 0, size); } -void rebuild_pws_compressed_append (hc_device_param_t *device_param, const u32 pws_cnt, const u8 chr) -{ - // this function is used if we have to modify the compressed pws buffer in order to - // append some data to each password candidate - - u32 *tmp_pws_comp = (u32 *) hcmalloc (device_param->size_pws_comp); - pw_idx_t *tmp_pws_idx = (pw_idx_t *) hcmalloc (device_param->size_pws_idx); - - for (u32 i = 0; i < pws_cnt; i++) - { - pw_idx_t *pw_idx_src = device_param->pws_idx + i; - pw_idx_t *pw_idx_dst = tmp_pws_idx + i; - - const u32 src_off = pw_idx_src->off; - const u32 src_cnt = pw_idx_src->cnt; - const u32 src_len = pw_idx_src->len; - - u8 buf[256]; - - memcpy (buf, device_param->pws_comp + src_off, src_len); - - buf[src_len] = chr; - - const u32 dst_len = src_len + 1; - - const u32 dst_pw_len4 = (dst_len + 3) & ~3; // round up to multiple of 4 - - const u32 dst_pw_len4_cnt = dst_pw_len4 / 4; - - pw_idx_dst->cnt = dst_pw_len4_cnt; - pw_idx_dst->len = src_len; // this is intenionally! src_len can not be dst_len, we dont want the kernel to think 0x80 is part of the password - - u8 *dst = (u8 *) (tmp_pws_comp + pw_idx_dst->off); - - memcpy (dst, buf, dst_len); - - memset (dst + dst_len, 0, dst_pw_len4 - dst_len); - - // prepare next element - - pw_idx_t *pw_idx_dst_next = pw_idx_dst + 1; - - pw_idx_dst_next->off = pw_idx_dst->off + pw_idx_dst->cnt; - } - - memcpy (device_param->pws_comp, tmp_pws_comp, device_param->size_pws_comp); - memcpy (device_param->pws_idx, tmp_pws_idx, device_param->size_pws_idx); - - hcfree (tmp_pws_comp); - hcfree (tmp_pws_idx); -} - int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt) { combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; @@ -3713,10 +3712,7 @@ static bool is_same_device_type (const hc_device_param_t *src, const hc_device_p void opencl_ctx_devices_sync_tuning (hashcat_ctx_t *hashcat_ctx) { - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; - user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - user_options_t *user_options = hashcat_ctx->user_options; + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; if (opencl_ctx->enabled == false) return;