From 454b0ad2942199e2e070e066bf4ccb8f2edc54e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Bolvansk=C3=BD?= Date: Tue, 6 Sep 2022 01:25:23 +0200 Subject: [PATCH] Do not hexify worldlist when --hex-charset is used --- docs/hashcat-plugin-development-guide.md | 3 ++- include/types.h | 3 ++- src/interface.c | 2 +- src/mpsp.c | 8 ++++---- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/docs/hashcat-plugin-development-guide.md b/docs/hashcat-plugin-development-guide.md index 3cee204ae..af88bb5cc 100644 --- a/docs/hashcat-plugin-development-guide.md +++ b/docs/hashcat-plugin-development-guide.md @@ -456,7 +456,7 @@ This configuration item is a bitmask field and is very similar to the module_opt * OPTS_TYPE_PT_ALWAYS_ASCII: This option prevents hashcat to automatically convert a password into the $HEX[...] encoding type. This automatic conversion is typically performed if the password itself contains the same character as the hash line separator character. * OPTS_TYPE_PT_ALWAYS_HEXIFY: This option forces all the cracked passwords to be written always in hex. In this case neither "$HEX[", nor "]", is added. * OPTS_TYPE_PT_LM: Special handling for LM passwords: all lower, 7 max, ... -* OPTS_TYPE_PT_HEX: Assume that all input data like wordlist and masks are always given in hex +* OPTS_TYPE_PT_HEX: Assume that wordlist is given in hex. * OPTS_TYPE_ST_UTF16LE: Same as OPTS_TYPE_PT_UTF16LE but applied on the salt buffer. * OPTS_TYPE_ST_UTF16BE: Same as OPTS_TYPE_PT_UTF16BE but applied on the salt buffer. * OPTS_TYPE_ST_UPPER: Same as OPTS_TYPE_PT_UPPER but applied on the salt buffer. @@ -468,6 +468,7 @@ This configuration item is a bitmask field and is very similar to the module_opt * OPTS_TYPE_ST_ADDBITS15: Same as OPTS_TYPE_PT_ADDBITS15 but applied on the salt buffer. * OPTS_TYPE_ST_HEX: Same as OPTS_TYPE_PT_HEX but applied on the salt buffer. * OPTS_TYPE_ST_BASE64: Same as OPTS_TYPE_ST_HEX but using base64 encoding. +* OPTS_TYPE_MT_HEX: Assume that mask is always given in hex. * OPTS_TYPE_HASH_COPY: This copies the original input hash line as it is into a buffer so that it can be used later. This is required if the original input hash line ships with the same data which is not copied into salt_t or esalt buffer because it is overhead data which is not used in any way. The hash line is copied to the buffer hash_info->orighash and can be used from the encoder function by simply returning hash_info->orighash. Please do not abuse this functionality, for two reasons: First, by being able to reconstruct the original hash line from only the hashcat data we verify that the correct amount of data has been stored in the hashcat memory structures (IOW, it is a good verification process). Second, the host memory requirement for saving this data increases drastically. * OPTS_TYPE_HASH_SPLIT: This needs to be used if the hash actually contains multiple hashes in the same hash line. A good example is the LM hash which is typically stored as a 128 bit hash, but actually is built on two 64 bit hashes. * OPTS_TYPE_LOOP_PREPARE: TBD diff --git a/include/types.h b/include/types.h index aa577f2be..ce04d81ad 100644 --- a/include/types.h +++ b/include/types.h @@ -420,7 +420,7 @@ typedef enum opts_type OPTS_TYPE_PT_ALWAYS_ASCII = (1ULL << 12), OPTS_TYPE_PT_ALWAYS_HEXIFY = (1ULL << 13), OPTS_TYPE_PT_LM = (1ULL << 14), // special handling: all lower, 7 max, ... - OPTS_TYPE_PT_HEX = (1ULL << 15), // input wordlist (and masks!) are always in hex + OPTS_TYPE_PT_HEX = (1ULL << 15), // input wordlist is always in hex OPTS_TYPE_ST_UTF16LE = (1ULL << 16), OPTS_TYPE_ST_UTF16BE = (1ULL << 17), OPTS_TYPE_ST_UPPER = (1ULL << 18), @@ -432,6 +432,7 @@ typedef enum opts_type OPTS_TYPE_ST_ADDBITS15 = (1ULL << 24), OPTS_TYPE_ST_HEX = (1ULL << 25), OPTS_TYPE_ST_BASE64 = (1ULL << 26), + OPTS_TYPE_MT_HEX = (1ULL << 27), // mask is always in hex OPTS_TYPE_HASH_COPY = (1ULL << 28), OPTS_TYPE_HASH_SPLIT = (1ULL << 29), OPTS_TYPE_LOOP_PREPARE = (1ULL << 30), // a kernel which is called each time before _loop kernel started. diff --git a/src/interface.c b/src/interface.c index 588aa6d05..1cba43229 100644 --- a/src/interface.c +++ b/src/interface.c @@ -294,7 +294,7 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) if (user_options->hex_charset) { - hashconfig->opts_type |= OPTS_TYPE_PT_HEX; + hashconfig->opts_type |= OPTS_TYPE_MT_HEX; } if (user_options->hex_wordlist) diff --git a/src/mpsp.c b/src/mpsp.c index b56653c81..05c7c3eb3 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -324,7 +324,7 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, const char *in_buf, size_t in_ } else { - if (hashconfig->opts_type & OPTS_TYPE_PT_HEX) + if (hashconfig->opts_type & OPTS_TYPE_MT_HEX) { in_pos++; @@ -437,7 +437,7 @@ static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_l } else { - if (hashconfig->opts_type & OPTS_TYPE_PT_HEX) + if (hashconfig->opts_type & OPTS_TYPE_MT_HEX) { mask_pos++; @@ -519,7 +519,7 @@ static int mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask_b } else { - if (hashconfig->opts_type & OPTS_TYPE_PT_HEX) + if (hashconfig->opts_type & OPTS_TYPE_MT_HEX) { mask_pos++; @@ -1168,7 +1168,7 @@ u32 mp_get_length (const char *mask, const u32 opts_type) ignore_next = true; } - if (opts_type & OPTS_TYPE_PT_HEX) + if (opts_type & OPTS_TYPE_MT_HEX) { ignore_next = true; }