From 26785924846ad6c482084c28ea8e2826057e7a70 Mon Sep 17 00:00:00 2001 From: jsteube Date: Mon, 12 Sep 2016 10:50:08 +0200 Subject: [PATCH] Move more hash-mode dependant configuration into hashconfig --- include/interface.h | 1 + src/hashcat.c | 73 +++------------------------------------------ src/interface.c | 63 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 69 deletions(-) diff --git a/include/interface.h b/include/interface.h index 2359a818a..a6fe6ae7e 100644 --- a/include/interface.h +++ b/include/interface.h @@ -1669,6 +1669,7 @@ int hashconfig_init (hashconfig_t *hashconfig, const uint hash_ void hashconfig_destroy (hashconfig_t *hashconfig); uint hashconfig_general_pw_min (hashconfig_t *hashconfig); uint hashconfig_general_pw_max (hashconfig_t *hashconfig); +void hashconfig_general_defaults (hashconfig_t *hashconfig, salt_t *salts_buf, const int salts_cnt, void *esalts_buf, char *optional_param1); void hashconfig_benchmark_defaults (hashconfig_t *hashconfig, salt_t *salt, void *esalt); char *hashconfig_benchmark_mask (hashconfig_t *hashconfig); diff --git a/src/hashcat.c b/src/hashcat.c index d66b8902a..6958ddfbc 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -6815,77 +6815,12 @@ int main (int argc, char **argv) local_free (hashes_buf); - /** - * special modification not set from parser - */ + char *optional_param1 = NULL; - switch (hashconfig->hash_mode) - { - case 6211: salts_buf->truecrypt_mdlen = 1 * 512; break; - case 6212: salts_buf->truecrypt_mdlen = 2 * 512; break; - case 6213: salts_buf->truecrypt_mdlen = 3 * 512; break; - case 6221: salts_buf->truecrypt_mdlen = 1 * 512; break; - case 6222: salts_buf->truecrypt_mdlen = 2 * 512; break; - case 6223: salts_buf->truecrypt_mdlen = 3 * 512; break; - case 6231: salts_buf->truecrypt_mdlen = 1 * 512; break; - case 6232: salts_buf->truecrypt_mdlen = 2 * 512; break; - case 6233: salts_buf->truecrypt_mdlen = 3 * 512; break; - case 6241: salts_buf->truecrypt_mdlen = 1 * 512; break; - case 6242: salts_buf->truecrypt_mdlen = 2 * 512; break; - case 6243: salts_buf->truecrypt_mdlen = 3 * 512; break; - case 13711: salts_buf->truecrypt_mdlen = 1 * 512; break; - case 13712: salts_buf->truecrypt_mdlen = 2 * 512; break; - case 13713: salts_buf->truecrypt_mdlen = 3 * 512; break; - case 13721: salts_buf->truecrypt_mdlen = 1 * 512; break; - case 13722: salts_buf->truecrypt_mdlen = 2 * 512; break; - case 13723: salts_buf->truecrypt_mdlen = 3 * 512; break; - case 13731: salts_buf->truecrypt_mdlen = 1 * 512; break; - case 13732: salts_buf->truecrypt_mdlen = 2 * 512; break; - case 13733: salts_buf->truecrypt_mdlen = 3 * 512; break; - case 13741: salts_buf->truecrypt_mdlen = 1 * 512; break; - case 13742: salts_buf->truecrypt_mdlen = 2 * 512; break; - case 13743: salts_buf->truecrypt_mdlen = 3 * 512; break; - case 13751: salts_buf->truecrypt_mdlen = 1 * 512; break; - case 13752: salts_buf->truecrypt_mdlen = 2 * 512; break; - case 13753: salts_buf->truecrypt_mdlen = 3 * 512; break; - case 13761: salts_buf->truecrypt_mdlen = 1 * 512; break; - case 13762: salts_buf->truecrypt_mdlen = 2 * 512; break; - case 13763: salts_buf->truecrypt_mdlen = 3 * 512; break; - } + if (truecrypt_keyfiles) optional_param1 = truecrypt_keyfiles; + if (veracrypt_keyfiles) optional_param1 = veracrypt_keyfiles; - if (truecrypt_keyfiles) - { - uint *keyfile_buf = ((tc_t *) esalts_buf)->keyfile_buf; - - char *keyfiles = mystrdup (truecrypt_keyfiles); - - char *keyfile = strtok (keyfiles, ","); - - do - { - cpu_crc32 (keyfile, (u8 *) keyfile_buf); - - } while ((keyfile = strtok (NULL, ",")) != NULL); - - free (keyfiles); - } - - if (veracrypt_keyfiles) - { - uint *keyfile_buf = ((tc_t *) esalts_buf)->keyfile_buf; - - char *keyfiles = mystrdup (veracrypt_keyfiles); - - char *keyfile = strtok (keyfiles, ","); - - do - { - cpu_crc32 (keyfile, (u8 *) keyfile_buf); - - } while ((keyfile = strtok (NULL, ",")) != NULL); - - free (keyfiles); - } + hashconfig_general_defaults (hashconfig, salts_buf, salts_cnt, esalts_buf, optional_param1); data.digests_cnt = digests_cnt; data.digests_done = digests_done; diff --git a/src/interface.c b/src/interface.c index 2e74522b6..5c69b3645 100644 --- a/src/interface.c +++ b/src/interface.c @@ -19952,6 +19952,69 @@ uint hashconfig_general_pw_max (hashconfig_t *hashconfig) return pw_max; } +void hashconfig_general_defaults (hashconfig_t *hashconfig, salt_t *salts_buf, const int salts_cnt, void *esalts_buf, char *optional_param1) +{ + /** + * special modification not set from parser + */ + + for (int salts_pos = 0; salts_pos < salts_cnt; salts_pos++) + { + switch (hashconfig->hash_mode) + { + case 6211: salts_buf[salts_pos].truecrypt_mdlen = 1 * 512; break; + case 6212: salts_buf[salts_pos].truecrypt_mdlen = 2 * 512; break; + case 6213: salts_buf[salts_pos].truecrypt_mdlen = 3 * 512; break; + case 6221: salts_buf[salts_pos].truecrypt_mdlen = 1 * 512; break; + case 6222: salts_buf[salts_pos].truecrypt_mdlen = 2 * 512; break; + case 6223: salts_buf[salts_pos].truecrypt_mdlen = 3 * 512; break; + case 6231: salts_buf[salts_pos].truecrypt_mdlen = 1 * 512; break; + case 6232: salts_buf[salts_pos].truecrypt_mdlen = 2 * 512; break; + case 6233: salts_buf[salts_pos].truecrypt_mdlen = 3 * 512; break; + case 6241: salts_buf[salts_pos].truecrypt_mdlen = 1 * 512; break; + case 6242: salts_buf[salts_pos].truecrypt_mdlen = 2 * 512; break; + case 6243: salts_buf[salts_pos].truecrypt_mdlen = 3 * 512; break; + case 13711: salts_buf[salts_pos].truecrypt_mdlen = 1 * 512; break; + case 13712: salts_buf[salts_pos].truecrypt_mdlen = 2 * 512; break; + case 13713: salts_buf[salts_pos].truecrypt_mdlen = 3 * 512; break; + case 13721: salts_buf[salts_pos].truecrypt_mdlen = 1 * 512; break; + case 13722: salts_buf[salts_pos].truecrypt_mdlen = 2 * 512; break; + case 13723: salts_buf[salts_pos].truecrypt_mdlen = 3 * 512; break; + case 13731: salts_buf[salts_pos].truecrypt_mdlen = 1 * 512; break; + case 13732: salts_buf[salts_pos].truecrypt_mdlen = 2 * 512; break; + case 13733: salts_buf[salts_pos].truecrypt_mdlen = 3 * 512; break; + case 13741: salts_buf[salts_pos].truecrypt_mdlen = 1 * 512; break; + case 13742: salts_buf[salts_pos].truecrypt_mdlen = 2 * 512; break; + case 13743: salts_buf[salts_pos].truecrypt_mdlen = 3 * 512; break; + case 13751: salts_buf[salts_pos].truecrypt_mdlen = 1 * 512; break; + case 13752: salts_buf[salts_pos].truecrypt_mdlen = 2 * 512; break; + case 13753: salts_buf[salts_pos].truecrypt_mdlen = 3 * 512; break; + case 13761: salts_buf[salts_pos].truecrypt_mdlen = 1 * 512; break; + case 13762: salts_buf[salts_pos].truecrypt_mdlen = 2 * 512; break; + case 13763: salts_buf[salts_pos].truecrypt_mdlen = 3 * 512; break; + } + } + + if (optional_param1) + { + char *tcvc_keyfiles = (char *) optional_param1; + + uint *keyfile_buf = ((tc_t *) esalts_buf)->keyfile_buf; + + char *keyfiles = mystrdup (tcvc_keyfiles); + + char *keyfile = strtok (keyfiles, ","); + + do + { + cpu_crc32 (keyfile, (u8 *) keyfile_buf); + + } while ((keyfile = strtok (NULL, ",")) != NULL); + + free (keyfiles); + } +} + void hashconfig_benchmark_defaults (hashconfig_t *hashconfig, salt_t *salt, void *esalt) { if (hashconfig->is_salted)