From f1c3f952ba29fa8baba3a2e1fe868d6b73b51576 Mon Sep 17 00:00:00 2001 From: philsmd Date: Fri, 25 Aug 2017 09:55:10 +0200 Subject: [PATCH] fixes show output of -m 9710, -m 9810 and -m 10410 --- docs/changes.txt | 1 + src/convert.c | 13 ++++++++----- src/potfile.c | 31 ++++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 328e886b8..338db8faf 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -33,6 +33,7 @@ - Fixed the parsing of command line options. It doesn't show two times the same error about an invalid option anymore - Fixed the parsing of DCC2 hashes by allowing the "#" character within the user name - Fixed the parsing of descrypt hashes if the hashes do have non-standard characters within the salt +- Fixed the output of --show when used together with the collider modes -m 9710, 9810 or 10410 - Fixed the version number used in the restore file header ## diff --git a/src/convert.c b/src/convert.c index 079043780..7d66ee17d 100644 --- a/src/convert.c +++ b/src/convert.c @@ -97,6 +97,12 @@ bool is_hexify (const u8 *buf, const int len) { if (len < 6) return false; // $HEX[] = 6 + // length of the hex string must be a multiple of 2 + // and the length of "$HEX[]" is 6 (also an even length) + // Therefore the overall length must be an even number: + + if ((len & 1) == 1) return false; + if (buf[0] != '$') return (false); if (buf[1] != 'H') return (false); if (buf[2] != 'E') return (false); @@ -156,12 +162,9 @@ bool need_hexify (const u8 *buf, const int len, const char separator, bool alway if (rc == false) { - if ((len & 1) == 0) + if (is_hexify (buf, len)) { - if (is_hexify (buf, len)) - { - rc = true; - } + rc = true; } } diff --git a/src/potfile.c b/src/potfile.c index 01ddd610e..697a418dd 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -734,7 +734,36 @@ int potfile_handle_show (hashcat_ctx_t *hashcat_ctx) tmp_buf[0] = 0; - const int tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, (u8 *) hash->pw_buf, hash->pw_len, 0, username, user_len, (char *) tmp_buf); + + // special case for collider modes: we do not use the $HEX[] format within the hash itself + // therefore we need to convert the $HEX[] password into hexadecimal (without "$HEX[" and "]") + + bool is_collider_hex_password = false; + + if ((hashconfig->hash_mode == 9710) || (hashconfig->hash_mode == 9810) || (hashconfig->hash_mode == 10410)) + { + if (is_hexify ((u8 *) hash->pw_buf, hash->pw_len) == true) + { + is_collider_hex_password = true; + } + } + + int tmp_len = 0; + + if (is_collider_hex_password == true) + { + u8 pass_unhexified[HCBUFSIZ_TINY] = { 0 }; + + u32 pass_unhexified_len = 0; + + pass_unhexified_len = exec_unhexify ((u8 *) hash->pw_buf, hash->pw_len, pass_unhexified, sizeof (pass_unhexified)); + + tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, pass_unhexified, pass_unhexified_len, 0, username, user_len, (char *) tmp_buf); + } + else + { + tmp_len = outfile_write (hashcat_ctx, (char *) out_buf, (u8 *) hash->pw_buf, hash->pw_len, 0, username, user_len, (char *) tmp_buf); + } EVENT_DATA (EVENT_POTFILE_HASH_SHOW, tmp_buf, tmp_len); }