mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-26 01:50:10 +00:00
Add module_hash_save_binary() and module_hash_init_selftest()
This commit is contained in:
parent
54edd16746
commit
86819c070f
@ -101,9 +101,6 @@ typedef struct hccapx hccapx_t;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
void to_hccapx_t (hashcat_ctx_t *hashcat_ctx, hccapx_t *hccapx, const u32 salt_pos, const u32 digest_pos);
|
||||
|
||||
|
||||
typedef struct seven_zip_hook
|
||||
{
|
||||
u32 ukey[8];
|
||||
|
@ -58,8 +58,9 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *ha
|
||||
|
||||
u64 module_extra_buffer_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param);
|
||||
char *module_jit_build_options (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra, MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const hc_device_param_t *device_param);
|
||||
|
||||
u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos);
|
||||
int module_hash_save_binary (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos, const char **buf);
|
||||
int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash);
|
||||
|
||||
void module_hook12 (hc_device_param_t *device_param, void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt);
|
||||
void module_hook23 (hc_device_param_t *device_param, void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt);
|
||||
|
@ -2306,8 +2306,9 @@ typedef struct module_ctx
|
||||
|
||||
u64 (*module_extra_buffer_size) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *, const hashes_t *, const hc_device_param_t *);
|
||||
char *(*module_jit_build_options) (const hashconfig_t *, const user_options_t *, const user_options_extra_t *, const hashes_t *, const hc_device_param_t *);
|
||||
|
||||
u32 (*module_deep_comp_kernel) (const hashes_t *, const u32, const u32);
|
||||
int (*module_hash_save_binary) (const hashes_t *, const u32, const u32, char **);
|
||||
int (*module_hash_init_selftest) (const hashconfig_t *, hash_t *);
|
||||
|
||||
void (*module_hook12) (hc_device_param_t *, const void *, const u32, const u64);
|
||||
void (*module_hook23) (hc_device_param_t *, const void *, const u32, const u64);
|
||||
|
@ -136,9 +136,11 @@ void module_init (module_ctx_t *module_ctx)
|
||||
module_ctx->module_hash_decode = module_hash_decode;
|
||||
module_ctx->module_hash_encode_status = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_encode = module_hash_encode;
|
||||
module_ctx->module_hash_init_selftest = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_mode = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_category = module_hash_category;
|
||||
module_ctx->module_hash_name = module_hash_name;
|
||||
module_ctx->module_hash_save_binary = MODULE_DEFAULT;
|
||||
module_ctx->module_hash_type = module_hash_type;
|
||||
module_ctx->module_hlfmt_disable = MODULE_DEFAULT;
|
||||
module_ctx->module_hook12 = MODULE_DEFAULT;
|
||||
|
47
src/hashes.c
47
src/hashes.c
@ -267,6 +267,7 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
module_ctx_t *module_ctx = hashcat_ctx->module_ctx;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
const char *hashfile = hashes->hashfile;
|
||||
@ -315,24 +316,17 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
for (u32 digest_pos = 0; digest_pos < salt_buf->digests_cnt; digest_pos++)
|
||||
{
|
||||
u32 idx = salt_buf->digests_offset + digest_pos;
|
||||
const u32 idx = salt_buf->digests_offset + digest_pos;
|
||||
|
||||
if (hashes->digests_shown[idx] == 1) continue;
|
||||
|
||||
if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE)
|
||||
if (module_ctx->module_hash_save_binary != MODULE_DEFAULT)
|
||||
{
|
||||
if ((hashconfig->hash_mode == 2500) || (hashconfig->hash_mode == 2501))
|
||||
{
|
||||
hccapx_t hccapx;
|
||||
char *binary_buf = NULL;
|
||||
|
||||
to_hccapx_t (hashcat_ctx, &hccapx, salt_pos, digest_pos);
|
||||
const int binary_len = module_ctx->module_hash_save_binary (hashes, salt_pos, digest_pos, &binary_buf);
|
||||
|
||||
hc_fwrite (&hccapx, sizeof (hccapx_t), 1, fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
hc_fwrite (binary_buf, binary_len, 1, fp);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1888,31 +1882,13 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
int parser_status;
|
||||
|
||||
if ((hashconfig->hash_mode == 2500) || (hashconfig->hash_mode == 2501))
|
||||
if (module_ctx->module_hash_init_selftest != MODULE_DEFAULT)
|
||||
{
|
||||
char *tmpdata = (char *) hcmalloc (sizeof (hccapx_t));
|
||||
|
||||
const size_t st_hash_len = strlen (hashconfig->st_hash);
|
||||
|
||||
for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2)
|
||||
parser_status = module_ctx->module_hash_init_selftest (hashconfig, &hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j);
|
||||
|
||||
tmpdata[i] = c;
|
||||
}
|
||||
|
||||
parser_status = module_ctx->module_hash_decode (hashconfig, hash.digest, hash.salt, hash.esalt, tmpdata, sizeof (hccapx_t));
|
||||
|
||||
hcfree (tmpdata);
|
||||
|
||||
wpa_eapol_t *wpa_eapol = (wpa_eapol_t *) st_esalts_buf;
|
||||
|
||||
wpa_eapol->detected_le = 1;
|
||||
wpa_eapol->detected_be = 0;
|
||||
|
||||
wpa_eapol->nonce_error_corrections = 3;
|
||||
}
|
||||
else if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE)
|
||||
if (hashconfig->opts_type & OPTS_TYPE_BINARY_HASHFILE)
|
||||
{
|
||||
char *tmpfile_bin;
|
||||
|
||||
@ -1959,6 +1935,7 @@ int hashes_init_selftest (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hcfree (hashconfig_st);
|
||||
}
|
||||
}
|
||||
|
||||
if (parser_status == PARSER_OK)
|
||||
{
|
||||
|
@ -1387,72 +1387,6 @@ bool default_unstable_warning (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYB
|
||||
|
||||
// migrate
|
||||
|
||||
void to_hccapx_t (hashcat_ctx_t *hashcat_ctx, hccapx_t *hccapx, const u32 salt_pos, const u32 digest_pos)
|
||||
{
|
||||
const hashes_t *hashes = hashcat_ctx->hashes;
|
||||
|
||||
const salt_t *salts_buf = hashes->salts_buf;
|
||||
const void *esalts_buf = hashes->esalts_buf;
|
||||
|
||||
memset (hccapx, 0, sizeof (hccapx_t));
|
||||
|
||||
hccapx->signature = HCCAPX_SIGNATURE;
|
||||
hccapx->version = HCCAPX_VERSION;
|
||||
|
||||
const salt_t *salt = &salts_buf[salt_pos];
|
||||
|
||||
const u32 digest_cur = salt->digests_offset + digest_pos;
|
||||
|
||||
hccapx->essid_len = salt->salt_len;
|
||||
|
||||
memcpy (hccapx->essid, salt->salt_buf, hccapx->essid_len);
|
||||
|
||||
wpa_eapol_t *wpa_eapols = (wpa_eapol_t *) esalts_buf;
|
||||
wpa_eapol_t *wpa_eapol = &wpa_eapols[digest_cur];
|
||||
|
||||
hccapx->message_pair = wpa_eapol->message_pair;
|
||||
hccapx->keyver = wpa_eapol->keyver;
|
||||
|
||||
hccapx->eapol_len = wpa_eapol->eapol_len;
|
||||
|
||||
if (wpa_eapol->keyver != 1)
|
||||
{
|
||||
u32 eapol_tmp[64] = { 0 };
|
||||
|
||||
for (u32 i = 0; i < 64; i++)
|
||||
{
|
||||
eapol_tmp[i] = byte_swap_32 (wpa_eapol->eapol[i]);
|
||||
}
|
||||
|
||||
memcpy (hccapx->eapol, eapol_tmp, wpa_eapol->eapol_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (hccapx->eapol, wpa_eapol->eapol, wpa_eapol->eapol_len);
|
||||
}
|
||||
|
||||
memcpy (hccapx->mac_ap, wpa_eapol->orig_mac_ap, 6);
|
||||
memcpy (hccapx->mac_sta, wpa_eapol->orig_mac_sta, 6);
|
||||
memcpy (hccapx->nonce_ap, wpa_eapol->orig_nonce_ap, 32);
|
||||
memcpy (hccapx->nonce_sta, wpa_eapol->orig_nonce_sta, 32);
|
||||
|
||||
if (wpa_eapol->keyver != 1)
|
||||
{
|
||||
u32 digest_tmp[4];
|
||||
|
||||
digest_tmp[0] = byte_swap_32 (wpa_eapol->keymic[0]);
|
||||
digest_tmp[1] = byte_swap_32 (wpa_eapol->keymic[1]);
|
||||
digest_tmp[2] = byte_swap_32 (wpa_eapol->keymic[2]);
|
||||
digest_tmp[3] = byte_swap_32 (wpa_eapol->keymic[3]);
|
||||
|
||||
memcpy (hccapx->keymic, digest_tmp, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (hccapx->keymic, wpa_eapol->keymic, 16);
|
||||
}
|
||||
}
|
||||
|
||||
int check_old_hccap (const char *hashfile)
|
||||
{
|
||||
FILE *fp = fopen (hashfile, "rb");
|
||||
|
@ -29338,3 +29338,117 @@ int module_hash_encode_status (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYB
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int module_hash_init_selftest (MAYBE_UNUSED const hashconfig_t *hashconfig, hash_t *hash)
|
||||
{
|
||||
|
||||
if ((hashconfig->hash_mode == 2500) || (hashconfig->hash_mode == 2501))
|
||||
{
|
||||
char *tmpdata = (char *) hcmalloc (sizeof (hccapx_t));
|
||||
|
||||
const size_t st_hash_len = strlen (hashconfig->st_hash);
|
||||
|
||||
for (size_t i = 0, j = 0; j < st_hash_len; i += 1, j += 2)
|
||||
{
|
||||
const u8 c = hex_to_u8 ((const u8 *) hashconfig->st_hash + j);
|
||||
|
||||
tmpdata[i] = c;
|
||||
}
|
||||
|
||||
parser_status = module_ctx->module_hash_decode (hashconfig, hash.digest, hash.salt, hash.esalt, tmpdata, sizeof (hccapx_t));
|
||||
|
||||
hcfree (tmpdata);
|
||||
|
||||
wpa_eapol_t *wpa_eapol = (wpa_eapol_t *) st_esalts_buf;
|
||||
|
||||
wpa_eapol->detected_le = 1;
|
||||
wpa_eapol->detected_be = 0;
|
||||
|
||||
wpa_eapol->nonce_error_corrections = 3;
|
||||
}
|
||||
}
|
||||
|
||||
int module_hash_save_binary (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED const u32 salt_pos, MAYBE_UNUSED const u32 digest_pos, const char **buf)
|
||||
{
|
||||
|
||||
|
||||
void to_hccapx_t (hashcat_ctx_t *hashcat_ctx, hccapx_t *hccapx, const u32 salt_pos, const u32 digest_pos)
|
||||
{
|
||||
const hashes_t *hashes = hashcat_ctx->hashes;
|
||||
|
||||
const salt_t *salts_buf = hashes->salts_buf;
|
||||
const void *esalts_buf = hashes->esalts_buf;
|
||||
|
||||
memset (hccapx, 0, sizeof (hccapx_t));
|
||||
|
||||
hccapx->signature = HCCAPX_SIGNATURE;
|
||||
hccapx->version = HCCAPX_VERSION;
|
||||
|
||||
const salt_t *salt = &salts_buf[salt_pos];
|
||||
|
||||
const u32 digest_cur = salt->digests_offset + digest_pos;
|
||||
|
||||
hccapx->essid_len = salt->salt_len;
|
||||
|
||||
memcpy (hccapx->essid, salt->salt_buf, hccapx->essid_len);
|
||||
|
||||
wpa_eapol_t *wpa_eapols = (wpa_eapol_t *) esalts_buf;
|
||||
wpa_eapol_t *wpa_eapol = &wpa_eapols[digest_cur];
|
||||
|
||||
hccapx->message_pair = wpa_eapol->message_pair;
|
||||
hccapx->keyver = wpa_eapol->keyver;
|
||||
|
||||
hccapx->eapol_len = wpa_eapol->eapol_len;
|
||||
|
||||
if (wpa_eapol->keyver != 1)
|
||||
{
|
||||
u32 eapol_tmp[64] = { 0 };
|
||||
|
||||
for (u32 i = 0; i < 64; i++)
|
||||
{
|
||||
eapol_tmp[i] = byte_swap_32 (wpa_eapol->eapol[i]);
|
||||
}
|
||||
|
||||
memcpy (hccapx->eapol, eapol_tmp, wpa_eapol->eapol_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (hccapx->eapol, wpa_eapol->eapol, wpa_eapol->eapol_len);
|
||||
}
|
||||
|
||||
memcpy (hccapx->mac_ap, wpa_eapol->orig_mac_ap, 6);
|
||||
memcpy (hccapx->mac_sta, wpa_eapol->orig_mac_sta, 6);
|
||||
memcpy (hccapx->nonce_ap, wpa_eapol->orig_nonce_ap, 32);
|
||||
memcpy (hccapx->nonce_sta, wpa_eapol->orig_nonce_sta, 32);
|
||||
|
||||
if (wpa_eapol->keyver != 1)
|
||||
{
|
||||
u32 digest_tmp[4];
|
||||
|
||||
digest_tmp[0] = byte_swap_32 (wpa_eapol->keymic[0]);
|
||||
digest_tmp[1] = byte_swap_32 (wpa_eapol->keymic[1]);
|
||||
digest_tmp[2] = byte_swap_32 (wpa_eapol->keymic[2]);
|
||||
digest_tmp[3] = byte_swap_32 (wpa_eapol->keymic[3]);
|
||||
|
||||
memcpy (hccapx->keymic, digest_tmp, 16);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (hccapx->keymic, wpa_eapol->keymic, 16);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void to_hccapx_t (hashcat_ctx_t *hashcat_ctx, hccapx_t *hccapx, const u32 salt_pos, const u32 digest_pos);
|
||||
|
||||
if ((hashconfig->hash_mode == 2500) || (hashconfig->hash_mode == 2501))
|
||||
{
|
||||
hccapx_t hccapx;
|
||||
|
||||
to_hccapx_t (hashcat_ctx, &hccapx, salt_pos, digest_pos);
|
||||
|
||||
hc_fwrite (&hccapx, sizeof (hccapx_t), 1, fp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user