diff --git a/include/interface_migrate.h b/include/interface_migrate.h index 56d16ae70..8a5f0103b 100644 --- a/include/interface_migrate.h +++ b/include/interface_migrate.h @@ -1,34 +1,4 @@ -/** - * algo specific - */ - -typedef struct pbkdf2_sha256 -{ - u32 salt_buf[16]; - -} pbkdf2_sha256_t; - -typedef struct pbkdf1_sha1_tmp -{ - // pbkdf1-sha1 is limited to 160 bits - - u32 ipad[5]; - u32 opad[5]; - - u32 out[5]; - -} pbkdf1_sha1_tmp_t; - -typedef struct pbkdf2_sha256_tmp -{ - u32 ipad[8]; - u32 opad[8]; - - u32 dgst[32]; - u32 out[32]; - -} pbkdf2_sha256_tmp_t; typedef enum kern_type { @@ -84,14 +54,3 @@ typedef enum kern_type } kern_type_t; -/** - * Default iteration numbers - */ - -typedef enum rounds_count -{ - ROUNDS_LIBREOFFICE = 100000, - ROUNDS_OPENOFFICE = 1024, - ROUNDS_KEEPASS = 6000, - -} rounds_count_t; diff --git a/src/interface_migrate.c b/src/interface_migrate.c index 548bb2fb0..c4fcb3b73 100644 --- a/src/interface_migrate.c +++ b/src/interface_migrate.c @@ -794,59 +794,6 @@ int md5s_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSE return (PARSER_OK); } -int md5pix_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig) -{ - u32 *digest = (u32 *) hash_buf->digest; - - token_t token; - - token.token_cnt = 1; - - token.sep[0] = ':'; - token.len_min[0] = 16; - token.len_max[0] = 16; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_BASE64B; - - const int rc_tokenizer = input_tokenizer (input_buf, input_len, &token); - - if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - - const u8 *hash_pos = token.buf[0]; - - digest[0] = itoa64_to_int (hash_pos[ 0]) << 0 - | itoa64_to_int (hash_pos[ 1]) << 6 - | itoa64_to_int (hash_pos[ 2]) << 12 - | itoa64_to_int (hash_pos[ 3]) << 18; - digest[1] = itoa64_to_int (hash_pos[ 4]) << 0 - | itoa64_to_int (hash_pos[ 5]) << 6 - | itoa64_to_int (hash_pos[ 6]) << 12 - | itoa64_to_int (hash_pos[ 7]) << 18; - digest[2] = itoa64_to_int (hash_pos[ 8]) << 0 - | itoa64_to_int (hash_pos[ 9]) << 6 - | itoa64_to_int (hash_pos[10]) << 12 - | itoa64_to_int (hash_pos[11]) << 18; - digest[3] = itoa64_to_int (hash_pos[12]) << 0 - | itoa64_to_int (hash_pos[13]) << 6 - | itoa64_to_int (hash_pos[14]) << 12 - | itoa64_to_int (hash_pos[15]) << 18; - - if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) - { - digest[0] -= MD5M_A; - digest[1] -= MD5M_B; - digest[2] -= MD5M_C; - digest[3] -= MD5M_D; - } - - digest[0] &= 0x00ffffff; - digest[1] &= 0x00ffffff; - digest[2] &= 0x00ffffff; - digest[3] &= 0x00ffffff; - - return (PARSER_OK); -} - int md5md5_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig) { u32 *digest = (u32 *) hash_buf->digest; @@ -1886,96 +1833,6 @@ int episerver4_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE return (PARSER_OK); } -int sha512grub_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig) -{ - u64 *digest = (u64 *) hash_buf->digest; - - salt_t *salt = hash_buf->salt; - - pbkdf2_sha512_t *pbkdf2_sha512 = (pbkdf2_sha512_t *) hash_buf->esalt; - - token_t token; - - token.token_cnt = 4; - - token.signatures_cnt = 1; - token.signatures_buf[0] = SIGNATURE_SHA512GRUB; - - token.len[0] = 19; - token.attr[0] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_SIGNATURE; - - token.len_min[1] = 1; - token.len_max[1] = 6; - token.sep[1] = '.'; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.len_min[2] = SALT_MIN; - token.len_max[2] = SALT_MAX; - token.sep[2] = '.'; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - token.len_min[3] = 128; - token.len_max[3] = 128; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - const int rc_tokenizer = input_tokenizer (input_buf, input_len, &token); - - if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - - const u8 *hash_pos = token.buf[3]; - - digest[0] = hex_to_u64 (hash_pos + 0); - digest[1] = hex_to_u64 (hash_pos + 16); - digest[2] = hex_to_u64 (hash_pos + 32); - digest[3] = hex_to_u64 (hash_pos + 48); - digest[4] = hex_to_u64 (hash_pos + 64); - digest[5] = hex_to_u64 (hash_pos + 80); - digest[6] = hex_to_u64 (hash_pos + 96); - digest[7] = hex_to_u64 (hash_pos + 112); - - digest[0] = byte_swap_64 (digest[0]); - digest[1] = byte_swap_64 (digest[1]); - digest[2] = byte_swap_64 (digest[2]); - digest[3] = byte_swap_64 (digest[3]); - digest[4] = byte_swap_64 (digest[4]); - digest[5] = byte_swap_64 (digest[5]); - digest[6] = byte_swap_64 (digest[6]); - digest[7] = byte_swap_64 (digest[7]); - - const u8 *salt_pos = token.buf[2]; - const int salt_len = token.len[2] / 2; - - u8 *salt_buf_ptr = (u8 *) pbkdf2_sha512->salt_buf; - - for (int i = 0, j = 0; i < salt_len; i += 1, j += 2) - { - salt_buf_ptr[i] = hex_to_u8 (salt_pos + j); - } - - salt_buf_ptr[salt_len + 3] = 0x01; - salt_buf_ptr[salt_len + 4] = 0x80; - - 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 = salt_len; - - const u8 *iter_pos = token.buf[1]; - - salt->salt_iter = hc_strtoul ((const char *) iter_pos, NULL, 10) - 1; - - return (PARSER_OK); -} - int sha512b64s_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig) { u64 *digest = (u64 *) hash_buf->digest; @@ -2942,567 +2799,6 @@ int streebog_512s_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MA return (PARSER_OK); } -int ecryptfs_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig) -{ - u32 *digest = (u32 *) hash_buf->digest; - - salt_t *salt = hash_buf->salt; - - token_t token; - - token.token_cnt = 5; - - token.signatures_cnt = 1; - token.signatures_buf[0] = SIGNATURE_ECRYPTFS; - - token.len[0] = 10; - token.attr[0] = TOKEN_ATTR_FIXED_LENGTH - | TOKEN_ATTR_VERIFY_SIGNATURE; - - token.sep[1] = '$'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.sep[2] = '$'; - token.len_min[2] = 1; - token.len_max[2] = 1; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.sep[3] = '$'; - token.len_min[3] = 16; - token.len_max[3] = 16; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - token.sep[4] = '$'; - token.len_min[4] = 16; - token.len_max[4] = 16; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - const int rc_tokenizer = input_tokenizer (input_buf, input_len, &token); - - if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - - // hash - - const u8 *hash_pos = token.buf[4]; - - digest[ 0] = hex_to_u32 (hash_pos + 0); - digest[ 1] = hex_to_u32 (hash_pos + 8); - digest[ 2] = 0; - digest[ 3] = 0; - digest[ 4] = 0; - digest[ 5] = 0; - digest[ 6] = 0; - digest[ 7] = 0; - digest[ 8] = 0; - digest[ 9] = 0; - digest[10] = 0; - digest[11] = 0; - digest[12] = 0; - digest[13] = 0; - digest[14] = 0; - digest[15] = 0; - - digest[0] = byte_swap_32 (digest[0]); - digest[1] = byte_swap_32 (digest[1]); - - // salt - - const u8 *salt_pos = token.buf[3]; - - salt->salt_buf[0] = hex_to_u32 (salt_pos + 0); - salt->salt_buf[1] = hex_to_u32 (salt_pos + 8); - - salt->salt_buf[0] = byte_swap_32 (salt->salt_buf[0]); - salt->salt_buf[1] = byte_swap_32 (salt->salt_buf[1]); - - salt->salt_iter = ROUNDS_ECRYPTFS; - salt->salt_len = 8; - - return (PARSER_OK); -} - -int keepass_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig) -{ - u32 *digest = (u32 *) hash_buf->digest; - - salt_t *salt = hash_buf->salt; - - keepass_t *keepass = (keepass_t *) hash_buf->esalt; - - bool is_keyfile_present = false; - - if (input_len < 128) return (PARSER_SALT_LENGTH); - - if ((input_buf[input_len - (64 + 1 + 2 + 1 + 2)] == '*') - && (input_buf[input_len - (64 + 1 + 2 + 1 + 1)] == '1') - && (input_buf[input_len - (64 + 1 + 2 + 1 + 0)] == '*')) is_keyfile_present = true; - - token_t token; - - token.signatures_cnt = 1; - token.signatures_buf[0] = SIGNATURE_KEEPASS; - - token.sep[0] = '*'; - token.len_min[0] = 9; - token.len_max[0] = 9; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_SIGNATURE; - - token.sep[1] = '*'; - token.len_min[1] = 1; - token.len_max[1] = 1; - token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.sep[2] = '*'; - token.len_min[2] = 1; - token.len_max[2] = 8; - token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.sep[3] = '*'; - token.len_min[3] = 1; - token.len_max[3] = 3; - token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - if (input_len < 16) return (PARSER_SALT_LENGTH); - - const u8 version = input_buf[10]; - - if (version == '1') - { - token.token_cnt = 11; - - token.sep[4] = '*'; - token.len_min[4] = 32; - token.len_max[4] = 32; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - token.sep[5] = '*'; - token.len_min[5] = 64; - token.len_max[5] = 64; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - token.sep[6] = '*'; - token.len_min[6] = 32; - token.len_max[6] = 32; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - token.sep[7] = '*'; - token.len_min[7] = 64; - token.len_max[7] = 64; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - token.sep[8] = '*'; - token.len_min[8] = 1; - token.len_max[8] = 1; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.sep[9] = '*'; - token.len_min[9] = 1; - token.len_max[9] = 6; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.sep[10] = '*'; - token.len_min[10] = 2; - token.len_max[10] = 600000; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - if (is_keyfile_present == true) - { - token.token_cnt = 14; - - token.sep[11] = '*'; - token.len_min[11] = 1; - token.len_max[11] = 1; - token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.sep[12] = '*'; - token.len_min[12] = 2; - token.len_max[12] = 2; - token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.sep[13] = '*'; - token.len_min[13] = 64; - token.len_max[13] = 64; - token.attr[13] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - } - } - else if (version == '2') - { - token.token_cnt = 9; - - token.sep[4] = '*'; - token.len_min[4] = 64; - token.len_max[4] = 64; - token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - token.sep[5] = '*'; - token.len_min[5] = 64; - token.len_max[5] = 64; - token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - token.sep[6] = '*'; - token.len_min[6] = 32; - token.len_max[6] = 32; - token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - token.sep[7] = '*'; - token.len_min[7] = 64; - token.len_max[7] = 64; - token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - token.sep[8] = '*'; - token.len_min[8] = 64; - token.len_max[8] = 64; - token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - - if (is_keyfile_present == true) - { - token.token_cnt = 12; - - token.sep[9] = '*'; - token.len_min[9] = 1; - token.len_max[9] = 1; - token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.sep[10] = '*'; - token.len_min[10] = 2; - token.len_max[10] = 2; - token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_DIGIT; - - token.sep[11] = '*'; - token.len_min[11] = 64; - token.len_max[11] = 64; - token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH - | TOKEN_ATTR_VERIFY_HEX; - } - } - else - { - return (PARSER_SALT_VALUE); - } - - const int rc_tokenizer = input_tokenizer (input_buf, input_len, &token); - - if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - - // version - - const u8 *version_pos = token.buf[1]; - - keepass->version = hc_strtoul ((const char *) version_pos, NULL, 10); - - // iter - - const u8 *rounds_pos = token.buf[2]; - - salt->salt_iter = hc_strtoul ((const char *) rounds_pos, NULL, 10); - - // algo - - const u8 *algorithm_pos = token.buf[3]; - - keepass->algorithm = hc_strtoul ((const char *) algorithm_pos, NULL, 10); - - // final_random_seed_pos - - const u8 *final_random_seed_pos = token.buf[4]; - - keepass->final_random_seed[0] = hex_to_u32 ((const u8 *) &final_random_seed_pos[ 0]); - keepass->final_random_seed[1] = hex_to_u32 ((const u8 *) &final_random_seed_pos[ 8]); - keepass->final_random_seed[2] = hex_to_u32 ((const u8 *) &final_random_seed_pos[16]); - keepass->final_random_seed[3] = hex_to_u32 ((const u8 *) &final_random_seed_pos[24]); - - keepass->final_random_seed[0] = byte_swap_32 (keepass->final_random_seed[0]); - keepass->final_random_seed[1] = byte_swap_32 (keepass->final_random_seed[1]); - keepass->final_random_seed[2] = byte_swap_32 (keepass->final_random_seed[2]); - keepass->final_random_seed[3] = byte_swap_32 (keepass->final_random_seed[3]); - - if (keepass->version == 2) - { - keepass->final_random_seed[4] = hex_to_u32 ((const u8 *) &final_random_seed_pos[32]); - keepass->final_random_seed[5] = hex_to_u32 ((const u8 *) &final_random_seed_pos[40]); - keepass->final_random_seed[6] = hex_to_u32 ((const u8 *) &final_random_seed_pos[48]); - keepass->final_random_seed[7] = hex_to_u32 ((const u8 *) &final_random_seed_pos[56]); - - keepass->final_random_seed[4] = byte_swap_32 (keepass->final_random_seed[4]); - keepass->final_random_seed[5] = byte_swap_32 (keepass->final_random_seed[5]); - keepass->final_random_seed[6] = byte_swap_32 (keepass->final_random_seed[6]); - keepass->final_random_seed[7] = byte_swap_32 (keepass->final_random_seed[7]); - } - - // transf_random_seed_pos - - const u8 *transf_random_seed_pos = token.buf[5]; - - keepass->transf_random_seed[0] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[ 0]); - keepass->transf_random_seed[1] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[ 8]); - keepass->transf_random_seed[2] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[16]); - keepass->transf_random_seed[3] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[24]); - keepass->transf_random_seed[4] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[32]); - keepass->transf_random_seed[5] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[40]); - keepass->transf_random_seed[6] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[48]); - keepass->transf_random_seed[7] = hex_to_u32 ((const u8 *) &transf_random_seed_pos[56]); - - keepass->transf_random_seed[0] = byte_swap_32 (keepass->transf_random_seed[0]); - keepass->transf_random_seed[1] = byte_swap_32 (keepass->transf_random_seed[1]); - keepass->transf_random_seed[2] = byte_swap_32 (keepass->transf_random_seed[2]); - keepass->transf_random_seed[3] = byte_swap_32 (keepass->transf_random_seed[3]); - keepass->transf_random_seed[4] = byte_swap_32 (keepass->transf_random_seed[4]); - keepass->transf_random_seed[5] = byte_swap_32 (keepass->transf_random_seed[5]); - keepass->transf_random_seed[6] = byte_swap_32 (keepass->transf_random_seed[6]); - keepass->transf_random_seed[7] = byte_swap_32 (keepass->transf_random_seed[7]); - - // enc_iv_pos - - const u8 *enc_iv_pos = token.buf[6]; - - keepass->enc_iv[0] = hex_to_u32 ((const u8 *) &enc_iv_pos[ 0]); - keepass->enc_iv[1] = hex_to_u32 ((const u8 *) &enc_iv_pos[ 8]); - keepass->enc_iv[2] = hex_to_u32 ((const u8 *) &enc_iv_pos[16]); - keepass->enc_iv[3] = hex_to_u32 ((const u8 *) &enc_iv_pos[24]); - - keepass->enc_iv[0] = byte_swap_32 (keepass->enc_iv[0]); - keepass->enc_iv[1] = byte_swap_32 (keepass->enc_iv[1]); - keepass->enc_iv[2] = byte_swap_32 (keepass->enc_iv[2]); - keepass->enc_iv[3] = byte_swap_32 (keepass->enc_iv[3]); - - const u8 *keyfile_pos = NULL; - - if (keepass->version == 1) - { - // contents_hash - - const u8 *contents_hash_pos = token.buf[7]; - - keepass->contents_hash[0] = hex_to_u32 ((const u8 *) &contents_hash_pos[ 0]); - keepass->contents_hash[1] = hex_to_u32 ((const u8 *) &contents_hash_pos[ 8]); - keepass->contents_hash[2] = hex_to_u32 ((const u8 *) &contents_hash_pos[16]); - keepass->contents_hash[3] = hex_to_u32 ((const u8 *) &contents_hash_pos[24]); - keepass->contents_hash[4] = hex_to_u32 ((const u8 *) &contents_hash_pos[32]); - keepass->contents_hash[5] = hex_to_u32 ((const u8 *) &contents_hash_pos[40]); - keepass->contents_hash[6] = hex_to_u32 ((const u8 *) &contents_hash_pos[48]); - keepass->contents_hash[7] = hex_to_u32 ((const u8 *) &contents_hash_pos[56]); - - keepass->contents_hash[0] = byte_swap_32 (keepass->contents_hash[0]); - keepass->contents_hash[1] = byte_swap_32 (keepass->contents_hash[1]); - keepass->contents_hash[2] = byte_swap_32 (keepass->contents_hash[2]); - keepass->contents_hash[3] = byte_swap_32 (keepass->contents_hash[3]); - keepass->contents_hash[4] = byte_swap_32 (keepass->contents_hash[4]); - keepass->contents_hash[5] = byte_swap_32 (keepass->contents_hash[5]); - keepass->contents_hash[6] = byte_swap_32 (keepass->contents_hash[6]); - keepass->contents_hash[7] = byte_swap_32 (keepass->contents_hash[7]); - - // contents - - const u8 *contents_pos = token.buf[10]; - const int contents_len = token.len[10]; - - keepass->contents_len = contents_len / 2; - - for (int i = 0, j = 0; j < contents_len; i += 1, j += 8) - { - keepass->contents[i] = hex_to_u32 ((const u8 *) &contents_pos[j]); - - keepass->contents[i] = byte_swap_32 (keepass->contents[i]); - } - - if (is_keyfile_present == true) - { - keyfile_pos = token.buf[13]; - } - } - else if (keepass->version == 2) - { - // expected_bytes - - const u8 *expected_bytes_pos = token.buf[7]; - - keepass->expected_bytes[0] = hex_to_u32 ((const u8 *) &expected_bytes_pos[ 0]); - keepass->expected_bytes[1] = hex_to_u32 ((const u8 *) &expected_bytes_pos[ 8]); - keepass->expected_bytes[2] = hex_to_u32 ((const u8 *) &expected_bytes_pos[16]); - keepass->expected_bytes[3] = hex_to_u32 ((const u8 *) &expected_bytes_pos[24]); - keepass->expected_bytes[4] = hex_to_u32 ((const u8 *) &expected_bytes_pos[32]); - keepass->expected_bytes[5] = hex_to_u32 ((const u8 *) &expected_bytes_pos[40]); - keepass->expected_bytes[6] = hex_to_u32 ((const u8 *) &expected_bytes_pos[48]); - keepass->expected_bytes[7] = hex_to_u32 ((const u8 *) &expected_bytes_pos[56]); - - keepass->expected_bytes[0] = byte_swap_32 (keepass->expected_bytes[0]); - keepass->expected_bytes[1] = byte_swap_32 (keepass->expected_bytes[1]); - keepass->expected_bytes[2] = byte_swap_32 (keepass->expected_bytes[2]); - keepass->expected_bytes[3] = byte_swap_32 (keepass->expected_bytes[3]); - keepass->expected_bytes[4] = byte_swap_32 (keepass->expected_bytes[4]); - keepass->expected_bytes[5] = byte_swap_32 (keepass->expected_bytes[5]); - keepass->expected_bytes[6] = byte_swap_32 (keepass->expected_bytes[6]); - keepass->expected_bytes[7] = byte_swap_32 (keepass->expected_bytes[7]); - - // contents_hash - - const u8 *contents_hash_pos = token.buf[8]; - - keepass->contents_hash[0] = hex_to_u32 ((const u8 *) &contents_hash_pos[ 0]); - keepass->contents_hash[1] = hex_to_u32 ((const u8 *) &contents_hash_pos[ 8]); - keepass->contents_hash[2] = hex_to_u32 ((const u8 *) &contents_hash_pos[16]); - keepass->contents_hash[3] = hex_to_u32 ((const u8 *) &contents_hash_pos[24]); - keepass->contents_hash[4] = hex_to_u32 ((const u8 *) &contents_hash_pos[32]); - keepass->contents_hash[5] = hex_to_u32 ((const u8 *) &contents_hash_pos[40]); - keepass->contents_hash[6] = hex_to_u32 ((const u8 *) &contents_hash_pos[48]); - keepass->contents_hash[7] = hex_to_u32 ((const u8 *) &contents_hash_pos[56]); - - keepass->contents_hash[0] = byte_swap_32 (keepass->contents_hash[0]); - keepass->contents_hash[1] = byte_swap_32 (keepass->contents_hash[1]); - keepass->contents_hash[2] = byte_swap_32 (keepass->contents_hash[2]); - keepass->contents_hash[3] = byte_swap_32 (keepass->contents_hash[3]); - keepass->contents_hash[4] = byte_swap_32 (keepass->contents_hash[4]); - keepass->contents_hash[5] = byte_swap_32 (keepass->contents_hash[5]); - keepass->contents_hash[6] = byte_swap_32 (keepass->contents_hash[6]); - keepass->contents_hash[7] = byte_swap_32 (keepass->contents_hash[7]); - - if (is_keyfile_present == true) - { - keyfile_pos = token.buf[11]; - } - } - - if (is_keyfile_present == true) - { - keepass->keyfile_len = 32; - - keepass->keyfile[0] = hex_to_u32 ((const u8 *) &keyfile_pos[ 0]); - keepass->keyfile[1] = hex_to_u32 ((const u8 *) &keyfile_pos[ 8]); - keepass->keyfile[2] = hex_to_u32 ((const u8 *) &keyfile_pos[16]); - keepass->keyfile[3] = hex_to_u32 ((const u8 *) &keyfile_pos[24]); - keepass->keyfile[4] = hex_to_u32 ((const u8 *) &keyfile_pos[32]); - keepass->keyfile[5] = hex_to_u32 ((const u8 *) &keyfile_pos[40]); - keepass->keyfile[6] = hex_to_u32 ((const u8 *) &keyfile_pos[48]); - keepass->keyfile[7] = hex_to_u32 ((const u8 *) &keyfile_pos[56]); - - keepass->keyfile[0] = byte_swap_32 (keepass->keyfile[0]); - keepass->keyfile[1] = byte_swap_32 (keepass->keyfile[1]); - keepass->keyfile[2] = byte_swap_32 (keepass->keyfile[2]); - keepass->keyfile[3] = byte_swap_32 (keepass->keyfile[3]); - keepass->keyfile[4] = byte_swap_32 (keepass->keyfile[4]); - keepass->keyfile[5] = byte_swap_32 (keepass->keyfile[5]); - keepass->keyfile[6] = byte_swap_32 (keepass->keyfile[6]); - keepass->keyfile[7] = byte_swap_32 (keepass->keyfile[7]); - } - - if (keepass->version == 1) - { - digest[0] = keepass->contents_hash[0]; - digest[1] = keepass->contents_hash[1]; - digest[2] = keepass->contents_hash[2]; - digest[3] = keepass->contents_hash[3]; - } - else - { - digest[0] = keepass->expected_bytes[0]; - digest[1] = keepass->expected_bytes[1]; - digest[2] = keepass->expected_bytes[2]; - digest[3] = keepass->expected_bytes[3]; - } - - salt->salt_buf[0] = keepass->transf_random_seed[0]; - salt->salt_buf[1] = keepass->transf_random_seed[1]; - salt->salt_buf[2] = keepass->transf_random_seed[2]; - salt->salt_buf[3] = keepass->transf_random_seed[3]; - salt->salt_buf[4] = keepass->transf_random_seed[4]; - salt->salt_buf[5] = keepass->transf_random_seed[5]; - salt->salt_buf[6] = keepass->transf_random_seed[6]; - salt->salt_buf[7] = keepass->transf_random_seed[7]; - - salt->salt_len = 32; - - return (PARSER_OK); -} - -int plaintext_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig) -{ - u32 *digest = (u32 *) hash_buf->digest; - - token_t token; - - token.token_cnt = 1; - - token.len_min[0] = 1; - token.len_max[0] = 55; - token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH; - - const int rc_tokenizer = input_tokenizer (input_buf, input_len, &token); - - if (rc_tokenizer != PARSER_OK) return (rc_tokenizer); - - memset (digest, 0, hashconfig->dgst_size); - - const u8 *pw_buf = token.buf[0]; - const int pw_len = token.len[0]; - - memcpy ((char *) digest + 64, pw_buf, pw_len); - - //strncpy ((char *) digest + 64, (char *) input_buf, 64); - - u32 w[16] = { 0 }; - - //strncpy ((char *) w, (char *) input_buf, 64); - - memcpy (w, pw_buf, pw_len); - - u8 *w_ptr = (u8 *) w; - - w_ptr[input_len] = 0x80; - - w[14] = input_len * 8; - - u32 dgst[4]; - - dgst[0] = MD4M_A; - dgst[1] = MD4M_B; - dgst[2] = MD4M_C; - dgst[3] = MD4M_D; - - md4_64 (w, dgst); - - if (hashconfig->opti_type & OPTI_TYPE_PRECOMPUTE_MERKLE) - { - dgst[0] -= MD4M_A; - dgst[1] -= MD4M_B; - dgst[2] -= MD4M_C; - dgst[3] -= MD4M_D; - } - - digest[0] = dgst[0]; - digest[1] = dgst[1]; - digest[2] = dgst[2]; - digest[3] = dgst[3]; - - return (PARSER_OK); -} - int sha256b64s_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED hashconfig_t *hashconfig) { u32 *digest = (u32 *) hash_buf->digest; @@ -4186,8 +3482,6 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->st_pass = ST_PASS_HASHCAT_PLAIN; break; - - case 111: hashconfig->hash_type = HASH_TYPE_SHA1; hashconfig->salt_type = SALT_TYPE_EMBEDDED; hashconfig->attack_exec = ATTACK_EXEC_INSIDE_KERNEL; @@ -5372,7 +4666,6 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) hashconfig->st_pass = ST_PASS_HASHCAT_PLAIN; break; - case 10100: hashconfig->hash_type = HASH_TYPE_SIPHASH; hashconfig->salt_type = SALT_TYPE_EMBEDDED; hashconfig->attack_exec = ATTACK_EXEC_INSIDE_KERNEL; diff --git a/src/modules/module_07701.c b/src/modules/module_07701.c index d09dd14ff..e71822e3c 100644 --- a/src/modules/module_07701.c +++ b/src/modules/module_07701.c @@ -17,7 +17,7 @@ static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 3; static const u32 DGST_SIZE = DGST_SIZE_4_4; // originally DGST_SIZE_4_2; static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; -static const char *HASH_NAME = "SAP CODVN B (BCODE) mangled from RFC_READ_TABLE"; +static const char *HASH_NAME = "SAP CODVN B (BCODE) from RFC_READ_TABLE"; static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 7701; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE diff --git a/src/modules/module_07801.c b/src/modules/module_07801.c index 43ea4fc18..a0b16acbd 100644 --- a/src/modules/module_07801.c +++ b/src/modules/module_07801.c @@ -17,7 +17,7 @@ static const u32 DGST_POS2 = 2; static const u32 DGST_POS3 = 1; static const u32 DGST_SIZE = DGST_SIZE_4_5; static const u32 HASH_CATEGORY = HASH_CATEGORY_EAS; -static const char *HASH_NAME = "SAP CODVN F/G (PASSCODE) mangled from RFC_READ_TABLE"; +static const char *HASH_NAME = "SAP CODVN F/G (PASSCODE) from RFC_READ_TABLE"; static const u32 HASH_TYPE = HASH_TYPE_GENERIC; static const u64 KERN_TYPE = 7801; static const u32 OPTI_TYPE = OPTI_TYPE_ZERO_BYTE