From bc1dd699e3a436b96dc11782a256475e3d484952 Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 15 Jan 2019 11:53:59 +0100 Subject: [PATCH] Add -m 1500 module --- include/interface.h | 11 -- include/interface_migrate.h | 3 - include/types.h | 11 ++ src/hashcat.c | 64 ++++----- src/interface.c | 31 +++-- src/interface_migrate.c | 127 +---------------- src/modules/module_01000.c | 2 +- src/modules/module_01500.c | 268 ++++++++++++++++++++++++++++++++++++ src/opencl.c | 13 +- src/shared.c | 14 +- 10 files changed, 349 insertions(+), 195 deletions(-) create mode 100644 src/modules/module_01500.c diff --git a/include/interface.h b/include/interface.h index 770b29c1a..c907d0af8 100644 --- a/include/interface.h +++ b/include/interface.h @@ -17,17 +17,6 @@ static const int MODULE_INTERFACE_VERSION_MINIMUM = 520; static const int MODULE_HASH_MODES_MAXIMUM = 100000; -typedef enum kernel_workload -{ - KERNEL_ACCEL_MIN = 1, - KERNEL_ACCEL_MAX = 1024, - KERNEL_LOOPS_MIN = 1, - KERNEL_LOOPS_MAX = 1024, - KERNEL_THREADS_MIN = 1, - KERNEL_THREADS_MAX = 1024, - -} kernel_workload_t; - /** * output functions */ diff --git a/include/interface_migrate.h b/include/interface_migrate.h index 4beb3ecd8..e69720365 100644 --- a/include/interface_migrate.h +++ b/include/interface_migrate.h @@ -933,7 +933,6 @@ typedef enum hash_type HASH_TYPE_DCC2 = 9, HASH_TYPE_WPA_EAPOL = 10, HASH_TYPE_LM = 11, - HASH_TYPE_DESCRYPT = 12, HASH_TYPE_ORACLEH = 13, HASH_TYPE_DESRACF = 14, HASH_TYPE_BCRYPT = 15, @@ -1015,7 +1014,6 @@ typedef enum kern_type KERN_TYPE_SHA256_SLTPWU = 1440, KERN_TYPE_HMACSHA256_PW = 1450, KERN_TYPE_HMACSHA256_SLT = 1460, - KERN_TYPE_DESCRYPT = 1500, KERN_TYPE_APR1CRYPT = 1600, KERN_TYPE_SHA512_PWSLT = 1710, KERN_TYPE_SHA512_SLTPW = 1720, @@ -1278,7 +1276,6 @@ typedef enum rounds_count int bcrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig); int cisco4_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig); int dcc2_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig); -int descrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig); int des_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig); int episerver_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig); int postgresql_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig); diff --git a/include/types.h b/include/types.h index e35eacd48..52a2dd4c5 100644 --- a/include/types.h +++ b/include/types.h @@ -1416,6 +1416,17 @@ typedef struct opencl_ctx } opencl_ctx_t; +typedef enum kernel_workload +{ + KERNEL_ACCEL_MIN = 1, + KERNEL_ACCEL_MAX = 1024, + KERNEL_LOOPS_MIN = 1, + KERNEL_LOOPS_MAX = 1024, + KERNEL_THREADS_MIN = 1, + KERNEL_THREADS_MAX = 1024, + +} kernel_workload_t; + #include "ext_ADL.h" #include "ext_nvapi.h" #include "ext_nvml.h" diff --git a/src/hashcat.c b/src/hashcat.c index 4772362f5..355ebb957 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -438,6 +438,7 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx) static int outer_loop (hashcat_ctx_t *hashcat_ctx) { + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; @@ -732,56 +733,57 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx) * create self-test threads */ - EVENT (EVENT_SELFTEST_STARTING); - - thread_param_t *threads_param = (thread_param_t *) hccalloc (opencl_ctx->devices_cnt, sizeof (thread_param_t)); + if ((user_options->self_test_disable == false) && (hashconfig->st_hash != NULL) && (hashconfig->st_pass != NULL)) + { + EVENT (EVENT_SELFTEST_STARTING); - hc_thread_t *selftest_threads = (hc_thread_t *) hccalloc (opencl_ctx->devices_cnt, sizeof (hc_thread_t)); + thread_param_t *threads_param = (thread_param_t *) hccalloc (opencl_ctx->devices_cnt, sizeof (thread_param_t)); - status_ctx->devices_status = STATUS_SELFTEST; + hc_thread_t *selftest_threads = (hc_thread_t *) hccalloc (opencl_ctx->devices_cnt, sizeof (hc_thread_t)); - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - thread_param_t *thread_param = threads_param + device_id; + status_ctx->devices_status = STATUS_SELFTEST; - thread_param->hashcat_ctx = hashcat_ctx; - thread_param->tid = device_id; + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + thread_param_t *thread_param = threads_param + device_id; - hc_thread_create (selftest_threads[device_id], thread_selftest, thread_param); - } + thread_param->hashcat_ctx = hashcat_ctx; + thread_param->tid = device_id; - hc_thread_wait (opencl_ctx->devices_cnt, selftest_threads); + hc_thread_create (selftest_threads[device_id], thread_selftest, thread_param); + } - hcfree (threads_param); + hc_thread_wait (opencl_ctx->devices_cnt, selftest_threads); - hcfree (selftest_threads); + hcfree (threads_param); - // check for any selftest failures + hcfree (selftest_threads); - for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) - { - if (opencl_ctx->enabled == false) continue; + // check for any selftest failures - if (user_options->self_test_disable == true) continue; + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) + { + if (opencl_ctx->enabled == false) continue; - hc_device_param_t *device_param = opencl_ctx->devices_param + device_id; + hc_device_param_t *device_param = opencl_ctx->devices_param + device_id; - if (device_param->skipped == true) continue; + if (device_param->skipped == true) continue; - if (device_param->st_status == ST_STATUS_FAILED) - { - event_log_error (hashcat_ctx, "Aborting session due to kernel self-test failure."); + if (device_param->st_status == ST_STATUS_FAILED) + { + event_log_error (hashcat_ctx, "Aborting session due to kernel self-test failure."); - event_log_warning (hashcat_ctx, "You can use --self-test-disable to override this, but do not report related errors."); - event_log_warning (hashcat_ctx, NULL); + event_log_warning (hashcat_ctx, "You can use --self-test-disable to override this, but do not report related errors."); + event_log_warning (hashcat_ctx, NULL); - return -1; + return -1; + } } - } - status_ctx->devices_status = STATUS_INIT; + status_ctx->devices_status = STATUS_INIT; - EVENT (EVENT_SELFTEST_FINISHED); + EVENT (EVENT_SELFTEST_FINISHED); + } /** * (old) weak hash check is the first to write to potfile, so open it for writing from here diff --git a/src/interface.c b/src/interface.c index 6cfcdf6a1..6669f3378 100644 --- a/src/interface.c +++ b/src/interface.c @@ -602,20 +602,27 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) #undef CHECK_MANDATORY - if (module_ctx->module_attack_exec != MODULE_DEFAULT) hashconfig->attack_exec = module_ctx->module_attack_exec (hashconfig, user_options, user_options_extra); + hashconfig->attack_exec = module_ctx->module_attack_exec (hashconfig, user_options, user_options_extra); + hashconfig->dgst_pos0 = module_ctx->module_dgst_pos0 (hashconfig, user_options, user_options_extra); + hashconfig->dgst_pos1 = module_ctx->module_dgst_pos1 (hashconfig, user_options, user_options_extra); + hashconfig->dgst_pos2 = module_ctx->module_dgst_pos2 (hashconfig, user_options, user_options_extra); + hashconfig->dgst_pos3 = module_ctx->module_dgst_pos3 (hashconfig, user_options, user_options_extra); + hashconfig->dgst_size = module_ctx->module_dgst_size (hashconfig, user_options, user_options_extra); + hashconfig->hash_category = module_ctx->module_hash_category (hashconfig, user_options, user_options_extra); + hashconfig->hash_name = module_ctx->module_hash_name (hashconfig, user_options, user_options_extra); + hashconfig->hash_type = module_ctx->module_hash_type (hashconfig, user_options, user_options_extra); + hashconfig->kern_type = module_ctx->module_kern_type (hashconfig, user_options, user_options_extra); + hashconfig->opti_type = module_ctx->module_opti_type (hashconfig, user_options, user_options_extra); + hashconfig->opts_type = module_ctx->module_opts_type (hashconfig, user_options, user_options_extra); + hashconfig->salt_type = module_ctx->module_salt_type (hashconfig, user_options, user_options_extra); + hashconfig->st_hash = module_ctx->module_st_hash (hashconfig, user_options, user_options_extra); + hashconfig->st_pass = module_ctx->module_st_pass (hashconfig, user_options, user_options_extra); + if (module_ctx->module_benchmark_mask != MODULE_DEFAULT) hashconfig->benchmark_mask = module_ctx->module_benchmark_mask (hashconfig, user_options, user_options_extra); - if (module_ctx->module_dgst_pos0 != MODULE_DEFAULT) hashconfig->dgst_pos0 = module_ctx->module_dgst_pos0 (hashconfig, user_options, user_options_extra); - if (module_ctx->module_dgst_pos1 != MODULE_DEFAULT) hashconfig->dgst_pos1 = module_ctx->module_dgst_pos1 (hashconfig, user_options, user_options_extra); - if (module_ctx->module_dgst_pos2 != MODULE_DEFAULT) hashconfig->dgst_pos2 = module_ctx->module_dgst_pos2 (hashconfig, user_options, user_options_extra); - if (module_ctx->module_dgst_pos3 != MODULE_DEFAULT) hashconfig->dgst_pos3 = module_ctx->module_dgst_pos3 (hashconfig, user_options, user_options_extra); - if (module_ctx->module_dgst_size != MODULE_DEFAULT) hashconfig->dgst_size = module_ctx->module_dgst_size (hashconfig, user_options, user_options_extra); if (module_ctx->module_dictstat_disable != MODULE_DEFAULT) hashconfig->dictstat_disable = module_ctx->module_dictstat_disable (hashconfig, user_options, user_options_extra); if (module_ctx->module_esalt_size != MODULE_DEFAULT) hashconfig->esalt_size = module_ctx->module_esalt_size (hashconfig, user_options, user_options_extra); if (module_ctx->module_forced_outfile_format != MODULE_DEFAULT) hashconfig->forced_outfile_format = module_ctx->module_forced_outfile_format (hashconfig, user_options, user_options_extra); - if (module_ctx->module_hash_category != MODULE_DEFAULT) hashconfig->hash_category = module_ctx->module_hash_category (hashconfig, user_options, user_options_extra); if (module_ctx->module_hash_mode != MODULE_DEFAULT) hashconfig->hash_mode = module_ctx->module_hash_mode (hashconfig, user_options, user_options_extra); - if (module_ctx->module_hash_name != MODULE_DEFAULT) hashconfig->hash_name = module_ctx->module_hash_name (hashconfig, user_options, user_options_extra); - if (module_ctx->module_hash_type != MODULE_DEFAULT) hashconfig->hash_type = module_ctx->module_hash_type (hashconfig, user_options, user_options_extra); if (module_ctx->module_hlfmt_disable != MODULE_DEFAULT) hashconfig->hlfmt_disable = module_ctx->module_hlfmt_disable (hashconfig, user_options, user_options_extra); if (module_ctx->module_hook_salt_size != MODULE_DEFAULT) hashconfig->hook_salt_size = module_ctx->module_hook_salt_size (hashconfig, user_options, user_options_extra); if (module_ctx->module_hook_size != MODULE_DEFAULT) hashconfig->hook_size = module_ctx->module_hook_size (hashconfig, user_options, user_options_extra); @@ -625,18 +632,12 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) if (module_ctx->module_kernel_loops_max != MODULE_DEFAULT) hashconfig->kernel_loops_max = module_ctx->module_kernel_loops_max (hashconfig, user_options, user_options_extra); if (module_ctx->module_kernel_threads_min != MODULE_DEFAULT) hashconfig->kernel_threads_min = module_ctx->module_kernel_threads_min (hashconfig, user_options, user_options_extra); if (module_ctx->module_kernel_threads_max != MODULE_DEFAULT) hashconfig->kernel_threads_max = module_ctx->module_kernel_threads_max (hashconfig, user_options, user_options_extra); - if (module_ctx->module_kern_type != MODULE_DEFAULT) hashconfig->kern_type = module_ctx->module_kern_type (hashconfig, user_options, user_options_extra); - if (module_ctx->module_opti_type != MODULE_DEFAULT) hashconfig->opti_type = module_ctx->module_opti_type (hashconfig, user_options, user_options_extra); - if (module_ctx->module_opts_type != MODULE_DEFAULT) hashconfig->opts_type = module_ctx->module_opts_type (hashconfig, user_options, user_options_extra); if (module_ctx->module_outfile_check_disable != MODULE_DEFAULT) hashconfig->outfile_check_disable = module_ctx->module_outfile_check_disable (hashconfig, user_options, user_options_extra); if (module_ctx->module_outfile_check_nocomp != MODULE_DEFAULT) hashconfig->outfile_check_nocomp = module_ctx->module_outfile_check_nocomp (hashconfig, user_options, user_options_extra); if (module_ctx->module_potfile_disable != MODULE_DEFAULT) hashconfig->potfile_disable = module_ctx->module_potfile_disable (hashconfig, user_options, user_options_extra); if (module_ctx->module_potfile_keep_all_hashes != MODULE_DEFAULT) hashconfig->potfile_keep_all_hashes = module_ctx->module_potfile_keep_all_hashes (hashconfig, user_options, user_options_extra); if (module_ctx->module_pwdump_column != MODULE_DEFAULT) hashconfig->pwdump_column = module_ctx->module_pwdump_column (hashconfig, user_options, user_options_extra); - if (module_ctx->module_salt_type != MODULE_DEFAULT) hashconfig->salt_type = module_ctx->module_salt_type (hashconfig, user_options, user_options_extra); if (module_ctx->module_separator != MODULE_DEFAULT) hashconfig->separator = module_ctx->module_separator (hashconfig, user_options, user_options_extra); - if (module_ctx->module_st_hash != MODULE_DEFAULT) hashconfig->st_hash = module_ctx->module_st_hash (hashconfig, user_options, user_options_extra); - if (module_ctx->module_st_pass != MODULE_DEFAULT) hashconfig->st_pass = module_ctx->module_st_pass (hashconfig, user_options, user_options_extra); if (module_ctx->module_tmp_size != MODULE_DEFAULT) hashconfig->tmp_size = module_ctx->module_tmp_size (hashconfig, user_options, user_options_extra); if (module_ctx->module_unstable_warning != MODULE_DEFAULT) hashconfig->unstable_warning = module_ctx->module_unstable_warning (hashconfig, user_options, user_options_extra); if (module_ctx->module_warmup_disable != MODULE_DEFAULT) hashconfig->warmup_disable = module_ctx->module_warmup_disable (hashconfig, user_options, user_options_extra); diff --git a/src/interface_migrate.c b/src/interface_migrate.c index 2f1925753..9395694d5 100644 --- a/src/interface_migrate.c +++ b/src/interface_migrate.c @@ -129,7 +129,6 @@ " 15300 | DPAPI masterkey file v1 | Operating Systems", " 15900 | DPAPI masterkey file v2 | Operating Systems", " 12800 | MS-AzureSync PBKDF2-HMAC-SHA256 | Operating Systems", - " 1500 | descrypt, DES (Unix), Traditional DES | Operating Systems", " 12400 | BSDi Crypt, Extended DES | Operating Systems", " 3200 | bcrypt $2*$, Blowfish (Unix) | Operating Systems", " 7400 | sha256crypt $5$, SHA256 (Unix) | Operating Systems", @@ -272,7 +271,6 @@ static const char *ST_PASS_HEX_16801 = "5b13d4babb3714ccc62c9f71864bc984efd6 /** * Missing self-test hashes: * - * ST_HASH_01500 the self-test can't work because the salt is part of the code at compile-time * ST_HASH_08900 the self-test can't work because the scrypt settings is part of the code at compile-time * ST_HASH_1374x missing example hash * ST_HASH_1376x missing example hash @@ -316,7 +314,6 @@ static const char *ST_HASH_01440 = "84ebe1bc3d59919a8c4f9337d66bd163661586c828b2 static const char *ST_HASH_01441 = "$episerver$*1*NDg1NTIz*8BFCg/YJBAuZs/wjbH3OWKe69BLr5Lao26ybpnD48Zk"; static const char *ST_HASH_01450 = "b435ffbacea34d5eb0dbc4d69a92f0152f2cf4cd364d34c2ece322ca22d8b334:21217"; static const char *ST_HASH_01460 = "8b9472281c36c3a693703de0e0f1ffab8fc0ecdd3bc5ead04c76dd74ef431e49:70108387805"; -//static const char *ST_HASH_01500 = "8133vc.5rieNk"; static const char *ST_HASH_01600 = "$apr1$62722340$zGjeAwVP2KwY6MtumUI1N/"; static const char *ST_HASH_01710 = "3f749c84d00c6f94a6651b5c195c71dacae08f3cea6fed760232856cef701f7bf60d7f38a587f69f159d4e4cbe00435aeb9c8c0a4927b252d76a744e16e87e91:388026522082"; static const char *ST_HASH_01711 = "{SSHA512}Bz8w5q6qEtB1Nnc8b1jfTvTXVTwohWag33oghQGOtLChnkZTw/cuJaHQlLJEI3AWKZGCRyLA6Phujdxo+is7AjA2MDcyNjY1Mg=="; @@ -538,7 +535,6 @@ static const char *HT_01430 = "sha256(utf16le($pass).$salt)"; static const char *HT_01440 = "sha256($salt.utf16le($pass))"; static const char *HT_01450 = "HMAC-SHA256 (key = $pass)"; static const char *HT_01460 = "HMAC-SHA256 (key = $salt)"; -static const char *HT_01500 = "descrypt, DES (Unix), Traditional DES"; static const char *HT_01600 = "Apache $apr1$ MD5, md5apr1, MD5 (APR)"; static const char *HT_01710 = "sha512($pass.$salt)"; static const char *HT_01720 = "sha512($salt.$pass)"; @@ -4017,68 +4013,6 @@ int episerver_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_ return (PARSER_OK); } -int descrypt_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig) -{ - u32 *digest = (u32 *) hash_buf->digest; - - salt_t *salt = hash_buf->salt; - - token_t token; - - token.token_cnt = 2; - - token.len[0] = 2; - token.attr[0] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_BASE64B; - - token.len[1] = 11; - token.attr[1] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_BASE64B; - - const int rc_tokenizer = input_tokenizer (input_buf, input_len, &token); - - if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - - const u8 *salt_pos = token.buf[0]; - const u8 *hash_pos = token.buf[1]; - - const int hash_len = token.len[1]; - - const u8 c10 = itoa64_to_int (hash_pos[10]); - - if (c10 & 3) return (PARSER_HASH_VALUE); - - // for ascii_to_ebcdic_digest - salt->salt_sign[0] = salt_pos[0]; - salt->salt_sign[1] = salt_pos[1]; - - salt->salt_buf[0] = itoa64_to_int (salt_pos[0]) - | itoa64_to_int (salt_pos[1]) << 6; - - // we need to add 2 additional bytes (the salt sign) such that the salt sorting algorithm - // doesn't eliminate salts that are identical but have different salt signs - - salt->salt_buf[0] |= salt_pos[0] << 16 - | salt_pos[1] << 24; - - salt->salt_len = 4; // actually it is only 2 (but we need to add the original salt_sign to it) - - u8 tmp_buf[100] = { 0 }; - - base64_decode (itoa64_to_int, hash_pos, hash_len, tmp_buf); - - memcpy (digest, tmp_buf, 8); - - u32 tt; - - IP (digest[0], digest[1], tt); - - digest[2] = 0; - digest[3] = 0; - - return (PARSER_OK); -} - int md4_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig) { u32 *digest = (u32 *) hash_buf->digest; @@ -18017,10 +17951,7 @@ u32 kernel_loops_mxx (hashcat_ctx_t *hashcat_ctx) } else { - if (hashconfig->hash_mode == 1500 && user_options->attack_mode == ATTACK_MODE_BF) - { - kernel_loops_fixed = 1024; - } + // respect the slow_candidates, too if (hashconfig->hash_mode == 3000 && user_options->attack_mode == ATTACK_MODE_BF) { @@ -18111,9 +18042,6 @@ void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, vo { case 22: salt->salt_len = 30; break; - case 1500: salt->salt_len = 2; - salt->salt_buf[0] = 388; // pure magic - break; case 1731: salt->salt_len = 4; break; case 2410: salt->salt_len = 4; @@ -18759,29 +18687,6 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const int out_size, snprintf (out_buf, out_size, "%s*1*%s*%s", SIGNATURE_EPISERVER, ptr_salt, ptr_plain); } - else if (hash_mode == 1500) - { - out_buf[0] = salt.salt_sign[0] & 0xff; - out_buf[1] = salt.salt_sign[1] & 0xff; - //original method, but changed because of this ticket: https://hashcat.net/trac/ticket/269 - //out_buf[0] = int_to_itoa64 ((salt.salt_buf[0] >> 0) & 0x3f); - //out_buf[1] = int_to_itoa64 ((salt.salt_buf[0] >> 6) & 0x3f); - - memset (tmp_buf, 0, sizeof (tmp_buf)); - - // the encoder is a bit too intelligent, it expects the input data in the wrong BOM - - digest_buf[0] = byte_swap_32 (digest_buf[0]); - digest_buf[1] = byte_swap_32 (digest_buf[1]); - - memcpy (tmp_buf, digest_buf, 8); - - base64_encode (int_to_itoa64, (const u8 *) tmp_buf, 8, (u8 *) ptr_plain); - - snprintf (out_buf + 2, out_len - 2, "%s", ptr_plain); - - out_buf[13] = 0; - } else if (hash_mode == 1600) { // the encoder is a bit too intelligent, it expects the input data in the wrong BOM @@ -22990,24 +22895,6 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->st_pass = ST_PASS_HASHCAT_PLAIN; break; - case 1500: hashconfig->hash_type = HASH_TYPE_DESCRYPT; - hashconfig->salt_type = SALT_TYPE_EMBEDDED; - hashconfig->attack_exec = ATTACK_EXEC_INSIDE_KERNEL; - hashconfig->opts_type = OPTS_TYPE_PT_GENERATE_LE - | OPTS_TYPE_PT_BITSLICE; - hashconfig->kern_type = KERN_TYPE_DESCRYPT; - hashconfig->dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2 - hashconfig->parse_func = descrypt_parse_hash; - hashconfig->opti_type = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_PRECOMPUTE_PERMUT; - hashconfig->dgst_pos0 = 0; - hashconfig->dgst_pos1 = 1; - hashconfig->dgst_pos2 = 2; - hashconfig->dgst_pos3 = 3; - hashconfig->st_hash = NULL; - hashconfig->st_pass = ST_PASS_HASHCAT_PLAIN; - break; - case 1600: hashconfig->hash_type = HASH_TYPE_MD5; hashconfig->salt_type = SALT_TYPE_EMBEDDED; hashconfig->attack_exec = ATTACK_EXEC_OUTSIDE_KERNEL; @@ -27269,7 +27156,6 @@ u32 default_pw_max (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED co switch (hashconfig->hash_mode) { case 112: pw_max = 30; break; // https://www.toadworld.com/platforms/oracle/b/weblog/archive/2013/11/12/oracle-12c-passwords - case 1500: pw_max = 8; break; // Underlaying DES max case 2100: pw_max = PW_MAX; break; case 2500: pw_max = 63; break; // WPA-EAPOL-PBKDF2: limits itself to 63 by RFC case 2501: pw_max = 64; break; // WPA-EAPOL-PMK: fixed length @@ -28059,10 +27945,6 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY { opencl_ctx->force_jit_compilation = 15700; } - else if (hashconfig->hash_mode == 1500 && user_options->attack_mode == ATTACK_MODE_BF && hashes->salts_cnt == 1 && user_options->slow_candidates == false) - { - opencl_ctx->force_jit_compilation = 1500; - } // scryptV stuff @@ -28214,11 +28096,6 @@ char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAY size_t size_scrypt4 = size_scrypt / 4; - - if (opencl_ctx->force_jit_compilation == 1500) - { - hc_asprintf (&build_opts_update, "%s -DDESCRYPT_SALT=%u", build_opts, hashes->salts_buf[0].salt_buf[0]); - } else if ((opencl_ctx->force_jit_compilation == 8900) || (opencl_ctx->force_jit_compilation == 15700)) { hc_asprintf (&build_opts_update,"%s -DSCRYPT_N=%u -DSCRYPT_R=%u -DSCRYPT_P=%u -DSCRYPT_TMTO=%u -DSCRYPT_TMP_ELEM=%" PRIu64, build_opts, hashes->salts_buf[0].scrypt_N, hashes->salts_buf[0].scrypt_r, hashes->salts_buf[0].scrypt_p, 1u << scrypt_tmto_final, (u64) scrypt_tmp_size / 16); @@ -28236,7 +28113,7 @@ bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE * too high kernel runtime, even on -u1 -n1, therefore likely to run into trap 6 */ - if ((hashconfig->hash_mode == 1500) + if ( || (hashconfig->hash_mode == 3000) || (hashconfig->hash_mode == 3200) || (hashconfig->hash_mode == 8900) diff --git a/src/modules/module_01000.c b/src/modules/module_01000.c index 9a908ae98..d7b7e410c 100644 --- a/src/modules/module_01000.c +++ b/src/modules/module_01000.c @@ -16,7 +16,7 @@ static const u32 DGST_POS1 = 3; static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_4; -static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH; +static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; static const char *HASH_NAME = "NTLM"; static const u32 HASH_TYPE = HASH_TYPE_MD4; static const u64 KERN_TYPE = 1000; diff --git a/src/modules/module_01500.c b/src/modules/module_01500.c new file mode 100644 index 000000000..f62ce2dab --- /dev/null +++ b/src/modules/module_01500.c @@ -0,0 +1,268 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "modules.h" +#include "bitops.h" +#include "convert.h" +#include "shared.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +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; // originally DGST_SIZE_4_2 +static const u32 HASH_CATEGORY = HASH_CATEGORY_OS; +static const char *HASH_NAME = "descrypt, DES (Unix), Traditional DES"; +static const u32 HASH_TYPE = HASH_TYPE_DESCRYPT; +static const u64 KERN_TYPE = 1500; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_PERMUT; +static const u64 OPTS_TYPE = OPTS_TYPE_STATE_BUFFER_LE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_BITSLICE; +static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED; +static const char *ST_PASS = NULL; // the self-test can't work because the salt is not part of the code at compile-time +static const char *ST_HASH = "8133vc.5rieNk"; + +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; } +u32 module_dgst_pos1 (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_POS1; } +u32 module_dgst_pos2 (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_POS2; } +u32 module_dgst_pos3 (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_POS3; } +u32 module_dgst_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) { return DGST_SIZE; } +u32 module_hash_category (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 HASH_CATEGORY; } +const char *module_hash_name (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 HASH_NAME; } +u32 module_hash_type (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 HASH_TYPE; } +u64 module_kern_type (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 KERN_TYPE; } +u32 module_opti_type (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 OPTI_TYPE; } +u64 module_opts_type (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 OPTS_TYPE; } +u32 module_salt_type (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 SALT_TYPE; } +const char *module_st_hash (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 ST_HASH; } +const char *module_st_pass (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 ST_PASS; } + +u32 module_kernel_loops_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) +{ + u32 kernel_loops_max = KERNEL_LOOPS_MAX; + + if (user_options->slow_candidates == false) + { + if (user_options->attack_mode == ATTACK_MODE_BF) + { + kernel_loops_max = 1024; + } + } + + return kernel_loops_max; +} + +u32 module_kernel_loops_min (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + u32 kernel_loops_min = KERNEL_LOOPS_MIN; + + if (user_options->slow_candidates == false) + { + if (user_options->attack_mode == ATTACK_MODE_BF) + { + kernel_loops_min = 1024; + } + } + + return kernel_loops_min; +} + +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) +{ + const u32 pw_max = 8; // Underlaying DES max + + return pw_max; +} + +char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param) +{ + char *jit_build_options = NULL; + + if ((user_options->attack_mode == ATTACK_MODE_BF) && (hashes->salts_cnt == 1) && (user_options->slow_candidates == false)) + { + hc_asprintf (&jit_build_options, "-DDESCRYPT_SALT=%u", hashes->salts_buf[0].salt_buf[0] & 0xfff); + } + + return jit_build_options; +} + +bool module_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) +{ + #if defined (__APPLE__) + return true; + #endif // __APPLE__ + + return false; +} + +int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len) +{ + u32 *digest = (u32 *) digest_buf; + + token_t token; + + token.token_cnt = 2; + + token.len[0] = 2; + token.attr[0] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64B; + + token.len[1] = 11; + token.attr[1] = TOKEN_ATTR_FIXED_LENGTH + | TOKEN_ATTR_VERIFY_BASE64B; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + const u8 *salt_pos = token.buf[0]; + const u8 *hash_pos = token.buf[1]; + + const int hash_len = token.len[1]; + + const u8 c10 = itoa64_to_int (hash_pos[10]); + + if (c10 & 3) return (PARSER_HASH_VALUE); + + // for ascii_to_ebcdic_digest + salt->salt_sign[0] = salt_pos[0]; + salt->salt_sign[1] = salt_pos[1]; + + salt->salt_buf[0] = itoa64_to_int (salt_pos[0]) + | itoa64_to_int (salt_pos[1]) << 6; + + // we need to add 2 additional bytes (the salt sign) such that the salt sorting algorithm + // doesn't eliminate salts that are identical but have different salt signs + + salt->salt_buf[0] |= salt_pos[0] << 16 + | salt_pos[1] << 24; + + salt->salt_len = 4; // actually it is only 2 (but we need to add the original salt_sign to it) + + u32 tmp[16] = { 0 }; + + base64_decode (itoa64_to_int, hash_pos, hash_len, (u8 *) tmp); + + digest[0] = tmp[0]; + digest[1] = tmp[1]; + digest[2] = 0; + digest[3] = 0; + + decoder_apply_options (hashconfig, digest); + + decoder_apply_optimizer (hashconfig, digest); + + 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 hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size) +{ + const u32 *digest = (const u32 *) digest_buf; + + // we can not change anything in the original buffer, otherwise destroying sorting + // therefore create some local buffer + + u32 tmp[4]; + + tmp[0] = digest[0]; + tmp[1] = digest[1]; + tmp[2] = 0; + tmp[3] = 0; + + encoder_apply_optimizer (hashconfig, tmp); + + encoder_apply_options (hashconfig, tmp); + + u8 ptr_plain[20] = { 0 }; + + base64_encode (int_to_itoa64, (const u8 *) tmp, 8, ptr_plain); + + line_buf[0] = salt->salt_sign[0] & 0xff; + line_buf[1] = salt->salt_sign[1] & 0xff; + + //original method, but changed because of this ticket: https://hashcat.net/trac/ticket/269 + //line_buf[0] = int_to_itoa64 ((salt->salt_buf[0] >> 0) & 0x3f); + //line_buf[1] = int_to_itoa64 ((salt->salt_buf[0] >> 6) & 0x3f); + + snprintf (line_buf + 2, line_size - 2, "%s", ptr_plain); + + const int out_len = 2 + 11; + + return out_len; +} + +void module_init (module_ctx_t *module_ctx) +{ + module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT; + module_ctx->module_interface_version = MODULE_INTERFACE_VERSION_CURRENT; + + module_ctx->module_attack_exec = module_attack_exec; + module_ctx->module_benchmark_esalt = MODULE_DEFAULT; + module_ctx->module_benchmark_hook_salt = MODULE_DEFAULT; + module_ctx->module_benchmark_mask = MODULE_DEFAULT; + module_ctx->module_benchmark_salt = MODULE_DEFAULT; + module_ctx->module_build_plain_postprocess = MODULE_DEFAULT; + module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; + module_ctx->module_dgst_pos0 = module_dgst_pos0; + module_ctx->module_dgst_pos1 = module_dgst_pos1; + module_ctx->module_dgst_pos2 = module_dgst_pos2; + 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_DEFAULT; + module_ctx->module_extra_buffer_size = MODULE_DEFAULT; + module_ctx->module_forced_outfile_format = MODULE_DEFAULT; + module_ctx->module_hash_binary_count = MODULE_DEFAULT; + module_ctx->module_hash_binary_parse = MODULE_DEFAULT; + module_ctx->module_hash_binary_save = MODULE_DEFAULT; + module_ctx->module_hash_binary_verify = MODULE_DEFAULT; + module_ctx->module_hash_decode_outfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + module_ctx->module_hash_category = module_hash_category; + module_ctx->module_hash_name = module_hash_name; + module_ctx->module_hash_type = module_hash_type; + module_ctx->module_hlfmt_disable = MODULE_DEFAULT; + module_ctx->module_hook12 = MODULE_DEFAULT; + module_ctx->module_hook23 = MODULE_DEFAULT; + module_ctx->module_hook_salt_size = MODULE_DEFAULT; + module_ctx->module_hook_size = MODULE_DEFAULT; + module_ctx->module_jit_build_options = module_jit_build_options; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = module_kernel_loops_max; + module_ctx->module_kernel_loops_min = module_kernel_loops_min; + module_ctx->module_kernel_threads_max = MODULE_DEFAULT; + module_ctx->module_kernel_threads_min = MODULE_DEFAULT; + module_ctx->module_kern_type = module_kern_type; + module_ctx->module_opti_type = module_opti_type; + module_ctx->module_opts_type = module_opts_type; + module_ctx->module_outfile_check_disable = MODULE_DEFAULT; + module_ctx->module_outfile_check_nocomp = MODULE_DEFAULT; + module_ctx->module_potfile_disable = MODULE_DEFAULT; + module_ctx->module_potfile_keep_all_hashes = MODULE_DEFAULT; + module_ctx->module_pwdump_column = MODULE_DEFAULT; + module_ctx->module_pw_max = module_pw_max; + module_ctx->module_pw_min = MODULE_DEFAULT; + module_ctx->module_salt_max = MODULE_DEFAULT; + module_ctx->module_salt_min = MODULE_DEFAULT; + module_ctx->module_salt_type = module_salt_type; + module_ctx->module_separator = MODULE_DEFAULT; + module_ctx->module_st_hash = module_st_hash; + module_ctx->module_st_pass = module_st_pass; + module_ctx->module_tmp_size = MODULE_DEFAULT; + module_ctx->module_unstable_warning = module_unstable_warning; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +} diff --git a/src/opencl.c b/src/opencl.c index c6214de87..0d7de4ff2 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -5024,11 +5024,20 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if (CL_rc == -1) return -1; + char *build_opts_update; + char *jit_build_options = module_ctx->module_jit_build_options (hashconfig, user_options, user_options_extra, hashes, device_param); - char *build_opts_update; + if (jit_build_options != NULL) + { + hc_asprintf (&build_opts_update, "%s %s", build_opts, jit_build_options); - hc_asprintf (&build_opts_update, "%s %s", build_opts, jit_build_options); + hcfree (jit_build_options); + } + else + { + build_opts_update = hcstrdup (build_opts); + } CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program, 1, &device_param->device, build_opts_update, NULL, NULL); diff --git a/src/shared.c b/src/shared.c index f136edc73..d317c5ca4 100644 --- a/src/shared.c +++ b/src/shared.c @@ -1138,22 +1138,22 @@ void decoder_apply_optimizer (const hashconfig_t *hashconfig, void *data) switch (hash_type) { case HASH_TYPE_DES: - FP (digest_buf[1], digest_buf[0], tt); + IP (digest_buf[0], digest_buf[1], tt); break; case HASH_TYPE_DESCRYPT: - FP (digest_buf[1], digest_buf[0], tt); + IP (digest_buf[0], digest_buf[1], tt); break; case HASH_TYPE_DESRACF: digest_buf[0] = rotl32 (digest_buf[0], 29); digest_buf[1] = rotl32 (digest_buf[1], 29); - FP (digest_buf[1], digest_buf[0], tt); + IP (digest_buf[0], digest_buf[1], tt); break; case HASH_TYPE_LM: - FP (digest_buf[1], digest_buf[0], tt); + IP (digest_buf[0], digest_buf[1], tt); break; case HASH_TYPE_NETNTLM: @@ -1162,15 +1162,15 @@ void decoder_apply_optimizer (const hashconfig_t *hashconfig, void *data) digest_buf[2] = rotl32 (digest_buf[2], 29); digest_buf[3] = rotl32 (digest_buf[3], 29); - FP (digest_buf[1], digest_buf[0], tt); - FP (digest_buf[3], digest_buf[2], tt); + IP (digest_buf[0], digest_buf[1], tt); + IP (digest_buf[2], digest_buf[3], tt); break; case HASH_TYPE_BSDICRYPT: digest_buf[0] = rotl32 (digest_buf[0], 31); digest_buf[1] = rotl32 (digest_buf[1], 31); - FP (digest_buf[1], digest_buf[0], tt); + IP (digest_buf[0], digest_buf[1], tt); break; } }