mirror of
https://github.com/hashcat/hashcat.git
synced 2025-02-08 13:42:46 +00:00
Support use of all available CPU cores for hash-mode specific hooks
This commit is contained in:
parent
d71afd6d7a
commit
a8555fa048
@ -8,6 +8,7 @@
|
|||||||
- Refactor hashcat backend interface to allow adding compute API other than OpenCL
|
- Refactor hashcat backend interface to allow adding compute API other than OpenCL
|
||||||
- Added CUDA as a new compute API to hashcat backend (enables hashcat to run on NVIDIA Jetson or IBM POWER9)
|
- Added CUDA as a new compute API to hashcat backend (enables hashcat to run on NVIDIA Jetson or IBM POWER9)
|
||||||
- Support use of all available GPU memory using CUDA backend
|
- Support use of all available GPU memory using CUDA backend
|
||||||
|
- Support use of all available CPU cores for hash-mode specific hooks
|
||||||
- Support on-the-fly loading of compressed wordlists in zip and gzip format
|
- Support on-the-fly loading of compressed wordlists in zip and gzip format
|
||||||
- Support for inline VeraCrypt PIM Brute-Force
|
- Support for inline VeraCrypt PIM Brute-Force
|
||||||
- Support deflate decompression for the 7-Zip hash-mode using zlib hook
|
- Support deflate decompression for the 7-Zip hash-mode using zlib hook
|
||||||
|
@ -154,4 +154,7 @@ int backend_session_update_combinator (hashcat_ctx_t *hashcat_ctx);
|
|||||||
int backend_session_update_mp (hashcat_ctx_t *hashcat_ctx);
|
int backend_session_update_mp (hashcat_ctx_t *hashcat_ctx);
|
||||||
int backend_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_l, const u32 css_cnt_r);
|
int backend_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_l, const u32 css_cnt_r);
|
||||||
|
|
||||||
|
void *hook12_thread (void *p);
|
||||||
|
void *hook23_thread (void *p);
|
||||||
|
|
||||||
#endif // _BACKEND_H
|
#endif // _BACKEND_H
|
||||||
|
@ -71,8 +71,8 @@ bool module_jit_cache_disable (MAYBE_UNUSED const hashconfig_t *ha
|
|||||||
u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos);
|
u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos);
|
||||||
int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash);
|
int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash);
|
||||||
|
|
||||||
void module_hook12 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt);
|
void module_hook12 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pw_pos);
|
||||||
void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt);
|
void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pw_pos);
|
||||||
|
|
||||||
int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz);
|
int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const void *tmps, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, MAYBE_UNUSED const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz);
|
||||||
|
|
||||||
|
@ -2461,6 +2461,22 @@ typedef struct thread_param
|
|||||||
|
|
||||||
} thread_param_t;
|
} thread_param_t;
|
||||||
|
|
||||||
|
typedef struct hook_thread_param
|
||||||
|
{
|
||||||
|
int tid;
|
||||||
|
int tsz;
|
||||||
|
|
||||||
|
module_ctx_t *module_ctx;
|
||||||
|
|
||||||
|
hc_device_param_t *device_param;
|
||||||
|
|
||||||
|
void *hook_salts_buf;
|
||||||
|
|
||||||
|
u32 salt_pos;
|
||||||
|
u64 pws_cnt;
|
||||||
|
|
||||||
|
} hook_thread_param_t;
|
||||||
|
|
||||||
#define MAX_TOKENS 128
|
#define MAX_TOKENS 128
|
||||||
#define MAX_SIGNATURES 16
|
#define MAX_SIGNATURES 16
|
||||||
|
|
||||||
|
110
src/backend.c
110
src/backend.c
@ -2877,7 +2877,42 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
|||||||
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;
|
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_hook12 (device_param, hashes->hook_salts_buf, salt_pos, pws_cnt);
|
const int hook_threads = (int) user_options->hook_threads;
|
||||||
|
|
||||||
|
hook_thread_param_t *hook_threads_param = (hook_thread_param_t *) hccalloc (hook_threads, sizeof (hook_thread_param_t));
|
||||||
|
|
||||||
|
for (int i = 0; i < hook_threads; i++)
|
||||||
|
{
|
||||||
|
hook_thread_param_t *hook_thread_param = hook_threads_param + i;
|
||||||
|
|
||||||
|
hook_thread_param->tid = i;
|
||||||
|
hook_thread_param->tsz = hook_threads;
|
||||||
|
|
||||||
|
hook_thread_param->module_ctx = module_ctx;
|
||||||
|
|
||||||
|
hook_thread_param->device_param = device_param;
|
||||||
|
|
||||||
|
hook_thread_param->hook_salts_buf = hashes->hook_salts_buf;
|
||||||
|
|
||||||
|
hook_thread_param->salt_pos = salt_pos;
|
||||||
|
|
||||||
|
hook_thread_param->pws_cnt = pws_cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
hc_thread_t *c_threads = (hc_thread_t *) calloc (hook_threads, sizeof (hc_thread_t));
|
||||||
|
|
||||||
|
for (int i = 0; i < hook_threads; i++)
|
||||||
|
{
|
||||||
|
hook_thread_param_t *hook_thread_param = hook_threads_param + i;
|
||||||
|
|
||||||
|
hc_thread_create (c_threads[i], hook12_thread, hook_thread_param);
|
||||||
|
}
|
||||||
|
|
||||||
|
hc_thread_wait (hook_threads, c_threads);
|
||||||
|
|
||||||
|
hcfree (c_threads);
|
||||||
|
|
||||||
|
hcfree (hook_threads_param);
|
||||||
|
|
||||||
if (device_param->is_cuda == true)
|
if (device_param->is_cuda == true)
|
||||||
{
|
{
|
||||||
@ -2957,7 +2992,42 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
|
|||||||
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;
|
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, hashes->hook_salts_buf, salt_pos, pws_cnt);
|
const int hook_threads = (int) user_options->hook_threads;
|
||||||
|
|
||||||
|
hook_thread_param_t *hook_threads_param = (hook_thread_param_t *) hccalloc (hook_threads, sizeof (hook_thread_param_t));
|
||||||
|
|
||||||
|
for (int i = 0; i < hook_threads; i++)
|
||||||
|
{
|
||||||
|
hook_thread_param_t *hook_thread_param = hook_threads_param + i;
|
||||||
|
|
||||||
|
hook_thread_param->tid = i;
|
||||||
|
hook_thread_param->tsz = hook_threads;
|
||||||
|
|
||||||
|
hook_thread_param->module_ctx = module_ctx;
|
||||||
|
|
||||||
|
hook_thread_param->device_param = device_param;
|
||||||
|
|
||||||
|
hook_thread_param->hook_salts_buf = hashes->hook_salts_buf;
|
||||||
|
|
||||||
|
hook_thread_param->salt_pos = salt_pos;
|
||||||
|
|
||||||
|
hook_thread_param->pws_cnt = pws_cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
hc_thread_t *c_threads = (hc_thread_t *) calloc (hook_threads, sizeof (hc_thread_t));
|
||||||
|
|
||||||
|
for (int i = 0; i < hook_threads; i++)
|
||||||
|
{
|
||||||
|
hook_thread_param_t *hook_thread_param = hook_threads_param + i;
|
||||||
|
|
||||||
|
hc_thread_create (c_threads[i], hook23_thread, hook_thread_param);
|
||||||
|
}
|
||||||
|
|
||||||
|
hc_thread_wait (hook_threads, c_threads);
|
||||||
|
|
||||||
|
hcfree (c_threads);
|
||||||
|
|
||||||
|
hcfree (hook_threads_param);
|
||||||
|
|
||||||
if (device_param->is_cuda == true)
|
if (device_param->is_cuda == true)
|
||||||
{
|
{
|
||||||
@ -10131,3 +10201,39 @@ int backend_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *hook12_thread (void *p)
|
||||||
|
{
|
||||||
|
hook_thread_param_t *hook_thread_param = (hook_thread_param_t *) p;
|
||||||
|
|
||||||
|
module_ctx_t *module_ctx = hook_thread_param->module_ctx;
|
||||||
|
|
||||||
|
const u64 tid = hook_thread_param->tid;
|
||||||
|
const u64 tsz = hook_thread_param->tsz;
|
||||||
|
const u64 pws_cnt = hook_thread_param->pws_cnt;
|
||||||
|
|
||||||
|
for (u64 pw_pos = tid; pw_pos < pws_cnt; pw_pos += tsz)
|
||||||
|
{
|
||||||
|
module_ctx->module_hook12 (hook_thread_param->device_param, hook_thread_param->hook_salts_buf, hook_thread_param->salt_pos, pw_pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void *hook23_thread (void *p)
|
||||||
|
{
|
||||||
|
hook_thread_param_t *hook_thread_param = (hook_thread_param_t *) p;
|
||||||
|
|
||||||
|
module_ctx_t *module_ctx = hook_thread_param->module_ctx;
|
||||||
|
|
||||||
|
const u64 tid = hook_thread_param->tid;
|
||||||
|
const u64 tsz = hook_thread_param->tsz;
|
||||||
|
const u64 pws_cnt = hook_thread_param->pws_cnt;
|
||||||
|
|
||||||
|
for (u64 pw_pos = tid; pw_pos < pws_cnt; pw_pos += tsz)
|
||||||
|
{
|
||||||
|
module_ctx->module_hook23 (hook_thread_param->device_param, hook_thread_param->hook_salts_buf, hook_thread_param->salt_pos, pw_pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
@ -94,7 +94,7 @@ typedef struct seven_zip_hook_salt
|
|||||||
|
|
||||||
static const char *SIGNATURE_SEVEN_ZIP = "$7z$";
|
static const char *SIGNATURE_SEVEN_ZIP = "$7z$";
|
||||||
|
|
||||||
void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt)
|
void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf, const u32 salt_pos, const u64 pw_pos)
|
||||||
{
|
{
|
||||||
seven_zip_hook_t *hook_items = (seven_zip_hook_t *) device_param->hooks_buf;
|
seven_zip_hook_t *hook_items = (seven_zip_hook_t *) device_param->hooks_buf;
|
||||||
|
|
||||||
@ -105,8 +105,6 @@ void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf,
|
|||||||
u32 *data_buf = seven_zip->data_buf;
|
u32 *data_buf = seven_zip->data_buf;
|
||||||
u32 unpack_size = seven_zip->unpack_size;
|
u32 unpack_size = seven_zip->unpack_size;
|
||||||
|
|
||||||
for (u64 pw_pos = 0; pw_pos < pws_cnt; pw_pos++)
|
|
||||||
{
|
|
||||||
// this hook data needs to be updated (the "hook_success" variable):
|
// this hook data needs to be updated (the "hook_success" variable):
|
||||||
|
|
||||||
seven_zip_hook_t *hook_item = &hook_items[pw_pos];
|
seven_zip_hook_t *hook_item = &hook_items[pw_pos];
|
||||||
@ -261,7 +259,7 @@ void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf,
|
|||||||
|
|
||||||
hcfree (decompressed_data);
|
hcfree (decompressed_data);
|
||||||
|
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
crc = cpu_crc32_buffer (decompressed_data, crc_len);
|
crc = cpu_crc32_buffer (decompressed_data, crc_len);
|
||||||
@ -277,7 +275,6 @@ void module_hook23 (hc_device_param_t *device_param, const void *hook_salts_buf,
|
|||||||
{
|
{
|
||||||
hook_item->hook_success = 0;
|
hook_item->hook_success = 0;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 module_hook_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)
|
u64 module_hook_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)
|
||||||
|
@ -455,7 +455,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
|||||||
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;
|
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_hook12 (device_param, hashes->st_hook_salts_buf, 0, 1);
|
module_ctx->module_hook12 (device_param, hashes->st_hook_salts_buf, 0, 0);
|
||||||
|
|
||||||
if (device_param->is_cuda == true)
|
if (device_param->is_cuda == true)
|
||||||
{
|
{
|
||||||
@ -502,7 +502,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
|
|||||||
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;
|
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, hashes->st_hook_salts_buf, 0, 1);
|
module_ctx->module_hook23 (device_param, hashes->st_hook_salts_buf, 0, 0);
|
||||||
|
|
||||||
if (device_param->is_cuda == true)
|
if (device_param->is_cuda == true)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user