From d855ddaf9e4f557c3bdc1991839006bea24fa86c Mon Sep 17 00:00:00 2001 From: jsteube Date: Tue, 2 Apr 2019 21:30:33 +0200 Subject: [PATCH] Make use of need_hexify to decide if hexification is needed for ESSID in -m 16800 and -m 16801 --- src/modules/module_16800.c | 68 ++++++++++++++++++++++++++++---------- src/modules/module_16801.c | 66 ++++++++++++++++++++++++++---------- src/potfile.c | 2 +- 3 files changed, 101 insertions(+), 35 deletions(-) diff --git a/src/modules/module_16800.c b/src/modules/module_16800.c index e3715088c..d56a651d4 100644 --- a/src/modules/module_16800.c +++ b/src/modules/module_16800.c @@ -432,26 +432,60 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE { const wpa_pmkid_t *wpa_pmkid = (const wpa_pmkid_t *) esalt_buf; - char tmp_buf[128]; + int line_len = 0; - const int tmp_len = hex_encode ((const u8 *) wpa_pmkid->essid_buf, wpa_pmkid->essid_len, (u8 *) tmp_buf); + if (need_hexify ((const u8 *) wpa_pmkid->essid_buf, wpa_pmkid->essid_len, ':', 0) == true) + { + char tmp_buf[128]; - tmp_buf[tmp_len] = 0; + int tmp_len = 0; - const int line_len = snprintf (line_buf, line_size, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", - wpa_pmkid->orig_mac_ap[0], - wpa_pmkid->orig_mac_ap[1], - wpa_pmkid->orig_mac_ap[2], - wpa_pmkid->orig_mac_ap[3], - wpa_pmkid->orig_mac_ap[4], - wpa_pmkid->orig_mac_ap[5], - wpa_pmkid->orig_mac_sta[0], - wpa_pmkid->orig_mac_sta[1], - wpa_pmkid->orig_mac_sta[2], - wpa_pmkid->orig_mac_sta[3], - wpa_pmkid->orig_mac_sta[4], - wpa_pmkid->orig_mac_sta[5], - tmp_buf); + tmp_buf[tmp_len++] = '$'; + tmp_buf[tmp_len++] = 'H'; + tmp_buf[tmp_len++] = 'E'; + tmp_buf[tmp_len++] = 'X'; + tmp_buf[tmp_len++] = '['; + + exec_hexify ((const u8 *) wpa_pmkid->essid_buf, wpa_pmkid->essid_len, (u8 *) tmp_buf + tmp_len); + + tmp_len += wpa_pmkid->essid_len * 2; + + tmp_buf[tmp_len++] = ']'; + + tmp_buf[tmp_len++] = 0; + + line_len = snprintf (line_buf, line_size, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", + wpa_pmkid->orig_mac_ap[0], + wpa_pmkid->orig_mac_ap[1], + wpa_pmkid->orig_mac_ap[2], + wpa_pmkid->orig_mac_ap[3], + wpa_pmkid->orig_mac_ap[4], + wpa_pmkid->orig_mac_ap[5], + wpa_pmkid->orig_mac_sta[0], + wpa_pmkid->orig_mac_sta[1], + wpa_pmkid->orig_mac_sta[2], + wpa_pmkid->orig_mac_sta[3], + wpa_pmkid->orig_mac_sta[4], + wpa_pmkid->orig_mac_sta[5], + tmp_buf); + } + else + { + line_len = snprintf (line_buf, line_size, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", + wpa_pmkid->orig_mac_ap[0], + wpa_pmkid->orig_mac_ap[1], + wpa_pmkid->orig_mac_ap[2], + wpa_pmkid->orig_mac_ap[3], + wpa_pmkid->orig_mac_ap[4], + wpa_pmkid->orig_mac_ap[5], + wpa_pmkid->orig_mac_sta[0], + wpa_pmkid->orig_mac_sta[1], + wpa_pmkid->orig_mac_sta[2], + wpa_pmkid->orig_mac_sta[3], + wpa_pmkid->orig_mac_sta[4], + wpa_pmkid->orig_mac_sta[5], + (const char *) wpa_pmkid->essid_buf); + } return line_len; } diff --git a/src/modules/module_16801.c b/src/modules/module_16801.c index e46691bcf..37a52dd1e 100644 --- a/src/modules/module_16801.c +++ b/src/modules/module_16801.c @@ -493,26 +493,58 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE if (wpa_pmkid->essid_len) { - char tmp_buf[128]; + if (need_hexify ((const u8 *) wpa_pmkid->essid_buf, wpa_pmkid->essid_len, ':', 0) == true) + { + char tmp_buf[128]; - const int tmp_len = hex_encode ((const u8 *) wpa_pmkid->essid_buf, wpa_pmkid->essid_len, (u8 *) tmp_buf); + int tmp_len = 0; - tmp_buf[tmp_len] = 0; + tmp_buf[tmp_len++] = '$'; + tmp_buf[tmp_len++] = 'H'; + tmp_buf[tmp_len++] = 'E'; + tmp_buf[tmp_len++] = 'X'; + tmp_buf[tmp_len++] = '['; - line_len = snprintf (line_buf, line_size, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", - wpa_pmkid->orig_mac_ap[0], - wpa_pmkid->orig_mac_ap[1], - wpa_pmkid->orig_mac_ap[2], - wpa_pmkid->orig_mac_ap[3], - wpa_pmkid->orig_mac_ap[4], - wpa_pmkid->orig_mac_ap[5], - wpa_pmkid->orig_mac_sta[0], - wpa_pmkid->orig_mac_sta[1], - wpa_pmkid->orig_mac_sta[2], - wpa_pmkid->orig_mac_sta[3], - wpa_pmkid->orig_mac_sta[4], - wpa_pmkid->orig_mac_sta[5], - tmp_buf); + exec_hexify ((const u8 *) wpa_pmkid->essid_buf, wpa_pmkid->essid_len, (u8 *) tmp_buf + tmp_len); + + tmp_len += wpa_pmkid->essid_len * 2; + + tmp_buf[tmp_len++] = ']'; + + tmp_buf[tmp_len++] = 0; + + line_len = snprintf (line_buf, line_size, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", + wpa_pmkid->orig_mac_ap[0], + wpa_pmkid->orig_mac_ap[1], + wpa_pmkid->orig_mac_ap[2], + wpa_pmkid->orig_mac_ap[3], + wpa_pmkid->orig_mac_ap[4], + wpa_pmkid->orig_mac_ap[5], + wpa_pmkid->orig_mac_sta[0], + wpa_pmkid->orig_mac_sta[1], + wpa_pmkid->orig_mac_sta[2], + wpa_pmkid->orig_mac_sta[3], + wpa_pmkid->orig_mac_sta[4], + wpa_pmkid->orig_mac_sta[5], + tmp_buf); + } + else + { + line_len = snprintf (line_buf, line_size, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", + wpa_pmkid->orig_mac_ap[0], + wpa_pmkid->orig_mac_ap[1], + wpa_pmkid->orig_mac_ap[2], + wpa_pmkid->orig_mac_ap[3], + wpa_pmkid->orig_mac_ap[4], + wpa_pmkid->orig_mac_ap[5], + wpa_pmkid->orig_mac_sta[0], + wpa_pmkid->orig_mac_sta[1], + wpa_pmkid->orig_mac_sta[2], + wpa_pmkid->orig_mac_sta[3], + wpa_pmkid->orig_mac_sta[4], + wpa_pmkid->orig_mac_sta[5], + (const char *) wpa_pmkid->essid_buf); + } } else { diff --git a/src/potfile.c b/src/potfile.c index 45e750c73..ec8351450 100644 --- a/src/potfile.c +++ b/src/potfile.c @@ -971,7 +971,7 @@ int potfile_handle_left (hashcat_ctx_t *hashcat_ctx) if ((hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) == 0) { - binary_len--; // no need to the newline + binary_len--; // no need for the newline } memcpy (out_buf, binary_buf, binary_len);