mirror of
https://github.com/hashcat/hashcat.git
synced 2025-02-08 21:52:51 +00:00
Update some formatting, added signature constant, Update new module functions module_extra_tuningdb_block() and module_deprecated_notice(), replaced some hex decode and encoding with real hex_encode() and hex_decode() functions.
This commit is contained in:
parent
00c9c2ed1b
commit
37957bf702
@ -72,6 +72,8 @@ typedef struct gpg_tmp
|
|||||||
|
|
||||||
} gpg_tmp_t;
|
} gpg_tmp_t;
|
||||||
|
|
||||||
|
static const char *SIGNATURE_GPG = "$gpg$";
|
||||||
|
|
||||||
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)
|
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 (gpg_t);
|
const u64 esalt_size = (const u64) sizeof (gpg_t);
|
||||||
@ -129,7 +131,6 @@ u32 module_deep_comp_kernel (MAYBE_UNUSED const hashes_t *hashes, MAYBE_UNUSED c
|
|||||||
|
|
||||||
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)
|
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)
|
||||||
{
|
{
|
||||||
|
|
||||||
u32 *digest = (u32 *) digest_buf;
|
u32 *digest = (u32 *) digest_buf;
|
||||||
|
|
||||||
gpg_t *gpg = (gpg_t *) esalt_buf;
|
gpg_t *gpg = (gpg_t *) esalt_buf;
|
||||||
@ -140,137 +141,157 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|||||||
|
|
||||||
// signature $gpg$
|
// signature $gpg$
|
||||||
token.signatures_cnt = 1;
|
token.signatures_cnt = 1;
|
||||||
token.signatures_buf[0] = "$gpg$";
|
token.signatures_buf[0] = SIGNATURE_GPG;
|
||||||
|
|
||||||
// signature $gpg$
|
// signature $gpg$
|
||||||
token.len_min[0] = 5;
|
token.len_min[0] = 5;
|
||||||
token.len_max[0] = 5;
|
token.len_max[0] = 5;
|
||||||
token.sep[0] = '*';
|
token.sep[0] = '*';
|
||||||
token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[0] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_SIGNATURE;
|
| TOKEN_ATTR_VERIFY_SIGNATURE;
|
||||||
|
|
||||||
// "1" -- unknown option
|
// "1" -- unknown option
|
||||||
token.len_min[1] = 1;
|
token.len_min[1] = 1;
|
||||||
token.len_max[1] = 1;
|
token.len_max[1] = 1;
|
||||||
token.sep[1] = '*';
|
token.sep[1] = '*';
|
||||||
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[1] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_DIGIT;
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||||
|
|
||||||
// size of the encrypted data in bytes
|
// size of the encrypted data in bytes
|
||||||
token.len_min[2] = 3;
|
token.len_min[2] = 3;
|
||||||
token.len_max[2] = 4;
|
token.len_max[2] = 4;
|
||||||
token.sep[2] = '*';
|
token.sep[2] = '*';
|
||||||
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[2] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_DIGIT;
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||||
|
|
||||||
// size of the key: 1024, 2048, 4096, etc.
|
// size of the key: 1024, 2048, 4096, etc.
|
||||||
token.len_min[3] = 3;
|
token.len_min[3] = 3;
|
||||||
token.len_max[3] = 4;
|
token.len_max[3] = 4;
|
||||||
token.sep[3] = '*';
|
token.sep[3] = '*';
|
||||||
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[3] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_DIGIT;
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||||
|
|
||||||
// encrypted key -- twice the amount of byte because its interpreted as characters
|
// encrypted key -- twice the amount of byte because its interpreted as characters
|
||||||
token.len_min[4] = 256;
|
token.len_min[4] = 256;
|
||||||
token.len_max[4] = 3072;
|
token.len_max[4] = 3072;
|
||||||
token.sep[4] = '*';
|
token.sep[4] = '*';
|
||||||
token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[4] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_HEX;
|
| TOKEN_ATTR_VERIFY_HEX;
|
||||||
|
|
||||||
// "3" - String2Key parameter
|
// "3" - String2Key parameter
|
||||||
token.len_min[5] = 1;
|
token.len_min[5] = 1;
|
||||||
token.len_max[5] = 1;
|
token.len_max[5] = 1;
|
||||||
token.sep[5] = '*';
|
token.sep[5] = '*';
|
||||||
token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[5] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_DIGIT;
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||||
|
|
||||||
// "254" - String2Key parameters
|
// "254" - String2Key parameters
|
||||||
token.len_min[6] = 3;
|
token.len_min[6] = 3;
|
||||||
token.len_max[6] = 3;
|
token.len_max[6] = 3;
|
||||||
token.sep[6] = '*';
|
token.sep[6] = '*';
|
||||||
token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[6] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_DIGIT;
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||||
|
|
||||||
// "2" - String2Key parameters
|
// "2" - String2Key parameters
|
||||||
token.len_min[7] = 1;
|
token.len_min[7] = 1;
|
||||||
token.len_max[7] = 1;
|
token.len_max[7] = 1;
|
||||||
token.sep[7] = '*';
|
token.sep[7] = '*';
|
||||||
token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[7] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_DIGIT;
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||||
|
|
||||||
// cipher mode: 7 or 9
|
// cipher mode: 7 or 9
|
||||||
token.len_min[8] = 1;
|
token.len_min[8] = 1;
|
||||||
token.len_max[8] = 1;
|
token.len_max[8] = 1;
|
||||||
token.sep[8] = '*';
|
token.sep[8] = '*';
|
||||||
token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[8] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_DIGIT;
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||||
|
|
||||||
// size of initial vector in bytes: 16
|
// size of initial vector in bytes: 16
|
||||||
token.len_min[9]= 2;
|
token.len_min[9] = 2;
|
||||||
token.len_max[9]= 2;
|
token.len_max[9] = 2;
|
||||||
token.sep[9] = '*';
|
token.sep[9] = '*';
|
||||||
token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[9] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_DIGIT;
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||||
|
|
||||||
// initial vector - twice the amount of bytes because its interpreted as characters
|
// initial vector - twice the amount of bytes because its interpreted as characters
|
||||||
token.len_min[10]= 32;
|
token.len_min[10] = 32;
|
||||||
token.len_max[10]= 32;
|
token.len_max[10] = 32;
|
||||||
token.sep[10] = '*';
|
token.sep[10] = '*';
|
||||||
token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[10] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_HEX;
|
| TOKEN_ATTR_VERIFY_HEX;
|
||||||
|
|
||||||
// iteration count
|
// iteration count
|
||||||
token.len_min[11]= 1;
|
token.len_min[11] = 1;
|
||||||
token.len_max[11]= 8;
|
token.len_max[11] = 8;
|
||||||
token.sep[11] = '*';
|
token.sep[11] = '*';
|
||||||
token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[11] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_DIGIT;
|
| TOKEN_ATTR_VERIFY_DIGIT;
|
||||||
|
|
||||||
// salt - 8 bytes / 16 characters
|
// salt - 8 bytes / 16 characters
|
||||||
token.len_min[12]= 16;
|
token.len_min[12] = 16;
|
||||||
token.len_max[12]= 16;
|
token.len_max[12] = 16;
|
||||||
token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH
|
token.attr[12] = TOKEN_ATTR_VERIFY_LENGTH
|
||||||
|TOKEN_ATTR_VERIFY_HEX;
|
| TOKEN_ATTR_VERIFY_HEX;
|
||||||
|
|
||||||
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
|
const int rc_tokenizer = input_tokenizer ((const u8 *) line_buf, line_len, &token);
|
||||||
|
|
||||||
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
if (rc_tokenizer != PARSER_OK) return (rc_tokenizer);
|
||||||
|
|
||||||
// Modulus size
|
// Modulus size
|
||||||
int enc_data_size = hc_strtoul ((const char *) token.buf[2], NULL, 10);
|
|
||||||
gpg->modulus_size = hc_strtoul ((const char *) token.buf[3], NULL, 10);
|
|
||||||
|
|
||||||
if ((gpg->modulus_size < 256) || (gpg->modulus_size > 16384)) return (PARSER_UNKNOWN_ERROR);
|
const int modulus_size = hc_strtoul ((const char *) token.buf[3], NULL, 10);
|
||||||
|
|
||||||
|
if ((modulus_size < 256) || (modulus_size > 16384)) return (PARSER_SALT_LENGTH);
|
||||||
|
|
||||||
|
gpg->modulus_size = modulus_size;
|
||||||
|
|
||||||
// Encrypted data
|
// Encrypted data
|
||||||
gpg->encrypted_data_size = exec_unhexify ((u8 *) (token.buf[4] - 5), token.len[4] + 6, (u8 *) gpg->encrypted_data, sizeof(gpg->encrypted_data));
|
|
||||||
|
|
||||||
if (gpg->encrypted_data_size != enc_data_size) return (PARSER_UNKNOWN_ERROR);
|
const int enc_data_size = hc_strtoul ((const char *) token.buf[2], NULL, 10);
|
||||||
|
|
||||||
|
const int encrypted_data_size = hex_decode ((const u8 *) token.buf[4], token.len[4], (u8 *) gpg->encrypted_data);
|
||||||
|
|
||||||
|
if (enc_data_size != encrypted_data_size) return (PARSER_CT_LENGTH);
|
||||||
|
|
||||||
|
gpg->encrypted_data_size = encrypted_data_size;
|
||||||
|
|
||||||
// Check String2Key parameters
|
// Check String2Key parameters
|
||||||
if (hc_strtoul ((const char *) token.buf[5], NULL, 10) != 3) return (PARSER_UNKNOWN_ERROR);
|
|
||||||
if (hc_strtoul ((const char *) token.buf[6], NULL, 10) != 254) return (PARSER_UNKNOWN_ERROR);
|
if (hc_strtoul ((const char *) token.buf[5], NULL, 10) != 3) return (PARSER_HASH_VALUE);
|
||||||
if (hc_strtoul ((const char *) token.buf[7], NULL, 10) != 2) return (PARSER_UNKNOWN_ERROR);
|
if (hc_strtoul ((const char *) token.buf[6], NULL, 10) != 254) return (PARSER_HASH_VALUE);
|
||||||
|
if (hc_strtoul ((const char *) token.buf[7], NULL, 10) != 2) return (PARSER_HASH_VALUE);
|
||||||
|
|
||||||
// Cipher algo
|
// Cipher algo
|
||||||
gpg->cipher_algo = hc_strtoul (token.buf[8], NULL, 10);
|
|
||||||
|
|
||||||
if ((gpg->cipher_algo != 7) && (gpg->cipher_algo != 9)) return (PARSER_UNKNOWN_ERROR);
|
const int cipher_algo = hc_strtoul ((const char *) token.buf[8], NULL, 10);
|
||||||
|
|
||||||
|
if ((cipher_algo != 7) && (cipher_algo != 9)) return (PARSER_CIPHER);
|
||||||
|
|
||||||
|
gpg->cipher_algo = cipher_algo;
|
||||||
|
|
||||||
// IV (size)
|
// IV (size)
|
||||||
if (hc_strtoul ((const char *) token.buf[9], NULL, 10) != sizeof(gpg->iv)) return (PARSER_IV_LENGTH);
|
|
||||||
|
|
||||||
size_t iv_size = exec_unhexify (token.buf[10] - 5, token.len[10] + 6, (u8 *) gpg->iv, sizeof(gpg->iv));
|
if (hc_strtoul ((const char *) token.buf[9], NULL, 10) != sizeof (gpg->iv)) return (PARSER_IV_LENGTH);
|
||||||
if (iv_size != sizeof(gpg->iv)) return (PARSER_IV_LENGTH);
|
|
||||||
|
const int iv_size = hex_decode ((const u8 *) token.buf[10], token.len[10], (u8 *) gpg->iv);
|
||||||
|
|
||||||
|
if (iv_size != sizeof (gpg->iv)) return (PARSER_IV_LENGTH);
|
||||||
|
|
||||||
|
// Salt Iter
|
||||||
|
|
||||||
const u32 salt_iter = hc_strtoul ((const char *) token.buf[11], NULL, 10);
|
const u32 salt_iter = hc_strtoul ((const char *) token.buf[11], NULL, 10);
|
||||||
|
|
||||||
if (salt_iter < 8 || salt_iter > 1000000) return (PARSER_SALT_ITERATION);
|
if (salt_iter < 8 || salt_iter > 1000000) return (PARSER_SALT_ITERATION);
|
||||||
|
|
||||||
salt->salt_iter = salt_iter;
|
salt->salt_iter = salt_iter;
|
||||||
salt->salt_repeats = gpg->cipher_algo == 7 ? 0 : 1; // "minus one", see also the scrypt module!
|
|
||||||
salt->salt_len = exec_unhexify (token.buf[12] - 5, token.len[12] + 6, (u8 *) salt->salt_buf, sizeof(salt->salt_buf));
|
|
||||||
|
|
||||||
if (salt->salt_len != 8) return (PARSER_UNKNOWN_ERROR);
|
// Salt Value
|
||||||
|
|
||||||
|
salt->salt_repeats = gpg->cipher_algo == 7 ? 0 : 1; // "minus one"
|
||||||
|
|
||||||
|
salt->salt_len = hex_decode ((const u8 *) token.buf[12], token.len[12], (u8 *) salt->salt_buf);
|
||||||
|
|
||||||
|
if (salt->salt_len != 8) return (PARSER_SALT_LENGTH);
|
||||||
|
|
||||||
// hash fake
|
// hash fake
|
||||||
digest[0] = gpg->iv[0];
|
digest[0] = gpg->iv[0];
|
||||||
@ -283,24 +304,18 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
|||||||
|
|
||||||
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)
|
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 u32 *digest = (const u32 *) digest_buf;
|
|
||||||
|
|
||||||
const gpg_t *gpg = (const gpg_t *) esalt_buf;
|
const gpg_t *gpg = (const gpg_t *) esalt_buf;
|
||||||
|
|
||||||
u8 hex_encrypted[(384 * 8) + 1] = { 0 };
|
u8 encrypted_data[(384 * 8) + 1];
|
||||||
u8 *encrypted_data = (u8 *) gpg->encrypted_data;
|
|
||||||
|
|
||||||
for (u32 i = 0, j = 0; i < gpg->encrypted_data_size; i++, j += 2)
|
hex_encode ((const u8 *) gpg->encrypted_data, gpg->encrypted_data_size, (u8 *) encrypted_data);
|
||||||
{
|
|
||||||
u8_to_hex (encrypted_data[i], hex_encrypted + j);
|
|
||||||
}
|
|
||||||
|
|
||||||
const int line_len = snprintf (line_buf, line_size, "%s*%d*%d*%d*%s*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x",
|
const int line_len = snprintf (line_buf, line_size, "%s*%d*%d*%d*%s*%d*%d*%d*%d*%d*%08x%08x%08x%08x*%d*%08x%08x",
|
||||||
"$gpg$",
|
SIGNATURE_GPG,
|
||||||
1, /* unknown field */
|
1, /* unknown field */
|
||||||
gpg->encrypted_data_size,
|
gpg->encrypted_data_size,
|
||||||
gpg->modulus_size,
|
gpg->modulus_size,
|
||||||
hex_encrypted,
|
encrypted_data,
|
||||||
3, /* version (major?) */
|
3, /* version (major?) */
|
||||||
254, /* version (minor?) */
|
254, /* version (minor?) */
|
||||||
2, /* key cipher (sha-1) */
|
2, /* key cipher (sha-1) */
|
||||||
@ -329,6 +344,7 @@ void module_init (module_ctx_t *module_ctx)
|
|||||||
module_ctx->module_benchmark_salt = MODULE_DEFAULT;
|
module_ctx->module_benchmark_salt = MODULE_DEFAULT;
|
||||||
module_ctx->module_build_plain_postprocess = MODULE_DEFAULT;
|
module_ctx->module_build_plain_postprocess = MODULE_DEFAULT;
|
||||||
module_ctx->module_deep_comp_kernel = module_deep_comp_kernel;
|
module_ctx->module_deep_comp_kernel = module_deep_comp_kernel;
|
||||||
|
module_ctx->module_deprecated_notice = MODULE_DEFAULT;
|
||||||
module_ctx->module_dgst_pos0 = module_dgst_pos0;
|
module_ctx->module_dgst_pos0 = module_dgst_pos0;
|
||||||
module_ctx->module_dgst_pos1 = module_dgst_pos1;
|
module_ctx->module_dgst_pos1 = module_dgst_pos1;
|
||||||
module_ctx->module_dgst_pos2 = module_dgst_pos2;
|
module_ctx->module_dgst_pos2 = module_dgst_pos2;
|
||||||
@ -338,6 +354,7 @@ void module_init (module_ctx_t *module_ctx)
|
|||||||
module_ctx->module_esalt_size = module_esalt_size;
|
module_ctx->module_esalt_size = module_esalt_size;
|
||||||
module_ctx->module_extra_buffer_size = MODULE_DEFAULT;
|
module_ctx->module_extra_buffer_size = MODULE_DEFAULT;
|
||||||
module_ctx->module_extra_tmp_size = MODULE_DEFAULT;
|
module_ctx->module_extra_tmp_size = MODULE_DEFAULT;
|
||||||
|
module_ctx->module_extra_tuningdb_block = MODULE_DEFAULT;
|
||||||
module_ctx->module_forced_outfile_format = MODULE_DEFAULT;
|
module_ctx->module_forced_outfile_format = MODULE_DEFAULT;
|
||||||
module_ctx->module_hash_binary_count = MODULE_DEFAULT;
|
module_ctx->module_hash_binary_count = MODULE_DEFAULT;
|
||||||
module_ctx->module_hash_binary_parse = MODULE_DEFAULT;
|
module_ctx->module_hash_binary_parse = MODULE_DEFAULT;
|
||||||
|
Loading…
Reference in New Issue
Block a user