mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 16:18:09 +00:00
Add hash-mode option OPTS_TYPE_PT_ALWAYS_ASCII to control need_hexify() from interface.c
This commit is contained in:
parent
7548295f3f
commit
2507f62722
@ -8,7 +8,7 @@
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
bool need_hexify (const u8 *buf, const int len, bool accept_utf8);
|
||||
bool need_hexify (const u8 *buf, const int len, bool always_ascii);
|
||||
void exec_hexify (const u8 *buf, const int len, u8 *out);
|
||||
|
||||
bool is_valid_hex_char (const u8 c);
|
||||
|
@ -344,22 +344,23 @@ typedef enum opts_type
|
||||
OPTS_TYPE_PT_GENERATE_BE = (1 << 9),
|
||||
OPTS_TYPE_PT_NEVERCRACK = (1 << 10), // if we want all possible results
|
||||
OPTS_TYPE_PT_BITSLICE = (1 << 11),
|
||||
OPTS_TYPE_ST_UNICODE = (1 << 12),
|
||||
OPTS_TYPE_ST_UPPER = (1 << 13),
|
||||
OPTS_TYPE_ST_LOWER = (1 << 14),
|
||||
OPTS_TYPE_ST_ADD01 = (1 << 15),
|
||||
OPTS_TYPE_ST_ADD02 = (1 << 16),
|
||||
OPTS_TYPE_ST_ADD80 = (1 << 17),
|
||||
OPTS_TYPE_ST_ADDBITS14 = (1 << 18),
|
||||
OPTS_TYPE_ST_ADDBITS15 = (1 << 19),
|
||||
OPTS_TYPE_ST_GENERATE_LE = (1 << 20),
|
||||
OPTS_TYPE_ST_GENERATE_BE = (1 << 21),
|
||||
OPTS_TYPE_ST_HEX = (1 << 22),
|
||||
OPTS_TYPE_ST_BASE64 = (1 << 23),
|
||||
OPTS_TYPE_HASH_COPY = (1 << 24),
|
||||
OPTS_TYPE_HOOK12 = (1 << 25),
|
||||
OPTS_TYPE_HOOK23 = (1 << 26),
|
||||
OPTS_TYPE_BINARY_HASHFILE = (1 << 27),
|
||||
OPTS_TYPE_PT_ALWAYS_ASCII = (1 << 12),
|
||||
OPTS_TYPE_ST_UNICODE = (1 << 13),
|
||||
OPTS_TYPE_ST_UPPER = (1 << 14),
|
||||
OPTS_TYPE_ST_LOWER = (1 << 15),
|
||||
OPTS_TYPE_ST_ADD01 = (1 << 16),
|
||||
OPTS_TYPE_ST_ADD02 = (1 << 17),
|
||||
OPTS_TYPE_ST_ADD80 = (1 << 18),
|
||||
OPTS_TYPE_ST_ADDBITS14 = (1 << 19),
|
||||
OPTS_TYPE_ST_ADDBITS15 = (1 << 20),
|
||||
OPTS_TYPE_ST_GENERATE_LE = (1 << 21),
|
||||
OPTS_TYPE_ST_GENERATE_BE = (1 << 22),
|
||||
OPTS_TYPE_ST_HEX = (1 << 23),
|
||||
OPTS_TYPE_ST_BASE64 = (1 << 24),
|
||||
OPTS_TYPE_HASH_COPY = (1 << 25),
|
||||
OPTS_TYPE_HOOK12 = (1 << 26),
|
||||
OPTS_TYPE_HOOK23 = (1 << 27),
|
||||
OPTS_TYPE_BINARY_HASHFILE = (1 << 28),
|
||||
|
||||
} opts_type_t;
|
||||
|
||||
|
@ -75,16 +75,32 @@ static bool printable_ascii (const u8 *buf, const int len)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool need_hexify (const u8 *buf, const int len, bool accept_utf8)
|
||||
bool need_hexify (const u8 *buf, const int len, bool always_ascii)
|
||||
{
|
||||
if (accept_utf8)
|
||||
if (always_ascii == true)
|
||||
{
|
||||
return !printable_utf8 (buf, len);
|
||||
if (printable_ascii (buf, len) == true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return !printable_ascii (buf, len);
|
||||
if (printable_utf8 (buf, len) == true)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void exec_hexify (const u8 *buf, const int len, u8 *out)
|
||||
|
@ -17430,7 +17430,8 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx)
|
||||
hashconfig->attack_exec = ATTACK_EXEC_INSIDE_KERNEL;
|
||||
hashconfig->opts_type = OPTS_TYPE_PT_GENERATE_LE
|
||||
| OPTS_TYPE_PT_UPPER
|
||||
| OPTS_TYPE_PT_BITSLICE;
|
||||
| OPTS_TYPE_PT_BITSLICE
|
||||
| OPTS_TYPE_PT_ALWAYS_ASCII;
|
||||
hashconfig->kern_type = KERN_TYPE_LM;
|
||||
hashconfig->dgst_size = DGST_SIZE_4_4; // originally DGST_SIZE_4_2
|
||||
hashconfig->parse_func = lm_parse_hash;
|
||||
|
@ -367,9 +367,9 @@ int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsign
|
||||
|
||||
if (outfile_ctx->outfile_format & OUTFILE_FMT_PLAIN)
|
||||
{
|
||||
bool accept_utf8 = hashcat_ctx->hashconfig->hash_type != HASH_TYPE_LM;
|
||||
const bool always_ascii = (hashconfig->hash_type & OPTS_TYPE_PT_ALWAYS_ASCII);
|
||||
|
||||
if ((user_options->outfile_autohex == true) && (need_hexify (plain_ptr, plain_len, accept_utf8) == true))
|
||||
if ((user_options->outfile_autohex == true) && (need_hexify (plain_ptr, plain_len, always_ascii) == true))
|
||||
{
|
||||
tmp_buf[tmp_len++] = '$';
|
||||
tmp_buf[tmp_len++] = 'H';
|
||||
|
@ -267,6 +267,7 @@ void potfile_write_close (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len)
|
||||
{
|
||||
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
const potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
@ -291,9 +292,9 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *
|
||||
|
||||
if (1)
|
||||
{
|
||||
bool accept_utf8 = hashcat_ctx->hashconfig->hash_type != HASH_TYPE_LM;
|
||||
const bool always_ascii = (hashconfig->hash_type & OPTS_TYPE_PT_ALWAYS_ASCII);
|
||||
|
||||
if ((user_options->outfile_autohex == true) && (need_hexify (plain_ptr, plain_len, accept_utf8) == true))
|
||||
if ((user_options->outfile_autohex == true) && (need_hexify (plain_ptr, plain_len, always_ascii) == true))
|
||||
{
|
||||
tmp_buf[tmp_len++] = '$';
|
||||
tmp_buf[tmp_len++] = 'H';
|
||||
|
@ -538,6 +538,7 @@ int status_get_input_mask_length (const hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
char *status_get_input_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id)
|
||||
{
|
||||
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
@ -582,10 +583,10 @@ char *status_get_input_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const i
|
||||
build_plain ((hashcat_ctx_t *) hashcat_ctx, device_param, &plain1, plain_buf1, &plain_len1);
|
||||
build_plain ((hashcat_ctx_t *) hashcat_ctx, device_param, &plain2, plain_buf2, &plain_len2);
|
||||
|
||||
bool accept_utf8 = hashcat_ctx->hashconfig->hash_type != HASH_TYPE_LM;
|
||||
const bool always_ascii = (hashconfig->hash_type & OPTS_TYPE_PT_ALWAYS_ASCII);
|
||||
|
||||
const bool need_hex1 = need_hexify (plain_ptr1, plain_len1, accept_utf8);
|
||||
const bool need_hex2 = need_hexify (plain_ptr2, plain_len2, accept_utf8);
|
||||
const bool need_hex1 = need_hexify (plain_ptr1, plain_len1, always_ascii);
|
||||
const bool need_hex2 = need_hexify (plain_ptr2, plain_len2, always_ascii);
|
||||
|
||||
if ((need_hex1 == true) || (need_hex2 == true))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user