mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 08:08:10 +00:00
Rename hash-mode 98765 to 32500 and add some missing memory initialization
This commit is contained in:
parent
4729342571
commit
b1afc4a9aa
@ -21,7 +21,6 @@
|
||||
#define COMPARE_S M2S(INCLUDE_PATH/inc_comp_single.cl)
|
||||
#define COMPARE_M M2S(INCLUDE_PATH/inc_comp_multi.cl)
|
||||
|
||||
|
||||
typedef struct payload
|
||||
{
|
||||
u32 pl_buf[64];
|
||||
@ -95,8 +94,9 @@ CONSTANT_VK u32 base64_table[64] =
|
||||
};
|
||||
|
||||
// Wow it's the right file
|
||||
|
||||
u32 base64_encode_three_bytes_better (u32 in){ //in has 3 u8s in, first u8 is not set)
|
||||
u32 base64_encode_three_bytes_better (u32 in)
|
||||
{
|
||||
//in has 3 u8s in, first u8 is not set)
|
||||
u32 out;
|
||||
|
||||
out = base64_table[(in >> 18) & 0x3F] << 24;
|
||||
@ -109,7 +109,6 @@ u32 base64_encode_three_bytes_better (u32 in){ //in has 3 u8s in, first u8 is no
|
||||
|
||||
void base64_encode_sha256 (u32 *out, const u32 *in)
|
||||
{
|
||||
|
||||
out[0] = base64_encode_three_bytes_better( (in[0] >> 8));
|
||||
out[1] = base64_encode_three_bytes_better((in[0] << 16) | (in[1] >> 16));
|
||||
out[2] = base64_encode_three_bytes_better((in[1] << 8) | (in[2] >> 24));
|
||||
@ -126,14 +125,10 @@ void base64_encode_sha256 (u32 *out, const u32 *in)
|
||||
// 0x7c = ord('A') ^ ord('=') so replaces the A that we'll get at the end with an =
|
||||
out[10] = base64_encode_three_bytes_better(in[7] << 8) ^ 0x7c;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
KERNEL_FQ void m98765_init (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
KERNEL_FQ void m32500_init (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
{
|
||||
|
||||
|
||||
const u64 gid = get_global_id (0);
|
||||
|
||||
if (gid >= GID_CNT) return;
|
||||
@ -144,11 +139,10 @@ KERNEL_FQ void m98765_init (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
sha256_update_global_swap (&ctx, pws[gid].i, pws[gid].pw_len);
|
||||
sha256_final (&ctx);
|
||||
|
||||
u32 w[16] = { 0 }; // only uses 11, but have to be 16 for sha256_hmac_init_global_swap function
|
||||
u32 w[16] = { 0 }; // only uses 11, but have to be 16 for sha256_hmac_init_global function
|
||||
|
||||
base64_encode_sha256 (w, ctx.h);
|
||||
|
||||
|
||||
// pbkdf
|
||||
|
||||
sha256_hmac_ctx_t sha256_hmac_ctx;
|
||||
@ -173,7 +167,7 @@ KERNEL_FQ void m98765_init (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
tmps[gid].opad[6] = sha256_hmac_ctx.opad.h[6];
|
||||
tmps[gid].opad[7] = sha256_hmac_ctx.opad.h[7];
|
||||
|
||||
sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[DIGESTS_OFFSET_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len);
|
||||
sha256_hmac_update_global_swap (&sha256_hmac_ctx, salt_bufs[SALT_POS_HOST].salt_buf, salt_bufs[SALT_POS_HOST].salt_len);
|
||||
|
||||
for (u32 i = 0, j = 1; i < 8; i += 8, j += 1)
|
||||
{
|
||||
@ -226,7 +220,7 @@ KERNEL_FQ void m98765_init (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
|
||||
}
|
||||
|
||||
KERNEL_FQ void m98765_loop (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
KERNEL_FQ void m32500_loop (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
{
|
||||
//pbkdf2hmac here
|
||||
|
||||
@ -334,7 +328,7 @@ KERNEL_FQ void m98765_loop (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
}
|
||||
}
|
||||
|
||||
KERNEL_FQ void m98765_comp (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
KERNEL_FQ void m32500_comp (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
{
|
||||
/**
|
||||
* base
|
||||
@ -397,8 +391,7 @@ KERNEL_FQ void m98765_comp (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
|
||||
if (gid >= GID_CNT) return;
|
||||
|
||||
|
||||
u32 ukey[8] = {0};
|
||||
u32 ukey[8];
|
||||
|
||||
ukey[0] = tmps[gid].out[0];
|
||||
ukey[1] = tmps[gid].out[1];
|
||||
@ -409,34 +402,32 @@ KERNEL_FQ void m98765_comp (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
ukey[6] = tmps[gid].out[6];
|
||||
ukey[7] = tmps[gid].out[7];
|
||||
|
||||
u32 ks[60] = {0};
|
||||
u32 ks[60];
|
||||
|
||||
AES256_set_decrypt_key (ks, ukey, s_te0, s_te1, s_te2, s_te3, s_td0, s_td1, s_td2, s_td3);
|
||||
|
||||
// iv
|
||||
|
||||
|
||||
|
||||
u32 prev_ct[4]; // iv is the first 4 u32s -> needs to be prev ct for cbc encryption (each block used prior ct)
|
||||
// todo: might want to swap in module
|
||||
|
||||
prev_ct[0] = hc_swap32 (esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[0]);
|
||||
prev_ct[1] = hc_swap32 (esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[1]);
|
||||
prev_ct[2] = hc_swap32 (esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[2]);
|
||||
prev_ct[3] = hc_swap32 (esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[3]);
|
||||
|
||||
|
||||
u32 isAscii = 0;
|
||||
|
||||
// ct
|
||||
u32 ct_buf[4] = {0}; //ct is the payload (- the first 4 u32s)
|
||||
u32 pt_buf[4] = {0};
|
||||
|
||||
|
||||
|
||||
// Padding is Crypto.pad.iso10126 -pads with random bytes until the last byte, and which defines the number of padding bytes
|
||||
// So knocking off last block to not account for any non-ascii padding
|
||||
// todo: pkcs_padding_bs16() might be able to replace this
|
||||
|
||||
for (u32 i=4; i < esalt_bufs[DIGESTS_OFFSET_HOST].pl_len-4; i+=4)
|
||||
{
|
||||
|
||||
ct_buf[0] = hc_swap32(esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[i ]);
|
||||
ct_buf[1] = hc_swap32(esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[i + 1]);
|
||||
ct_buf[2] = hc_swap32(esalt_bufs[DIGESTS_OFFSET_HOST].pl_buf[i + 2]);
|
||||
@ -444,15 +435,14 @@ KERNEL_FQ void m98765_comp (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
|
||||
AES256_decrypt (ks, ct_buf, pt_buf, s_td0, s_td1, s_td2, s_td3, s_td4);
|
||||
|
||||
for(u32 x = 0; x < 4; x ++){
|
||||
for(u32 x = 0; x < 4; x ++)
|
||||
{
|
||||
pt_buf[x] ^= prev_ct[x];
|
||||
isAscii |= pt_buf[x] & 0x80808080; //check the ciphertext is human readable
|
||||
prev_ct[x] = ct_buf[x]; //set previous CT as the new IV for the next block
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
const u32 r0 = isAscii;
|
||||
const u32 r1 = 0;
|
||||
const u32 r2 = 0;
|
||||
@ -463,7 +453,4 @@ KERNEL_FQ void m98765_comp (KERN_ATTR_TMPS_ESALT (doge_tmp_t, payload_t))
|
||||
#ifdef KERNEL_STATIC
|
||||
#include COMPARE_M
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "modules.h"
|
||||
@ -11,8 +10,6 @@
|
||||
#include "convert.h"
|
||||
#include "shared.h"
|
||||
|
||||
|
||||
|
||||
static const u32 ATTACK_EXEC = ATTACK_EXEC_OUTSIDE_KERNEL;
|
||||
static const u32 DGST_POS0 = 0;
|
||||
static const u32 DGST_POS1 = 1;
|
||||
@ -21,19 +18,14 @@ static const u32 DGST_POS3 = 3;
|
||||
static const u32 DGST_SIZE = DGST_SIZE_4_4;
|
||||
static const u32 HASH_CATEGORY = HASH_CATEGORY_RAW_HASH;
|
||||
static const char *HASH_NAME = "Dogechain";
|
||||
static const u64 KERN_TYPE = 98765;
|
||||
static const u64 KERN_TYPE = 32500;
|
||||
static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
|
||||
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP;
|
||||
static const u64 OPTS_TYPE = OPTS_TYPE_HASH_COPY;
|
||||
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
||||
|
||||
|
||||
static const char *ST_PASS = "hashcat";
|
||||
static const char *ST_HASH = "$dogechain$0*5000*EEmAkgiMlVrToRhu2suq91R5Frf+VQCvNzv9lj6OwRWIf/3IM31wqhJM7gGQpinXH9kqHkuQ2DMZxspgA7QFAddsUWvZxGdNAkaeKy90EAsTLIuDQnH3plfBQfmL6j5NPaH7Nr7kF1PdvM0pbUw6XHySBYkD/rPHNM6n58NRK4xfO4VVMykeX3+m2LaVyv5s269r/op38svRPT0YFGpRcanY6/U1BeSrvG2IXii1BKXXAcVEN4GFmyEQRWKI0uZE+3M0atf7UEPD4K9tmEKosqdsF4MFLiBtfI4eq0+926ijoezDmUPvHIiyQZ9CH2jZ*6jOgqW/GxL9He1afQiINIg==";
|
||||
|
||||
static const char *SIGNATURE_DOGECHAIN = "$dogechain$0";
|
||||
|
||||
|
||||
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) { return ATTACK_EXEC; }
|
||||
u32 module_dgst_pos0 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS0; }
|
||||
u32 module_dgst_pos1 (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return DGST_POS1; }
|
||||
@ -49,12 +41,13 @@ u32 module_salt_type (MAYBE_UNUSED const hashconfig_t *hashconfig,
|
||||
const char *module_st_hash (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_HASH; }
|
||||
const char *module_st_pass (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED const user_options_t *user_options, MAYBE_UNUSED const user_options_extra_t *user_options_extra) { return ST_PASS; }
|
||||
|
||||
static const char *SIGNATURE_DOGECHAIN = "$dogechain$0";
|
||||
|
||||
typedef struct payload
|
||||
{
|
||||
u32 pl_buf[64];
|
||||
u32 pl_len;
|
||||
|
||||
|
||||
} payload_t;
|
||||
|
||||
typedef struct doge_tmp
|
||||
@ -67,7 +60,6 @@ typedef struct doge_tmp
|
||||
|
||||
} doge_tmp_t;
|
||||
|
||||
|
||||
u64 module_esalt_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)
|
||||
{
|
||||
const u64 esalt_size = (const u64) sizeof (payload_t);
|
||||
@ -92,6 +84,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
|
||||
hc_token_t token;
|
||||
|
||||
memset (&token, 0, sizeof (hc_token_t));
|
||||
|
||||
token.token_cnt = 4;
|
||||
|
||||
token.signatures_cnt = 1;
|
||||
@ -142,8 +136,8 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
|
||||
int tmp_len = base64_decode (base64_to_int, (const u8 *) data_pos, data_len, tmp_buf);
|
||||
|
||||
|
||||
memcpy (payload->pl_buf, tmp_buf, tmp_len);
|
||||
|
||||
payload->pl_len = tmp_len/4;
|
||||
|
||||
// salt
|
||||
@ -160,6 +154,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
salt->salt_len = tmp_len;
|
||||
|
||||
// iter
|
||||
|
||||
const u8 *iter_pos = token.buf[1];
|
||||
|
||||
salt->salt_iter = hc_strtoul ((const char *) iter_pos, NULL, 10) - 1;
|
||||
@ -171,13 +166,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
digest[2] = 0;
|
||||
digest[3] = 0;
|
||||
|
||||
|
||||
return (PARSER_OK);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
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, MAYBE_UNUSED const void *hook_salt_buf, MAYBE_UNUSED const hashinfo_t *hash_info, char *line_buf, MAYBE_UNUSED const int line_size)
|
||||
{
|
||||
const int line_len = snprintf (line_buf, line_size, "%s", hash_info->orighash);
|
||||
@ -185,7 +176,6 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
return line_len;
|
||||
}
|
||||
|
||||
|
||||
void module_init (module_ctx_t *module_ctx)
|
||||
{
|
||||
module_ctx->module_context_size = MODULE_CONTEXT_SIZE_CURRENT;
|
Loading…
Reference in New Issue
Block a user