1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-01-12 00:31:41 +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,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; 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", tmp_buf[tmp_len++] = '$';
wpa_pmkid->orig_mac_ap[0], tmp_buf[tmp_len++] = 'H';
wpa_pmkid->orig_mac_ap[1], tmp_buf[tmp_len++] = 'E';
wpa_pmkid->orig_mac_ap[2], tmp_buf[tmp_len++] = 'X';
wpa_pmkid->orig_mac_ap[3], tmp_buf[tmp_len++] = '[';
wpa_pmkid->orig_mac_ap[4],
wpa_pmkid->orig_mac_ap[5], exec_hexify ((const u8 *) wpa_pmkid->essid_buf, wpa_pmkid->essid_len, (u8 *) tmp_buf + tmp_len);
wpa_pmkid->orig_mac_sta[0],
wpa_pmkid->orig_mac_sta[1], tmp_len += wpa_pmkid->essid_len * 2;
wpa_pmkid->orig_mac_sta[2],
wpa_pmkid->orig_mac_sta[3], tmp_buf[tmp_len++] = ']';
wpa_pmkid->orig_mac_sta[4],
wpa_pmkid->orig_mac_sta[5], tmp_buf[tmp_len++] = 0;
tmp_buf);
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; return line_len;
} }

View File

@ -493,26 +493,58 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
if (wpa_pmkid->essid_len) 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", exec_hexify ((const u8 *) wpa_pmkid->essid_buf, wpa_pmkid->essid_len, (u8 *) tmp_buf + tmp_len);
wpa_pmkid->orig_mac_ap[0],
wpa_pmkid->orig_mac_ap[1], tmp_len += wpa_pmkid->essid_len * 2;
wpa_pmkid->orig_mac_ap[2],
wpa_pmkid->orig_mac_ap[3], tmp_buf[tmp_len++] = ']';
wpa_pmkid->orig_mac_ap[4],
wpa_pmkid->orig_mac_ap[5], tmp_buf[tmp_len++] = 0;
wpa_pmkid->orig_mac_sta[0],
wpa_pmkid->orig_mac_sta[1], line_len = snprintf (line_buf, line_size, "%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s",
wpa_pmkid->orig_mac_sta[2], wpa_pmkid->orig_mac_ap[0],
wpa_pmkid->orig_mac_sta[3], wpa_pmkid->orig_mac_ap[1],
wpa_pmkid->orig_mac_sta[4], wpa_pmkid->orig_mac_ap[2],
wpa_pmkid->orig_mac_sta[5], wpa_pmkid->orig_mac_ap[3],
tmp_buf); 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 else
{ {

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);