WPA: Changed format for outfile and potfile from essid:mac1:mac2 to hash:mac_ap:mac_sta:essid

Fixes https://github.com/hashcat/hashcat/issues/1113
pull/1118/head
Jens Steube 7 years ago
parent 778f568d91
commit dd55c1eb66

@ -796,6 +796,8 @@ typedef struct wpa
u8 orig_nonce_ap[32];
u8 orig_nonce_sta[32];
int essid_reuse;
u8 essid_len;
u8 essid[32];
} wpa_t;

@ -93,7 +93,7 @@
- Threads: Restored strerror as %m is unsupported by the BSDs
- Wordlists: Disable dictstat handling for hash-mode 3000 as it virtually creates words in the wordlist which is not the case for other modes
- Wordlists: Fixed memory leak in case access a file in a wordlist folder fails
- WPA: Changed format for outfile and potfile from essid:mac1:mac2 to hash:essid
- WPA: Changed format for outfile and potfile from essid:mac1:mac2 to hash:mac_ap:mac_sta:essid
- WPA: Changed format for outfile_check from essid:mac1:mac2 to hash
* changes v3.20 -> v3.30:

@ -8,6 +8,9 @@
#include <ctype.h>
bool is_hexify (const u8 *buf, const int len);
int exec_unhexify (const u8 *in_buf, const int in_len, u8 *out_buf, const int out_sz);
bool need_hexify (const u8 *buf, const int len, const char separator, bool always_ascii);
void exec_hexify (const u8 *buf, const int len, u8 *out);

@ -184,6 +184,8 @@ typedef struct wpa
u8 orig_nonce_ap[32];
u8 orig_nonce_sta[32];
int essid_reuse;
u8 essid_len;
u8 essid[32];
} wpa_t;

@ -87,6 +87,36 @@ static bool matches_separator (const u8 *buf, const int len, const char separato
return false;
}
bool is_hexify (const u8 *buf, const int len)
{
if (len < 6) return false; // $HEX[] = 6
if (buf[0] != '$') return (false);
if (buf[1] != 'H') return (false);
if (buf[2] != 'E') return (false);
if (buf[3] != 'X') return (false);
if (buf[4] != '[') return (false);
if (buf[len - 1] != ']') return (false);
return true;
}
int exec_unhexify (const u8 *in_buf, const int in_len, u8 *out_buf, const int out_sz)
{
int i, j;
for (i = 0, j = 5; j < in_len - 1; i += 1, j += 2)
{
const u8 c = hex_to_u8 (&in_buf[j]);
out_buf[i] = c;
}
memset (out_buf + i, 0, out_sz - i);
return (i);
}
bool need_hexify (const u8 *buf, const int len, const char separator, bool always_ascii)
{
bool rc = false;

@ -2740,6 +2740,10 @@ int wpa_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED
salt->salt_iter = ROUNDS_WPA2 - 1;
memcpy (wpa->essid, in.essid, in.essid_len);
wpa->essid_len = in.essid_len;
u8 *pke_ptr = (u8 *) wpa->pke;
memcpy (pke_ptr, "Pairwise key expansion", 23);
@ -15676,12 +15680,50 @@ int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const size_t out_le
}
else if (hash_mode == 2500)
{
snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x:%s",
wpa_t *wpas = (wpa_t *) esalts_buf;
wpa_t *wpa = &wpas[salt_pos];
char *essid = (char *) wpa->essid;
char tmp_buf[HCBUFSIZ_TINY];
int tmp_len = 0;
if (need_hexify (wpa->essid, wpa->essid_len, hashconfig->separator, 0) == true)
{
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 (wpa->essid, wpa->essid_len, (u8 *) tmp_buf + tmp_len);
tmp_len += wpa->essid_len * 2;
tmp_buf[tmp_len++] = ']';
essid = tmp_buf;
}
snprintf (out_buf, out_len - 1, "%08x%08x%08x%08x:%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x:%s",
salt.salt_buf[12],
salt.salt_buf[13],
salt.salt_buf[14],
salt.salt_buf[15],
(char *) salt.salt_buf);
wpa->orig_mac_ap[0],
wpa->orig_mac_ap[1],
wpa->orig_mac_ap[2],
wpa->orig_mac_ap[3],
wpa->orig_mac_ap[4],
wpa->orig_mac_ap[5],
wpa->orig_mac_sta[0],
wpa->orig_mac_sta[1],
wpa->orig_mac_sta[2],
wpa->orig_mac_sta[3],
wpa->orig_mac_sta[4],
wpa->orig_mac_sta[5],
essid);
}
else if (hash_mode == 4400)
{

@ -451,7 +451,7 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
}
else if (hashconfig->hash_mode == 2500)
{
// here we have in line_hash_buf: hash:essid (without the plain)
// here we have in line_hash_buf: hash:macap:macsta:essid:password
char *sep_pos = strrchr (line_hash_buf, ':');
@ -463,13 +463,18 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
const size_t hash_len = strlen (hash_pos);
if (hash_len != 32) continue;
if (hash_len != 32 + 1 + 12 + 1 + 12) continue;
char *essid_pos = sep_pos + 1;
const size_t essid_len = strlen (essid_pos);
int essid_len = (int) strlen (essid_pos);
if (essid_len > 36) continue;
if (is_hexify ((const u8 *) essid_pos, (const int) essid_len) == true)
{
essid_len = exec_unhexify ((const u8 *) essid_pos, (int) essid_len, (u8 *) essid_pos, (int) essid_len);
}
if (essid_len > 32) continue;
if (hashconfig->is_salted)
{

@ -34,27 +34,11 @@ u32 convert_from_hex (hashcat_ctx_t *hashcat_ctx, char *line_buf, const u32 line
return (i);
}
if (line_len >= 6) // $HEX[] = 6
if (is_hexify (line_buf, line_len) == true)
{
if (line_buf[0] != '$') return (line_len);
if (line_buf[1] != 'H') return (line_len);
if (line_buf[2] != 'E') return (line_len);
if (line_buf[3] != 'X') return (line_len);
if (line_buf[4] != '[') return (line_len);
if (line_buf[line_len - 1] != ']') return (line_len);
const int new_len = exec_unhexify ((const u8 *) line_buf, (int) line_len, (u8 *) line_buf, (int) line_len);
size_t i, j;
for (i = 0, j = 5; j < line_len - 1; i += 1, j += 2)
{
const u8 c = hex_to_u8 ((const u8 *) &line_buf[j]);
line_buf[i] = c;
}
memset (line_buf + i, 0, line_len - i);
return (i);
return (u32) new_len;
}
return (line_len);

Loading…
Cancel
Save