1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-22 14:48:12 +00:00

Merge branch 'hashcat:master' into blake

This commit is contained in:
Zgzorx 2023-02-13 16:25:41 +01:00 committed by GitHub
commit 6fcc8177cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 229 additions and 11 deletions

View File

@ -2240,6 +2240,7 @@ DECLSPEC int hc_enc_next (PRIVATE_AS hc_enc_t *hc_enc, PRIVATE_AS const u32 *src
int extraBytesToRead = 0;
/* old version, doesnt work with https://github.com/hashcat/hashcat/issues/3592
if (c >= 0xfc)
{
extraBytesToRead = 5;
@ -2260,6 +2261,50 @@ DECLSPEC int hc_enc_next (PRIVATE_AS hc_enc_t *hc_enc, PRIVATE_AS const u32 *src
{
extraBytesToRead = 1;
}
*/
if (c <= 0x7f)
{
extraBytesToRead = 0;
}
else if ((c >= 0xc2) && (c <= 0xdf))
{
extraBytesToRead = 1;
}
else if (c == 0xe0)
{
extraBytesToRead = 2;
}
else if (c == 0xec)
{
extraBytesToRead = 2;
}
else if (c == 0xed)
{
extraBytesToRead = 2;
}
else if (c == 0xef)
{
extraBytesToRead = 2;
}
else if (c == 0xf0)
{
extraBytesToRead = 3;
}
else if (c == 0xf3)
{
extraBytesToRead = 3;
}
else if (c == 0xf4)
{
extraBytesToRead = 3;
}
else
{
hc_enc->pos = src_len;
return -1;
}
if ((src_pos + extraBytesToRead) >= src_sz)
{
@ -2283,9 +2328,11 @@ DECLSPEC int hc_enc_next (PRIVATE_AS hc_enc_t *hc_enc, PRIVATE_AS const u32 *src
switch (extraBytesToRead)
{
/* old version, doesnt work with https://github.com/hashcat/hashcat/issues/3592
/*
case 5:
ch += src_ptr[src_pos++]; ch <<= 6; /* remember, illegal UTF-8 */
ch += src_ptr[src_pos++]; ch <<= 6; /* remember, illegal UTF-8 */
ch += src_ptr[src_pos++]; ch <<= 6; // remember, illegal UTF-8
ch += src_ptr[src_pos++]; ch <<= 6; // remember, illegal UTF-8
ch += src_ptr[src_pos++]; ch <<= 6;
ch += src_ptr[src_pos++]; ch <<= 6;
ch += src_ptr[src_pos++]; ch <<= 6;
@ -2293,13 +2340,14 @@ DECLSPEC int hc_enc_next (PRIVATE_AS hc_enc_t *hc_enc, PRIVATE_AS const u32 *src
ch -= offsetsFromUTF8_5;
break;
case 4:
ch += src_ptr[src_pos++]; ch <<= 6; /* remember, illegal UTF-8 */
ch += src_ptr[src_pos++]; ch <<= 6; // remember, illegal UTF-8
ch += src_ptr[src_pos++]; ch <<= 6;
ch += src_ptr[src_pos++]; ch <<= 6;
ch += src_ptr[src_pos++]; ch <<= 6;
ch += src_ptr[src_pos++];
ch -= offsetsFromUTF8_4;
break;
*/
case 3:
ch += src_ptr[src_pos++]; ch <<= 6;
ch += src_ptr[src_pos++]; ch <<= 6;
@ -2386,6 +2434,7 @@ DECLSPEC int hc_enc_next_global (PRIVATE_AS hc_enc_t *hc_enc, GLOBAL_AS const u3
int extraBytesToRead = 0;
/* old version, doesnt work with https://github.com/hashcat/hashcat/issues/3592
if (c >= 0xfc)
{
extraBytesToRead = 5;
@ -2406,6 +2455,50 @@ DECLSPEC int hc_enc_next_global (PRIVATE_AS hc_enc_t *hc_enc, GLOBAL_AS const u3
{
extraBytesToRead = 1;
}
*/
if (c <= 0x7f)
{
extraBytesToRead = 0;
}
else if ((c >= 0xc2) && (c <= 0xdf))
{
extraBytesToRead = 1;
}
else if (c == 0xe0)
{
extraBytesToRead = 2;
}
else if (c == 0xec)
{
extraBytesToRead = 2;
}
else if (c == 0xed)
{
extraBytesToRead = 2;
}
else if (c == 0xef)
{
extraBytesToRead = 2;
}
else if (c == 0xf0)
{
extraBytesToRead = 3;
}
else if (c == 0xf3)
{
extraBytesToRead = 3;
}
else if (c == 0xf4)
{
extraBytesToRead = 3;
}
else
{
hc_enc->pos = src_len;
return -1;
}
if ((src_pos + extraBytesToRead) >= src_sz)
{
@ -2429,9 +2522,11 @@ DECLSPEC int hc_enc_next_global (PRIVATE_AS hc_enc_t *hc_enc, GLOBAL_AS const u3
switch (extraBytesToRead)
{
/* old version, doesnt work with https://github.com/hashcat/hashcat/issues/3592
/*
case 5:
ch += src_ptr[src_pos++]; ch <<= 6; /* remember, illegal UTF-8 */
ch += src_ptr[src_pos++]; ch <<= 6; /* remember, illegal UTF-8 */
ch += src_ptr[src_pos++]; ch <<= 6; // remember, illegal UTF-8
ch += src_ptr[src_pos++]; ch <<= 6; // remember, illegal UTF-8
ch += src_ptr[src_pos++]; ch <<= 6;
ch += src_ptr[src_pos++]; ch <<= 6;
ch += src_ptr[src_pos++]; ch <<= 6;
@ -2439,13 +2534,14 @@ DECLSPEC int hc_enc_next_global (PRIVATE_AS hc_enc_t *hc_enc, GLOBAL_AS const u3
ch -= offsetsFromUTF8_5;
break;
case 4:
ch += src_ptr[src_pos++]; ch <<= 6; /* remember, illegal UTF-8 */
ch += src_ptr[src_pos++]; ch <<= 6; // remember, illegal UTF-8
ch += src_ptr[src_pos++]; ch <<= 6;
ch += src_ptr[src_pos++]; ch <<= 6;
ch += src_ptr[src_pos++]; ch <<= 6;
ch += src_ptr[src_pos++];
ch -= offsetsFromUTF8_4;
break;
*/
case 3:
ch += src_ptr[src_pos++]; ch <<= 6;
ch += src_ptr[src_pos++]; ch <<= 6;

View File

@ -61,6 +61,20 @@ KERNEL_FQ void m00030_mxx (KERN_ATTR_VECTOR ())
w[0] = w0;
#if VECT_SIZE == 1
md5_ctx_t ctx;
md5_init (&ctx);
md5_update_utf16le (&ctx, w, pw_len);
md5_update (&ctx, s, salt_len);
md5_final (&ctx);
#else
md5_ctx_vector_t ctx;
md5_init_vector (&ctx);
@ -71,6 +85,8 @@ KERNEL_FQ void m00030_mxx (KERN_ATTR_VECTOR ())
md5_final_vector (&ctx);
#endif
const u32x r0 = ctx.h[DGST_R0];
const u32x r1 = ctx.h[DGST_R1];
const u32x r2 = ctx.h[DGST_R2];
@ -139,6 +155,20 @@ KERNEL_FQ void m00030_sxx (KERN_ATTR_VECTOR ())
w[0] = w0;
#if VECT_SIZE == 1
md5_ctx_t ctx;
md5_init (&ctx);
md5_update_utf16le (&ctx, w, pw_len);
md5_update (&ctx, s, salt_len);
md5_final (&ctx);
#else
md5_ctx_vector_t ctx;
md5_init_vector (&ctx);
@ -149,6 +179,8 @@ KERNEL_FQ void m00030_sxx (KERN_ATTR_VECTOR ())
md5_final_vector (&ctx);
#endif
const u32x r0 = ctx.h[DGST_R0];
const u32x r1 = ctx.h[DGST_R1];
const u32x r2 = ctx.h[DGST_R2];

View File

@ -58,6 +58,16 @@ KERNEL_FQ void m00040_mxx (KERN_ATTR_VECTOR ())
w[0] = w0;
#if VECT_SIZE == 1
md5_ctx_t ctx = ctx0;
md5_update_utf16le (&ctx, w, pw_len);
md5_final (&ctx);
#else
md5_ctx_vector_t ctx;
md5_init_vector_from_scalar (&ctx, &ctx0);
@ -66,6 +76,8 @@ KERNEL_FQ void m00040_mxx (KERN_ATTR_VECTOR ())
md5_final_vector (&ctx);
#endif
const u32x r0 = ctx.h[DGST_R0];
const u32x r1 = ctx.h[DGST_R1];
const u32x r2 = ctx.h[DGST_R2];
@ -131,6 +143,16 @@ KERNEL_FQ void m00040_sxx (KERN_ATTR_VECTOR ())
w[0] = w0;
#if VECT_SIZE == 1
md5_ctx_t ctx = ctx0;
md5_update_utf16le (&ctx, w, pw_len);
md5_final (&ctx);
#else
md5_ctx_vector_t ctx;
md5_init_vector_from_scalar (&ctx, &ctx0);
@ -139,6 +161,8 @@ KERNEL_FQ void m00040_sxx (KERN_ATTR_VECTOR ())
md5_final_vector (&ctx);
#endif
const u32x r0 = ctx.h[DGST_R0];
const u32x r1 = ctx.h[DGST_R1];
const u32x r2 = ctx.h[DGST_R2];

View File

@ -52,6 +52,18 @@ KERNEL_FQ void m00070_mxx (KERN_ATTR_VECTOR ())
w[0] = w0;
#if VECT_SIZE == 1
md5_ctx_t ctx;
md5_init (&ctx);
md5_update_utf16le (&ctx, w, pw_len);
md5_final (&ctx);
#else
md5_ctx_vector_t ctx;
md5_init_vector (&ctx);
@ -60,6 +72,8 @@ KERNEL_FQ void m00070_mxx (KERN_ATTR_VECTOR ())
md5_final_vector (&ctx);
#endif
const u32x r0 = ctx.h[DGST_R0];
const u32x r1 = ctx.h[DGST_R1];
const u32x r2 = ctx.h[DGST_R2];
@ -119,6 +133,18 @@ KERNEL_FQ void m00070_sxx (KERN_ATTR_VECTOR ())
w[0] = w0;
#if VECT_SIZE == 1
md5_ctx_t ctx;
md5_init (&ctx);
md5_update_utf16le (&ctx, w, pw_len);
md5_final (&ctx);
#else
md5_ctx_vector_t ctx;
md5_init_vector (&ctx);
@ -127,6 +153,8 @@ KERNEL_FQ void m00070_sxx (KERN_ATTR_VECTOR ())
md5_final_vector (&ctx);
#endif
const u32x r0 = ctx.h[DGST_R0];
const u32x r1 = ctx.h[DGST_R1];
const u32x r2 = ctx.h[DGST_R2];

View File

@ -22,7 +22,6 @@
- Added hash-mode: bcrypt(sha256($pass))
- Added hash-mode: md5(md5($salt).md5(md5($pass)))
##
## Performance
##
@ -49,6 +48,7 @@
- Modules: Added support for non-zero IVs for -m 6800 (Lastpass). Also added `tools/lastpass2hashcat.py`
- Status Code: Add specific return code for self-test fail (-11)
- SCRYPT: Increase buffer sizes in module for hash mode 8900 to allow longer SCRYPT digests
- Unicode: Update UTF8 to UTF16 conversion to match RFC 3629
* changes v6.2.5 -> v6.2.6

View File

@ -68,17 +68,29 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
token.token_cnt = 1;
token.len_min[0] = 1;
token.len_max[0] = 55;
token.len_max[0] = 55 * 2 + 6; /* 55 without $HEX[...] */
token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH;
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
const u8 *unhex_buf = token.buf[0];
int unhex_len = token.len[0];
if (is_hexify (unhex_buf, unhex_len))
{
unhex_len = exec_unhexify (unhex_buf, unhex_len, (u8 *) unhex_buf, unhex_len);
}
else if (unhex_len > 55)
{
return (PARSER_HASH_LENGTH);
}
memset (digest, 0, hashconfig->dgst_size);
const u8 *pw_buf = token.buf[0];
const int pw_len = token.len[0];
const u8 *pw_buf = unhex_buf;
const int pw_len = unhex_len;
memcpy ((char *) digest + 64, pw_buf, pw_len);
@ -116,7 +128,33 @@ int module_hash_encode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
{
char *ptr = (char *) digest_buf;
return snprintf (line_buf, line_size, "%s", ptr + 64);
const char *line_ptr = ptr + 64;
size_t line_len = strnlen (line_ptr, 55);
if (need_hexify ((const u8 *) line_ptr, line_len, ':', 0))
{
char tmp_buf[55 * 2 + 6 + 1] = { 0 };
int tmp_len = 0;
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 ((const u8 *) line_ptr, line_len, (u8 *) tmp_buf + tmp_len);
tmp_len += line_len * 2;
tmp_buf[tmp_len++] = ']';
tmp_buf[tmp_len++] = 0;
return snprintf (line_buf, tmp_len, "%s", tmp_buf);
}
return snprintf (line_buf, line_size, "%s", line_ptr);
}
void module_init (module_ctx_t *module_ctx)