mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-14 03:39:09 +00:00
Get rid of OPTS_TYPE_HASH_COPY in -m 19210
This commit is contained in:
parent
32853374b9
commit
33be14995a
@ -26,8 +26,7 @@ static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE
|
||||
| OPTI_TYPE_SLOW_HASH_SIMD_LOOP;
|
||||
static const u64 OPTS_TYPE = OPTS_TYPE_STOCK_MODULE
|
||||
| OPTS_TYPE_PT_GENERATE_LE
|
||||
| OPTS_TYPE_ST_BASE64
|
||||
| OPTS_TYPE_HASH_COPY;
|
||||
| OPTS_TYPE_ST_BASE64;
|
||||
static const u32 SALT_TYPE = SALT_TYPE_EMBEDDED;
|
||||
static const char *ST_PASS = "hashcat";
|
||||
static const char *ST_HASH = "@S@vm2nBGHes6QkXra0f74XmouSiRzjYD3r/0py+txv0Kr8A4hCPMGFHoZqr41JFiYcJPPOeIheqFseMyLyw/15Pw==@NDY2MDEwNjk3YjBjYzM2MzliMzc3Mzc0ZTNiMTAzNzE=";
|
||||
@ -78,12 +77,12 @@ u64 module_tmp_size (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSED c
|
||||
}
|
||||
|
||||
static const int ROUNDS_QNX = 4096;
|
||||
static const int HASH_SIZE = 64;
|
||||
static const int HASH_SIZE = 64;
|
||||
|
||||
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, MAYBE_UNUSED void *hook_salt_buf, MAYBE_UNUSED hashinfo_t *hash_info, const char *line_buf, MAYBE_UNUSED const int line_len)
|
||||
{
|
||||
u64 *digest = (u64 *) digest_buf;
|
||||
|
||||
|
||||
pbkdf2_sha512_t *pbkdf2_sha512 = (pbkdf2_sha512_t *) esalt_buf;
|
||||
|
||||
hc_token_t token;
|
||||
@ -94,7 +93,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
|
||||
// @digest@hash@salt
|
||||
// @digest,iterations@hash@salt
|
||||
|
||||
|
||||
token.sep[0] = '@';
|
||||
token.len[0] = 0;
|
||||
token.attr[0] = TOKEN_ATTR_FIXED_LENGTH;
|
||||
@ -107,17 +106,23 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
token.sep[2] = '@';
|
||||
token.len_min[2] = 64;
|
||||
token.len_max[2] = 100;
|
||||
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_BASE64A;
|
||||
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_BASE64A;
|
||||
|
||||
token.sep[3] = '@';
|
||||
token.len_min[3] = 32;
|
||||
token.len_max[3] = 60;
|
||||
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH | TOKEN_ATTR_VERIFY_BASE64A;
|
||||
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH
|
||||
| TOKEN_ATTR_VERIFY_BASE64A;
|
||||
|
||||
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
|
||||
|
||||
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
||||
|
||||
u8 tmp_buf[512];
|
||||
|
||||
memset (tmp_buf, 0, sizeof (tmp_buf));
|
||||
|
||||
// check hash type
|
||||
|
||||
if (token.buf[1][0] != 'S') return (PARSER_SIGNATURE_UNMATCHED);
|
||||
@ -133,22 +138,37 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
iter = hc_strtoul ((const char *) token.buf[1] + 2, NULL, 10);
|
||||
}
|
||||
|
||||
// iter++; the additional round is added in the init kernel
|
||||
salt->salt_iter = iter - 1; // iter++; the additional round is added in the init kernel
|
||||
|
||||
salt->salt_iter = iter - 1;
|
||||
// salt
|
||||
|
||||
const u8 *salt_pos = token.buf[3];
|
||||
const int salt_len = token.len[3];
|
||||
|
||||
memset (tmp_buf, 0, sizeof (tmp_buf));
|
||||
|
||||
const int decoded_salt_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf);
|
||||
|
||||
if (decoded_salt_len < 1) return (PARSER_SALT_LENGTH);
|
||||
if (decoded_salt_len > 256) return (PARSER_SALT_LENGTH);
|
||||
|
||||
memcpy (salt->salt_buf, tmp_buf, decoded_salt_len);
|
||||
|
||||
salt->salt_len = decoded_salt_len;
|
||||
|
||||
memcpy (pbkdf2_sha512->salt_buf, tmp_buf, decoded_salt_len);
|
||||
|
||||
// hash
|
||||
|
||||
const u8 *hash_pos = token.buf[2];
|
||||
const int hash_len = token.len[2];
|
||||
|
||||
int decoded_len;
|
||||
u8 tmp_buf[512];
|
||||
memset (tmp_buf, 0, sizeof (tmp_buf));
|
||||
const int decoded_hash_len = base64_decode (base64_to_int, hash_pos, hash_len, tmp_buf);
|
||||
|
||||
if (decoded_hash_len != HASH_SIZE) return (PARSER_SALT_LENGTH);
|
||||
|
||||
memcpy (digest, tmp_buf, decoded_hash_len);
|
||||
|
||||
decoded_len = base64_decode (base64_to_int, hash_pos, hash_len, tmp_buf);
|
||||
if (decoded_len != HASH_SIZE) {
|
||||
return (PARSER_SALT_LENGTH);
|
||||
}
|
||||
memcpy (digest, tmp_buf, 64);
|
||||
digest[0] = byte_swap_64 (digest[0]);
|
||||
digest[1] = byte_swap_64 (digest[1]);
|
||||
digest[2] = byte_swap_64 (digest[2]);
|
||||
@ -158,37 +178,49 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
digest[6] = byte_swap_64 (digest[6]);
|
||||
digest[7] = byte_swap_64 (digest[7]);
|
||||
|
||||
// salt
|
||||
|
||||
const u8 *salt_pos = token.buf[3];
|
||||
const int salt_len = token.len[3];
|
||||
|
||||
memset (tmp_buf, 0, sizeof (tmp_buf));
|
||||
|
||||
decoded_len = base64_decode (base64_to_int, salt_pos, salt_len, tmp_buf);
|
||||
|
||||
if (decoded_len < 1) {
|
||||
return (PARSER_SALT_LENGTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy (pbkdf2_sha512->salt_buf, tmp_buf, decoded_len);
|
||||
salt->salt_buf[0] = pbkdf2_sha512->salt_buf[0];
|
||||
salt->salt_buf[1] = pbkdf2_sha512->salt_buf[1];
|
||||
salt->salt_buf[2] = pbkdf2_sha512->salt_buf[2];
|
||||
salt->salt_buf[3] = pbkdf2_sha512->salt_buf[3];
|
||||
salt->salt_buf[4] = pbkdf2_sha512->salt_buf[4];
|
||||
salt->salt_buf[5] = pbkdf2_sha512->salt_buf[5];
|
||||
salt->salt_buf[6] = pbkdf2_sha512->salt_buf[6];
|
||||
salt->salt_buf[7] = pbkdf2_sha512->salt_buf[7];
|
||||
salt->salt_len = decoded_len;
|
||||
}
|
||||
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)
|
||||
{
|
||||
return snprintf (line_buf, line_size, "%s", hash_info->orighash);
|
||||
const u64 *digest = (const u64 *) digest_buf;
|
||||
|
||||
const pbkdf2_sha512_t *pbkdf2_sha512 = (const pbkdf2_sha512_t *) esalt_buf;
|
||||
|
||||
// need missing example for custom iterator count
|
||||
|
||||
// salt
|
||||
|
||||
u8 salt_buf[512] = { 0 };
|
||||
|
||||
base64_encode (int_to_base64, (const u8 *) pbkdf2_sha512->salt_buf, (const int) salt->salt_len, salt_buf);
|
||||
|
||||
// hash
|
||||
|
||||
u64 hash_tmp[8];
|
||||
|
||||
hash_tmp[0] = byte_swap_64 (digest[0]);
|
||||
hash_tmp[1] = byte_swap_64 (digest[1]);
|
||||
hash_tmp[2] = byte_swap_64 (digest[2]);
|
||||
hash_tmp[3] = byte_swap_64 (digest[3]);
|
||||
hash_tmp[4] = byte_swap_64 (digest[4]);
|
||||
hash_tmp[5] = byte_swap_64 (digest[5]);
|
||||
hash_tmp[6] = byte_swap_64 (digest[6]);
|
||||
hash_tmp[7] = byte_swap_64 (digest[7]);
|
||||
|
||||
u8 hash_buf[512] = { 0 };
|
||||
|
||||
base64_encode (int_to_base64, (const u8 *) hash_tmp, (const int) 64, hash_buf);
|
||||
|
||||
// out
|
||||
|
||||
u8 *out_buf = (u8 *) line_buf;
|
||||
|
||||
const int out_len = snprintf ((char *) out_buf, line_size, "@S@%s@%s",
|
||||
hash_buf,
|
||||
salt_buf);
|
||||
|
||||
return out_len;
|
||||
}
|
||||
|
||||
void module_init (module_ctx_t *module_ctx)
|
||||
|
Loading…
Reference in New Issue
Block a user