From 91f6d7c32e821d0b4fdae21b9c51dc5044204455 Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 26 Jan 2019 21:13:53 +0100 Subject: [PATCH] Add -m 99999 module --- include/interface_migrate.h | 1 - src/Makefile | 2 +- src/interface_migrate.c | 35 ------- src/modules/module_99999.c | 189 ++++++++++++++++++++++++++++++++++++ 4 files changed, 190 insertions(+), 37 deletions(-) create mode 100644 src/modules/module_99999.c diff --git a/include/interface_migrate.h b/include/interface_migrate.h index e96056e05..8177aa7f9 100644 --- a/include/interface_migrate.h +++ b/include/interface_migrate.h @@ -883,7 +883,6 @@ typedef enum kern_type KERN_TYPE_ANSIBLE_VAULT = 16900, KERN_TYPE_TOTP_HMACSHA1 = 18100, KERN_TYPE_APFS = 18300, - KERN_TYPE_PLAINTEXT = 99999, } kern_type_t; diff --git a/src/Makefile b/src/Makefile index 873261a42..5b196c0f6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -389,7 +389,7 @@ WIN_64_OBJS += $(foreach OBJ,$(OBJS_XXHASH),obj/$(OBJ).WIN.64.o) endif endif -MODULE_OBJS_ALL := bitops convert cpu_aes cpu_crc32 cpu_des cpu_md5 ext_lzma filehandling keyboard_layout memory shared +MODULE_OBJS_ALL := bitops convert cpu_aes cpu_crc32 cpu_des cpu_md4 cpu_md5 ext_lzma filehandling keyboard_layout memory shared ifeq ($(USE_SYSTEM_LZMA),0) MODULE_OBJS_ALL += Alloc Lzma2Dec LzmaDec diff --git a/src/interface_migrate.c b/src/interface_migrate.c index 54e275c83..9b26d10bc 100644 --- a/src/interface_migrate.c +++ b/src/interface_migrate.c @@ -201,7 +201,6 @@ " 16300 | Ethereum Pre-Sale Wallet, PBKDF2-HMAC-SHA256 | Password Managers", " 16900 | Ansible Vault | Password Managers", " 18100 | TOTP (HMAC-SHA1) | One-Time Passwords", - " 99999 | Plaintext | Plaintext", static const char *ST_PASS_HASHCAT_PLAIN = "hashcat"; @@ -414,7 +413,6 @@ static const char *ST_HASH_16700 = "$fvde$1$16$84286044060108438487434858307513$ static const char *ST_HASH_16900 = "$ansible$0*0*6b761adc6faeb0cc0bf197d3d4a4a7d3f1682e4b169cae8fa6b459b3214ed41e*426d313c5809d4a80a4b9bc7d4823070*d8bad190c7fbc7c3cb1c60a27abfb0ff59d6fb73178681c7454d94a0f56a4360"; static const char *ST_HASH_18100 = "597056:3600"; static const char *ST_HASH_18300 = "$fvde$2$16$58778104701476542047675521040224$20000$39602e86b7cea4a34f4ff69ff6ed706d68954ee474de1d2a9f6a6f2d24d172001e484c1d4eaa237d"; -static const char *ST_HASH_99999 = "hashcat"; static const char *HT_00030 = "md5(utf16le($pass).$salt)"; @@ -568,7 +566,6 @@ static const char *HT_16700 = "FileVault 2"; static const char *HT_16900 = "Ansible Vault"; static const char *HT_18100 = "TOTP (HMAC-SHA1)"; static const char *HT_18300 = "Apple File System (APFS)"; -static const char *HT_99999 = "Plaintext"; static const char *HT_00022 = "Juniper NetScreen/SSG (ScreenOS)"; static const char *HT_00023 = "Skype"; @@ -17557,12 +17554,6 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const int out_size, byte_swap_32 (apple_secure_notes->ZCRYPTOWRAPPEDKEY[8]), byte_swap_32 (apple_secure_notes->ZCRYPTOWRAPPEDKEY[9])); } - else if (hash_mode == 99999) - { - char *ptr = (char *) digest_buf; - - snprintf (out_buf, out_size, "%s", ptr + 64); - } else { if (hash_type == HASH_TYPE_MD4) @@ -21670,32 +21661,6 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->st_pass = ST_PASS_HASHCAT_PLAIN; break; - case 99999: hashconfig->hash_type = HASH_TYPE_PLAINTEXT; - hashconfig->salt_type = SALT_TYPE_NONE; - hashconfig->attack_exec = ATTACK_EXEC_INSIDE_KERNEL; - hashconfig->opts_type = OPTS_TYPE_PT_GENERATE_LE - | OPTS_TYPE_PT_ADD80 - | OPTS_TYPE_PT_ADDBITS14; - hashconfig->kern_type = KERN_TYPE_MD4; - hashconfig->dgst_size = DGST_SIZE_4_32; // originally DGST_SIZE_4_2 - hashconfig->parse_func = plaintext_parse_hash; - hashconfig->opti_type = OPTI_TYPE_ZERO_BYTE - | OPTI_TYPE_PRECOMPUTE_INIT - | OPTI_TYPE_PRECOMPUTE_MERKLE - | OPTI_TYPE_MEET_IN_MIDDLE - | OPTI_TYPE_EARLY_SKIP - | OPTI_TYPE_NOT_ITERATED - | OPTI_TYPE_NOT_SALTED - | OPTI_TYPE_RAW_HASH; - hashconfig->dgst_pos0 = 0; - hashconfig->dgst_pos1 = 3; - hashconfig->dgst_pos2 = 2; - hashconfig->dgst_pos3 = 1; - hashconfig->st_hash = ST_HASH_99999; - hashconfig->st_pass = ST_PASS_HASHCAT_PLAIN; - break; - - default: return -1; } // esalt_size diff --git a/src/modules/module_99999.c b/src/modules/module_99999.c new file mode 100644 index 000000000..d089a2817 --- /dev/null +++ b/src/modules/module_99999.c @@ -0,0 +1,189 @@ + +/** + * 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" +#include "cpu_md4.h" +#include "inc_hash_constants.h" + +static const u32 ATTACK_EXEC = ATTACK_EXEC_INSIDE_KERNEL; +static const u32 DGST_POS0 = 0; +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_32; // originally DGST_SIZE_4_; +static const u32 HASH_CATEGORY = HASH_CATEGORY_PLAIN; +static const char *HASH_NAME = "Plaintext"; +static const u32 HASH_TYPE = HASH_TYPE_MD4; +static const u64 KERN_TYPE = 1000; +static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE + | OPTI_TYPE_PRECOMPUTE_INIT + | OPTI_TYPE_PRECOMPUTE_MERKLE + | OPTI_TYPE_MEET_IN_MIDDLE + | OPTI_TYPE_EARLY_SKIP + | OPTI_TYPE_NOT_ITERATED + | OPTI_TYPE_NOT_SALTED + | OPTI_TYPE_RAW_HASH; +static const u64 OPTS_TYPE = OPTS_TYPE_STATE_BUFFER_LE + | OPTS_TYPE_PT_GENERATE_LE + | OPTS_TYPE_PT_ADD80 + | OPTS_TYPE_PT_ADDBITS14; +static const u32 SALT_TYPE = SALT_TYPE_NONE; +static const char *ST_PASS = "hashcat"; +static const char *ST_HASH = "hashcat"; + +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; } + +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 void *hook_salt_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 = 1; + + token.len_min[0] = 1; + token.len_max[0] = 55; + token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; + + const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token); + + if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); + + memset (digest, 0, hashconfig->dgst_size); + + const u8 *pw_buf = token.buf[0]; + const int pw_len = token.len[0]; + + memcpy ((char *) digest + 64, pw_buf, pw_len); + + //strncpy ((char *) digest + 64, (char *) input_buf, 64); + + u32 w[16] = { 0 }; + + //strncpy ((char *) w, (char *) input_buf, 64); + + memcpy (w, pw_buf, pw_len); + + u8 *w_ptr = (u8 *) w; + + w_ptr[line_len] = 0x80; + + w[14] = line_len * 8; + + u32 dgst[4]; + + dgst[0] = MD4M_A; + dgst[1] = MD4M_B; + dgst[2] = MD4M_C; + dgst[3] = MD4M_D; + + md4_64 (w, dgst); + + decoder_apply_options (hashconfig, dgst); + + decoder_apply_optimizer (hashconfig, dgst); + + digest[0] = dgst[0]; + digest[1] = dgst[1]; + digest[2] = dgst[2]; + digest[3] = dgst[3]; + + 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) +{ + char *ptr = (char *) digest_buf; + + return snprintf (line_buf, line_size, "%s", ptr + 64); +} + +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_category = module_hash_category; + module_ctx->module_hash_decode = module_hash_decode; + module_ctx->module_hash_decode_outfile = MODULE_DEFAULT; + module_ctx->module_hash_decode_zero_hash = MODULE_DEFAULT; + module_ctx->module_hash_encode = module_hash_encode; + module_ctx->module_hash_encode_status = MODULE_DEFAULT; + module_ctx->module_hash_init_selftest = MODULE_DEFAULT; + module_ctx->module_hash_mode = MODULE_DEFAULT; + 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_DEFAULT; + module_ctx->module_kernel_accel_max = MODULE_DEFAULT; + module_ctx->module_kernel_accel_min = MODULE_DEFAULT; + module_ctx->module_kernel_loops_max = MODULE_DEFAULT; + module_ctx->module_kernel_loops_min = MODULE_DEFAULT; + 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_DEFAULT; + 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_DEFAULT; + module_ctx->module_warmup_disable = MODULE_DEFAULT; +}