1
mirror of https://github.com/hashcat/hashcat synced 2024-12-23 14:13:43 +01:00

Add OPTI_TYPE_REGISTER_LIMIT flag to enable register limiting in CUDA

This commit is contained in:
Jens Steube 2020-02-04 21:53:27 +01:00
parent 17a64f5019
commit 4788c61dd2
7 changed files with 42 additions and 14 deletions

View File

@ -372,7 +372,8 @@ typedef enum opti_type
OPTI_TYPE_USES_BITS_8 = (1 << 16),
OPTI_TYPE_USES_BITS_16 = (1 << 17),
OPTI_TYPE_USES_BITS_32 = (1 << 18),
OPTI_TYPE_USES_BITS_64 = (1 << 19)
OPTI_TYPE_USES_BITS_64 = (1 << 19),
OPTI_TYPE_REGISTER_LIMIT = (1 << 20), // We'll limit the register count to 128
} opti_type_t;

View File

@ -6949,6 +6949,8 @@ static u32 get_kernel_threads (const hc_device_param_t *device_param)
static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const char *kernel_name, char *source_file, char *cached_file, const char *build_options_buf, const bool cache_disable, cl_program *opencl_program, CUmodule *cuda_module)
{
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
bool cached = true;
if (cache_disable == true)
@ -7052,6 +7054,8 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
char *mod_info_log = (char *) hcmalloc (LOG_SIZE + 1);
char *mod_error_log = (char *) hcmalloc (LOG_SIZE + 1);
int mod_cnt = 6;
CUjit_option mod_opts[7];
void *mod_vals[7];
@ -7073,14 +7077,21 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
mod_opts[5] = CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES;
mod_vals[5] = (void *) LOG_SIZE;
mod_opts[6] = CU_JIT_MAX_REGISTERS;
mod_vals[6] = (void *) 128;
if (hashconfig->opti_type & OPTI_TYPE_REGISTER_LIMIT)
{
mod_opts[6] = CU_JIT_MAX_REGISTERS;
mod_vals[6] = (void *) 128;
mod_cnt++;
}
#if defined (WITH_CUBIN)
char *jit_info_log = (char *) hcmalloc (LOG_SIZE + 1);
char *jit_error_log = (char *) hcmalloc (LOG_SIZE + 1);
int jit_cnt = 6;
CUjit_option jit_opts[7];
void *jit_vals[7];
@ -7102,12 +7113,17 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
jit_opts[5] = CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES;
jit_vals[5] = (void *) LOG_SIZE;
jit_opts[6] = CU_JIT_MAX_REGISTERS;
jit_vals[6] = (void *) 128;
if (hashconfig->opti_type & OPTI_TYPE_REGISTER_LIMIT)
{
jit_opts[6] = CU_JIT_MAX_REGISTERS;
jit_vals[6] = (void *) 128;
jit_cnt++;
}
CUlinkState state;
if (hc_cuLinkCreate (hashcat_ctx, 7, jit_opts, jit_vals, &state) == -1)
if (hc_cuLinkCreate (hashcat_ctx, jit_cnt, jit_opts, jit_vals, &state) == -1)
{
event_log_error (hashcat_ctx, "* Device #%u: Kernel %s link failed. Error Log:", device_param->device_id + 1, source_file);
event_log_error (hashcat_ctx, "%s", jit_error_log);
@ -7144,7 +7160,7 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
event_log_info (hashcat_ctx, NULL);
#endif
if (hc_cuModuleLoadDataEx (hashcat_ctx, cuda_module, cubin, 7, mod_opts, mod_vals) == -1)
if (hc_cuModuleLoadDataEx (hashcat_ctx, cuda_module, cubin, mod_cnt, mod_opts, mod_vals) == -1)
{
event_log_error (hashcat_ctx, "* Device #%u: Kernel %s load failed. Error Log:", device_param->device_id + 1, source_file);
event_log_error (hashcat_ctx, "%s", mod_error_log);
@ -7171,7 +7187,7 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
#else
if (hc_cuModuleLoadDataEx (hashcat_ctx, cuda_module, binary, 7, mod_opts, mod_vals) == -1)
if (hc_cuModuleLoadDataEx (hashcat_ctx, cuda_module, binary, mod_cnt, mod_opts, mod_vals) == -1)
{
event_log_error (hashcat_ctx, "* Device #%u: Kernel %s load failed. Error Log:", device_param->device_id + 1, source_file);
event_log_error (hashcat_ctx, "%s", mod_error_log);
@ -7259,6 +7275,8 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
char *mod_info_log = (char *) hcmalloc (LOG_SIZE + 1);
char *mod_error_log = (char *) hcmalloc (LOG_SIZE + 1);
int mod_cnt = 6;
CUjit_option mod_opts[7];
void *mod_vals[7];
@ -7280,10 +7298,15 @@ static bool load_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_p
mod_opts[5] = CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES;
mod_vals[5] = (void *) LOG_SIZE;
mod_opts[6] = CU_JIT_MAX_REGISTERS;
mod_vals[6] = (void *) 128;
if (hashconfig->opti_type & OPTI_TYPE_REGISTER_LIMIT)
{
mod_opts[6] = CU_JIT_MAX_REGISTERS;
mod_vals[6] = (void *) 128;
if (hc_cuModuleLoadDataEx (hashcat_ctx, cuda_module, kernel_sources[0], 7, mod_opts, mod_vals) == -1)
mod_cnt++;
}
if (hc_cuModuleLoadDataEx (hashcat_ctx, cuda_module, kernel_sources[0], mod_cnt, mod_opts, mod_vals) == -1)
{
event_log_error (hashcat_ctx, "* Device #%u: Kernel %s load failed. Error Log:", device_param->device_id + 1, source_file);
event_log_error (hashcat_ctx, "%s", mod_error_log);

View File

@ -20,6 +20,7 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_FORUM_SOFTWARE;
static const char *HASH_NAME = "Drupal7";
static const u64 KERN_TYPE = 7900;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
| OPTI_TYPE_REGISTER_LIMIT
| OPTI_TYPE_USES_BITS_64;
static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE;
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;

View File

@ -19,7 +19,8 @@ static const u32 DGST_SIZE = DGST_SIZE_4_8;
static const u32 HASH_CATEGORY = HASH_CATEGORY_DOCUMENTS;
static const char *HASH_NAME = "PDF 1.7 Level 8 (Acrobat 10 - 11)";
static const u64 KERN_TYPE = 10700;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
| OPTI_TYPE_REGISTER_LIMIT;
static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE
| OPTS_TYPE_HASH_COPY;
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;

View File

@ -20,7 +20,8 @@ static const u32 DGST_SIZE = DGST_SIZE_4_4;
static const u32 HASH_CATEGORY = HASH_CATEGORY_OS;
static const char *HASH_NAME = "BSDi Crypt, Extended DES";
static const u64 KERN_TYPE = 12400;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
| OPTI_TYPE_REGISTER_LIMIT;
static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_LE;
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
static const char *ST_PASS = "hashcat";

View File

@ -20,6 +20,7 @@ static const u32 HASH_CATEGORY = HASH_CATEGORY_PASSWORD_MANAGER;
static const char *HASH_NAME = "Electrum Wallet (Salt-Type 1-3)";
static const u64 KERN_TYPE = 16600;
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
| OPTI_TYPE_REGISTER_LIMIT
| OPTI_TYPE_PRECOMPUTE_INIT;
static const u64 OPTS_TYPE = OPTS_TYPE_PT_GENERATE_BE
| OPTS_TYPE_PT_ADD80

View File

@ -8,7 +8,7 @@ my $amd_cache = "~/.AMD";
my $hashcat_path = ".";
my $kernels_cache = "$hashcat_path/kernels";
my $hashcat_bin = "$hashcat_path/hashcat";
my $device = 1;
my $device = 3;
my $workload_profile = 3;
my $runtime = 24;
my $sleep_sec = 12;