From 6a33be5ea505634ad6430fe6fb97c49d0b4cfaf9 Mon Sep 17 00:00:00 2001 From: jsteube Date: Thu, 7 Feb 2019 17:11:49 +0100 Subject: [PATCH] Get rid of module_build_plain_postprocess() --- include/modules.h | 2 +- src/hashes.c | 2 +- src/modules/module_06241.c | 14 +++++++++++++- src/modules/module_06242.c | 14 +++++++++++++- src/modules/module_06243.c | 14 +++++++++++++- src/modules/module_18100.c | 2 +- 6 files changed, 42 insertions(+), 6 deletions(-) diff --git a/include/modules.h b/include/modules.h index d681a08e7..fc6897fda 100644 --- a/include/modules.h +++ b/include/modules.h @@ -72,6 +72,6 @@ int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *ha void module_hook12 (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 pws_cnt); -int module_build_plain_postprocess (const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, 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, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz); #endif // _MODULES_H diff --git a/src/hashes.c b/src/hashes.c index 3b9f5075b..c716572bb 100644 --- a/src/hashes.c +++ b/src/hashes.c @@ -285,7 +285,7 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl { u32 temp_buf[64] = { 0 }; - const int temp_len = module_ctx->module_build_plain_postprocess (plain_buf, sizeof (plain_buf), plain_len, temp_buf, sizeof (temp_buf)); + const int temp_len = module_ctx->module_build_plain_postprocess (hashcat_ctx->hashconfig, hashcat_ctx->hashes, plain_buf, sizeof (plain_buf), plain_len, temp_buf, sizeof (temp_buf)); if (temp_len < (int) sizeof (plain_buf)) { diff --git a/src/modules/module_06241.c b/src/modules/module_06241.c index c6b1300e2..850f49346 100644 --- a/src/modules/module_06241.c +++ b/src/modules/module_06241.c @@ -73,6 +73,18 @@ typedef struct tc static const int ROUNDS_TRUECRYPT_1K = 1000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + const tc_t *tc = (const tc_t *) hashes->esalts_buf; + + if (src_len < (int) dst_sz) + { + memcpy (dst_buf, src_buf, src_len); + } + + return execute_keyboard_layout_mapping (dst_buf, src_len, tc->keyboard_layout_mapping_buf, tc->keyboard_layout_mapping_cnt); +} + bool module_potfile_disable (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 bool potfile_disable = true; @@ -243,7 +255,7 @@ void module_init (module_ctx_t *module_ctx) 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_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; diff --git a/src/modules/module_06242.c b/src/modules/module_06242.c index 1b54b0d1c..8f630a9e4 100644 --- a/src/modules/module_06242.c +++ b/src/modules/module_06242.c @@ -73,6 +73,18 @@ typedef struct tc static const int ROUNDS_TRUECRYPT_1K = 1000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + const tc_t *tc = (const tc_t *) hashes->esalts_buf; + + if (src_len < (int) dst_sz) + { + memcpy (dst_buf, src_buf, src_len); + } + + return execute_keyboard_layout_mapping (dst_buf, src_len, tc->keyboard_layout_mapping_buf, tc->keyboard_layout_mapping_cnt); +} + bool module_potfile_disable (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 bool potfile_disable = true; @@ -243,7 +255,7 @@ void module_init (module_ctx_t *module_ctx) 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_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; diff --git a/src/modules/module_06243.c b/src/modules/module_06243.c index 8a3b666ea..0d339cd8c 100644 --- a/src/modules/module_06243.c +++ b/src/modules/module_06243.c @@ -73,6 +73,18 @@ typedef struct tc static const int ROUNDS_TRUECRYPT_1K = 1000; static const float MIN_SUFFICIENT_ENTROPY_FILE = 7.0f; +int module_build_plain_postprocess (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const hashes_t *hashes, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) +{ + const tc_t *tc = (const tc_t *) hashes->esalts_buf; + + if (src_len < (int) dst_sz) + { + memcpy (dst_buf, src_buf, src_len); + } + + return execute_keyboard_layout_mapping (dst_buf, src_len, tc->keyboard_layout_mapping_buf, tc->keyboard_layout_mapping_cnt); +} + bool module_potfile_disable (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 bool potfile_disable = true; @@ -243,7 +255,7 @@ void module_init (module_ctx_t *module_ctx) 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_build_plain_postprocess = module_build_plain_postprocess; module_ctx->module_deep_comp_kernel = MODULE_DEFAULT; module_ctx->module_dgst_pos0 = module_dgst_pos0; module_ctx->module_dgst_pos1 = module_dgst_pos1; diff --git a/src/modules/module_18100.c b/src/modules/module_18100.c index ab9491800..9660b20dd 100644 --- a/src/modules/module_18100.c +++ b/src/modules/module_18100.c @@ -48,7 +48,7 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig, 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_build_plain_postprocess (const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, 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, const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz) { return base32_encode (int_to_base32, (const u8 *) src_buf, src_len, (u8 *) dst_buf); }