mirror of
https://github.com/hashcat/hashcat.git
synced 2025-07-02 21:02:38 +00:00
- Add code to recognize Microsofts OpenCL D3D12 platform
- Skip memory-free detection on MS OpenCL platform to avoid crashes - Improve salt usage of 70100/70200, use decoder/kernels from 8900 - Add REPLACE bridge type support (eg. BRIDGE_TYPE_REPLACE_LOOP) - Switch 70000, 70100 and 70200 to BRIDGE_TYPE_REPLACE_LOOP - Add synchronization barriers on d2h copy when using bridges - Improve speed status display updates when using bridges - Set AMD_DIRECT_DISPATCH=0 to reduce CPU burning loop on AMD backends - Set benchmark/selftest hash on 70100/70200 to 16:8:1
This commit is contained in:
parent
1a49b6c81e
commit
b02b1b5033
@ -26,21 +26,7 @@ typedef struct
|
||||
|
||||
} scrypt_tmp_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 salt_buf[64];
|
||||
u32 salt_len;
|
||||
|
||||
u32 digest_buf[64];
|
||||
u32 digest_len;
|
||||
|
||||
u32 N;
|
||||
u32 r;
|
||||
u32 p;
|
||||
|
||||
} scrypt_t;
|
||||
|
||||
KERNEL_FQ void m70100_init (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, scrypt_t))
|
||||
KERNEL_FQ void m70100_init (KERN_ATTR_TMPS (scrypt_tmp_t))
|
||||
{
|
||||
/**
|
||||
* base
|
||||
@ -54,10 +40,10 @@ KERNEL_FQ void m70100_init (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, scrypt_t))
|
||||
|
||||
sha256_hmac_init_global_swap (&sha256_hmac_ctx, pws[gid].i, pws[gid].pw_len);
|
||||
|
||||
sha256_hmac_update_global_swap (&sha256_hmac_ctx, esalt_bufs[DIGESTS_OFFSET_HOST].salt_buf, esalt_bufs[DIGESTS_OFFSET_HOST].salt_len);
|
||||
sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len);
|
||||
|
||||
u32 r = esalt_bufs[DIGESTS_OFFSET_HOST].r;
|
||||
u32 p = esalt_bufs[DIGESTS_OFFSET_HOST].p;
|
||||
u32 r = salt_bufs[SALT_POS_HOST].scrypt_r;
|
||||
u32 p = salt_bufs[SALT_POS_HOST].scrypt_p;
|
||||
|
||||
u32 chunk_bytes = 64 * r * 2;
|
||||
|
||||
@ -115,11 +101,11 @@ KERNEL_FQ void m70100_init (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, scrypt_t))
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void m70100_loop (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, scrypt_t))
|
||||
KERNEL_FQ void m70100_loop (KERN_ATTR_TMPS (scrypt_tmp_t))
|
||||
{
|
||||
}
|
||||
|
||||
KERNEL_FQ void m70100_comp (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, scrypt_t))
|
||||
KERNEL_FQ void m70100_comp (KERN_ATTR_TMPS (scrypt_tmp_t))
|
||||
{
|
||||
/**
|
||||
* base
|
||||
@ -143,8 +129,8 @@ KERNEL_FQ void m70100_comp (KERN_ATTR_TMPS_ESALT (scrypt_tmp_t, scrypt_t))
|
||||
|
||||
sha256_hmac_init_global_swap (&ctx, pws[gid].i, pws[gid].pw_len);
|
||||
|
||||
u32 r = esalt_bufs[DIGESTS_OFFSET_HOST].r;
|
||||
u32 p = esalt_bufs[DIGESTS_OFFSET_HOST].p;
|
||||
u32 r = salt_bufs[SALT_POS_HOST].scrypt_r;
|
||||
u32 p = salt_bufs[SALT_POS_HOST].scrypt_p;
|
||||
|
||||
u32 chunk_bytes = 64 * r * 2;
|
||||
|
||||
|
@ -22,6 +22,7 @@ static const char CL_VENDOR_INTEL_SDK[] = "Intel(R) Corporation";
|
||||
static const char CL_VENDOR_MESA[] = "Mesa";
|
||||
static const char CL_VENDOR_NV[] = "NVIDIA Corporation";
|
||||
static const char CL_VENDOR_POCL[] = "The pocl project";
|
||||
static const char CL_VENDOR_MICROSOFT[] = "Microsoft";
|
||||
|
||||
int backend_ctx_init (hashcat_ctx_t *hashcat_ctx);
|
||||
void backend_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
|
@ -187,6 +187,7 @@ typedef enum vendor_id
|
||||
VENDOR_ID_POCL = (1U << 6),
|
||||
VENDOR_ID_AMD_USE_INTEL = (1U << 7),
|
||||
VENDOR_ID_AMD_USE_HIP = (1U << 8),
|
||||
VENDOR_ID_MICROSOFT = (1U << 9),
|
||||
VENDOR_ID_GENERIC = (1U << 31)
|
||||
|
||||
} vendor_id_t;
|
||||
@ -442,40 +443,43 @@ typedef enum opts_type
|
||||
OPTS_TYPE_MT_HEX = (1ULL << 27), // mask is always in hex
|
||||
OPTS_TYPE_HASH_COPY = (1ULL << 28),
|
||||
OPTS_TYPE_HASH_SPLIT = (1ULL << 29),
|
||||
OPTS_TYPE_LOOP_PREPARE = (1ULL << 30), // a kernel which is called each time before _loop kernel started.
|
||||
OPTS_TYPE_INIT = (1ULL << 30), // Added v7, since bridge can fully replace these, but are set by default automatically
|
||||
OPTS_TYPE_LOOP = (1ULL << 31), // Added v7, since bridge can fully replace these, but are set by default automatically
|
||||
OPTS_TYPE_COMP = (1ULL << 32), // Added v7, since bridge can fully replace these, but are set by default automatically
|
||||
OPTS_TYPE_LOOP_PREPARE = (1ULL << 33), // a kernel which is called each time before _loop kernel started.
|
||||
// like a hook12 kernel but without extra buffers.
|
||||
OPTS_TYPE_LOOP_EXTENDED = (1ULL << 31), // a kernel which is called each time normal _loop kernel finished.
|
||||
OPTS_TYPE_LOOP_EXTENDED = (1ULL << 34), // a kernel which is called each time normal _loop kernel finished.
|
||||
// but unlike a hook kernel this kernel is called for every _loop iteration offset
|
||||
OPTS_TYPE_HOOK12 = (1ULL << 32),
|
||||
OPTS_TYPE_HOOK23 = (1ULL << 33),
|
||||
OPTS_TYPE_INIT2 = (1ULL << 34),
|
||||
OPTS_TYPE_LOOP2_PREPARE = (1ULL << 35), // same as OPTS_TYPE_LOOP_PREPARE but for loop2 kernel
|
||||
OPTS_TYPE_LOOP2 = (1ULL << 36),
|
||||
OPTS_TYPE_AUX1 = (1ULL << 37),
|
||||
OPTS_TYPE_AUX2 = (1ULL << 38),
|
||||
OPTS_TYPE_AUX3 = (1ULL << 39),
|
||||
OPTS_TYPE_AUX4 = (1ULL << 40),
|
||||
OPTS_TYPE_BINARY_HASHFILE = (1ULL << 41),
|
||||
OPTS_TYPE_HOOK12 = (1ULL << 35),
|
||||
OPTS_TYPE_HOOK23 = (1ULL << 36),
|
||||
OPTS_TYPE_INIT2 = (1ULL << 37),
|
||||
OPTS_TYPE_LOOP2_PREPARE = (1ULL << 38), // same as OPTS_TYPE_LOOP_PREPARE but for loop2 kernel
|
||||
OPTS_TYPE_LOOP2 = (1ULL << 39),
|
||||
OPTS_TYPE_AUX1 = (1ULL << 40),
|
||||
OPTS_TYPE_AUX2 = (1ULL << 41),
|
||||
OPTS_TYPE_AUX3 = (1ULL << 42),
|
||||
OPTS_TYPE_AUX4 = (1ULL << 43),
|
||||
OPTS_TYPE_BINARY_HASHFILE = (1ULL << 44),
|
||||
OPTS_TYPE_BINARY_HASHFILE_OPTIONAL
|
||||
= (1ULL << 42), // this allows us to not enforce the use of a binary file. requires OPTS_TYPE_BINARY_HASHFILE set to be effective.
|
||||
OPTS_TYPE_PT_ADD06 = (1ULL << 43),
|
||||
OPTS_TYPE_KEYBOARD_MAPPING = (1ULL << 44),
|
||||
OPTS_TYPE_DEEP_COMP_KERNEL = (1ULL << 45), // if we have to iterate through each hash inside the comp kernel, for example if each hash has to be decrypted separately
|
||||
OPTS_TYPE_TM_KERNEL = (1ULL << 46),
|
||||
OPTS_TYPE_SUGGEST_KG = (1ULL << 47), // suggest keep guessing for modules the user maybe wants to use --keep-guessing
|
||||
OPTS_TYPE_COPY_TMPS = (1ULL << 48), // if we want to use data from tmps buffer (for example get the PMK in WPA)
|
||||
OPTS_TYPE_POTFILE_NOPASS = (1ULL << 49), // sometimes the password should not be printed to potfile
|
||||
OPTS_TYPE_DYNAMIC_SHARED = (1ULL << 50), // use dynamic shared memory (note: needs special kernel changes)
|
||||
OPTS_TYPE_SELF_TEST_DISABLE = (1ULL << 51), // some algos use JiT in combinations with a salt or create too much startup time
|
||||
OPTS_TYPE_MP_MULTI_DISABLE = (1ULL << 52), // do not multiply the kernel-accel with the multiprocessor count per device to allow more fine-tuned workload settings
|
||||
OPTS_TYPE_NATIVE_THREADS = (1ULL << 53), // forces "native" thread count: CPU=1, GPU-Intel=8, GPU-AMD=64 (wavefront), GPU-NV=32 (warps)
|
||||
OPTS_TYPE_MAXIMUM_THREADS = (1ULL << 54), // disable else branch in pre-compilation thread count optimization setting
|
||||
OPTS_TYPE_POST_AMP_UTF16LE = (1ULL << 55), // run the utf8 to utf16le conversion kernel after they have been processed from amplifiers
|
||||
= (1ULL << 45), // this allows us to not enforce the use of a binary file. requires OPTS_TYPE_BINARY_HASHFILE set to be effective.
|
||||
OPTS_TYPE_PT_ADD06 = (1ULL << 46),
|
||||
OPTS_TYPE_KEYBOARD_MAPPING = (1ULL << 47),
|
||||
OPTS_TYPE_DEEP_COMP_KERNEL = (1ULL << 48), // if we have to iterate through each hash inside the comp kernel, for example if each hash has to be decrypted separately
|
||||
OPTS_TYPE_TM_KERNEL = (1ULL << 49),
|
||||
OPTS_TYPE_SUGGEST_KG = (1ULL << 50), // suggest keep guessing for modules the user maybe wants to use --keep-guessing
|
||||
OPTS_TYPE_COPY_TMPS = (1ULL << 51), // if we want to use data from tmps buffer (for example get the PMK in WPA)
|
||||
OPTS_TYPE_POTFILE_NOPASS = (1ULL << 52), // sometimes the password should not be printed to potfile
|
||||
OPTS_TYPE_DYNAMIC_SHARED = (1ULL << 53), // use dynamic shared memory (note: needs special kernel changes)
|
||||
OPTS_TYPE_SELF_TEST_DISABLE = (1ULL << 54), // some algos use JiT in combinations with a salt or create too much startup time
|
||||
OPTS_TYPE_MP_MULTI_DISABLE = (1ULL << 55), // do not multiply the kernel-accel with the multiprocessor count per device to allow more fine-tuned workload settings
|
||||
OPTS_TYPE_NATIVE_THREADS = (1ULL << 56), // forces "native" thread count: CPU=1, GPU-Intel=8, GPU-AMD=64 (wavefront), GPU-NV=32 (warps)
|
||||
OPTS_TYPE_MAXIMUM_THREADS = (1ULL << 57), // disable else branch in pre-compilation thread count optimization setting
|
||||
OPTS_TYPE_POST_AMP_UTF16LE = (1ULL << 58), // run the utf8 to utf16le conversion kernel after they have been processed from amplifiers
|
||||
OPTS_TYPE_AUTODETECT_DISABLE
|
||||
= (1ULL << 56), // skip autodetect engine
|
||||
OPTS_TYPE_STOCK_MODULE = (1ULL << 57), // module included with hashcat default distribution
|
||||
= (1ULL << 59), // skip autodetect engine
|
||||
OPTS_TYPE_STOCK_MODULE = (1ULL << 60), // module included with hashcat default distribution
|
||||
OPTS_TYPE_MULTIHASH_DESPITE_ESALT
|
||||
= (1ULL << 58), // overrule multihash cracking check same salt but not same esalt
|
||||
= (1ULL << 61), // overrule multihash cracking check same salt but not same esalt
|
||||
|
||||
} opts_type_t;
|
||||
|
||||
@ -485,18 +489,29 @@ typedef enum bridge_type
|
||||
BRIDGE_TYPE_MATCH_TUNINGS = (1ULL << 1), // Disables autotune and adjusts -n, -u and -T for the backend device according to match bridge dimensions
|
||||
BRIDGE_TYPE_UPDATE_SELFTEST = (1ULL << 2), // updates the selftest configured in the module. Can be useful for generic hash modes such as the python one
|
||||
|
||||
BRIDGE_TYPE_LAUNCH_INIT = (1ULL << 10), // attention! not yet implemented
|
||||
BRIDGE_TYPE_LAUNCH_LOOP = (1ULL << 11),
|
||||
BRIDGE_TYPE_LAUNCH_LOOP2 = (1ULL << 12),
|
||||
BRIDGE_TYPE_LAUNCH_COMP = (1ULL << 13), // attention! not yet implemented
|
||||
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_001 = (1ULL << 20), // This override the workitem counts reported from the bridge device
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_002 = (1ULL << 21), // Can be useful if this is not a physical hardware
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_004 = (1ULL << 22),
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_008 = (1ULL << 23),
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_016 = (1ULL << 24),
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_032 = (1ULL << 25),
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_064 = (1ULL << 26),
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_128 = (1ULL << 27),
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_256 = (1ULL << 26),
|
||||
// BRIDGE_TYPE_REPLACE_* is like
|
||||
// BRIDGE_TYPE_LAUNCH_*, but
|
||||
// deactivates KERN_RUN INIT/LOOP/COMP
|
||||
|
||||
BRIDGE_TYPE_REPLACE_INIT = (1ULL << 20), // attention! not yet implemented
|
||||
BRIDGE_TYPE_REPLACE_LOOP = (1ULL << 21),
|
||||
BRIDGE_TYPE_REPLACE_LOOP2 = (1ULL << 22),
|
||||
BRIDGE_TYPE_REPLACE_COMP = (1ULL << 23), // attention! not yet implemented
|
||||
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_001 = (1ULL << 30), // This override the workitem counts reported from the bridge device
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_002 = (1ULL << 31), // Can be useful if this is not a physical hardware
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_004 = (1ULL << 32),
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_008 = (1ULL << 33),
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_016 = (1ULL << 34),
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_032 = (1ULL << 35),
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_064 = (1ULL << 36),
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_128 = (1ULL << 37),
|
||||
BRIDGE_TYPE_FORCE_WORKITEMS_256 = (1ULL << 36),
|
||||
|
||||
} bridge_type_t;
|
||||
|
||||
|
@ -1156,7 +1156,10 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
}
|
||||
}
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_INIT)
|
||||
{
|
||||
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_1, pws_pos, pws_cnt, false, 0) == -1) return -1;
|
||||
}
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_HOOK12)
|
||||
{
|
||||
@ -1273,7 +1276,10 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
device_param->kernel_param.loop_pos = loop_pos;
|
||||
device_param->kernel_param.loop_cnt = loop_left;
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_LOOP)
|
||||
{
|
||||
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_2, pws_pos, pws_cnt, true, slow_iteration) == -1) return -1;
|
||||
}
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_LOOP_EXTENDED)
|
||||
{
|
||||
@ -1352,11 +1358,15 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
if (device_param->is_cuda == true)
|
||||
{
|
||||
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_tmps, device_param->h_tmps, pws_cnt * hashconfig->tmp_size, device_param->cuda_stream) == -1) return -1;
|
||||
|
||||
if (hc_cuStreamSynchronize (hashcat_ctx, device_param->cuda_stream) == -1) return -1;
|
||||
}
|
||||
|
||||
if (device_param->is_hip == true)
|
||||
{
|
||||
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_tmps, device_param->h_tmps, pws_cnt * hashconfig->tmp_size, device_param->hip_stream) == -1) return -1;
|
||||
|
||||
if (hc_hipStreamSynchronize (hashcat_ctx, device_param->hip_stream) == -1) return -1;
|
||||
}
|
||||
|
||||
#if defined (__APPLE__)
|
||||
@ -1368,8 +1378,39 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
|
||||
if (device_param->is_opencl == true)
|
||||
{
|
||||
/* blocking */
|
||||
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_tmps, CL_TRUE, 0, pws_cnt * hashconfig->tmp_size, device_param->h_tmps, 0, NULL, NULL) == -1) return -1;
|
||||
}
|
||||
|
||||
//bug?
|
||||
//while (status_ctx->run_thread_level2 == false) break;
|
||||
if (status_ctx->run_thread_level2 == false) break;
|
||||
|
||||
/**
|
||||
* speed
|
||||
*/
|
||||
|
||||
const u64 perf_sum_all = (u64) (pws_cnt);
|
||||
|
||||
double speed_msec = hc_timer_get (device_param->timer_speed);
|
||||
|
||||
const u32 speed_pos = device_param->speed_pos;
|
||||
|
||||
device_param->speed_cnt[speed_pos] = perf_sum_all;
|
||||
|
||||
device_param->speed_msec[speed_pos] = speed_msec;
|
||||
|
||||
if (user_options->speed_only == true)
|
||||
{
|
||||
if (speed_msec > 4000)
|
||||
{
|
||||
device_param->speed_pos = 1;
|
||||
|
||||
device_param->speed_only_finish = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_HOOK23)
|
||||
@ -1557,11 +1598,15 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
if (device_param->is_cuda == true)
|
||||
{
|
||||
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_tmps, device_param->h_tmps, pws_cnt * hashconfig->tmp_size, device_param->cuda_stream) == -1) return -1;
|
||||
|
||||
if (hc_cuStreamSynchronize (hashcat_ctx, device_param->cuda_stream) == -1) return -1;
|
||||
}
|
||||
|
||||
if (device_param->is_hip == true)
|
||||
{
|
||||
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_tmps, device_param->h_tmps, pws_cnt * hashconfig->tmp_size, device_param->hip_stream) == -1) return -1;
|
||||
|
||||
if (hc_hipStreamSynchronize (hashcat_ctx, device_param->hip_stream) == -1) return -1;
|
||||
}
|
||||
|
||||
#if defined (__APPLE__)
|
||||
@ -1573,6 +1618,7 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
|
||||
if (device_param->is_opencl == true)
|
||||
{
|
||||
/* blocking */
|
||||
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_tmps, CL_TRUE, 0, pws_cnt * hashconfig->tmp_size, device_param->h_tmps, 0, NULL, NULL) == -1) return -1;
|
||||
}
|
||||
}
|
||||
@ -1635,8 +1681,11 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
}
|
||||
|
||||
if (aux_cnt == 0)
|
||||
{
|
||||
if (hashconfig->opts_type & OPTS_TYPE_COMP)
|
||||
{
|
||||
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_3, pws_pos, pws_cnt, false, 0) == -1) return -1;
|
||||
}
|
||||
|
||||
if (status_ctx->run_thread_level2 == false) break;
|
||||
}
|
||||
@ -1660,10 +1709,13 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hashconfig->opts_type & OPTS_TYPE_COMP)
|
||||
{
|
||||
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_3, pws_pos, pws_cnt, false, 0) == -1) return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* maybe we should add this zero of temporary buffers
|
||||
@ -4928,6 +4980,10 @@ int backend_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
opencl_platform_vendor_id = VENDOR_ID_POCL;
|
||||
}
|
||||
else if (strcmp (opencl_platform_vendor, CL_VENDOR_MICROSOFT) == 0)
|
||||
{
|
||||
opencl_platform_vendor_id = VENDOR_ID_MICROSOFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
opencl_platform_vendor_id = VENDOR_ID_GENERIC;
|
||||
@ -6714,6 +6770,10 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
|
||||
{
|
||||
opencl_device_vendor_id = VENDOR_ID_POCL;
|
||||
}
|
||||
else if (strcmp (opencl_device_vendor, CL_VENDOR_MICROSOFT) == 0)
|
||||
{
|
||||
opencl_device_vendor_id = VENDOR_ID_MICROSOFT;
|
||||
}
|
||||
else
|
||||
{
|
||||
opencl_device_vendor_id = VENDOR_ID_GENERIC;
|
||||
@ -8281,7 +8341,7 @@ int backend_ctx_devices_init (hashcat_ctx_t *hashcat_ctx, const int comptime)
|
||||
|
||||
device_param->device_available_mem = device_param->device_global_mem - MAX_ALLOC_CHECKS_SIZE;
|
||||
|
||||
if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) && ((device_param->opencl_platform_vendor_id != VENDOR_ID_INTEL_SDK) || (device_param->device_host_unified_memory == 0)))
|
||||
if ((device_param->opencl_device_type & CL_DEVICE_TYPE_GPU) && (device_param->opencl_platform_vendor_id != VENDOR_ID_MICROSOFT) && ((device_param->opencl_platform_vendor_id != VENDOR_ID_INTEL_SDK) || (device_param->device_host_unified_memory == 0)))
|
||||
{
|
||||
// OK, so the problem here is the following:
|
||||
// There's just CL_DEVICE_GLOBAL_MEM_SIZE to ask OpenCL about the total memory on the device,
|
||||
|
@ -181,6 +181,8 @@ bool bridges_init (hashcat_ctx_t *hashcat_ctx)
|
||||
CHECK_MANDATORY (bridge_ctx->get_unit_info);
|
||||
CHECK_MANDATORY (bridge_ctx->get_workitem_count);
|
||||
|
||||
if (hashconfig->bridge_type & BRIDGE_TYPE_REPLACE_LOOP) CHECK_MANDATORY (bridge_ctx->launch_loop);
|
||||
if (hashconfig->bridge_type & BRIDGE_TYPE_REPLACE_LOOP2) CHECK_MANDATORY (bridge_ctx->launch_loop2);
|
||||
if (hashconfig->bridge_type & BRIDGE_TYPE_LAUNCH_LOOP) CHECK_MANDATORY (bridge_ctx->launch_loop);
|
||||
if (hashconfig->bridge_type & BRIDGE_TYPE_LAUNCH_LOOP2) CHECK_MANDATORY (bridge_ctx->launch_loop2);
|
||||
|
||||
|
@ -32,20 +32,6 @@ typedef struct
|
||||
|
||||
} scrypt_tmp_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 salt_buf[64];
|
||||
u32 salt_len;
|
||||
|
||||
u32 digest_buf[64];
|
||||
u32 digest_len;
|
||||
|
||||
u32 N;
|
||||
u32 r;
|
||||
u32 p;
|
||||
|
||||
} scrypt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *V;
|
||||
@ -177,24 +163,24 @@ bool salt_prepare (void *platform_context, MAYBE_UNUSED hashconfig_t *hashconfig
|
||||
{
|
||||
// selftest hash
|
||||
|
||||
scrypt_t *scrypt_st = (scrypt_t *) hashes->st_esalts_buf;
|
||||
salt_t *scrypt_st = (salt_t *) hashes->st_salts_buf;
|
||||
|
||||
const size_t chunk_bytes = 64 * 2 * scrypt_st->r;
|
||||
const size_t chunk_bytes = 64 * 2 * scrypt_st->scrypt_r;
|
||||
|
||||
size_t largest_V = chunk_bytes * scrypt_st->N;
|
||||
//size_t largest_X = chunk_bytes * scrypt_st->p;
|
||||
size_t largest_V = chunk_bytes * scrypt_st->scrypt_N;
|
||||
//size_t largest_X = chunk_bytes * scrypt_st->scrypt_p;
|
||||
size_t largest_Y = chunk_bytes;
|
||||
|
||||
// from here regular hashes
|
||||
|
||||
scrypt_t *scrypt = (scrypt_t *) hashes->esalts_buf;
|
||||
salt_t *scrypt = (salt_t *) hashes->salts_buf;
|
||||
|
||||
for (u32 salt_idx = 0; salt_idx < hashes->salts_cnt; salt_idx++, scrypt++)
|
||||
{
|
||||
const size_t chunk_bytes = 64 * 2 * scrypt->r;
|
||||
const size_t chunk_bytes = 64 * 2 * scrypt->scrypt_r;
|
||||
|
||||
const size_t sz_V = chunk_bytes * scrypt->N;
|
||||
//const size_t sz_X = chunk_bytes * scrypt->p;
|
||||
const size_t sz_V = chunk_bytes * scrypt->scrypt_N;
|
||||
//const size_t sz_X = chunk_bytes * scrypt->scrypt_p;
|
||||
const size_t sz_Y = chunk_bytes;
|
||||
|
||||
if (sz_V > largest_V) largest_V = sz_V;
|
||||
@ -238,9 +224,9 @@ bool launch_loop (MAYBE_UNUSED void *platform_context, MAYBE_UNUSED hc_device_pa
|
||||
|
||||
unit_t *unit_buf = &bridge_scrypt_jane->units_buf[unit_idx];
|
||||
|
||||
scrypt_t *esalts_buf = (scrypt_t *) hashes->esalts_buf;
|
||||
salt_t *salts_buf = (salt_t *) hashes->salts_buf;
|
||||
|
||||
scrypt_t *esalt_buf = &esalts_buf[salt_pos];
|
||||
salt_t *salt_buf = &salts_buf[salt_pos];
|
||||
|
||||
scrypt_tmp_t *scrypt_tmp = (scrypt_tmp_t *) device_param->h_tmps;
|
||||
|
||||
@ -248,9 +234,9 @@ bool launch_loop (MAYBE_UNUSED void *platform_context, MAYBE_UNUSED hc_device_pa
|
||||
//scrypt_mix_word_t *X = unit_buf->X;
|
||||
scrypt_mix_word_t *Y = unit_buf->Y;
|
||||
|
||||
const u32 N = esalt_buf->N;
|
||||
const u32 r = esalt_buf->r;
|
||||
const u32 p = esalt_buf->p;
|
||||
const u32 N = salt_buf->scrypt_N;
|
||||
const u32 r = salt_buf->scrypt_r;
|
||||
const u32 p = salt_buf->scrypt_p;
|
||||
|
||||
const size_t chunk_bytes = 64 * 2 * r;
|
||||
|
||||
|
@ -35,20 +35,6 @@ typedef struct
|
||||
|
||||
} scrypt_tmp_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 salt_buf[64];
|
||||
u32 salt_len;
|
||||
|
||||
u32 digest_buf[64];
|
||||
u32 digest_len;
|
||||
|
||||
u32 N;
|
||||
u32 r;
|
||||
u32 p;
|
||||
|
||||
} scrypt_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *V;
|
||||
@ -179,19 +165,19 @@ bool salt_prepare (void *platform_context, MAYBE_UNUSED hashconfig_t *hashconfig
|
||||
{
|
||||
// selftest hash
|
||||
|
||||
scrypt_t *scrypt_st = (scrypt_t *) hashes->st_esalts_buf;
|
||||
salt_t *scrypt_st = (salt_t *) hashes->st_salts_buf;
|
||||
|
||||
size_t largest_V = 128 * scrypt_st->r * scrypt_st->N; // yescrypt: the temporary storage V must be 128rN bytes in length
|
||||
size_t largest_XY = 256 * scrypt_st->r * scrypt_st->p; // yescrypt: the temporary storage XY must be 256r or 256rp bytes in length
|
||||
size_t largest_V = 128 * scrypt_st->scrypt_r * scrypt_st->scrypt_N; // yescrypt: the temporary storage V must be 128rN bytes in length
|
||||
size_t largest_XY = 256 * scrypt_st->scrypt_r * scrypt_st->scrypt_p; // yescrypt: the temporary storage XY must be 256r or 256rp bytes in length
|
||||
|
||||
// from here regular hashes
|
||||
|
||||
scrypt_t *scrypt = (scrypt_t *) hashes->esalts_buf;
|
||||
salt_t *scrypt = (salt_t *) hashes->salts_buf;
|
||||
|
||||
for (u32 salt_idx = 0; salt_idx < hashes->salts_cnt; salt_idx++, scrypt++)
|
||||
{
|
||||
const size_t sz_V = 128 * scrypt->r * scrypt->N; // yescrypt: the temporary storage V must be 128rN bytes in length
|
||||
const size_t sz_XY = 256 * scrypt->r * scrypt->p; // yescrypt: the temporary storage XY must be 256r or 256rp bytes in length
|
||||
const size_t sz_V = 128 * scrypt->scrypt_r * scrypt->scrypt_N; // yescrypt: the temporary storage V must be 128rN bytes in length
|
||||
const size_t sz_XY = 256 * scrypt->scrypt_r * scrypt->scrypt_p; // yescrypt: the temporary storage XY must be 256r or 256rp bytes in length
|
||||
|
||||
if (sz_V > largest_V) largest_V = sz_V;
|
||||
if (sz_XY > largest_XY) largest_XY = sz_XY;
|
||||
@ -231,9 +217,9 @@ bool launch_loop (MAYBE_UNUSED void *platform_context, MAYBE_UNUSED hc_device_pa
|
||||
|
||||
unit_t *unit_buf = &bridge_scrypt_yescrypt->units_buf[unit_idx];
|
||||
|
||||
scrypt_t *esalts_buf = (scrypt_t *) hashes->esalts_buf;
|
||||
salt_t *salts_buf = (salt_t *) hashes->salts_buf;
|
||||
|
||||
scrypt_t *esalt_buf = &esalts_buf[salt_pos];
|
||||
salt_t *salt_buf = &salts_buf[salt_pos];
|
||||
|
||||
// hashcat guarantees h_tmps[] is 64 byte aligned, so is *B
|
||||
|
||||
@ -248,14 +234,14 @@ bool launch_loop (MAYBE_UNUSED void *platform_context, MAYBE_UNUSED hc_device_pa
|
||||
// With that in mind, we can optimize by using a constant p=1,
|
||||
// allowing the compiler to eliminate branches in smix().
|
||||
|
||||
for (u32 i = 0; i < esalt_buf->p; i++)
|
||||
for (u32 i = 0; i < salt_buf->scrypt_p; i++)
|
||||
{
|
||||
// Same here: using constants allows the compiler to optimize away branches in smix(),
|
||||
// so there's no need to call smix1()/smix2() directly and unnecessarily complicate the code.
|
||||
|
||||
smix (B, esalt_buf->r, esalt_buf->N, 1, 0, 0, unit_buf->V, 0, NULL, unit_buf->XY, NULL, NULL);
|
||||
smix (B, salt_buf->scrypt_r, salt_buf->scrypt_N, 1, 0, 0, unit_buf->V, 0, NULL, unit_buf->XY, NULL, NULL);
|
||||
|
||||
B += 128 * esalt_buf->r;
|
||||
B += 128 * salt_buf->scrypt_r;
|
||||
}
|
||||
|
||||
scrypt_tmp++;
|
||||
|
@ -336,6 +336,11 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx)
|
||||
}
|
||||
}
|
||||
|
||||
if (hashconfig->attack_exec == ATTACK_EXEC_OUTSIDE_KERNEL)
|
||||
{
|
||||
hashconfig->opts_type |= OPTS_TYPE_INIT | OPTS_TYPE_LOOP | OPTS_TYPE_COMP;
|
||||
}
|
||||
|
||||
hashconfig->has_optimized_kernel = false;
|
||||
hashconfig->has_pure_kernel = false;
|
||||
|
||||
@ -500,8 +505,22 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx)
|
||||
}
|
||||
}
|
||||
|
||||
// selftest bridge update
|
||||
// bridges have some serious impact on hashconfig
|
||||
if (hashconfig->bridge_type & BRIDGE_TYPE_REPLACE_LOOP)
|
||||
{
|
||||
hashconfig->opts_type &= ~OPTS_TYPE_LOOP;
|
||||
|
||||
hashconfig->bridge_type |= BRIDGE_TYPE_LAUNCH_LOOP;
|
||||
}
|
||||
|
||||
if (hashconfig->bridge_type & BRIDGE_TYPE_REPLACE_LOOP2)
|
||||
{
|
||||
hashconfig->opts_type &= ~OPTS_TYPE_LOOP2;
|
||||
|
||||
hashconfig->bridge_type |= BRIDGE_TYPE_LAUNCH_LOOP2;
|
||||
}
|
||||
|
||||
// selftest bridge update
|
||||
if (hashconfig->bridge_type & BRIDGE_TYPE_UPDATE_SELFTEST)
|
||||
{
|
||||
if (bridge_ctx->st_update_hash) hashconfig->st_hash = bridge_ctx->st_update_hash (bridge_ctx->platform_context);
|
||||
|
@ -26,7 +26,7 @@ static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE
|
||||
| OPTS_TYPE_MP_MULTI_DISABLE;
|
||||
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
||||
static const u64 BRIDGE_TYPE = BRIDGE_TYPE_MATCH_TUNINGS // optional - improves performance
|
||||
| BRIDGE_TYPE_LAUNCH_LOOP;
|
||||
| BRIDGE_TYPE_REPLACE_LOOP;
|
||||
static const char *BRIDGE_NAME = "argon2id_reference";
|
||||
static const char *ST_PASS = "hashcat";
|
||||
static const char *ST_HASH = "$argon2id$v=19$m=4096,t=3,p=1$FoIjFnZlM2JSJWYXUgMFAw$eYKMzhbW8uyT1LLtKRdRcJj2CQeRrdr2pKv/Y71YbAQ";
|
||||
|
@ -15,7 +15,7 @@ static const u32 DGST_POS0 = 0;
|
||||
static const u32 DGST_POS1 = 1;
|
||||
static const u32 DGST_POS2 = 2;
|
||||
static const u32 DGST_POS3 = 3;
|
||||
static const u32 DGST_SIZE = DGST_SIZE_4_4;
|
||||
static const u32 DGST_SIZE = DGST_SIZE_4_16;
|
||||
static const u32 HASH_CATEGORY = HASH_CATEGORY_GENERIC_KDF;
|
||||
static const char *HASH_NAME = "scrypt [Bridged: Scrypt-Jane ROMix]";
|
||||
static const u64 KERN_TYPE = 70100;
|
||||
@ -26,10 +26,10 @@ static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE
|
||||
| OPTS_TYPE_MP_MULTI_DISABLE;
|
||||
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
||||
static const u64 BRIDGE_TYPE = BRIDGE_TYPE_MATCH_TUNINGS // optional - improves performance
|
||||
| BRIDGE_TYPE_LAUNCH_LOOP;
|
||||
| BRIDGE_TYPE_REPLACE_LOOP;
|
||||
static const char *BRIDGE_NAME = "scrypt_jane";
|
||||
static const char *ST_PASS = "hashcat";
|
||||
static const char *ST_HASH = "SCRYPT:16384:8:2:ODEzMTA2Mw==:NuOcXzv+MOqXmwTXnH6bbUEjN/vjlDG28IM7WXaUkk0=";
|
||||
static const char *ST_HASH = "SCRYPT:16384:8:1:OTEyNzU0ODg=:Cc8SPjRH1hFQhuIPCdF51uNGtJ2aOY/isuoMlMUsJ8c=";
|
||||
|
||||
u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; }
|
||||
u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; }
|
||||
@ -50,20 +50,6 @@ u64 module_bridge_type (MAYBE_UNUSED const hashconfig_t *hashconfig,
|
||||
|
||||
static const char *SIGNATURE_SCRYPT = "SCRYPT";
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 salt_buf[64];
|
||||
u32 salt_len;
|
||||
|
||||
u32 digest_buf[64];
|
||||
u32 digest_len;
|
||||
|
||||
u32 N;
|
||||
u32 r;
|
||||
u32 p;
|
||||
|
||||
} scrypt_t;
|
||||
|
||||
u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
// this overrides the reductions of PW_MAX in case optimized kernel is selected
|
||||
@ -74,13 +60,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con
|
||||
return pw_max;
|
||||
}
|
||||
|
||||
u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
const u64 esalt_size = (const u64) sizeof (scrypt_t);
|
||||
|
||||
return esalt_size;
|
||||
}
|
||||
|
||||
u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
#define SCRYPT_R_MAX 16
|
||||
@ -95,45 +74,44 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
{
|
||||
u32 *digest = (u32 *) digest_buf;
|
||||
|
||||
scrypt_t *scrypt = (scrypt_t *) esalt_buf;
|
||||
|
||||
hc_token_t token;
|
||||
|
||||
memset (&token, 0, sizeof (hc_token_t));
|
||||
|
||||
token.token_cnt = 6;
|
||||
|
||||
token.signatures_cnt = 1;
|
||||
token.signatures_buf[0] = SIGNATURE_SCRYPT;
|
||||
|
||||
token.len_min[0] = 6;
|
||||
token.len_max[0] = 6;
|
||||
token.sep[0] = ':';
|
||||
token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
token.len[0] = 6;
|
||||
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_SIGNATURE;
|
||||
|
||||
token.sep[1] = ':';
|
||||
token.len_min[1] = 1;
|
||||
token.len_max[1] = 6;
|
||||
token.sep[1] = ':';
|
||||
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH;
|
||||
|
||||
token.sep[2] = ':';
|
||||
token.len_min[2] = 1;
|
||||
token.len_max[2] = 6;
|
||||
token.sep[2] = ':';
|
||||
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH;
|
||||
|
||||
token.sep[3] = ':';
|
||||
token.len_min[3] = 1;
|
||||
token.len_max[3] = 6;
|
||||
token.sep[3] = ':';
|
||||
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH;
|
||||
|
||||
token.sep[4] = ':';
|
||||
token.len_min[4] = 0;
|
||||
token.len_max[4] = 45;
|
||||
token.sep[4] = ':';
|
||||
token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_BASE64A;
|
||||
|
||||
token.sep[5] = ':';
|
||||
token.len_min[5] = 44;
|
||||
token.len_max[5] = 88;
|
||||
token.sep[5] = ':';
|
||||
token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_BASE64A;
|
||||
|
||||
@ -147,68 +125,60 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
const u8 *r_pos = token.buf[2];
|
||||
const u8 *p_pos = token.buf[3];
|
||||
|
||||
scrypt->N = hc_strtoul ((const char *) N_pos, NULL, 10);
|
||||
scrypt->r = hc_strtoul ((const char *) r_pos, NULL, 10);
|
||||
scrypt->p = hc_strtoul ((const char *) p_pos, NULL, 10);
|
||||
salt->scrypt_N = hc_strtoul ((const char *) N_pos, NULL, 10);
|
||||
salt->scrypt_r = hc_strtoul ((const char *) r_pos, NULL, 10);
|
||||
salt->scrypt_p = hc_strtoul ((const char *) p_pos, NULL, 10);
|
||||
|
||||
if (scrypt->r > 16) return (PARSER_SALT_VALUE);
|
||||
if (scrypt->p > 16) return (PARSER_SALT_VALUE);
|
||||
salt->salt_iter = 1;
|
||||
|
||||
if (salt->scrypt_N % 1024) return (PARSER_SALT_VALUE); // we set loop count to 1024 fixed
|
||||
|
||||
// salt
|
||||
|
||||
const u8 *salt_pos = token.buf[4];
|
||||
const int salt_len = token.len[4];
|
||||
|
||||
scrypt->salt_len = base64_decode (base64_to_int, (const u8 *) salt_pos, salt_len, (u8 *) scrypt->salt_buf);
|
||||
u8 tmp_buf[128] = { 0 };
|
||||
|
||||
const int tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf);
|
||||
|
||||
memcpy (salt->salt_buf, tmp_buf, tmp_len);
|
||||
|
||||
salt->salt_len = tmp_len;
|
||||
|
||||
// digest - base64 decode
|
||||
|
||||
const u8 *hash_pos = token.buf[5];
|
||||
const int hash_len = token.len[5];
|
||||
|
||||
scrypt->digest_len = base64_decode (base64_to_int, (const u8 *) hash_pos, hash_len, (u8 *) scrypt->digest_buf);
|
||||
memset (tmp_buf, 0, sizeof (tmp_buf));
|
||||
|
||||
// comparison digest
|
||||
const int digest_len = base64_decode (base64_to_int, hash_pos, hash_len, tmp_buf);
|
||||
|
||||
digest[0] = scrypt->digest_buf[0];
|
||||
digest[1] = scrypt->digest_buf[1];
|
||||
digest[2] = scrypt->digest_buf[2];
|
||||
digest[3] = scrypt->digest_buf[3];
|
||||
// digest_len should be safe because of 88 limit
|
||||
|
||||
// fake salt, we just need to make this unique
|
||||
memcpy (digest, tmp_buf, digest_len);
|
||||
|
||||
salt->salt_buf[0] = digest[0];
|
||||
salt->salt_buf[1] = digest[1];
|
||||
salt->salt_buf[2] = digest[2];
|
||||
salt->salt_buf[3] = digest[3];
|
||||
salt->salt_buf[4] = scrypt->N;
|
||||
salt->salt_buf[5] = scrypt->r;
|
||||
salt->salt_buf[6] = scrypt->p;
|
||||
salt->salt_buf[7] = 0;
|
||||
|
||||
salt->salt_len = 32;
|
||||
salt->salt_iter = 1;
|
||||
salt->salt_len_pc = digest_len;
|
||||
|
||||
return (PARSER_OK);
|
||||
}
|
||||
|
||||
int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size)
|
||||
{
|
||||
const scrypt_t *scrypt = (const scrypt_t *) esalt_buf;
|
||||
|
||||
char base64_salt[64] = { 0 };
|
||||
|
||||
base64_encode (int_to_base64, (const u8 *) scrypt->salt_buf, scrypt->salt_len, (u8 *) base64_salt);
|
||||
base64_encode (int_to_base64, (const u8 *) salt->salt_buf, salt->salt_len, (u8 *) base64_salt);
|
||||
|
||||
char base64_digest[128] = { 0 };
|
||||
|
||||
base64_encode (int_to_base64, (const u8 *) scrypt->digest_buf, scrypt->digest_len, (u8 *) base64_digest);
|
||||
base64_encode (int_to_base64, (const u8 *) digest_buf, salt->salt_len_pc, (u8 *) base64_digest);
|
||||
|
||||
const int line_len = snprintf (line_buf, line_size, "%s:%u:%u:%u:%s:%s",
|
||||
SIGNATURE_SCRYPT,
|
||||
scrypt->N,
|
||||
scrypt->r,
|
||||
scrypt->p,
|
||||
salt->scrypt_N,
|
||||
salt->scrypt_r,
|
||||
salt->scrypt_p,
|
||||
base64_salt,
|
||||
base64_digest);
|
||||
|
||||
@ -237,7 +207,7 @@ void module_init (module_ctx_t *module_ctx)
|
||||
module_ctx->module_dgst_pos3 = module_dgst_pos3;
|
||||
module_ctx->module_dgst_size = module_dgst_size;
|
||||
module_ctx->module_dictstat_disable = MODULE_DEFAULT;
|
||||
module_ctx->module_esalt_size = module_esalt_size;
|
||||
module_ctx->module_esalt_size = MODULE_DEFAULT;
|
||||
module_ctx->module_extra_buffer_size = MODULE_DEFAULT;
|
||||
module_ctx->module_extra_tmp_size = MODULE_DEFAULT;
|
||||
module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT;
|
||||
|
@ -15,7 +15,7 @@ static const u32 DGST_POS0 = 0;
|
||||
static const u32 DGST_POS1 = 1;
|
||||
static const u32 DGST_POS2 = 2;
|
||||
static const u32 DGST_POS3 = 3;
|
||||
static const u32 DGST_SIZE = DGST_SIZE_4_4;
|
||||
static const u32 DGST_SIZE = DGST_SIZE_4_16;
|
||||
static const u32 HASH_CATEGORY = HASH_CATEGORY_GENERIC_KDF;
|
||||
static const char *HASH_NAME = "scrypt [Bridged: Scrypt-Yescrypt]";
|
||||
static const u64 KERN_TYPE = 70100;
|
||||
@ -26,10 +26,10 @@ static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE
|
||||
| OPTS_TYPE_MP_MULTI_DISABLE;
|
||||
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
||||
static const u64 BRIDGE_TYPE = BRIDGE_TYPE_MATCH_TUNINGS // optional - improves performance
|
||||
| BRIDGE_TYPE_LAUNCH_LOOP;
|
||||
| BRIDGE_TYPE_REPLACE_LOOP;
|
||||
static const char *BRIDGE_NAME = "scrypt_yescrypt";
|
||||
static const char *ST_PASS = "hashcat";
|
||||
static const char *ST_HASH = "SCRYPT:16384:8:2:ODEzMTA2Mw==:NuOcXzv+MOqXmwTXnH6bbUEjN/vjlDG28IM7WXaUkk0=";
|
||||
static const char *ST_HASH = "SCRYPT:16384:8:1:OTEyNzU0ODg=:Cc8SPjRH1hFQhuIPCdF51uNGtJ2aOY/isuoMlMUsJ8c=";
|
||||
|
||||
u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ATTACK_EXEC; }
|
||||
u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; }
|
||||
@ -50,20 +50,6 @@ u64 module_bridge_type (MAYBE_UNUSED const hashconfig_t *hashconfig,
|
||||
|
||||
static const char *SIGNATURE_SCRYPT = "SCRYPT";
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 salt_buf[64];
|
||||
u32 salt_len;
|
||||
|
||||
u32 digest_buf[64];
|
||||
u32 digest_len;
|
||||
|
||||
u32 N;
|
||||
u32 r;
|
||||
u32 p;
|
||||
|
||||
} scrypt_t;
|
||||
|
||||
u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
// this overrides the reductions of PW_MAX in case optimized kernel is selected
|
||||
@ -74,13 +60,6 @@ u32 module_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED con
|
||||
return pw_max;
|
||||
}
|
||||
|
||||
u64 module_esalt_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
const u64 esalt_size = (const u64) sizeof (scrypt_t);
|
||||
|
||||
return esalt_size;
|
||||
}
|
||||
|
||||
u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra)
|
||||
{
|
||||
#define SCRYPT_R_MAX 16
|
||||
@ -95,45 +74,44 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
{
|
||||
u32 *digest = (u32 *) digest_buf;
|
||||
|
||||
scrypt_t *scrypt = (scrypt_t *) esalt_buf;
|
||||
|
||||
hc_token_t token;
|
||||
|
||||
memset (&token, 0, sizeof (hc_token_t));
|
||||
|
||||
token.token_cnt = 6;
|
||||
|
||||
token.signatures_cnt = 1;
|
||||
token.signatures_buf[0] = SIGNATURE_SCRYPT;
|
||||
|
||||
token.len_min[0] = 6;
|
||||
token.len_max[0] = 6;
|
||||
token.sep[0] = ':';
|
||||
token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
token.len[0] = 6;
|
||||
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_SIGNATURE;
|
||||
|
||||
token.sep[1] = ':';
|
||||
token.len_min[1] = 1;
|
||||
token.len_max[1] = 6;
|
||||
token.sep[1] = ':';
|
||||
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH;
|
||||
|
||||
token.sep[2] = ':';
|
||||
token.len_min[2] = 1;
|
||||
token.len_max[2] = 6;
|
||||
token.sep[2] = ':';
|
||||
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH;
|
||||
|
||||
token.sep[3] = ':';
|
||||
token.len_min[3] = 1;
|
||||
token.len_max[3] = 6;
|
||||
token.sep[3] = ':';
|
||||
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH;
|
||||
|
||||
token.sep[4] = ':';
|
||||
token.len_min[4] = 0;
|
||||
token.len_max[4] = 45;
|
||||
token.sep[4] = ':';
|
||||
token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_BASE64A;
|
||||
|
||||
token.sep[5] = ':';
|
||||
token.len_min[5] = 44;
|
||||
token.len_max[5] = 88;
|
||||
token.sep[5] = ':';
|
||||
token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_BASE64A;
|
||||
|
||||
@ -147,68 +125,60 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
const u8 *r_pos = token.buf[2];
|
||||
const u8 *p_pos = token.buf[3];
|
||||
|
||||
scrypt->N = hc_strtoul ((const char *) N_pos, NULL, 10);
|
||||
scrypt->r = hc_strtoul ((const char *) r_pos, NULL, 10);
|
||||
scrypt->p = hc_strtoul ((const char *) p_pos, NULL, 10);
|
||||
salt->scrypt_N = hc_strtoul ((const char *) N_pos, NULL, 10);
|
||||
salt->scrypt_r = hc_strtoul ((const char *) r_pos, NULL, 10);
|
||||
salt->scrypt_p = hc_strtoul ((const char *) p_pos, NULL, 10);
|
||||
|
||||
if (scrypt->r > 16) return (PARSER_SALT_VALUE);
|
||||
if (scrypt->p > 16) return (PARSER_SALT_VALUE);
|
||||
salt->salt_iter = 1;
|
||||
|
||||
if (salt->scrypt_N % 1024) return (PARSER_SALT_VALUE); // we set loop count to 1024 fixed
|
||||
|
||||
// salt
|
||||
|
||||
const u8 *salt_pos = token.buf[4];
|
||||
const int salt_len = token.len[4];
|
||||
|
||||
scrypt->salt_len = base64_decode (base64_to_int, (const u8 *) salt_pos, salt_len, (u8 *) scrypt->salt_buf);
|
||||
u8 tmp_buf[128] = { 0 };
|
||||
|
||||
const int tmp_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf);
|
||||
|
||||
memcpy (salt->salt_buf, tmp_buf, tmp_len);
|
||||
|
||||
salt->salt_len = tmp_len;
|
||||
|
||||
// digest - base64 decode
|
||||
|
||||
const u8 *hash_pos = token.buf[5];
|
||||
const int hash_len = token.len[5];
|
||||
|
||||
scrypt->digest_len = base64_decode (base64_to_int, (const u8 *) hash_pos, hash_len, (u8 *) scrypt->digest_buf);
|
||||
memset (tmp_buf, 0, sizeof (tmp_buf));
|
||||
|
||||
// comparison digest
|
||||
const int digest_len = base64_decode (base64_to_int, hash_pos, hash_len, tmp_buf);
|
||||
|
||||
digest[0] = scrypt->digest_buf[0];
|
||||
digest[1] = scrypt->digest_buf[1];
|
||||
digest[2] = scrypt->digest_buf[2];
|
||||
digest[3] = scrypt->digest_buf[3];
|
||||
// digest_len should be safe because of 88 limit
|
||||
|
||||
// fake salt, we just need to make this unique
|
||||
memcpy (digest, tmp_buf, digest_len);
|
||||
|
||||
salt->salt_buf[0] = digest[0];
|
||||
salt->salt_buf[1] = digest[1];
|
||||
salt->salt_buf[2] = digest[2];
|
||||
salt->salt_buf[3] = digest[3];
|
||||
salt->salt_buf[4] = scrypt->N;
|
||||
salt->salt_buf[5] = scrypt->r;
|
||||
salt->salt_buf[6] = scrypt->p;
|
||||
salt->salt_buf[7] = 0;
|
||||
|
||||
salt->salt_len = 32;
|
||||
salt->salt_iter = 1;
|
||||
salt->salt_len_pc = digest_len;
|
||||
|
||||
return (PARSER_OK);
|
||||
}
|
||||
|
||||
int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size)
|
||||
{
|
||||
const scrypt_t *scrypt = (const scrypt_t *) esalt_buf;
|
||||
|
||||
char base64_salt[64] = { 0 };
|
||||
|
||||
base64_encode (int_to_base64, (const u8 *) scrypt->salt_buf, scrypt->salt_len, (u8 *) base64_salt);
|
||||
base64_encode (int_to_base64, (const u8 *) salt->salt_buf, salt->salt_len, (u8 *) base64_salt);
|
||||
|
||||
char base64_digest[128] = { 0 };
|
||||
|
||||
base64_encode (int_to_base64, (const u8 *) scrypt->digest_buf, scrypt->digest_len, (u8 *) base64_digest);
|
||||
base64_encode (int_to_base64, (const u8 *) digest_buf, salt->salt_len_pc, (u8 *) base64_digest);
|
||||
|
||||
const int line_len = snprintf (line_buf, line_size, "%s:%u:%u:%u:%s:%s",
|
||||
SIGNATURE_SCRYPT,
|
||||
scrypt->N,
|
||||
scrypt->r,
|
||||
scrypt->p,
|
||||
salt->scrypt_N,
|
||||
salt->scrypt_r,
|
||||
salt->scrypt_p,
|
||||
base64_salt,
|
||||
base64_digest);
|
||||
|
||||
@ -237,7 +207,7 @@ void module_init (module_ctx_t *module_ctx)
|
||||
module_ctx->module_dgst_pos3 = module_dgst_pos3;
|
||||
module_ctx->module_dgst_size = module_dgst_size;
|
||||
module_ctx->module_dictstat_disable = MODULE_DEFAULT;
|
||||
module_ctx->module_esalt_size = module_esalt_size;
|
||||
module_ctx->module_esalt_size = MODULE_DEFAULT;
|
||||
module_ctx->module_extra_buffer_size = MODULE_DEFAULT;
|
||||
module_ctx->module_extra_tmp_size = MODULE_DEFAULT;
|
||||
module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT;
|
||||
|
@ -561,7 +561,10 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
||||
}
|
||||
}
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_INIT)
|
||||
{
|
||||
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 0, 1, false, 0) == -1) return -1;
|
||||
}
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_HOOK12)
|
||||
{
|
||||
@ -647,7 +650,10 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
||||
device_param->kernel_param.loop_pos = loop_pos;
|
||||
device_param->kernel_param.loop_cnt = loop_left;
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_LOOP)
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -704,11 +710,15 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
||||
if (device_param->is_cuda == true)
|
||||
{
|
||||
if (hc_cuMemcpyHtoDAsync (hashcat_ctx, device_param->cuda_d_tmps, device_param->h_tmps, hashconfig->tmp_size, device_param->cuda_stream) == -1) return -1;
|
||||
|
||||
if (hc_cuStreamSynchronize (hashcat_ctx, device_param->cuda_stream) == -1) return -1;
|
||||
}
|
||||
|
||||
if (device_param->is_hip == true)
|
||||
{
|
||||
if (hc_hipMemcpyHtoDAsync (hashcat_ctx, device_param->hip_d_tmps, device_param->h_tmps, hashconfig->tmp_size, device_param->hip_stream) == -1) return -1;
|
||||
|
||||
if (hc_hipStreamSynchronize (hashcat_ctx, device_param->hip_stream) == -1) return -1;
|
||||
}
|
||||
|
||||
#if defined (__APPLE__)
|
||||
@ -720,6 +730,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
||||
|
||||
if (device_param->is_opencl == true)
|
||||
{
|
||||
/* blocking */
|
||||
if (hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->opencl_command_queue, device_param->opencl_d_tmps, CL_TRUE, 0, hashconfig->tmp_size, device_param->h_tmps, 0, NULL, NULL) == -1) return -1;
|
||||
}
|
||||
}
|
||||
@ -912,8 +923,11 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
||||
}
|
||||
}
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_COMP)
|
||||
{
|
||||
if (run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 0, 1, false, 0) == -1) return -1;
|
||||
}
|
||||
}
|
||||
|
||||
device_param->spin_damp = spin_damp_sav;
|
||||
|
||||
|
@ -591,6 +591,10 @@ void setup_environment_variables (const folder_config_t *folder_config)
|
||||
// we can't free tmpdir at this point!
|
||||
}
|
||||
|
||||
// creates too much cpu load
|
||||
if (getenv ("AMD_DIRECT_DISPATCH") == NULL)
|
||||
putenv ((char *) "AMD_DIRECT_DISPATCH=0");
|
||||
|
||||
/*
|
||||
if (getenv ("CL_CONFIG_USE_VECTORIZER") == NULL)
|
||||
putenv ((char *) "CL_CONFIG_USE_VECTORIZER=False");
|
||||
|
@ -19,7 +19,7 @@ sub module_generate_hash
|
||||
my $salt = shift;
|
||||
my $N = shift // 16384;
|
||||
my $r = shift // 8;
|
||||
my $p = shift // 2;
|
||||
my $p = shift // 1;
|
||||
|
||||
my $hash_buf = scrypt_hash ($word, $salt, $N, $r, $p, 32);
|
||||
|
||||
|
@ -19,7 +19,7 @@ sub module_generate_hash
|
||||
my $salt = shift;
|
||||
my $N = shift // 16384;
|
||||
my $r = shift // 8;
|
||||
my $p = shift // 2;
|
||||
my $p = shift // 1;
|
||||
|
||||
my $hash_buf = scrypt_hash ($word, $salt, $N, $r, $p, 32);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user