Add support for -a 1 in -S mode

pull/1723/head
jsteube 6 years ago
parent 32b915fd01
commit d96b649751

@ -6,6 +6,7 @@
#ifndef _HASH_MANAGEMENT_H
#define _HASH_MANAGEMENT_H
int sort_by_string (const void *v1, const void *v2);
int sort_by_digest_p0p1 (const void *v1, const void *v2, void *v3);
int sort_by_salt (const void *v1, const void *v2);
int sort_by_salt_buf (const void *v1, const void *v2, MAYBE_UNUSED void * v3);

@ -8,6 +8,8 @@
typedef struct extra_info_straight
{
u64 pos;
FILE *fp;
u64 rule_pos_prev;
@ -23,6 +25,8 @@ typedef struct extra_info_straight
typedef struct extra_info_combi
{
u64 pos;
FILE *base_fp;
FILE *combs_fp;

@ -609,91 +609,91 @@ typedef enum user_options_map
IDX_BENCHMARK = 'b',
IDX_BITMAP_MAX = 0xff02,
IDX_BITMAP_MIN = 0xff03,
IDX_CPU_AFFINITY = 0xff0a,
IDX_CPU_AFFINITY = 0xff0b,
IDX_CUSTOM_CHARSET_1 = '1',
IDX_CUSTOM_CHARSET_2 = '2',
IDX_CUSTOM_CHARSET_3 = '3',
IDX_CUSTOM_CHARSET_4 = '4',
IDX_DEBUG_FILE = 0xff0b,
IDX_DEBUG_MODE = 0xff0c,
IDX_ENCODING_FROM = 0xff0d,
IDX_ENCODING_TO = 0xff0e,
IDX_EXAMPLE_HASHES = 0xff0f,
IDX_FORCE = 0xff10,
IDX_GPU_TEMP_ABORT = 0xff11,
IDX_GPU_TEMP_DISABLE = 0xff12,
IDX_DEBUG_FILE = 0xff0c,
IDX_DEBUG_MODE = 0xff0d,
IDX_ENCODING_FROM = 0xff0e,
IDX_ENCODING_TO = 0xff0f,
IDX_EXAMPLE_HASHES = 0xff10,
IDX_FORCE = 0xff11,
IDX_GPU_TEMP_ABORT = 0xff12,
IDX_GPU_TEMP_DISABLE = 0xff13,
IDX_HASH_MODE = 'm',
IDX_HCCAPX_MESSAGE_PAIR = 0xff13,
IDX_HCCAPX_MESSAGE_PAIR = 0xff14,
IDX_HELP = 'h',
IDX_HEX_CHARSET = 0xff14,
IDX_HEX_SALT = 0xff15,
IDX_HEX_WORDLIST = 0xff16,
IDX_HEX_CHARSET = 0xff15,
IDX_HEX_SALT = 0xff16,
IDX_HEX_WORDLIST = 0xff17,
IDX_INCREMENT = 'i',
IDX_INCREMENT_MAX = 0xff17,
IDX_INCREMENT_MIN = 0xff18,
IDX_INDUCTION_DIR = 0xff19,
IDX_KEEP_GUESSING = 0xff1a,
IDX_INCREMENT_MAX = 0xff18,
IDX_INCREMENT_MIN = 0xff19,
IDX_INDUCTION_DIR = 0xff1a,
IDX_KEEP_GUESSING = 0xff1b,
IDX_KERNEL_ACCEL = 'n',
IDX_KERNEL_LOOPS = 'u',
IDX_KEYSPACE = 0xff1b,
IDX_LEFT = 0xff1c,
IDX_KEYSPACE = 0xff1c,
IDX_LEFT = 0xff1d,
IDX_LIMIT = 'l',
IDX_LOGFILE_DISABLE = 0xff1d,
IDX_LOOPBACK = 0xff1e,
IDX_MACHINE_READABLE = 0xff1f,
IDX_MARKOV_CLASSIC = 0xff20,
IDX_MARKOV_DISABLE = 0xff21,
IDX_MARKOV_HCSTAT2 = 0xff22,
IDX_LOGFILE_DISABLE = 0xff1e,
IDX_LOOPBACK = 0xff1f,
IDX_MACHINE_READABLE = 0xff20,
IDX_MARKOV_CLASSIC = 0xff21,
IDX_MARKOV_DISABLE = 0xff22,
IDX_MARKOV_HCSTAT2 = 0xff23,
IDX_MARKOV_THRESHOLD = 't',
IDX_NONCE_ERROR_CORRECTIONS = 0xff23,
IDX_NVIDIA_SPIN_DAMP = 0xff24,
IDX_NONCE_ERROR_CORRECTIONS = 0xff24,
IDX_NVIDIA_SPIN_DAMP = 0xff25,
IDX_OPENCL_DEVICES = 'd',
IDX_OPENCL_DEVICE_TYPES = 'D',
IDX_OPENCL_INFO = 'I',
IDX_OPENCL_PLATFORMS = 0xff25,
IDX_OPENCL_VECTOR_WIDTH = 0xff26,
IDX_OPENCL_PLATFORMS = 0xff26,
IDX_OPENCL_VECTOR_WIDTH = 0xff27,
IDX_OPTIMIZED_KERNEL_ENABLE = 'O',
IDX_OUTFILE_AUTOHEX_DISABLE = 0xff27,
IDX_OUTFILE_CHECK_DIR = 0xff28,
IDX_OUTFILE_CHECK_TIMER = 0xff29,
IDX_OUTFILE_FORMAT = 0xff2a,
IDX_OUTFILE_AUTOHEX_DISABLE = 0xff28,
IDX_OUTFILE_CHECK_DIR = 0xff29,
IDX_OUTFILE_CHECK_TIMER = 0xff2a,
IDX_OUTFILE_FORMAT = 0xff2b,
IDX_OUTFILE = 'o',
IDX_POTFILE_DISABLE = 0xff2b,
IDX_POTFILE_PATH = 0xff2c,
IDX_PROGRESS_ONLY = 0xff2d,
IDX_QUIET = 0xff2e,
IDX_REMOVE = 0xff2f,
IDX_REMOVE_TIMER = 0xff30,
IDX_RESTORE = 0xff31,
IDX_RESTORE_DISABLE = 0xff32,
IDX_RESTORE_FILE_PATH = 0xff33,
IDX_POTFILE_DISABLE = 0xff2c,
IDX_POTFILE_PATH = 0xff2d,
IDX_PROGRESS_ONLY = 0xff2e,
IDX_QUIET = 0xff2f,
IDX_REMOVE = 0xff30,
IDX_REMOVE_TIMER = 0xff31,
IDX_RESTORE = 0xff32,
IDX_RESTORE_DISABLE = 0xff33,
IDX_RESTORE_FILE_PATH = 0xff34,
IDX_RP_FILE = 'r',
IDX_RP_GEN_FUNC_MAX = 0xff34,
IDX_RP_GEN_FUNC_MIN = 0xff35,
IDX_RP_GEN_FUNC_MAX = 0xff35,
IDX_RP_GEN_FUNC_MIN = 0xff36,
IDX_RP_GEN = 'g',
IDX_RP_GEN_SEED = 0xff36,
IDX_RP_GEN_SEED = 0xff37,
IDX_RULE_BUF_L = 'j',
IDX_RULE_BUF_R = 'k',
IDX_RUNTIME = 0xff37,
IDX_SCRYPT_TMTO = 0xff38,
IDX_RUNTIME = 0xff38,
IDX_SCRYPT_TMTO = 0xff39,
IDX_SEGMENT_SIZE = 'c',
IDX_SELF_TEST_DISABLE = 0xff39,
IDX_SELF_TEST_DISABLE = 0xff3a,
IDX_SEPARATOR = 'p',
IDX_SESSION = 0xff3a,
IDX_SHOW = 0xff3b,
IDX_SESSION = 0xff3b,
IDX_SHOW = 0xff3c,
IDX_SKIP = 's',
IDX_SLOW_CANDIDATES = 'S',
IDX_SPEED_ONLY = 0xff3c,
IDX_STATUS = 0xff3d,
IDX_STATUS_TIMER = 0xff3e,
IDX_STDOUT_FLAG = 0xff3f,
IDX_TRUECRYPT_KEYFILES = 0xff40,
IDX_USERNAME = 0xff41,
IDX_VERACRYPT_KEYFILES = 0xff42,
IDX_VERACRYPT_PIM = 0xff43,
IDX_SPEED_ONLY = 0xff3d,
IDX_STATUS = 0xff3e,
IDX_STATUS_TIMER = 0xff3f,
IDX_STDOUT_FLAG = 0xff40,
IDX_TRUECRYPT_KEYFILES = 0xff41,
IDX_USERNAME = 0xff42,
IDX_VERACRYPT_KEYFILES = 0xff43,
IDX_VERACRYPT_PIM = 0xff44,
IDX_VERSION_LOWER = 'v',
IDX_VERSION = 'V',
IDX_WORDLIST_AUTOHEX_DISABLE = 0xff44,
IDX_WORDLIST_AUTOHEX_DISABLE = 0xff45,
IDX_WORKLOAD_PROFILE = 'w',
} user_options_map_t;
@ -1096,7 +1096,7 @@ typedef struct hc_device_param
u32 *pws_comp;
u64 pws_cnt;
pw_pre_t *pws_pre_buf;
pw_pre_t *pws_pre_buf; // for slow candidates
u64 pws_pre_cnt;
pw_pre_t *pws_base_buf; // for debug mode
@ -1633,6 +1633,8 @@ typedef struct user_options
bool runtime_chgd;
bool segment_size_chgd;
bool workload_profile_chgd;
bool skip_chgd;
bool limit_chgd;
bool advice_disable;
bool benchmark;

@ -16,8 +16,29 @@
#include "rp.h"
#include "rp_cpu.h"
#include "slow_candidates.h"
#include "user_options.h"
#include "dispatch.h"
static u64 get_highest_words_done (const hashcat_ctx_t *hashcat_ctx)
{
const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
u64 words_cur = 0;
for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped == true) continue;
const u64 words_done = device_param->words_done;
if (words_done > words_cur) words_cur = words_done;
}
return words_cur;
}
static u64 get_lowest_words_done (const hashcat_ctx_t *hashcat_ctx)
{
const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
@ -146,322 +167,146 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par
iconv_tmp = (char *) hcmalloc (HCBUFSIZ_TINY);
}
if (user_options->slow_candidates == true)
while (status_ctx->run_thread_level1 == true)
{
while (status_ctx->run_thread_level1 == true)
hc_thread_mutex_lock (status_ctx->mux_dispatcher);
if (feof (stdin) != 0)
{
hc_thread_mutex_lock (status_ctx->mux_dispatcher);
hc_thread_mutex_unlock (status_ctx->mux_dispatcher);
if (feof (stdin) != 0)
{
hc_thread_mutex_unlock (status_ctx->mux_dispatcher);
break;
}
break;
}
u64 words_extra_total = 0;
u64 words_extra_total = 0;
memset (device_param->pws_comp, 0, device_param->size_pws_comp);
memset (device_param->pws_idx, 0, device_param->size_pws_idx);
memset (device_param->pws_comp, 0, device_param->size_pws_comp);
memset (device_param->pws_idx, 0, device_param->size_pws_idx);
memset (device_param->pws_pre_buf, 0, device_param->size_pws_pre);
memset (device_param->pws_base_buf, 0, device_param->size_pws_base);
while (device_param->pws_cnt < device_param->kernel_power)
{
const int rc_select = select_read_timeout_console (1);
device_param->pws_pre_cnt = 0;
device_param->pws_base_cnt = 0;
if (rc_select == -1) break;
while (device_param->pws_pre_cnt < device_param->kernel_power)
if (rc_select == 0)
{
const int rc_select = select_read_timeout_console (1);
if (rc_select == -1) break;
if (rc_select == 0)
{
if (status_ctx->run_thread_level1 == false) break;
status_ctx->stdin_read_timeout_cnt++;
continue;
}
status_ctx->stdin_read_timeout_cnt = 0;
char *line_buf = fgets (buf, HCBUFSIZ_LARGE - 1, stdin);
if (line_buf == NULL) break;
size_t line_len = in_superchop (line_buf);
line_len = convert_from_hex (hashcat_ctx, line_buf, (u32) line_len);
// do the on-the-fly encoding
if (iconv_enabled == true)
{
char *iconv_ptr = iconv_tmp;
size_t iconv_sz = HCBUFSIZ_TINY;
const size_t iconv_rc = iconv (iconv_ctx, &line_buf, &line_len, &iconv_ptr, &iconv_sz);
if (iconv_rc == (size_t) -1) continue;
line_buf = iconv_tmp;
line_len = HCBUFSIZ_TINY - iconv_sz;
}
// post-process rule engine
char rule_buf_out[RP_PASSWORD_SIZE];
if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l))
{
if (line_len >= RP_PASSWORD_SIZE) continue;
memset (rule_buf_out, 0, sizeof (rule_buf_out));
const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out);
if (rule_len_out < 0) continue;
line_buf = rule_buf_out;
line_len = (size_t) rule_len_out;
}
if (line_len >= PW_MAX) continue;
if (status_ctx->run_thread_level1 == false) break;
// hmm that's always the case, or?
status_ctx->stdin_read_timeout_cnt++;
const u32 attack_kern = user_options_extra->attack_kern;
continue;
}
if (attack_kern == ATTACK_KERN_STRAIGHT)
{
if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max))
{
words_extra_total++;
status_ctx->stdin_read_timeout_cnt = 0;
continue;
}
}
char *line_buf = fgets (buf, HCBUFSIZ_LARGE - 1, stdin);
pw_pre_add (device_param, (u8 *) line_buf, (int) line_len, NULL, 0, 0);
if (line_buf == NULL) break;
if (status_ctx->run_thread_level1 == false) break;
}
size_t line_len = in_superchop (line_buf);
hc_thread_mutex_unlock (status_ctx->mux_dispatcher);
line_len = convert_from_hex (hashcat_ctx, line_buf, (u32) line_len);
u64 pre_rejects = 0;
// do the on-the-fly encoding
if (0)
{
}
else
if (iconv_enabled == true)
{
u64 pws_pre_cnt = device_param->pws_pre_cnt;
char *iconv_ptr = iconv_tmp;
size_t iconv_sz = HCBUFSIZ_TINY;
for (u64 pws_pre_idx = 0; pws_pre_idx < pws_pre_cnt; pws_pre_idx++)
{
pw_pre_t *pw_pre = device_param->pws_pre_buf + pws_pre_idx;
const size_t iconv_rc = iconv (iconv_ctx, &line_buf, &line_len, &iconv_ptr, &iconv_sz);
pw_base_add (device_param, pw_pre);
if (iconv_rc == (size_t) -1) continue;
pw_add (device_param, (const u8 *) pw_pre->pw_buf, (const int) pw_pre->pw_len);
}
line_buf = iconv_tmp;
line_len = HCBUFSIZ_TINY - iconv_sz;
}
words_extra_total += pre_rejects;
if (words_extra_total > 0)
{
hc_thread_mutex_lock (status_ctx->mux_counter);
// post-process rule engine
for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{
status_ctx->words_progress_rejected[salt_pos] += words_extra_total * straight_ctx->kernel_rules_cnt;
}
char rule_buf_out[RP_PASSWORD_SIZE];
hc_thread_mutex_unlock (status_ctx->mux_counter);
}
if (status_ctx->run_thread_level1 == false) break;
if (device_param->pws_cnt)
if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l))
{
// flush
int CL_rc;
CL_rc = run_copy (hashcat_ctx, device_param, device_param->pws_cnt);
if (CL_rc == -1)
{
hcfree (buf);
return -1;
}
CL_rc = run_cracker (hashcat_ctx, device_param, device_param->pws_cnt);
if (line_len >= RP_PASSWORD_SIZE) continue;
if (CL_rc == -1)
{
hcfree (buf);
memset (rule_buf_out, 0, sizeof (rule_buf_out));
return -1;
}
const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out);
device_param->pws_cnt = 0;
if (rule_len_out < 0) continue;
device_param->pws_base_cnt = 0;
line_buf = rule_buf_out;
line_len = (size_t) rule_len_out;
}
if (status_ctx->run_thread_level1 == false) break;
if (device_param->speed_only_finish == true) break;
}
}
else
{
while (status_ctx->run_thread_level1 == true)
{
hc_thread_mutex_lock (status_ctx->mux_dispatcher);
if (feof (stdin) != 0)
{
hc_thread_mutex_unlock (status_ctx->mux_dispatcher);
break;
}
if (line_len >= PW_MAX) continue;
u64 words_extra_total = 0;
// hmm that's always the case, or?
memset (device_param->pws_comp, 0, device_param->size_pws_comp);
memset (device_param->pws_idx, 0, device_param->size_pws_idx);
const u32 attack_kern = user_options_extra->attack_kern;
while (device_param->pws_cnt < device_param->kernel_power)
if (attack_kern == ATTACK_KERN_STRAIGHT)
{
const int rc_select = select_read_timeout_console (1);
if (rc_select == -1) break;
if (rc_select == 0)
if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max))
{
if (status_ctx->run_thread_level1 == false) break;
status_ctx->stdin_read_timeout_cnt++;
words_extra_total++;
continue;
}
}
status_ctx->stdin_read_timeout_cnt = 0;
char *line_buf = fgets (buf, HCBUFSIZ_LARGE - 1, stdin);
if (line_buf == NULL) break;
size_t line_len = in_superchop (line_buf);
line_len = convert_from_hex (hashcat_ctx, line_buf, (u32) line_len);
// do the on-the-fly encoding
if (iconv_enabled == true)
{
char *iconv_ptr = iconv_tmp;
size_t iconv_sz = HCBUFSIZ_TINY;
const size_t iconv_rc = iconv (iconv_ctx, &line_buf, &line_len, &iconv_ptr, &iconv_sz);
if (iconv_rc == (size_t) -1) continue;
line_buf = iconv_tmp;
line_len = HCBUFSIZ_TINY - iconv_sz;
}
// post-process rule engine
char rule_buf_out[RP_PASSWORD_SIZE];
if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l))
{
if (line_len >= RP_PASSWORD_SIZE) continue;
memset (rule_buf_out, 0, sizeof (rule_buf_out));
const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out);
if (rule_len_out < 0) continue;
line_buf = rule_buf_out;
line_len = (size_t) rule_len_out;
}
if (line_len >= PW_MAX) continue;
// hmm that's always the case, or?
const u32 attack_kern = user_options_extra->attack_kern;
if (attack_kern == ATTACK_KERN_STRAIGHT)
{
if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max))
{
words_extra_total++;
continue;
}
}
pw_add (device_param, (const u8 *) line_buf, (const int) line_len);
pw_add (device_param, (const u8 *) line_buf, (const int) line_len);
if (status_ctx->run_thread_level1 == false) break;
}
if (status_ctx->run_thread_level1 == false) break;
}
hc_thread_mutex_unlock (status_ctx->mux_dispatcher);
hc_thread_mutex_unlock (status_ctx->mux_dispatcher);
if (words_extra_total > 0)
{
hc_thread_mutex_lock (status_ctx->mux_counter);
if (words_extra_total > 0)
for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{
hc_thread_mutex_lock (status_ctx->mux_counter);
for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{
status_ctx->words_progress_rejected[salt_pos] += words_extra_total * straight_ctx->kernel_rules_cnt;
}
hc_thread_mutex_unlock (status_ctx->mux_counter);
status_ctx->words_progress_rejected[salt_pos] += words_extra_total * straight_ctx->kernel_rules_cnt;
}
if (status_ctx->run_thread_level1 == false) break;
hc_thread_mutex_unlock (status_ctx->mux_counter);
}
if (device_param->pws_cnt == 0) break;
if (status_ctx->run_thread_level1 == false) break;
// flush
if (device_param->pws_cnt == 0) break;
int CL_rc;
// flush
CL_rc = run_copy (hashcat_ctx, device_param, device_param->pws_cnt);
int CL_rc;
if (CL_rc == -1)
{
hcfree (buf);
CL_rc = run_copy (hashcat_ctx, device_param, device_param->pws_cnt);
return -1;
}
if (CL_rc == -1)
{
hcfree (buf);
CL_rc = run_cracker (hashcat_ctx, device_param, device_param->pws_cnt);
return -1;
}
if (CL_rc == -1)
{
hcfree (buf);
CL_rc = run_cracker (hashcat_ctx, device_param, device_param->pws_cnt);
return -1;
}
if (CL_rc == -1)
{
hcfree (buf);
device_param->pws_cnt = 0;
return -1;
}
if (status_ctx->run_thread_level1 == false) break;
device_param->pws_cnt = 0;
if (device_param->speed_only_finish == true) break;
}
if (status_ctx->run_thread_level1 == false) break;
if (device_param->speed_only_finish == true) break;
}
device_param->kernel_accel_prev = device_param->kernel_accel;
@ -517,6 +362,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
const u32 attack_mode = user_options->attack_mode;
@ -526,13 +372,43 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
{
// attack modes from here
if (attack_mode == ATTACK_MODE_BF)
if (attack_mode == ATTACK_MODE_STRAIGHT)
{
extra_info_mask_t extra_info_mask;
char *dictfile = straight_ctx->dict;
memset (&extra_info_mask, 0, sizeof (extra_info_mask));
FILE *fp = fopen (dictfile, "rb");
extra_info_mask.out_len = mask_ctx->css_cnt;
if (fp == NULL)
{
event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno));
return -1;
}
extra_info_straight_t extra_info_straight;
memset (&extra_info_straight, 0, sizeof (extra_info_straight));
extra_info_straight.fp = fp;
hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (sizeof (hashcat_ctx_t));
memcpy (hashcat_ctx_tmp, hashcat_ctx, sizeof (hashcat_ctx_t)); // yes we actually want to copy these pointers
hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (sizeof (wl_data_t));
const int rc_wl_data_init = wl_data_init (hashcat_ctx_tmp);
if (rc_wl_data_init == -1)
{
fclose (fp);
hcfree (hashcat_ctx_tmp->wl_data);
hcfree (hashcat_ctx_tmp);
return -1;
}
u64 words_cur = 0;
@ -540,12 +416,17 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
{
u64 words_fin = 0;
memset (device_param->pws_comp, 0, device_param->size_pws_comp);
memset (device_param->pws_idx, 0, device_param->size_pws_idx);
memset (device_param->pws_comp, 0, device_param->size_pws_comp);
memset (device_param->pws_idx, 0, device_param->size_pws_idx);
memset (device_param->pws_base_buf, 0, device_param->size_pws_base);
u64 pre_rejects = -1;
// this greatly reduces spam on hashcat console
u64 pre_rejects = -1u;
const u64 pre_rejects_ignore = get_power (opencl_ctx, device_param) / 2;
while (pre_rejects)
while (pre_rejects > pre_rejects_ignore)
{
u64 words_extra_total = 0;
@ -559,25 +440,34 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
while (words_extra)
{
const u64 work = get_work (hashcat_ctx, device_param, words_extra);
u64 work = get_work (hashcat_ctx, device_param, words_extra);
if (work == 0) break;
words_extra = 0;
u64 words_off = device_param->words_off;
words_fin = words_off + work;
words_extra = 0;
slow_candidates_seek (hashcat_ctx_tmp, &extra_info_straight, words_cur, words_off);
words_cur = words_off;
for (u64 i = words_cur; i < words_fin; i++)
{
extra_info_mask.pos = i;
extra_info_straight.pos = i;
slow_candidates_next (hashcat_ctx, &extra_info_mask);
slow_candidates_next (hashcat_ctx_tmp, &extra_info_straight);
pw_pre_add (device_param, extra_info_mask.out_buf, extra_info_mask.out_len, NULL, 0, 0);
if ((extra_info_straight.out_len < hashconfig->pw_min) || (extra_info_straight.out_len > hashconfig->pw_max))
{
pre_rejects++;
continue;
}
pw_pre_add (device_param, extra_info_straight.out_buf, extra_info_straight.out_len, extra_info_straight.base_buf, extra_info_straight.base_len, extra_info_straight.rule_pos_prev);
if (status_ctx->run_thread_level1 == false) break;
}
@ -589,19 +479,15 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (status_ctx->run_thread_level1 == false) break;
}
if (0)
{
}
else
u64 pws_pre_cnt = device_param->pws_pre_cnt;
for (u64 pws_pre_idx = 0; pws_pre_idx < pws_pre_cnt; pws_pre_idx++)
{
u64 pws_pre_cnt = device_param->pws_pre_cnt;
pw_pre_t *pw_pre = device_param->pws_pre_buf + pws_pre_idx;
for (u64 pws_pre_idx = 0; pws_pre_idx < pws_pre_cnt; pws_pre_idx++)
{
pw_pre_t *pw_pre = device_param->pws_pre_buf + pws_pre_idx;
pw_base_add (device_param, pw_pre);
pw_add (device_param, (const u8 *) pw_pre->pw_buf, (const int) pw_pre->pw_len);
}
pw_add (device_param, (const u8 *) pw_pre->pw_buf, (const int) pw_pre->pw_len);
}
words_extra_total += pre_rejects;
@ -635,6 +521,12 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (CL_rc == -1)
{
fclose (fp);
hcfree (hashcat_ctx_tmp->wl_data);
hcfree (hashcat_ctx_tmp);
return -1;
}
@ -642,25 +534,41 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (CL_rc == -1)
{
fclose (fp);
hcfree (hashcat_ctx_tmp->wl_data);
hcfree (hashcat_ctx_tmp);
return -1;
}
device_param->pws_cnt = 0;
device_param->pws_base_cnt = 0;
}
if (device_param->speed_only_finish == true) break;
if (status_ctx->run_thread_level2 == true)
{
device_param->words_done = words_fin;
device_param->words_done = MAX (device_param->words_done, words_fin);
status_ctx->words_cur = get_lowest_words_done (hashcat_ctx);
status_ctx->words_cur = get_highest_words_done (hashcat_ctx);
}
if (status_ctx->run_thread_level1 == false) break;
if (words_fin == 0) break;
}
fclose (fp);
wl_data_destroy (hashcat_ctx_tmp);
hcfree (hashcat_ctx_tmp->wl_data);
hcfree (hashcat_ctx_tmp);
}
else if (attack_mode == ATTACK_MODE_COMBI)
{
@ -737,9 +645,13 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
memset (device_param->pws_idx, 0, device_param->size_pws_idx);
memset (device_param->pws_base_buf, 0, device_param->size_pws_base);
u64 pre_rejects = -1u;
u64 pre_rejects = -1;
// this greatly reduces spam on hashcat console
while (pre_rejects)
const u64 pre_rejects_ignore = get_power (opencl_ctx, device_param) / 2;
while (pre_rejects > pre_rejects_ignore)
{
u64 words_extra_total = 0;
@ -753,7 +665,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
while (words_extra)
{
const u64 work = get_work (hashcat_ctx, device_param, words_extra);
u64 work = get_work (hashcat_ctx, device_param, words_extra);
if (work == 0) break;
@ -769,11 +681,13 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
for (u64 i = words_cur; i < words_fin; i++)
{
extra_info_combi.pos = i;
slow_candidates_next (hashcat_ctx_tmp, &extra_info_combi);
if ((extra_info_combi.out_len < hashconfig->pw_min) || (extra_info_combi.out_len > hashconfig->pw_max))
{
words_extra++;
pre_rejects++;
continue;
}
@ -790,21 +704,15 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (status_ctx->run_thread_level1 == false) break;
}
if (0)
{
}
else
{
u64 pws_pre_cnt = device_param->pws_pre_cnt;
u64 pws_pre_cnt = device_param->pws_pre_cnt;
for (u64 pws_pre_idx = 0; pws_pre_idx < pws_pre_cnt; pws_pre_idx++)
{
pw_pre_t *pw_pre = device_param->pws_pre_buf + pws_pre_idx;
for (u64 pws_pre_idx = 0; pws_pre_idx < pws_pre_cnt; pws_pre_idx++)
{
pw_pre_t *pw_pre = device_param->pws_pre_buf + pws_pre_idx;
pw_base_add (device_param, pw_pre);
pw_base_add (device_param, pw_pre);
pw_add (device_param, (const u8 *) pw_pre->pw_buf, (const int) pw_pre->pw_len);
}
pw_add (device_param, (const u8 *) pw_pre->pw_buf, (const int) pw_pre->pw_len);
}
words_extra_total += pre_rejects;
@ -873,9 +781,9 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (status_ctx->run_thread_level2 == true)
{
device_param->words_done = words_fin;
device_param->words_done = MAX (device_param->words_done, words_fin);
status_ctx->words_cur = get_lowest_words_done (hashcat_ctx);
status_ctx->words_cur = get_highest_words_done (hashcat_ctx);
}
if (status_ctx->run_thread_level1 == false) break;
@ -893,43 +801,13 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
hcfree (hashcat_ctx_tmp);
}
else if (attack_mode == ATTACK_MODE_STRAIGHT)
else if (attack_mode == ATTACK_MODE_BF)
{
char *dictfile = straight_ctx->dict;
FILE *fp = fopen (dictfile, "rb");
if (fp == NULL)
{
event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno));
return -1;
}
extra_info_straight_t extra_info_straight;
memset (&extra_info_straight, 0, sizeof (extra_info_straight));
extra_info_straight.fp = fp;
hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (sizeof (hashcat_ctx_t));
memcpy (hashcat_ctx_tmp, hashcat_ctx, sizeof (hashcat_ctx_t)); // yes we actually want to copy these pointers
hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (sizeof (wl_data_t));
const int rc_wl_data_init = wl_data_init (hashcat_ctx_tmp);
if (rc_wl_data_init == -1)
{
fclose (fp);
hcfree (hashcat_ctx_tmp->wl_data);
extra_info_mask_t extra_info_mask;
hcfree (hashcat_ctx_tmp);
memset (&extra_info_mask, 0, sizeof (extra_info_mask));
return -1;
}
extra_info_mask.out_len = mask_ctx->css_cnt;
u64 words_cur = 0;
@ -937,13 +815,16 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
{
u64 words_fin = 0;
memset (device_param->pws_comp, 0, device_param->size_pws_comp);
memset (device_param->pws_idx, 0, device_param->size_pws_idx);
memset (device_param->pws_base_buf, 0, device_param->size_pws_base);
memset (device_param->pws_comp, 0, device_param->size_pws_comp);
memset (device_param->pws_idx, 0, device_param->size_pws_idx);
u64 pre_rejects = -1;
// this greatly reduces spam on hashcat console
u64 pre_rejects = -1u;
const u64 pre_rejects_ignore = get_power (opencl_ctx, device_param) / 2;
while (pre_rejects)
while (pre_rejects > pre_rejects_ignore)
{
u64 words_extra_total = 0;
@ -957,7 +838,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
while (words_extra)
{
const u64 work = get_work (hashcat_ctx, device_param, words_extra);
u64 work = get_work (hashcat_ctx, device_param, words_extra);
if (work == 0) break;
@ -967,22 +848,15 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
words_fin = words_off + work;
slow_candidates_seek (hashcat_ctx_tmp, &extra_info_straight, words_cur, words_off);
words_cur = words_off;
for (u64 i = words_cur; i < words_fin; i++)
{
slow_candidates_next (hashcat_ctx_tmp, &extra_info_straight);
if ((extra_info_straight.out_len < hashconfig->pw_min) || (extra_info_straight.out_len > hashconfig->pw_max))
{
words_extra++;
extra_info_mask.pos = i;
continue;
}
slow_candidates_next (hashcat_ctx, &extra_info_mask);
pw_pre_add (device_param, extra_info_straight.out_buf, extra_info_straight.out_len, extra_info_straight.base_buf, extra_info_straight.base_len, extra_info_straight.rule_pos_prev);
pw_pre_add (device_param, extra_info_mask.out_buf, extra_info_mask.out_len, NULL, 0, 0);
if (status_ctx->run_thread_level1 == false) break;
}
@ -994,21 +868,13 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (status_ctx->run_thread_level1 == false) break;
}
if (0)
{
}
else
{
u64 pws_pre_cnt = device_param->pws_pre_cnt;
u64 pws_pre_cnt = device_param->pws_pre_cnt;
for (u64 pws_pre_idx = 0; pws_pre_idx < pws_pre_cnt; pws_pre_idx++)
{
pw_pre_t *pw_pre = device_param->pws_pre_buf + pws_pre_idx;
pw_base_add (device_param, pw_pre);
for (u64 pws_pre_idx = 0; pws_pre_idx < pws_pre_cnt; pws_pre_idx++)
{
pw_pre_t *pw_pre = device_param->pws_pre_buf + pws_pre_idx;
pw_add (device_param, (const u8 *) pw_pre->pw_buf, (const int) pw_pre->pw_len);
}
pw_add (device_param, (const u8 *) pw_pre->pw_buf, (const int) pw_pre->pw_len);
}
words_extra_total += pre_rejects;
@ -1042,12 +908,6 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (CL_rc == -1)
{
fclose (fp);
hcfree (hashcat_ctx_tmp->wl_data);
hcfree (hashcat_ctx_tmp);
return -1;
}
@ -1055,41 +915,25 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (CL_rc == -1)
{
fclose (fp);
hcfree (hashcat_ctx_tmp->wl_data);
hcfree (hashcat_ctx_tmp);
return -1;
}
device_param->pws_cnt = 0;
device_param->pws_base_cnt = 0;
}
if (device_param->speed_only_finish == true) break;
if (status_ctx->run_thread_level2 == true)
{
device_param->words_done = words_fin;
device_param->words_done = MAX (device_param->words_done, words_fin);
status_ctx->words_cur = get_lowest_words_done (hashcat_ctx);
status_ctx->words_cur = get_highest_words_done (hashcat_ctx);
}
if (status_ctx->run_thread_level1 == false) break;
if (words_fin == 0) break;
}
fclose (fp);
wl_data_destroy (hashcat_ctx_tmp);
hcfree (hashcat_ctx_tmp->wl_data);
hcfree (hashcat_ctx_tmp);
}
}
else
@ -1139,7 +983,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (status_ctx->run_thread_level2 == true)
{
device_param->words_done = words_fin;
device_param->words_done = MAX (device_param->words_done, words_fin);
status_ctx->words_cur = get_lowest_words_done (hashcat_ctx);
}
@ -1406,7 +1250,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (status_ctx->run_thread_level2 == true)
{
device_param->words_done = words_fin;
device_param->words_done = MAX (device_param->words_done, words_fin);
status_ctx->words_cur = get_lowest_words_done (hashcat_ctx);
}

@ -27,6 +27,14 @@
#include "timer.h"
#include "locking.h"
int sort_by_string (const void *p1, const void *p2)
{
const char *s1 = (const char *) p1;
const char *s2 = (const char *) p2;
return strcmp (s1, s2);
}
int sort_by_digest_p0p1 (const void *v1, const void *v2, void *v3)
{
const u32 *d1 = (const u32 *) v1;

@ -27,49 +27,49 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u
{
extra_info_straight_t *extra_info_straight = (extra_info_straight_t *) extra_info;
FILE *fp = extra_info_straight->fp;
const u64 overlap = end % straight_ctx->kernel_rules_cnt;
for (u64 i = cur; i < end; i++)
{
if ((i % straight_ctx->kernel_rules_cnt) == 0)
{
char *line_buf = NULL;
u32 line_len = 0;
const u64 init = end - overlap;
while (1)
{
FILE *fp = extra_info_straight->fp;
for (u64 i = cur; i < init; i += straight_ctx->kernel_rules_cnt)
{
char *line_buf;
u32 line_len;
get_next_word (hashcat_ctx, fp, &line_buf, &line_len);
while (1)
{
get_next_word (hashcat_ctx, fp, &line_buf, &line_len);
// post-process rule engine
// post-process rule engine
char rule_buf_out[RP_PASSWORD_SIZE];
char rule_buf_out[RP_PASSWORD_SIZE];
if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l))
{
if (line_len >= RP_PASSWORD_SIZE) continue;
if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l))
{
if (line_len >= RP_PASSWORD_SIZE) continue;
memset (rule_buf_out, 0, sizeof (rule_buf_out));
memset (rule_buf_out, 0, sizeof (rule_buf_out));
const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out);
const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out);
if (rule_len_out < 0) continue;
if (rule_len_out < 0) continue;
line_buf = rule_buf_out;
line_len = (u32) rule_len_out;
}
line_buf = rule_buf_out;
line_len = (u32) rule_len_out;
break;
}
break;
}
memcpy (extra_info_straight->base_buf, line_buf, line_len);
memcpy (extra_info_straight->base_buf, line_buf, line_len);
extra_info_straight->base_len = line_len;
extra_info_straight->base_len = line_len;
}
}
extra_info_straight->rule_pos_prev = overlap;
extra_info_straight->rule_pos = overlap;
extra_info_straight->rule_pos_prev = end % straight_ctx->kernel_rules_cnt;
extra_info_straight->rule_pos = extra_info_straight->rule_pos_prev;
}
else if (attack_mode == ATTACK_MODE_COMBI)
{
@ -78,49 +78,45 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u
FILE *base_fp = extra_info_combi->base_fp;
FILE *combs_fp = extra_info_combi->combs_fp;
u64 overlap_cur = cur % combinator_ctx->combs_cnt;
const u64 overlap = end % combinator_ctx->combs_cnt;
const u64 init = end - overlap;
for (u64 i = cur; i < init; i += combinator_ctx->combs_cnt)
for (u64 i = cur; i < end; i++)
{
char *line_buf = NULL;
u32 line_len = 0;
while (1)
if ((i % combinator_ctx->combs_cnt) == 0)
{
get_next_word (hashcat_ctx, base_fp, &line_buf, &line_len);
// post-process rule engine
char *line_buf = NULL;
u32 line_len = 0;
if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l))
while (1)
{
if (line_len >= RP_PASSWORD_SIZE) continue;
get_next_word (hashcat_ctx, base_fp, &line_buf, &line_len);
// post-process rule engine
char rule_buf_out[RP_PASSWORD_SIZE];
memset (rule_buf_out, 0, sizeof (rule_buf_out));
if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l))
{
if (line_len >= RP_PASSWORD_SIZE) continue;
const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out);
memset (rule_buf_out, 0, sizeof (rule_buf_out));
if (rule_len_out < 0) continue;
}
const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out);
break;
}
if (rule_len_out < 0) continue;
memcpy (extra_info_combi->base_buf, line_buf, line_len);
line_buf = rule_buf_out;
line_len = (u32) rule_len_out;
}
extra_info_combi->base_len = line_len;
break;
}
rewind (combs_fp);
memcpy (extra_info_combi->base_buf, line_buf, line_len);
overlap_cur = 0;
}
extra_info_combi->base_len = line_len;
rewind (combs_fp);
}
for (u64 i = overlap_cur; i < overlap; i++)
{
char *line_buf = extra_info_combi->scratch_buf;
u32 line_len = 0;
@ -147,8 +143,9 @@ void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u
}
}
extra_info_combi->comb_pos_prev = overlap;
extra_info_combi->comb_pos = overlap;
extra_info_combi->comb_pos_prev = end % combinator_ctx->combs_cnt;
extra_info_combi->comb_pos = extra_info_combi->comb_pos_prev;
}
else if (attack_mode == ATTACK_MODE_BF)
{
@ -171,15 +168,15 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info)
{
extra_info_straight_t *extra_info_straight = (extra_info_straight_t *) extra_info;
FILE *fp = extra_info_straight->fp;
if (extra_info_straight->rule_pos == 0)
if ((extra_info_straight->pos % straight_ctx->kernel_rules_cnt) == 0)
{
char *line_buf;
u32 line_len;
char *line_buf = NULL;
u32 line_len = 0;
while (1)
{
FILE *fp = extra_info_straight->fp;
get_next_word (hashcat_ctx, fp, &line_buf, &line_len);
line_len = (u32) convert_from_hex (hashcat_ctx, line_buf, line_len);
@ -243,10 +240,10 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info)
FILE *base_fp = extra_info_combi->base_fp;
FILE *combs_fp = extra_info_combi->combs_fp;
if (extra_info_combi->comb_pos == 0)
if ((extra_info_combi->pos % combinator_ctx->combs_cnt) == 0)
{
char *line_buf;
u32 line_len;
char *line_buf = NULL;
u32 line_len = 0;
while (1)
{
@ -284,8 +281,7 @@ void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info)
extra_info_combi->out_len = extra_info_combi->base_len;
char *line_buf = extra_info_combi->scratch_buf;
u32 line_len = 0;
u32 line_len = 0;
while (1)
{

@ -334,8 +334,10 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
case IDX_EXAMPLE_HASHES: user_options->example_hashes = true; break;
case IDX_FORCE: user_options->force = true; break;
case IDX_SELF_TEST_DISABLE: user_options->self_test_disable = true; break;
case IDX_SKIP: user_options->skip = hc_strtoull (optarg, NULL, 10); break;
case IDX_LIMIT: user_options->limit = hc_strtoull (optarg, NULL, 10); break;
case IDX_SKIP: user_options->skip = hc_strtoull (optarg, NULL, 10);
user_options->skip_chgd = true; break;
case IDX_LIMIT: user_options->limit = hc_strtoull (optarg, NULL, 10);
user_options->limit_chgd = true; break;
case IDX_KEEP_GUESSING: user_options->keep_guessing = true; break;
case IDX_KEYSPACE: user_options->keyspace = true; break;
case IDX_BENCHMARK: user_options->benchmark = true; break;
@ -491,6 +493,22 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
}
}
/*
if (user_options->skip_chgd == true && user_options->skip == 0)
{
event_log_error (hashcat_ctx, "Invalid --skip value specified.");
return -1;
}
*/
if (user_options->limit_chgd == true && user_options->limit == 0)
{
event_log_error (hashcat_ctx, "Invalid --limit value specified.");
return -1;
}
if (user_options->runtime_chgd == true && user_options->runtime == 0)
{
event_log_error (hashcat_ctx, "Invalid --runtime value specified.");
@ -1130,6 +1148,18 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
show_error = false;
}
if (user_options->hc_argc == 1)
{
// stdin mode
if (user_options->slow_candidates == true)
{
event_log_error (hashcat_ctx, "Use of --slow-candidates is not possible in stdin mode.");
return -1;
}
}
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
{

Loading…
Cancel
Save