mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-26 01:50:10 +00:00
Add module_build_plain_postprocess()
This commit is contained in:
parent
704f353395
commit
e537197184
@ -2,6 +2,8 @@
|
||||
#ifndef _MODULES_H
|
||||
#define _MODULES_H
|
||||
|
||||
void module_init (module_ctx_t *module_ctx);
|
||||
|
||||
u32 module_attack_exec (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra);
|
||||
void *module_benchmark_esalt (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra);
|
||||
void *module_benchmark_hook_salt (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra);
|
||||
@ -42,14 +44,14 @@ const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *ha
|
||||
u64 module_tmp_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);
|
||||
bool module_warmup_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra);
|
||||
|
||||
int module_hash_decode_outfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, const char *line_buf, MAYBE_UNUSED const int line_len);
|
||||
int module_hash_decode_zero_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf);
|
||||
int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, const char *line_buf, MAYBE_UNUSED const int line_len);
|
||||
int module_hash_encode (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);
|
||||
int module_hash_decode_outfile (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, const char *line_buf, MAYBE_UNUSED const int line_len);
|
||||
int module_hash_decode_zero_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf);
|
||||
int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED void *digest_buf, MAYBE_UNUSED salt_t *salt, MAYBE_UNUSED void *esalt_buf, const char *line_buf, MAYBE_UNUSED const int line_len);
|
||||
int module_hash_encode (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);
|
||||
|
||||
void hook12_func (hc_device_param_t *device_param, void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt);
|
||||
void hook23_func (hc_device_param_t *device_param, void *hook_salts_buf, const u32 salt_pos, const u64 pws_cnt);
|
||||
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);
|
||||
|
||||
void module_init (module_ctx_t *module_ctx);
|
||||
int module_build_plain_postprocess (const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz);
|
||||
|
||||
#endif // _MODULES_H
|
||||
|
@ -2288,6 +2288,8 @@ typedef struct module_ctx
|
||||
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);
|
||||
|
||||
int (*module_build_plain_postprocess) (const u32 *, const size_t, const int, u32 *, const size_t);
|
||||
|
||||
} module_ctx_t;
|
||||
|
||||
typedef struct hashcat_ctx
|
||||
|
@ -120,6 +120,7 @@ void module_init (module_ctx_t *module_ctx)
|
||||
module_ctx->module_benchmark_hook_salt = NULL;
|
||||
module_ctx->module_benchmark_mask = NULL;
|
||||
module_ctx->module_benchmark_salt = NULL;
|
||||
module_ctx->module_build_plain_postprocess = NULL;
|
||||
module_ctx->module_dgst_pos0 = module_dgst_pos0;
|
||||
module_ctx->module_dgst_pos1 = module_dgst_pos1;
|
||||
module_ctx->module_dgst_pos2 = module_dgst_pos2;
|
||||
|
25
src/hashes.c
25
src/hashes.c
@ -263,10 +263,11 @@ int save_hash (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain)
|
||||
{
|
||||
debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx;
|
||||
loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
const debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx;
|
||||
const hashes_t *hashes = hashcat_ctx->hashes;
|
||||
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
const loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx;
|
||||
const module_ctx_t *module_ctx = hashcat_ctx->module_ctx;
|
||||
|
||||
const u32 salt_pos = plain->salt_pos;
|
||||
const u32 digest_pos = plain->digest_pos; // relative
|
||||
@ -288,18 +289,18 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl
|
||||
|
||||
build_plain (hashcat_ctx, device_param, plain, plain_buf, &plain_len);
|
||||
|
||||
// TOTP should be base32 encoded
|
||||
if (hashconfig->hash_mode == KERN_TYPE_TOTP_HMACSHA1)
|
||||
if (module_ctx->module_build_plain_postprocess)
|
||||
{
|
||||
// we need a temp buffer for the base32 encoding
|
||||
u32 temp_buf[64] = { 0 };
|
||||
u8 *temp_ptr = (u8 *) temp_buf;
|
||||
|
||||
// encode our plain
|
||||
plain_len = base32_encode (int_to_base32, (const u8 *) plain_ptr, plain_len, (u8 *) temp_buf);
|
||||
const int temp_len = module_ctx->module_build_plain_postprocess (plain_buf, sizeof (plain_buf), plain_len, temp_buf, sizeof (temp_buf));
|
||||
|
||||
// copy the base32 content into our plain buffer
|
||||
strncpy ((char *) plain_ptr, (char *) temp_ptr, sizeof (plain_buf));
|
||||
if (temp_len < (int) sizeof (plain_buf))
|
||||
{
|
||||
memcpy (plain_buf, temp_buf, temp_len);
|
||||
|
||||
plain_len = temp_len;
|
||||
}
|
||||
}
|
||||
|
||||
// crackpos
|
||||
|
@ -1425,7 +1425,6 @@ bool default_potfile_disable (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE
|
||||
return potfile_disable;
|
||||
}
|
||||
|
||||
|
||||
// migrate
|
||||
|
||||
void to_hccapx_t (hashcat_ctx_t *hashcat_ctx, hccapx_t *hccapx, const u32 salt_pos, const u32 digest_pos)
|
||||
|
@ -28533,3 +28533,19 @@ bool potfile_keep_all_hashes
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
int build_plain_postprocess (const u32 *src_buf, MAYBE_UNUSED const size_t src_sz, const int src_len, u32 *dst_buf, MAYBE_UNUSED const size_t dst_sz)
|
||||
{
|
||||
// TOTP should be base32 encoded
|
||||
if (hashconfig->hash_mode == 18100)
|
||||
{
|
||||
|
||||
|
||||
// encode our plain
|
||||
return base32_encode (int_to_base32, (const u8 *) src_buf, src_len, (u8 *) temp_buf);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user