1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-01-12 08:41:07 +00:00

Make use of need_hexify to decide if hexification is needed for ESSID in -m 16800 and -m 16801

This commit is contained in:
jsteube 2019-04-02 21:30:33 +02:00
parent a9663cdb53
commit d855ddaf9e
3 changed files with 101 additions and 35 deletions

View File

@ -432,13 +432,29 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
{ {
const wpa_pmkid_t *wpa_pmkid = (const wpa_pmkid_t *) esalt_buf; const wpa_pmkid_t *wpa_pmkid = (const wpa_pmkid_t *) esalt_buf;
int line_len = 0;
if (need_hexify ((const u8 *) wpa_pmkid->essid_buf, wpa_pmkid->essid_len, ':', 0) == true)
{
char tmp_buf[128]; 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++] = '[';
const int line_len = snprintf (line_buf, line_size, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s", 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[0],
wpa_pmkid->orig_mac_ap[1], wpa_pmkid->orig_mac_ap[1],
wpa_pmkid->orig_mac_ap[2], wpa_pmkid->orig_mac_ap[2],
@ -452,6 +468,24 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
wpa_pmkid->orig_mac_sta[4], wpa_pmkid->orig_mac_sta[4],
wpa_pmkid->orig_mac_sta[5], wpa_pmkid->orig_mac_sta[5],
tmp_buf); 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; return line_len;
} }

View File

@ -492,12 +492,26 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
int line_len = 0; int line_len = 0;
if (wpa_pmkid->essid_len) if (wpa_pmkid->essid_len)
{
if (need_hexify ((const u8 *) wpa_pmkid->essid_buf, wpa_pmkid->essid_len, ':', 0) == true)
{ {
char tmp_buf[128]; 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++] = '[';
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", 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[0],
@ -515,6 +529,24 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
tmp_buf); tmp_buf);
} }
else 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
{ {
line_len = snprintf (line_buf, line_size, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x", line_len = snprintf (line_buf, line_size, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x",
wpa_pmkid->orig_mac_ap[0], wpa_pmkid->orig_mac_ap[0],

View File

@ -971,7 +971,7 @@ int potfile_handle_left (hashcat_ctx_t *hashcat_ctx)
if ((hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE) == 0) 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); memcpy (out_buf, binary_buf, binary_len);