Get rid of hash_mode depending branches in status.c

This commit is contained in:
jsteube
2019-01-05 19:18:30 +01:00
parent e0deb3f825
commit 888da50aad
6 changed files with 81 additions and 57 deletions

View File

@@ -592,7 +592,6 @@ int ascii_digest (const hashconfig_t *hashconfig, const hashes_t *hashes, const
return out_len;
/*
if (salt_type == SALT_TYPE_GENERIC)
{

View File

@@ -28994,5 +28994,66 @@ u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED c
}
}
int module_hash_encode_status (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const void *digest_buf, MAYBE_UNUSED const salt_t *salt, MAYBE_UNUSED const void *esalt_buf, char *line_buf, MAYBE_UNUSED const int line_size)
{
if (hashes->digests_cnt == 1)
{
if ((hashconfig->hash_mode == 2500) || (hashconfig->hash_mode == 2501))
{
char *tmp_buf;
wpa_eapol_t *wpa_eapol = (wpa_eapol_t *) hashes->esalts_buf;
hc_asprintf (&tmp_buf, "%s (AP:%02x:%02x:%02x:%02x:%02x:%02x STA:%02x:%02x:%02x:%02x:%02x:%02x)",
(char *) hashes->salts_buf[0].salt_buf,
wpa_eapol->orig_mac_ap[0],
wpa_eapol->orig_mac_ap[1],
wpa_eapol->orig_mac_ap[2],
wpa_eapol->orig_mac_ap[3],
wpa_eapol->orig_mac_ap[4],
wpa_eapol->orig_mac_ap[5],
wpa_eapol->orig_mac_sta[0],
wpa_eapol->orig_mac_sta[1],
wpa_eapol->orig_mac_sta[2],
wpa_eapol->orig_mac_sta[3],
wpa_eapol->orig_mac_sta[4],
wpa_eapol->orig_mac_sta[5]);
return tmp_buf;
}
else if (hashconfig->hash_mode == 5200)
{
return hashes->hashfile;
}
else if (hashconfig->hash_mode == 9000)
{
return hashes->hashfile;
}
else if ((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299))
{
return hashes->hashfile;
}
else if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799))
{
return hashes->hashfile;
}
}
else
{
if (hashconfig->hash_mode == 3000)
{
char *tmp_buf;
char out_buf1[64] = { 0 };
char out_buf2[64] = { 0 };
ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, out_buf1, sizeof (out_buf1), 0, 0);
ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, out_buf2, sizeof (out_buf2), 0, 1);
hc_asprintf (&tmp_buf, "%s, %s", out_buf1, out_buf2);
return tmp_buf;
}
}
}

View File

@@ -300,49 +300,27 @@ const char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx)
{
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
const hashes_t *hashes = hashcat_ctx->hashes;
const module_ctx_t *module_ctx = hashcat_ctx->module_ctx;
if (hashes->digests_cnt == 1)
if (module_ctx->module_hash_encode_status)
{
if ((hashconfig->hash_mode == 2500) || (hashconfig->hash_mode == 2501))
{
char *tmp_buf;
char *tmp_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
wpa_eapol_t *wpa_eapol = (wpa_eapol_t *) hashes->esalts_buf;
const int tmp_len = module_ctx->module_hash_encode_status (hashconfig, hashes->digests_buf, hashes->salts_buf, hashes->esalts_buf, tmp_buf, HCBUFSIZ_LARGE);
hc_asprintf (&tmp_buf, "%s (AP:%02x:%02x:%02x:%02x:%02x:%02x STA:%02x:%02x:%02x:%02x:%02x:%02x)",
(char *) hashes->salts_buf[0].salt_buf,
wpa_eapol->orig_mac_ap[0],
wpa_eapol->orig_mac_ap[1],
wpa_eapol->orig_mac_ap[2],
wpa_eapol->orig_mac_ap[3],
wpa_eapol->orig_mac_ap[4],
wpa_eapol->orig_mac_ap[5],
wpa_eapol->orig_mac_sta[0],
wpa_eapol->orig_mac_sta[1],
wpa_eapol->orig_mac_sta[2],
wpa_eapol->orig_mac_sta[3],
wpa_eapol->orig_mac_sta[4],
wpa_eapol->orig_mac_sta[5]);
char *tmp_buf2 = (char *) hcmalloc (tmp_len + 1);
return tmp_buf;
}
else if (hashconfig->hash_mode == 5200)
{
return hashes->hashfile;
}
else if (hashconfig->hash_mode == 9000)
{
return hashes->hashfile;
}
else if ((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299))
{
return hashes->hashfile;
}
else if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799))
{
return hashes->hashfile;
}
else
memcpy (tmp_buf2, tmp_buf, tmp_len);
free (tmp_buf);
tmp_buf2[tmp_len] = 0;
return tmp_buf2;
}
else
{
if (hashes->digests_cnt == 1)
{
char *tmp_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
@@ -358,23 +336,6 @@ const char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx)
return tmp_buf2;
}
}
else
{
if (hashconfig->hash_mode == 3000)
{
char *tmp_buf;
char out_buf1[64] = { 0 };
char out_buf2[64] = { 0 };
ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, out_buf1, sizeof (out_buf1), 0, 0);
ascii_digest (hashcat_ctx->hashconfig, hashcat_ctx->hashes, hashcat_ctx->module_ctx, out_buf2, sizeof (out_buf2), 0, 1);
hc_asprintf (&tmp_buf, "%s, %s", out_buf1, out_buf2);
return tmp_buf;
}
else
{
return hashes->hashfile;