From 4ed18af14c37c229ee51693a492a7147d775c316 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Sat, 8 Feb 2020 12:24:47 +0100 Subject: [PATCH] Make VeraCrypt PIM configuration mechanism easier to read --- include/types.h | 4 ++++ src/modules/module_13711.c | 2 +- src/modules/module_13712.c | 2 +- src/modules/module_13713.c | 2 +- src/modules/module_13721.c | 2 +- src/modules/module_13722.c | 2 +- src/modules/module_13723.c | 2 +- src/modules/module_13731.c | 2 +- src/modules/module_13732.c | 2 +- src/modules/module_13733.c | 2 +- src/modules/module_13741.c | 2 +- src/modules/module_13742.c | 2 +- src/modules/module_13743.c | 2 +- src/modules/module_13751.c | 2 +- src/modules/module_13752.c | 2 +- src/modules/module_13753.c | 2 +- src/modules/module_13761.c | 2 +- src/modules/module_13762.c | 2 +- src/modules/module_13763.c | 2 +- src/modules/module_13771.c | 2 +- src/modules/module_13772.c | 2 +- src/modules/module_13773.c | 2 +- src/user_options.c | 14 ++++++++------ 23 files changed, 33 insertions(+), 27 deletions(-) diff --git a/include/types.h b/include/types.h index 3ff3f5c6b..dfccc083a 100644 --- a/include/types.h +++ b/include/types.h @@ -646,6 +646,8 @@ typedef enum user_options_defaults USAGE = false, USERNAME = false, VERSION = false, + VERACRYPT_PIM_START = 485, + VERACRYPT_PIM_STOP = 485, WORDLIST_AUTOHEX_DISABLE = false, WORKLOAD_PROFILE = 2, @@ -1938,6 +1940,8 @@ typedef struct user_options bool stdin_timeout_abort_chgd; bool usage; bool username; + bool veracrypt_pim_start_chgd; + bool veracrypt_pim_stop_chgd; bool version; bool wordlist_autohex_disable; #ifdef WITH_BRAIN diff --git a/src/modules/module_13711.c b/src/modules/module_13711.c index 3f9b114d5..b04f6e935 100644 --- a/src/modules/module_13711.c +++ b/src/modules/module_13711.c @@ -246,7 +246,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13712.c b/src/modules/module_13712.c index ff2cb7825..5bd1c8368 100644 --- a/src/modules/module_13712.c +++ b/src/modules/module_13712.c @@ -246,7 +246,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13713.c b/src/modules/module_13713.c index 2477326d2..3b7a1a90a 100644 --- a/src/modules/module_13713.c +++ b/src/modules/module_13713.c @@ -246,7 +246,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13721.c b/src/modules/module_13721.c index e1ffa152d..272fbe3fe 100644 --- a/src/modules/module_13721.c +++ b/src/modules/module_13721.c @@ -244,7 +244,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13722.c b/src/modules/module_13722.c index efde93aa3..64324fa03 100644 --- a/src/modules/module_13722.c +++ b/src/modules/module_13722.c @@ -244,7 +244,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13723.c b/src/modules/module_13723.c index 852a31fde..ba5d7a644 100644 --- a/src/modules/module_13723.c +++ b/src/modules/module_13723.c @@ -244,7 +244,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13731.c b/src/modules/module_13731.c index 06e5fde42..a1fca2f9a 100644 --- a/src/modules/module_13731.c +++ b/src/modules/module_13731.c @@ -255,7 +255,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13732.c b/src/modules/module_13732.c index a916d6b0d..3b3508ab9 100644 --- a/src/modules/module_13732.c +++ b/src/modules/module_13732.c @@ -255,7 +255,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13733.c b/src/modules/module_13733.c index e0ee9d78c..f62d75dd9 100644 --- a/src/modules/module_13733.c +++ b/src/modules/module_13733.c @@ -255,7 +255,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13741.c b/src/modules/module_13741.c index 2c66fbd02..a55c085d2 100644 --- a/src/modules/module_13741.c +++ b/src/modules/module_13741.c @@ -247,7 +247,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = user_options->veracrypt_pim_start; vc->pim_stop = user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13742.c b/src/modules/module_13742.c index 90ae74e1c..cd9c63191 100644 --- a/src/modules/module_13742.c +++ b/src/modules/module_13742.c @@ -247,7 +247,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = user_options->veracrypt_pim_start; vc->pim_stop = user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13743.c b/src/modules/module_13743.c index e9fba371d..ff834d82f 100644 --- a/src/modules/module_13743.c +++ b/src/modules/module_13743.c @@ -247,7 +247,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = user_options->veracrypt_pim_start; vc->pim_stop = user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13751.c b/src/modules/module_13751.c index 8847376ee..110c0e6a1 100644 --- a/src/modules/module_13751.c +++ b/src/modules/module_13751.c @@ -246,7 +246,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13752.c b/src/modules/module_13752.c index c443a5ecb..88f12bfc1 100644 --- a/src/modules/module_13752.c +++ b/src/modules/module_13752.c @@ -246,7 +246,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13753.c b/src/modules/module_13753.c index 7301607a8..73c165b31 100644 --- a/src/modules/module_13753.c +++ b/src/modules/module_13753.c @@ -246,7 +246,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13761.c b/src/modules/module_13761.c index e219ad859..47b1fb25a 100644 --- a/src/modules/module_13761.c +++ b/src/modules/module_13761.c @@ -247,7 +247,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = user_options->veracrypt_pim_start; vc->pim_stop = user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13762.c b/src/modules/module_13762.c index fd6c7e43f..c738664d6 100644 --- a/src/modules/module_13762.c +++ b/src/modules/module_13762.c @@ -247,7 +247,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = user_options->veracrypt_pim_start; vc->pim_stop = user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13763.c b/src/modules/module_13763.c index 7821e6cf4..b4459d849 100644 --- a/src/modules/module_13763.c +++ b/src/modules/module_13763.c @@ -247,7 +247,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = user_options->veracrypt_pim_start; vc->pim_stop = user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13771.c b/src/modules/module_13771.c index 71b1c0b77..6fbcd8ccc 100644 --- a/src/modules/module_13771.c +++ b/src/modules/module_13771.c @@ -250,7 +250,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13772.c b/src/modules/module_13772.c index d2516a20c..76421b2c5 100644 --- a/src/modules/module_13772.c +++ b/src/modules/module_13772.c @@ -250,7 +250,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/modules/module_13773.c b/src/modules/module_13773.c index 28b6eae55..823683f66 100644 --- a/src/modules/module_13773.c +++ b/src/modules/module_13773.c @@ -250,7 +250,7 @@ int module_hash_binary_parse (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE salt_t *salt = hash->salt; - if ((user_options->veracrypt_pim_start) && (user_options->veracrypt_pim_stop)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == true)) { vc->pim_start = 15 + user_options->veracrypt_pim_start; vc->pim_stop = 15 + user_options->veracrypt_pim_stop; diff --git a/src/user_options.c b/src/user_options.c index 57e09a7ce..ec19a0354 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -257,8 +257,8 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->usage = USAGE; user_options->username = USERNAME; user_options->veracrypt_keyfiles = NULL; - user_options->veracrypt_pim_start = 0; - user_options->veracrypt_pim_stop = 0; + user_options->veracrypt_pim_start = VERACRYPT_PIM_START; + user_options->veracrypt_pim_stop = VERACRYPT_PIM_STOP; user_options->version = VERSION; user_options->wordlist_autohex_disable = WORDLIST_AUTOHEX_DISABLE; user_options->workload_profile = WORKLOAD_PROFILE; @@ -460,8 +460,10 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_KEYBOARD_LAYOUT_MAPPING: user_options->keyboard_layout_mapping = optarg; break; case IDX_TRUECRYPT_KEYFILES: user_options->truecrypt_keyfiles = optarg; break; case IDX_VERACRYPT_KEYFILES: user_options->veracrypt_keyfiles = optarg; break; - case IDX_VERACRYPT_PIM_START: user_options->veracrypt_pim_start = hc_strtoul (optarg, NULL, 10); break; - case IDX_VERACRYPT_PIM_STOP: user_options->veracrypt_pim_stop = hc_strtoul (optarg, NULL, 10); break; + case IDX_VERACRYPT_PIM_START: user_options->veracrypt_pim_start = hc_strtoul (optarg, NULL, 10); + user_options->veracrypt_pim_start_chgd = true; break; + case IDX_VERACRYPT_PIM_STOP: user_options->veracrypt_pim_stop = hc_strtoul (optarg, NULL, 10); + user_options->veracrypt_pim_stop_chgd = true; break; case IDX_SEGMENT_SIZE: user_options->segment_size = hc_strtoul (optarg, NULL, 10); user_options->segment_size_chgd = true; break; case IDX_SCRYPT_TMTO: user_options->scrypt_tmto = hc_strtoul (optarg, NULL, 10); break; @@ -720,14 +722,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } - if ((user_options->veracrypt_pim_start != 0) && (user_options->veracrypt_pim_stop == 0)) + if ((user_options->veracrypt_pim_start_chgd == true) && (user_options->veracrypt_pim_stop_chgd == false)) { event_log_error (hashcat_ctx, "If --veracrypt-pim-start is specified then --veracrypt-pim-stop needs to be specified, too."); return -1; } - if ((user_options->veracrypt_pim_start == 0) && (user_options->veracrypt_pim_stop != 0)) + if ((user_options->veracrypt_pim_start_chgd == false) && (user_options->veracrypt_pim_stop_chgd == true)) { event_log_error (hashcat_ctx, "If --veracrypt-pim-stop is specified then --veracrypt-pim-start needs to be specified, too.");