Add support for OPTS_TYPE_PT_HEX

pull/2209/head
Jens Steube 5 years ago
parent a0284b8378
commit 786efc2d7c

@ -392,36 +392,37 @@ typedef enum opts_type
OPTS_TYPE_PT_ALWAYS_ASCII = (1ULL << 13),
OPTS_TYPE_PT_ALWAYS_HEXIFY = (1ULL << 14),
OPTS_TYPE_PT_LM = (1ULL << 15), // special handling: all lower, 7 max, ...
OPTS_TYPE_ST_UTF16LE = (1ULL << 16),
OPTS_TYPE_ST_UTF16BE = (1ULL << 17),
OPTS_TYPE_ST_UPPER = (1ULL << 18),
OPTS_TYPE_ST_LOWER = (1ULL << 19),
OPTS_TYPE_ST_ADD01 = (1ULL << 20),
OPTS_TYPE_ST_ADD02 = (1ULL << 21),
OPTS_TYPE_ST_ADD80 = (1ULL << 22),
OPTS_TYPE_ST_ADDBITS14 = (1ULL << 23),
OPTS_TYPE_ST_ADDBITS15 = (1ULL << 24),
OPTS_TYPE_ST_HEX = (1ULL << 25),
OPTS_TYPE_ST_BASE64 = (1ULL << 26),
OPTS_TYPE_ST_HASH_MD5 = (1ULL << 27),
OPTS_TYPE_HASH_COPY = (1ULL << 28),
OPTS_TYPE_HASH_SPLIT = (1ULL << 29),
OPTS_TYPE_HOOK12 = (1ULL << 30),
OPTS_TYPE_HOOK23 = (1ULL << 31),
OPTS_TYPE_INIT2 = (1ULL << 32),
OPTS_TYPE_LOOP2 = (1ULL << 33),
OPTS_TYPE_AUX1 = (1ULL << 34),
OPTS_TYPE_AUX2 = (1ULL << 35),
OPTS_TYPE_AUX3 = (1ULL << 36),
OPTS_TYPE_AUX4 = (1ULL << 37),
OPTS_TYPE_BINARY_HASHFILE = (1ULL << 38),
OPTS_TYPE_PREFERED_THREAD = (1ULL << 39), // some algorithms (complicated ones with many branches) benefit from this
OPTS_TYPE_PT_ADD06 = (1ULL << 40),
OPTS_TYPE_KEYBOARD_MAPPING = (1ULL << 41),
OPTS_TYPE_DEEP_COMP_KERNEL = (1ULL << 42), // if we have to iterate through each hash inside the comp kernel, for example if each hash has to be decrypted separately
OPTS_TYPE_SUGGEST_KG = (1ULL << 43), // suggest keep guessing for modules the user maybe wants to use --keep-guessing
OPTS_TYPE_COPY_TMPS = (1ULL << 44), // if we want to use data from tmps buffer (for example get the PMK in WPA)
OPTS_TYPE_POTFILE_NOPASS = (1ULL << 45), // sometimes the password should not be printed to potfile
OPTS_TYPE_PT_HEX = (1ULL << 16), // input wordlist (and masks!) are always in hex
OPTS_TYPE_ST_UTF16LE = (1ULL << 17),
OPTS_TYPE_ST_UTF16BE = (1ULL << 18),
OPTS_TYPE_ST_UPPER = (1ULL << 19),
OPTS_TYPE_ST_LOWER = (1ULL << 20),
OPTS_TYPE_ST_ADD01 = (1ULL << 21),
OPTS_TYPE_ST_ADD02 = (1ULL << 22),
OPTS_TYPE_ST_ADD80 = (1ULL << 23),
OPTS_TYPE_ST_ADDBITS14 = (1ULL << 24),
OPTS_TYPE_ST_ADDBITS15 = (1ULL << 25),
OPTS_TYPE_ST_HEX = (1ULL << 26),
OPTS_TYPE_ST_BASE64 = (1ULL << 27),
OPTS_TYPE_ST_HASH_MD5 = (1ULL << 28),
OPTS_TYPE_HASH_COPY = (1ULL << 29),
OPTS_TYPE_HASH_SPLIT = (1ULL << 30),
OPTS_TYPE_HOOK12 = (1ULL << 31),
OPTS_TYPE_HOOK23 = (1ULL << 32),
OPTS_TYPE_INIT2 = (1ULL << 33),
OPTS_TYPE_LOOP2 = (1ULL << 34),
OPTS_TYPE_AUX1 = (1ULL << 35),
OPTS_TYPE_AUX2 = (1ULL << 36),
OPTS_TYPE_AUX3 = (1ULL << 37),
OPTS_TYPE_AUX4 = (1ULL << 38),
OPTS_TYPE_BINARY_HASHFILE = (1ULL << 39),
OPTS_TYPE_PREFERED_THREAD = (1ULL << 40), // some algorithms (complicated ones with many branches) benefit from this
OPTS_TYPE_PT_ADD06 = (1ULL << 41),
OPTS_TYPE_KEYBOARD_MAPPING = (1ULL << 42),
OPTS_TYPE_DEEP_COMP_KERNEL = (1ULL << 43), // if we have to iterate through each hash inside the comp kernel, for example if each hash has to be decrypted separately
OPTS_TYPE_SUGGEST_KG = (1ULL << 44), // suggest keep guessing for modules the user maybe wants to use --keep-guessing
OPTS_TYPE_COPY_TMPS = (1ULL << 45), // if we want to use data from tmps buffer (for example get the PMK in WPA)
OPTS_TYPE_POTFILE_NOPASS = (1ULL << 46), // sometimes the password should not be printed to potfile
} opts_type_t;

@ -292,6 +292,16 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx)
}
}
if (user_options->hex_charset)
{
hashconfig->opts_type |= OPTS_TYPE_PT_HEX;
}
if (user_options->hex_wordlist)
{
hashconfig->opts_type |= OPTS_TYPE_PT_HEX;
}
if (user_options->hex_salt)
{
if (hashconfig->salt_type == SALT_TYPE_GENERIC)

@ -254,7 +254,7 @@ static int mp_add_cs_buf (hashcat_ctx_t *hashcat_ctx, const u32 *in_buf, size_t
static int mp_expand (hashcat_ctx_t *hashcat_ctx, const char *in_buf, size_t in_len, cs_t *mp_sys, cs_t *mp_usr, u32 mp_usr_offset, int interpret)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
size_t in_pos;
@ -317,7 +317,7 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, const char *in_buf, size_t in_
}
else
{
if (user_options->hex_charset == true)
if (hashconfig->opts_type & OPTS_TYPE_PT_HEX)
{
in_pos++;
@ -362,7 +362,7 @@ static int mp_expand (hashcat_ctx_t *hashcat_ctx, const char *in_buf, size_t in_
static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, cs_t *css_buf, u32 *css_cnt)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
memset (css_buf, 0, 256 * sizeof (cs_t));
@ -430,7 +430,7 @@ static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_l
}
else
{
if (user_options->hex_charset == true)
if (hashconfig->opts_type & OPTS_TYPE_PT_HEX)
{
mask_pos++;
@ -488,7 +488,7 @@ static int mp_gen_css (hashcat_ctx_t *hashcat_ctx, char *mask_buf, size_t mask_l
static int mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask_buf, const size_t mask_len, const u32 len, char *new_mask_buf)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
u32 mask_pos;
@ -512,7 +512,7 @@ static int mp_get_truncated_mask (hashcat_ctx_t *hashcat_ctx, const char *mask_b
}
else
{
if (user_options->hex_charset == true)
if (hashconfig->opts_type & OPTS_TYPE_PT_HEX)
{
mask_pos++;

@ -44,6 +44,25 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
// password : move the known password into a fake buffer
pw_t tmp;
memset (&tmp, 0, sizeof (tmp));
char *tmp_ptr = (char *) &tmp.i;
const size_t tmp_len = strlen (hashconfig->st_pass);
if (hashconfig->opts_type & OPTS_TYPE_PT_HEX)
{
tmp.pw_len = hex_decode ((const u8 *) hashconfig->st_pass, (const int) tmp_len, (u8 *) tmp_ptr);
}
else
{
memcpy (tmp_ptr, hashconfig->st_pass, tmp_len);
tmp.pw_len = (u32) tmp_len;
}
u32 highest_pw_len = 0;
if (user_options->slow_candidates == true)
@ -53,13 +72,15 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
device_param->kernel_params_buf32[30] = 1;
}
pw_t pw; memset (&pw, 0, sizeof (pw));
pw_t pw;
memset (&pw, 0, sizeof (pw));
char *pw_ptr = (char *) &pw.i;
const size_t pw_len = strlen (hashconfig->st_pass);
const size_t pw_len = tmp.pw_len;
memcpy (pw_ptr, hashconfig->st_pass, pw_len);
memcpy (pw_ptr, tmp_ptr, pw_len);
pw.pw_len = (u32) pw_len;
@ -87,9 +108,9 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
char *pw_ptr = (char *) &pw.i;
const size_t pw_len = strlen (hashconfig->st_pass);
const size_t pw_len = tmp.pw_len;
memcpy (pw_ptr, hashconfig->st_pass, pw_len);
memcpy (pw_ptr, tmp_ptr, pw_len);
pw.pw_len = (u32) pw_len;
@ -119,9 +140,9 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
char *pw_ptr = (char *) &pw.i;
const size_t pw_len = strlen (hashconfig->st_pass);
const size_t pw_len = tmp.pw_len;
memcpy (pw_ptr, hashconfig->st_pass, pw_len - 1);
memcpy (pw_ptr, tmp_ptr, pw_len - 1);
pw.pw_len = (u32) pw_len - 1;
@ -136,7 +157,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
char *comb_ptr = (char *) &comb.i;
memcpy (comb_ptr, hashconfig->st_pass + pw_len - 1, 1);
memcpy (comb_ptr, tmp_ptr + pw_len - 1, 1);
comb.pw_len = 1;
@ -186,9 +207,9 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
char *pw_ptr = (char *) &pw.i;
const size_t pw_len = strlen (hashconfig->st_pass);
const size_t pw_len = tmp.pw_len;
memcpy (pw_ptr, hashconfig->st_pass, pw_len);
memcpy (pw_ptr, tmp_ptr, pw_len);
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER)
{
@ -215,7 +236,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
char *bf_ptr = (char *) &bf.i;
memcpy (bf_ptr, hashconfig->st_pass, 1);
memcpy (bf_ptr, tmp_ptr, 1);
if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE)
{
@ -223,7 +244,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
for (int i = 0, j = 0; i < 1; i += 1, j += 2)
{
bf_ptr[j + 0] = hashconfig->st_pass[i];
bf_ptr[j + 0] = tmp_ptr[i];
bf_ptr[j + 1] = 0;
}
}
@ -234,7 +255,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
for (int i = 0, j = 0; i < 1; i += 1, j += 2)
{
bf_ptr[j + 0] = 0;
bf_ptr[j + 1] = hashconfig->st_pass[i];
bf_ptr[j + 1] = tmp_ptr[i];
}
}
@ -264,9 +285,9 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
char *pw_ptr = (char *) &pw.i;
const size_t pw_len = strlen (hashconfig->st_pass);
const size_t pw_len = tmp.pw_len;
memcpy (pw_ptr + 1, hashconfig->st_pass + 1, pw_len - 1);
memcpy (pw_ptr + 1, tmp_ptr + 1, pw_len - 1);
size_t new_pass_len = pw_len;
@ -276,7 +297,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
for (size_t i = 1, j = 2; i < new_pass_len; i += 1, j += 2)
{
pw_ptr[j + 0] = hashconfig->st_pass[i];
pw_ptr[j + 0] = tmp_ptr[i];
pw_ptr[j + 1] = 0;
}
@ -289,7 +310,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
for (size_t i = 1, j = 2; i < new_pass_len; i += 1, j += 2)
{
pw_ptr[j + 0] = 0;
pw_ptr[j + 1] = hashconfig->st_pass[i];
pw_ptr[j + 1] = tmp_ptr[i];
}
new_pass_len *= 2;
@ -366,9 +387,9 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
char *pw_ptr = (char *) &pw.i;
const size_t pw_len = strlen (hashconfig->st_pass);
const size_t pw_len = tmp.pw_len;
memcpy (pw_ptr, hashconfig->st_pass, pw_len);
memcpy (pw_ptr, tmp_ptr, pw_len);
pw.pw_len = (u32) pw_len;

@ -16,11 +16,12 @@
size_t convert_from_hex (hashcat_ctx_t *hashcat_ctx, char *line_buf, const size_t line_len)
{
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
const user_options_t *user_options = hashcat_ctx->user_options;
if (line_len & 1) return (line_len); // not in hex
if (user_options->hex_wordlist == true)
if (hashconfig->opts_type & OPTS_TYPE_PT_HEX)
{
size_t i, j;

Loading…
Cancel
Save