2016-09-11 09:42:19 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2016-09-11 09:42:19 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
2016-09-14 14:07:24 +00:00
|
|
|
#include "types.h"
|
2016-10-09 20:41:55 +00:00
|
|
|
#include "event.h"
|
2016-09-14 14:07:24 +00:00
|
|
|
#include "opencl.h"
|
2016-09-30 07:25:51 +00:00
|
|
|
#include "hashes.h"
|
2016-09-11 09:42:19 +00:00
|
|
|
#include "weak_hash.h"
|
2016-09-14 14:07:24 +00:00
|
|
|
|
2016-10-15 17:47:53 +00:00
|
|
|
int weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 salt_pos)
|
2016-09-14 14:07:24 +00:00
|
|
|
{
|
2016-10-06 13:16:30 +00:00
|
|
|
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
|
|
|
hashes_t *hashes = hashcat_ctx->hashes;
|
|
|
|
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
2016-09-30 20:52:44 +00:00
|
|
|
|
2016-09-16 15:01:18 +00:00
|
|
|
salt_t *salt_buf = &hashes->salts_buf[salt_pos];
|
2016-09-14 14:07:24 +00:00
|
|
|
|
|
|
|
device_param->kernel_params_buf32[27] = salt_pos;
|
|
|
|
device_param->kernel_params_buf32[30] = 1;
|
|
|
|
device_param->kernel_params_buf32[31] = salt_buf->digests_cnt;
|
|
|
|
device_param->kernel_params_buf32[32] = salt_buf->digests_offset;
|
|
|
|
device_param->kernel_params_buf32[33] = 0;
|
|
|
|
device_param->kernel_params_buf32[34] = 1;
|
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 cmd0_rule_old = straight_ctx->kernel_rules_buf[0].cmds[0];
|
2016-09-14 14:07:24 +00:00
|
|
|
|
2016-09-27 11:13:07 +00:00
|
|
|
straight_ctx->kernel_rules_buf[0].cmds[0] = 0;
|
2016-09-14 14:07:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* run the kernel
|
|
|
|
*/
|
|
|
|
|
2016-10-15 17:47:53 +00:00
|
|
|
int CL_rc;
|
|
|
|
|
2016-09-14 14:07:24 +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-07-16 14:13:45 +00:00
|
|
|
{
|
2017-07-18 11:23:42 +00:00
|
|
|
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 1, false, 0);
|
2016-10-15 17:47:53 +00:00
|
|
|
|
2017-07-16 14:13:45 +00:00
|
|
|
if (CL_rc == -1) return -1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-18 11:23:42 +00:00
|
|
|
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_4, 1, false, 0);
|
2017-07-16 14:13:45 +00:00
|
|
|
|
|
|
|
if (CL_rc == -1) return -1;
|
|
|
|
}
|
2016-09-14 14:07:24 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-10-15 17:47:53 +00:00
|
|
|
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 1, false, 0);
|
|
|
|
|
|
|
|
if (CL_rc == -1) return -1;
|
2016-09-14 14:07:24 +00:00
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 loop_step = 16;
|
2016-09-14 14:07:24 +00:00
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
const u32 iter = salt_buf->salt_iter;
|
2016-09-14 14:07:24 +00:00
|
|
|
|
2016-10-04 04:35:49 +00:00
|
|
|
for (u32 loop_pos = 0; loop_pos < iter; loop_pos += loop_step)
|
2016-09-14 14:07:24 +00:00
|
|
|
{
|
2016-10-04 04:35:49 +00:00
|
|
|
u32 loop_left = iter - loop_pos;
|
2016-09-14 14:07:24 +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;
|
|
|
|
|
2016-10-15 17:47:53 +00:00
|
|
|
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 1, false, 0);
|
|
|
|
|
|
|
|
if (CL_rc == -1) return -1;
|
2016-09-14 14:07:24 +00:00
|
|
|
}
|
|
|
|
|
2016-10-15 17:47:53 +00:00
|
|
|
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 1, false, 0);
|
|
|
|
|
|
|
|
if (CL_rc == -1) return -1;
|
2016-09-14 14:07:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* result
|
|
|
|
*/
|
|
|
|
|
2016-09-30 20:52:44 +00:00
|
|
|
check_cracked (hashcat_ctx, device_param, salt_pos);
|
2016-09-14 14:07:24 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* cleanup
|
|
|
|
*/
|
|
|
|
|
|
|
|
device_param->kernel_params_buf32[27] = 0;
|
|
|
|
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;
|
|
|
|
device_param->kernel_params_buf32[34] = 0;
|
|
|
|
|
2016-09-27 11:13:07 +00:00
|
|
|
straight_ctx->kernel_rules_buf[0].cmds[0] = cmd0_rule_old;
|
2016-10-15 17:47:53 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-09-14 14:07:24 +00:00
|
|
|
}
|