2017-06-13 17:07:08 +00:00
|
|
|
/**
|
|
|
|
* Author......: See docs/credits.txt
|
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "types.h"
|
|
|
|
#include "event.h"
|
|
|
|
#include "bitops.h"
|
|
|
|
#include "convert.h"
|
2019-04-25 12:45:17 +00:00
|
|
|
#include "backend.h"
|
2017-06-13 17:07:08 +00:00
|
|
|
#include "thread.h"
|
|
|
|
#include "selftest.h"
|
|
|
|
|
|
|
|
static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
|
|
|
{
|
|
|
|
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
|
|
|
hashes_t *hashes = hashcat_ctx->hashes;
|
2018-12-19 09:58:06 +00:00
|
|
|
module_ctx_t *module_ctx = hashcat_ctx->module_ctx;
|
2017-06-13 17:07:08 +00:00
|
|
|
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
2018-09-01 10:31:17 +00:00
|
|
|
user_options_t *user_options = hashcat_ctx->user_options;
|
2017-06-13 17:07:08 +00:00
|
|
|
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
|
|
|
|
|
|
|
if (hashconfig->st_hash == NULL) return 0;
|
|
|
|
|
|
|
|
// init : replace hashes with selftest hash
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
|
|
|
device_param->kernel_params[15] = &device_param->cuda_d_st_digests_buf;
|
|
|
|
device_param->kernel_params[17] = &device_param->cuda_d_st_salts_buf;
|
|
|
|
device_param->kernel_params[18] = &device_param->cuda_d_st_esalts_buf;
|
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
|
|
|
device_param->kernel_params[15] = &device_param->hip_d_st_digests_buf;
|
|
|
|
device_param->kernel_params[17] = &device_param->hip_d_st_salts_buf;
|
|
|
|
device_param->kernel_params[18] = &device_param->hip_d_st_esalts_buf;
|
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
|
|
|
device_param->kernel_params[15] = &device_param->opencl_d_st_digests_buf;
|
|
|
|
device_param->kernel_params[17] = &device_param->opencl_d_st_salts_buf;
|
|
|
|
device_param->kernel_params[18] = &device_param->opencl_d_st_esalts_buf;
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
|
|
|
device_param->kernel_params_buf32[31] = 1;
|
|
|
|
device_param->kernel_params_buf32[32] = 0;
|
|
|
|
|
|
|
|
// password : move the known password into a fake buffer
|
|
|
|
|
2019-10-09 17:15:37 +00:00
|
|
|
const u32 module_opts_type = module_ctx->module_opts_type (hashconfig, user_options, user_options_extra);
|
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
pw_t tmp;
|
|
|
|
|
|
|
|
memset (&tmp, 0, sizeof (tmp));
|
|
|
|
|
|
|
|
char *tmp_ptr = (char *) &tmp.i;
|
|
|
|
|
|
|
|
const size_t tmp_len = strlen (hashconfig->st_pass);
|
|
|
|
|
2019-10-09 17:15:37 +00:00
|
|
|
if (module_opts_type & OPTS_TYPE_PT_HEX)
|
2019-10-09 08:49:58 +00:00
|
|
|
{
|
|
|
|
tmp.pw_len = hex_decode ((const u8 *) hashconfig->st_pass, (const int) tmp_len, (u8 *) tmp_ptr);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
memcpy (tmp_ptr, hashconfig->st_pass, tmp_len);
|
|
|
|
|
|
|
|
tmp.pw_len = (u32) tmp_len;
|
|
|
|
}
|
|
|
|
|
2021-07-29 12:23:24 +00:00
|
|
|
pw_t pw;
|
|
|
|
pw_t comb;
|
|
|
|
bf_t bf;
|
|
|
|
|
2017-06-13 17:07:08 +00:00
|
|
|
u32 highest_pw_len = 0;
|
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (user_options->slow_candidates == true)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
|
|
|
device_param->kernel_params_buf32[30] = 1;
|
2018-09-01 10:31:17 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
memset (&pw, 0, sizeof (pw));
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
char *pw_ptr = (char *) &pw.i;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
const size_t pw_len = tmp.pw_len;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
memcpy (pw_ptr, tmp_ptr, pw_len);
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
pw.pw_len = (u32) pw_len;
|
2018-02-18 10:10:01 +00:00
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_pws_buf, &pw, 1 * sizeof (pw_t), device_param->cuda_stream) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_pws_buf, &pw, 1 * sizeof (pw_t), device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_pws_buf, CL_FALSE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
|
|
|
|
{
|
|
|
|
device_param->kernel_params_buf32[30] = 1;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-07-10 14:41:24 +00:00
|
|
|
memset (&pw, 0, sizeof (pw));
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
char *pw_ptr = (char *) &pw.i;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
const size_t pw_len = tmp.pw_len;
|
2018-07-23 17:09:58 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
memcpy (pw_ptr, tmp_ptr, pw_len);
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
pw.pw_len = (u32) pw_len;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER)
|
|
|
|
{
|
|
|
|
uppercase ((u8 *) pw_ptr, pw.pw_len);
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_pws_buf, &pw, 1 * sizeof (pw_t), device_param->cuda_stream) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_pws_buf, &pw, 1 * sizeof (pw_t), device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_pws_buf, CL_FALSE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2018-07-23 17:09:58 +00:00
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
device_param->kernel_params_buf32[30] = 1;
|
|
|
|
device_param->kernel_params_buf32[33] = COMBINATOR_MODE_BASE_LEFT;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-07-10 14:41:24 +00:00
|
|
|
memset (&pw, 0, sizeof (pw));
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
char *pw_ptr = (char *) &pw.i;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
const size_t pw_len = tmp.pw_len;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
memcpy (pw_ptr, tmp_ptr, pw_len - 1);
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
pw.pw_len = (u32) pw_len - 1;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER)
|
|
|
|
{
|
|
|
|
uppercase ((u8 *) pw_ptr, pw.pw_len);
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-07-10 14:41:24 +00:00
|
|
|
memset (&comb, 0, sizeof (comb));
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
char *comb_ptr = (char *) &comb.i;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
memcpy (comb_ptr, tmp_ptr + pw_len - 1, 1);
|
2018-09-01 10:31:17 +00:00
|
|
|
|
|
|
|
comb.pw_len = 1;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER)
|
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
uppercase ((u8 *) comb_ptr, comb.pw_len);
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01)
|
|
|
|
{
|
|
|
|
comb_ptr[comb.pw_len] = 0x01;
|
|
|
|
}
|
|
|
|
|
2018-10-15 08:39:28 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD06)
|
|
|
|
{
|
|
|
|
comb_ptr[comb.pw_len] = 0x06;
|
|
|
|
}
|
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80)
|
|
|
|
{
|
|
|
|
comb_ptr[comb.pw_len] = 0x80;
|
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_combs_c, &comb, 1 * sizeof (pw_t), device_param->cuda_stream) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_pws_buf, &pw, 1 * sizeof (pw_t), device_param->cuda_stream) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_combs_c, &comb, 1 * sizeof (pw_t), device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_pws_buf, &pw, 1 * sizeof (pw_t), device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_combs_c, CL_FALSE, 0, 1 * sizeof (pw_t), &comb, 0, NULL, NULL) == -1) return -1;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_pws_buf, CL_FALSE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
device_param->kernel_params_buf32[30] = 1;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2020-02-22 06:59:58 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_TM_KERNEL)
|
2018-09-01 10:31:17 +00:00
|
|
|
{
|
2019-07-10 14:41:24 +00:00
|
|
|
memset (&pw, 0, sizeof (pw));
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
char *pw_ptr = (char *) &pw.i;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
const size_t pw_len = tmp.pw_len;
|
2018-09-01 10:31:17 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
memcpy (pw_ptr, tmp_ptr, pw_len);
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
uppercase ((u8 *) pw_ptr, pw_len);
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
|
|
|
|
pw.pw_len = (u32) pw_len;
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_pws_buf, &pw, 1 * sizeof (pw_t), device_param->cuda_stream) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_pws_buf, &pw, 1 * sizeof (pw_t), device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_pws_buf, CL_FALSE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
else
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2019-07-10 14:41:24 +00:00
|
|
|
memset (&bf, 0, sizeof (bf));
|
2018-09-01 10:31:17 +00:00
|
|
|
|
|
|
|
char *bf_ptr = (char *) &bf.i;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
memcpy (bf_ptr, tmp_ptr, 1);
|
2018-09-01 10:31:17 +00:00
|
|
|
|
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
memset (bf_ptr, 0, 4);
|
|
|
|
|
|
|
|
for (int i = 0, j = 0; i < 1; i += 1, j += 2)
|
|
|
|
{
|
2019-10-09 08:49:58 +00:00
|
|
|
bf_ptr[j + 0] = tmp_ptr[i];
|
2018-09-01 10:31:17 +00:00
|
|
|
bf_ptr[j + 1] = 0;
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
else if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE)
|
|
|
|
{
|
|
|
|
memset (bf_ptr, 0, 4);
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
for (int i = 0, j = 0; i < 1; i += 1, j += 2)
|
|
|
|
{
|
|
|
|
bf_ptr[j + 0] = 0;
|
2019-10-09 08:49:58 +00:00
|
|
|
bf_ptr[j + 1] = tmp_ptr[i];
|
2018-09-01 10:31:17 +00:00
|
|
|
}
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER)
|
|
|
|
{
|
|
|
|
uppercase ((u8 *) bf_ptr, 4);
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_GENERATE_BE)
|
|
|
|
{
|
|
|
|
bf.i = byte_swap_32 (bf.i);
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_bfs_c, &bf, 1 * sizeof (bf_t), device_param->cuda_stream) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_bfs_c, &bf, 1 * sizeof (bf_t), device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_bfs_c, CL_FALSE, 0, 1 * sizeof (bf_t), &bf, 0, NULL, NULL) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-07-10 14:41:24 +00:00
|
|
|
memset (&pw, 0, sizeof (pw));
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
char *pw_ptr = (char *) &pw.i;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
const size_t pw_len = tmp.pw_len;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
memcpy (pw_ptr + 1, tmp_ptr + 1, pw_len - 1);
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
size_t new_pass_len = pw_len;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
memset (pw_ptr, 0, pw_len);
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
for (size_t i = 1, j = 2; i < new_pass_len; i += 1, j += 2)
|
|
|
|
{
|
2019-10-09 08:49:58 +00:00
|
|
|
pw_ptr[j + 0] = tmp_ptr[i];
|
2018-09-01 10:31:17 +00:00
|
|
|
pw_ptr[j + 1] = 0;
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
new_pass_len *= 2;
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
else if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE)
|
|
|
|
{
|
|
|
|
memset (pw_ptr, 0, pw_len);
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
for (size_t i = 1, j = 2; i < new_pass_len; i += 1, j += 2)
|
|
|
|
{
|
|
|
|
pw_ptr[j + 0] = 0;
|
2019-10-09 08:49:58 +00:00
|
|
|
pw_ptr[j + 1] = tmp_ptr[i];
|
2018-09-01 10:31:17 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
new_pass_len *= 2;
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER)
|
|
|
|
{
|
|
|
|
uppercase ((u8 *) pw_ptr, new_pass_len);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hashconfig->opti_type & OPTI_TYPE_SINGLE_HASH)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT)
|
|
|
|
{
|
|
|
|
memcpy (pw_ptr + new_pass_len, (char *) hashes->st_salts_buf[0].salt_buf, 64 - new_pass_len);
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
new_pass_len += hashes->st_salts_buf[0].salt_len;
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
pw.pw_len = (u32) new_pass_len;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01)
|
|
|
|
{
|
|
|
|
pw_ptr[new_pass_len] = 0x01;
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-10-15 08:39:28 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD06)
|
|
|
|
{
|
|
|
|
pw_ptr[new_pass_len] = 0x06;
|
|
|
|
}
|
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80)
|
|
|
|
{
|
|
|
|
pw_ptr[new_pass_len] = 0x80;
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS14)
|
|
|
|
{
|
|
|
|
pw.i[14] = (u32) new_pass_len * 8;
|
|
|
|
pw.i[15] = 0;
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS15)
|
|
|
|
{
|
|
|
|
pw.i[14] = 0;
|
|
|
|
pw.i[15] = (u32) new_pass_len * 8;
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_PT_GENERATE_BE)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 14; i++) pw.i[i] = byte_swap_32 (pw.i[i]);
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_pws_buf, &pw, 1 * sizeof (pw_t), device_param->cuda_stream) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_pws_buf, &pw, 1 * sizeof (pw_t), device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_pws_buf, CL_FALSE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
highest_pw_len = pw.pw_len;
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
else
|
|
|
|
{
|
2019-07-10 14:41:24 +00:00
|
|
|
memset (&pw, 0, sizeof (pw));
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
char *pw_ptr = (char *) &pw.i;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
const size_t pw_len = tmp.pw_len;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-10-09 08:49:58 +00:00
|
|
|
memcpy (pw_ptr, tmp_ptr, pw_len);
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
pw.pw_len = (u32) pw_len;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_pws_buf, &pw, 1 * sizeof (pw_t), device_param->cuda_stream) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_pws_buf, &pw, 1 * sizeof (pw_t), device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_pws_buf, CL_FALSE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// main : run the kernel
|
|
|
|
|
2019-04-19 10:26:37 +00:00
|
|
|
const double spin_damp_sav = device_param->spin_damp;
|
2019-04-18 12:29:39 +00:00
|
|
|
|
|
|
|
device_param->spin_damp = 0;
|
|
|
|
|
2017-06-13 17:07:08 +00:00
|
|
|
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
|
|
|
|
{
|
2017-07-18 12:45:15 +00:00
|
|
|
if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2017-06-29 10:19:05 +00:00
|
|
|
if (highest_pw_len < 16)
|
|
|
|
{
|
2020-09-29 13:56:32 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 0, 1, false, 0) == -1) return -1;
|
2017-06-29 10:19:05 +00:00
|
|
|
}
|
|
|
|
else if (highest_pw_len < 32)
|
|
|
|
{
|
2020-09-29 13:56:32 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 0, 1, false, 0) == -1) return -1;
|
2017-06-29 10:19:05 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-09-29 13:56:32 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 0, 1, false, 0) == -1) return -1;
|
2017-06-29 10:19:05 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
2017-07-18 11:23:42 +00:00
|
|
|
else
|
|
|
|
{
|
2020-09-29 13:56:32 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_4, 0, 1, false, 0) == -1) return -1;
|
2017-07-18 11:23:42 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// missing handling hooks
|
|
|
|
|
2021-05-20 12:34:24 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_POST_AMP_UTF16LE)
|
|
|
|
{
|
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
|
|
|
if (run_cuda_kernel_utf8toutf16le (hashcat_ctx, device_param, device_param->cuda_d_pws_buf, 1) == -1) return -1;
|
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
|
|
|
if (run_hip_kernel_utf8toutf16le (hashcat_ctx, device_param, device_param->hip_d_pws_buf, 1) == -1) return -1;
|
|
|
|
}
|
|
|
|
|
2021-05-20 12:34:24 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
|
|
|
if (run_opencl_kernel_utf8toutf16le (hashcat_ctx, device_param, device_param->opencl_d_pws_buf, 1) == -1) return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-29 13:56:32 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 0, 1, false, 0) == -1) return -1;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2017-06-14 10:07:33 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_HOOK12)
|
|
|
|
{
|
2020-09-29 13:56:32 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_12, 0, 1, false, 0) == -1) return -1;
|
2017-06-14 10:07:33 +00:00
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyDtoHAsync (hashcat_ctx, device_param->hooks_buf, device_param->cuda_d_hooks, device_param->size_hooks, device_param->cuda_stream) == -1) return -1;
|
|
|
|
|
|
|
|
if (hc_cuStreamSynchronize (hashcat_ctx, device_param->cuda_stream) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyDtoHAsync (hashcat_ctx, device_param->hooks_buf, device_param->hip_d_hooks, device_param->size_hooks, device_param->hip_stream) == -1) return -1;
|
|
|
|
|
|
|
|
if (hc_hipStreamSynchronize (hashcat_ctx, device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2021-07-28 21:07:10 +00:00
|
|
|
/* blocking */
|
2019-07-10 14:41:24 +00:00
|
|
|
if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-14 10:07:33 +00:00
|
|
|
|
2020-08-29 14:12:15 +00:00
|
|
|
module_ctx->module_hook12 (device_param, module_ctx->hook_extra_params[0], hashes->st_hook_salts_buf, 0, 0);
|
2017-06-14 10:07:33 +00:00
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_hooks, device_param->hooks_buf, device_param->size_hooks, device_param->cuda_stream) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_hooks, device_param->hooks_buf, device_param->size_hooks, device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_FALSE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-14 10:07:33 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
const u32 loop_step = hashconfig->kernel_loops_min + ((hashconfig->kernel_loops_max - hashconfig->kernel_loops_min) / 32);
|
|
|
|
|
2017-06-13 17:07:08 +00:00
|
|
|
const u32 salt_pos = 0;
|
|
|
|
|
|
|
|
salt_t *salt_buf = &hashes->st_salts_buf[salt_pos];
|
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
const u32 salt_repeats = hashes->salts_buf[salt_pos].salt_repeats;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
for (u32 salt_repeat = 0; salt_repeat <= salt_repeats; salt_repeat++)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2021-06-11 16:36:19 +00:00
|
|
|
device_param->kernel_params_buf32[34] = salt_repeat;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_LOOP_PREPARE)
|
2020-02-20 15:00:21 +00:00
|
|
|
{
|
2021-06-11 16:36:19 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2P, 0, 1, false, 0) == -1) return -1;
|
2020-02-20 15:00:21 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
const u32 iter = salt_buf->salt_iter;
|
2017-06-14 10:07:33 +00:00
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
for (u32 loop_pos = 0; loop_pos < iter; loop_pos += loop_step)
|
2019-05-04 19:52:00 +00:00
|
|
|
{
|
2021-06-11 16:36:19 +00:00
|
|
|
u32 loop_left = iter - loop_pos;
|
2019-05-04 19:52:00 +00:00
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
loop_left = MIN (loop_left, loop_step);
|
2017-06-14 10:07:33 +00:00
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
device_param->kernel_params_buf32[28] = loop_pos;
|
|
|
|
device_param->kernel_params_buf32[29] = loop_left;
|
2017-06-14 10:07:33 +00:00
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 0, 1, false, 0) == -1) return -1;
|
|
|
|
|
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_LOOP_EXTENDED)
|
|
|
|
{
|
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2E, 0, 1, false, 0) == -1) return -1;
|
|
|
|
}
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_HOOK23)
|
2019-05-04 19:52:00 +00:00
|
|
|
{
|
2021-06-11 16:36:19 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_23, 0, 1, false, 0) == -1) return -1;
|
|
|
|
|
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyDtoHAsync (hashcat_ctx, device_param->hooks_buf, device_param->cuda_d_hooks, device_param->size_hooks, device_param->cuda_stream) == -1) return -1;
|
|
|
|
|
|
|
|
if (hc_cuStreamSynchronize (hashcat_ctx, device_param->cuda_stream) == -1) return -1;
|
2021-06-11 16:36:19 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyDtoHAsync (hashcat_ctx, device_param->hooks_buf, device_param->hip_d_hooks, device_param->size_hooks, device_param->hip_stream) == -1) return -1;
|
|
|
|
|
|
|
|
if (hc_hipStreamSynchronize (hashcat_ctx, device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2021-07-28 21:07:10 +00:00
|
|
|
/* blocking */
|
2021-06-11 16:36:19 +00:00
|
|
|
if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_TRUE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
module_ctx->module_hook23 (device_param, module_ctx->hook_extra_params[0], hashes->st_hook_salts_buf, 0, 0);
|
|
|
|
|
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_hooks, device_param->hooks_buf, device_param->size_hooks, device_param->cuda_stream) == -1) return -1;
|
2021-06-11 16:36:19 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_hooks, device_param->hooks_buf, device_param->size_hooks, device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_hooks, CL_FALSE, 0, device_param->size_hooks, device_param->hooks_buf, 0, NULL, NULL) == -1) return -1;
|
2021-06-11 16:36:19 +00:00
|
|
|
}
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-14 10:07:33 +00:00
|
|
|
}
|
|
|
|
|
2017-10-25 11:25:18 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_INIT2)
|
|
|
|
{
|
2020-09-29 13:56:32 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_INIT2, 0, 1, false, 0) == -1) return -1;
|
2017-10-25 11:25:18 +00:00
|
|
|
}
|
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
for (u32 salt_repeat = 0; salt_repeat <= salt_repeats; salt_repeat++)
|
2017-10-25 11:25:18 +00:00
|
|
|
{
|
2021-06-11 16:36:19 +00:00
|
|
|
device_param->kernel_params_buf32[34] = salt_repeat;
|
2017-10-25 11:25:18 +00:00
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_LOOP2_PREPARE)
|
2017-10-25 11:25:18 +00:00
|
|
|
{
|
2021-06-11 16:36:19 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_LOOP2P, 0, 1, false, 0) == -1) return -1;
|
|
|
|
}
|
2017-10-25 11:25:18 +00:00
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_LOOP2)
|
|
|
|
{
|
|
|
|
const u32 iter2 = salt_buf->salt_iter2;
|
2017-10-25 11:25:18 +00:00
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
for (u32 loop_pos = 0; loop_pos < iter2; loop_pos += loop_step)
|
|
|
|
{
|
|
|
|
u32 loop_left = iter2 - loop_pos;
|
2017-10-25 11:25:18 +00:00
|
|
|
|
2021-06-11 16:36:19 +00:00
|
|
|
loop_left = MIN (loop_left, loop_step);
|
|
|
|
|
|
|
|
device_param->kernel_params_buf32[28] = loop_pos;
|
|
|
|
device_param->kernel_params_buf32[29] = loop_left;
|
|
|
|
|
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_LOOP2, 0, 1, false, 0) == -1) return -1;
|
|
|
|
}
|
2017-10-25 11:25:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-19 09:58:06 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_DEEP_COMP_KERNEL)
|
2017-06-14 12:05:50 +00:00
|
|
|
{
|
|
|
|
device_param->kernel_params_buf32[28] = 0;
|
2018-08-31 13:47:48 +00:00
|
|
|
device_param->kernel_params_buf32[29] = 1;
|
|
|
|
|
2019-12-15 20:09:04 +00:00
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_AUX1)
|
|
|
|
{
|
2020-09-29 13:56:32 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX1, 0, 1, false, 0) == -1) return -1;
|
2019-12-15 20:09:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_AUX2)
|
|
|
|
{
|
2020-09-29 13:56:32 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX2, 0, 1, false, 0) == -1) return -1;
|
2019-12-15 20:09:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_AUX3)
|
|
|
|
{
|
2020-09-29 13:56:32 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX3, 0, 1, false, 0) == -1) return -1;
|
2019-12-15 20:09:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (hashconfig->opts_type & OPTS_TYPE_AUX4)
|
|
|
|
{
|
2020-09-29 13:56:32 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_AUX4, 0, 1, false, 0) == -1) return -1;
|
2019-12-15 20:09:04 +00:00
|
|
|
}
|
2018-02-13 08:13:35 +00:00
|
|
|
}
|
2019-12-24 16:24:27 +00:00
|
|
|
|
2020-09-29 13:56:32 +00:00
|
|
|
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 0, 1, false, 0) == -1) return -1;
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
|
|
|
|
2019-04-18 12:29:39 +00:00
|
|
|
device_param->spin_damp = spin_damp_sav;
|
|
|
|
|
2017-06-13 17:07:08 +00:00
|
|
|
// check : check if cracked
|
|
|
|
|
2019-11-26 09:55:57 +00:00
|
|
|
u32 num_cracked = 0;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2021-07-25 19:19:50 +00:00
|
|
|
cl_event opencl_event;
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_cuMemcpyDtoHAsync (hashcat_ctx, &num_cracked, device_param->cuda_d_result, sizeof (u32), device_param->cuda_stream) == -1) return -1;
|
|
|
|
|
2021-07-27 10:00:39 +00:00
|
|
|
if (hc_cuEventRecord (hashcat_ctx, device_param->cuda_event3, device_param->cuda_stream) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_hipMemcpyDtoHAsync (hashcat_ctx, &num_cracked, device_param->hip_d_result, sizeof (u32), device_param->hip_stream) == -1) return -1;
|
|
|
|
|
2021-07-27 10:00:39 +00:00
|
|
|
if (hc_hipEventRecord (hashcat_ctx, device_param->hip_event3, device_param->hip_stream) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2021-07-25 19:19:50 +00:00
|
|
|
if (hc_clEnqueueReadBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_result, CL_FALSE, 0, sizeof (u32), &num_cracked, 0, NULL, &opencl_event) == -1) return -1;
|
2021-07-29 12:23:24 +00:00
|
|
|
|
|
|
|
if (hc_clFlush (hashcat_ctx, device_param->opencl_command_queue) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
|
|
|
// finish : cleanup and restore
|
|
|
|
|
|
|
|
device_param->kernel_params_buf32[28] = 0;
|
|
|
|
device_param->kernel_params_buf32[29] = 0;
|
|
|
|
device_param->kernel_params_buf32[30] = 0;
|
|
|
|
device_param->kernel_params_buf32[31] = 0;
|
|
|
|
device_param->kernel_params_buf32[32] = 0;
|
|
|
|
device_param->kernel_params_buf32[33] = 0;
|
2021-06-11 16:36:19 +00:00
|
|
|
device_param->kernel_params_buf32[34] = 0;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
|
|
|
device_param->kernel_params[15] = &device_param->cuda_d_digests_buf;
|
|
|
|
device_param->kernel_params[17] = &device_param->cuda_d_salt_bufs;
|
|
|
|
device_param->kernel_params[18] = &device_param->cuda_d_esalt_bufs;
|
|
|
|
|
2021-07-25 19:19:50 +00:00
|
|
|
if (run_cuda_kernel_bzero (hashcat_ctx, device_param, device_param->cuda_d_pws_buf, device_param->size_pws) == -1) return -1;
|
|
|
|
if (run_cuda_kernel_bzero (hashcat_ctx, device_param, device_param->cuda_d_tmps, device_param->size_tmps) == -1) return -1;
|
|
|
|
if (run_cuda_kernel_bzero (hashcat_ctx, device_param, device_param->cuda_d_hooks, device_param->size_hooks) == -1) return -1;
|
|
|
|
if (run_cuda_kernel_bzero (hashcat_ctx, device_param, device_param->cuda_d_plain_bufs, device_param->size_plains) == -1) return -1;
|
|
|
|
if (run_cuda_kernel_bzero (hashcat_ctx, device_param, device_param->cuda_d_digests_shown, device_param->size_shown) == -1) return -1;
|
|
|
|
if (run_cuda_kernel_bzero (hashcat_ctx, device_param, device_param->cuda_d_result, device_param->size_results) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
|
|
|
device_param->kernel_params[15] = &device_param->hip_d_digests_buf;
|
|
|
|
device_param->kernel_params[17] = &device_param->hip_d_salt_bufs;
|
|
|
|
device_param->kernel_params[18] = &device_param->hip_d_esalt_bufs;
|
|
|
|
|
2021-07-25 19:19:50 +00:00
|
|
|
if (run_hip_kernel_bzero (hashcat_ctx, device_param, device_param->hip_d_pws_buf, device_param->size_pws) == -1) return -1;
|
|
|
|
if (run_hip_kernel_bzero (hashcat_ctx, device_param, device_param->hip_d_tmps, device_param->size_tmps) == -1) return -1;
|
|
|
|
if (run_hip_kernel_bzero (hashcat_ctx, device_param, device_param->hip_d_hooks, device_param->size_hooks) == -1) return -1;
|
|
|
|
if (run_hip_kernel_bzero (hashcat_ctx, device_param, device_param->hip_d_plain_bufs, device_param->size_plains) == -1) return -1;
|
|
|
|
if (run_hip_kernel_bzero (hashcat_ctx, device_param, device_param->hip_d_digests_shown, device_param->size_shown) == -1) return -1;
|
|
|
|
if (run_hip_kernel_bzero (hashcat_ctx, device_param, device_param->hip_d_result, device_param->size_results) == -1) return -1;
|
2021-07-11 10:38:59 +00:00
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
|
|
|
device_param->kernel_params[15] = &device_param->opencl_d_digests_buf;
|
|
|
|
device_param->kernel_params[17] = &device_param->opencl_d_salt_bufs;
|
|
|
|
device_param->kernel_params[18] = &device_param->opencl_d_esalt_bufs;
|
|
|
|
|
2019-07-10 14:41:24 +00:00
|
|
|
if (run_opencl_kernel_bzero (hashcat_ctx, device_param, device_param->opencl_d_pws_buf, device_param->size_pws) == -1) return -1;
|
|
|
|
if (run_opencl_kernel_bzero (hashcat_ctx, device_param, device_param->opencl_d_tmps, device_param->size_tmps) == -1) return -1;
|
|
|
|
if (run_opencl_kernel_bzero (hashcat_ctx, device_param, device_param->opencl_d_hooks, device_param->size_hooks) == -1) return -1;
|
|
|
|
if (run_opencl_kernel_bzero (hashcat_ctx, device_param, device_param->opencl_d_plain_bufs, device_param->size_plains) == -1) return -1;
|
|
|
|
if (run_opencl_kernel_bzero (hashcat_ctx, device_param, device_param->opencl_d_digests_shown, device_param->size_shown) == -1) return -1;
|
|
|
|
if (run_opencl_kernel_bzero (hashcat_ctx, device_param, device_param->opencl_d_result, device_param->size_results) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2018-09-01 10:31:17 +00:00
|
|
|
if (user_options->slow_candidates == true)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2019-07-10 14:41:24 +00:00
|
|
|
if (run_cuda_kernel_bzero (hashcat_ctx, device_param, device_param->cuda_d_rules_c, device_param->size_rules_c) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
|
|
|
if (run_hip_kernel_bzero (hashcat_ctx, device_param, device_param->hip_d_rules_c, device_param->size_rules_c) == -1) return -1;
|
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2019-07-10 14:41:24 +00:00
|
|
|
if (run_opencl_kernel_bzero (hashcat_ctx, device_param, device_param->opencl_d_rules_c, device_param->size_rules_c) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
else
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2018-09-01 10:31:17 +00:00
|
|
|
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
|
|
|
|
{
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2019-07-10 14:41:24 +00:00
|
|
|
if (run_cuda_kernel_bzero (hashcat_ctx, device_param, device_param->cuda_d_rules_c, device_param->size_rules_c) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
|
|
|
if (run_hip_kernel_bzero (hashcat_ctx, device_param, device_param->hip_d_rules_c, device_param->size_rules_c) == -1) return -1;
|
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2019-07-10 14:41:24 +00:00
|
|
|
if (run_opencl_kernel_bzero (hashcat_ctx, device_param, device_param->opencl_d_rules_c, device_param->size_rules_c) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
}
|
|
|
|
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
|
|
|
|
{
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2019-07-10 14:41:24 +00:00
|
|
|
if (run_cuda_kernel_bzero (hashcat_ctx, device_param, device_param->cuda_d_combs_c, device_param->size_combs) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
|
|
|
if (run_hip_kernel_bzero (hashcat_ctx, device_param, device_param->hip_d_combs_c, device_param->size_combs) == -1) return -1;
|
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2019-07-10 14:41:24 +00:00
|
|
|
if (run_opencl_kernel_bzero (hashcat_ctx, device_param, device_param->opencl_d_combs_c, device_param->size_combs) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
}
|
|
|
|
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
|
|
|
|
{
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2019-07-10 14:41:24 +00:00
|
|
|
if (run_cuda_kernel_bzero (hashcat_ctx, device_param, device_param->cuda_d_bfs_c, device_param->size_bfs) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
|
|
|
if (run_hip_kernel_bzero (hashcat_ctx, device_param, device_param->hip_d_bfs_c, device_param->size_bfs) == -1) return -1;
|
|
|
|
}
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
2019-07-10 14:41:24 +00:00
|
|
|
if (run_opencl_kernel_bzero (hashcat_ctx, device_param, device_param->opencl_d_bfs_c, device_param->size_bfs) == -1) return -1;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
2018-09-01 10:31:17 +00:00
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
|
|
|
|
2021-07-25 19:19:50 +00:00
|
|
|
// synchronize and ..
|
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-27 10:00:39 +00:00
|
|
|
if (hc_cuEventSynchronize (hashcat_ctx, device_param->cuda_event3) == -1) return -1;
|
2021-07-25 19:19:50 +00:00
|
|
|
}
|
2021-07-11 10:38:59 +00:00
|
|
|
|
2021-07-25 19:19:50 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-27 10:00:39 +00:00
|
|
|
if (hc_hipEventSynchronize (hashcat_ctx, device_param->hip_event3) == -1) return -1;
|
2021-07-25 19:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
|
|
|
if (hc_clWaitForEvents (hashcat_ctx, 1, &opencl_event) == -1) return -1;
|
|
|
|
|
|
|
|
if (hc_clReleaseEvent (hashcat_ctx, opencl_event) == -1) return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// check return
|
2021-07-11 10:38:59 +00:00
|
|
|
if (num_cracked == 0)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
|
|
|
hc_thread_mutex_lock (status_ctx->mux_display);
|
2019-11-26 09:55:57 +00:00
|
|
|
|
2019-07-12 18:38:12 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "* Device #%u: ATTENTION! CUDA kernel self-test failed.", device_param->device_id + 1);
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "* Device #%u: ATTENTION! HIP kernel self-test failed.", device_param->device_id + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
|
|
|
event_log_error (hashcat_ctx, "* Device #%u: ATTENTION! OpenCL kernel self-test failed.", device_param->device_id + 1);
|
|
|
|
}
|
|
|
|
|
2017-06-13 17:07:08 +00:00
|
|
|
event_log_warning (hashcat_ctx, "Your device driver installation is probably broken.");
|
|
|
|
event_log_warning (hashcat_ctx, "See also: https://hashcat.net/faq/wrongdriver");
|
|
|
|
event_log_warning (hashcat_ctx, NULL);
|
|
|
|
|
|
|
|
hc_thread_mutex_unlock (status_ctx->mux_display);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
2021-07-11 10:38:59 +00:00
|
|
|
|
2017-06-13 17:07:08 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2018-09-18 21:37:30 +00:00
|
|
|
HC_API_CALL void *thread_selftest (void *p)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
|
|
|
thread_param_t *thread_param = (thread_param_t *) p;
|
|
|
|
|
|
|
|
hashcat_ctx_t *hashcat_ctx = thread_param->hashcat_ctx;
|
|
|
|
|
2019-04-25 12:45:17 +00:00
|
|
|
backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2019-04-25 12:45:17 +00:00
|
|
|
if (backend_ctx->enabled == false) return NULL;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
2017-06-29 10:19:05 +00:00
|
|
|
user_options_t *user_options = hashcat_ctx->user_options;
|
|
|
|
|
|
|
|
if (user_options->self_test_disable == true) return NULL;
|
|
|
|
|
2019-04-25 12:45:17 +00:00
|
|
|
hc_device_param_t *device_param = backend_ctx->devices_param + thread_param->tid;
|
2017-06-13 17:07:08 +00:00
|
|
|
|
|
|
|
if (device_param->skipped == true) return NULL;
|
|
|
|
|
2019-03-04 09:29:57 +00:00
|
|
|
if (device_param->skipped_warning == true) return NULL;
|
|
|
|
|
2019-05-04 19:52:00 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-12 07:28:26 +00:00
|
|
|
if (hc_cuCtxPushCurrent (hashcat_ctx, device_param->cuda_context) == -1) return NULL;
|
2019-05-04 19:52:00 +00:00
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
|
|
|
if (hc_hipCtxPushCurrent (hashcat_ctx, device_param->hip_context) == -1) return NULL;
|
|
|
|
}
|
|
|
|
|
2017-06-13 17:07:08 +00:00
|
|
|
const int rc_selftest = selftest (hashcat_ctx, device_param);
|
|
|
|
|
2018-06-13 10:22:54 +00:00
|
|
|
if (user_options->benchmark == true)
|
2017-06-13 17:07:08 +00:00
|
|
|
{
|
2018-06-13 10:22:54 +00:00
|
|
|
device_param->st_status = ST_STATUS_IGNORED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (rc_selftest == 0)
|
|
|
|
{
|
|
|
|
device_param->st_status = ST_STATUS_PASSED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
device_param->st_status = ST_STATUS_FAILED;
|
|
|
|
}
|
2017-06-13 17:07:08 +00:00
|
|
|
}
|
|
|
|
|
2021-07-12 07:28:26 +00:00
|
|
|
if (device_param->is_cuda == true)
|
|
|
|
{
|
2021-07-22 12:18:10 +00:00
|
|
|
if (hc_cuStreamSynchronize (hashcat_ctx, device_param->cuda_stream) == -1) return NULL;
|
|
|
|
|
2021-07-12 07:28:26 +00:00
|
|
|
if (hc_cuCtxPopCurrent (hashcat_ctx, &device_param->cuda_context) == -1) return NULL;
|
|
|
|
}
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (device_param->is_hip == true)
|
|
|
|
{
|
2021-07-22 12:18:10 +00:00
|
|
|
if (hc_hipStreamSynchronize (hashcat_ctx, device_param->hip_stream) == -1) return NULL;
|
|
|
|
|
2021-07-11 10:38:59 +00:00
|
|
|
if (hc_hipCtxPopCurrent (hashcat_ctx, &device_param->hip_context) == -1) return NULL;
|
|
|
|
}
|
2021-07-22 12:18:10 +00:00
|
|
|
|
|
|
|
if (device_param->is_opencl == true)
|
|
|
|
{
|
|
|
|
if (hc_clFinish (hashcat_ctx, device_param->opencl_command_queue) == -1) return NULL;
|
|
|
|
}
|
2021-07-11 10:38:59 +00:00
|
|
|
|
2017-06-13 17:07:08 +00:00
|
|
|
return NULL;
|
|
|
|
}
|