Allow using -L with -a 7 (other modes need no modification) for fast hashes

pull/1288/head
jsteube 7 years ago
parent f7a8e7c54b
commit f97c0d38d7

@ -33,118 +33,266 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
combinator_ctx->scratch_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
if (user_options->length_limit_disable == true)
{
// nothing to do
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
// display
// this is always need to be COMBINATOR_MODE_BASE_LEFT
char *dictfile1 = user_options_extra->hc_workv[0];
char *dictfile2 = user_options_extra->hc_workv[1];
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
// display
// at this point we know the file actually exist
// find the bigger dictionary and use as base
char *dictfile1 = user_options_extra->hc_workv[0];
char *dictfile2 = user_options_extra->hc_workv[1];
if (hc_path_is_file (dictfile1) == false)
{
event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile1);
// at this point we know the file actually exist
// find the bigger dictionary and use as base
return -1;
}
if (hc_path_is_file (dictfile1) == false)
{
event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile1);
if (hc_path_is_file (dictfile2) == false)
{
event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile2);
return -1;
}
return -1;
}
if (hc_path_is_file (dictfile2) == false)
{
event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile2);
FILE *fp1 = NULL;
FILE *fp2 = NULL;
return -1;
}
if ((fp1 = fopen (dictfile1, "rb")) == NULL)
{
event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno));
FILE *fp1 = NULL;
FILE *fp2 = NULL;
return -1;
}
if ((fp1 = fopen (dictfile1, "rb")) == NULL)
{
event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno));
if ((fp2 = fopen (dictfile2, "rb")) == NULL)
{
event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
return -1;
}
fclose (fp1);
if ((fp2 = fopen (dictfile2, "rb")) == NULL)
{
event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
return -1;
}
fclose (fp1);
combinator_ctx->combs_cnt = 1;
return -1;
}
u64 words1_cnt = 0;
combinator_ctx->combs_cnt = 1;
const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt);
u64 words1_cnt = 0;
if (rc1 == -1)
{
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1);
const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt);
fclose (fp1);
fclose (fp2);
if (rc1 == -1)
{
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1);
return -1;
}
fclose (fp1);
fclose (fp2);
if (words1_cnt == 0)
{
event_log_error (hashcat_ctx, "%s: empty file.", dictfile1);
return -1;
}
fclose (fp1);
fclose (fp2);
if (words1_cnt == 0)
{
event_log_error (hashcat_ctx, "%s: empty file.", dictfile1);
return -1;
}
fclose (fp1);
fclose (fp2);
combinator_ctx->combs_cnt = 1;
return -1;
}
u64 words2_cnt = 0;
combinator_ctx->combs_cnt = 1;
const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt);
u64 words2_cnt = 0;
if (rc2 == -1)
{
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile2);
const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt);
fclose (fp1);
fclose (fp2);
if (rc2 == -1)
{
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile2);
return -1;
}
fclose (fp1);
fclose (fp2);
if (words2_cnt == 0)
{
event_log_error (hashcat_ctx, "%s: empty file.", dictfile2);
return -1;
}
if (words2_cnt == 0)
{
event_log_error (hashcat_ctx, "%s: empty file.", dictfile2);
fclose (fp1);
fclose (fp2);
return -1;
}
fclose (fp1);
fclose (fp2);
return -1;
combinator_ctx->dict1 = dictfile1;
combinator_ctx->dict2 = dictfile2;
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT;
combinator_ctx->combs_cnt = words2_cnt;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
fclose (fp1);
fclose (fp2);
char *dictfile = user_options_extra->hc_workv[1];
combinator_ctx->dict1 = dictfile1;
combinator_ctx->dict2 = dictfile2;
// at this point we know the file actually exist
if (user_options->length_limit_disable == true)
{
if (hc_path_is_file (dictfile) == false)
{
event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile);
return -1;
}
FILE *fp = NULL;
if ((fp = fopen (dictfile, "rb")) == NULL)
{
event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno));
return -1;
}
mask_ctx->bfs_cnt = 1;
u64 words_cnt = 0;
const int rc = count_words (hashcat_ctx, fp, dictfile, &words_cnt);
if (rc == -1)
{
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile);
fclose (fp);
return -1;
}
fclose (fp);
combinator_ctx->combs_cnt = words_cnt;
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT;
combinator_ctx->combs_cnt = words2_cnt;
}
else
}
else
{
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
// display
char *dictfile1 = user_options_extra->hc_workv[0];
char *dictfile2 = user_options_extra->hc_workv[1];
// at this point we know the file actually exist
// find the bigger dictionary and use as base
if (hc_path_is_file (dictfile1) == false)
{
event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile1);
return -1;
}
if (hc_path_is_file (dictfile2) == false)
{
event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile2);
return -1;
}
FILE *fp1 = NULL;
FILE *fp2 = NULL;
if ((fp1 = fopen (dictfile1, "rb")) == NULL)
{
event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno));
return -1;
}
if ((fp2 = fopen (dictfile2, "rb")) == NULL)
{
event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
fclose (fp1);
return -1;
}
combinator_ctx->combs_cnt = 1;
u64 words1_cnt = 0;
const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt);
if (rc1 == -1)
{
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1);
fclose (fp1);
fclose (fp2);
return -1;
}
if (words1_cnt == 0)
{
event_log_error (hashcat_ctx, "%s: empty file.", dictfile1);
fclose (fp1);
fclose (fp2);
return -1;
}
combinator_ctx->combs_cnt = 1;
u64 words2_cnt = 0;
const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt);
if (rc2 == -1)
{
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile2);
fclose (fp1);
fclose (fp2);
return -1;
}
if (words2_cnt == 0)
{
event_log_error (hashcat_ctx, "%s: empty file.", dictfile2);
fclose (fp1);
fclose (fp2);
return -1;
}
fclose (fp1);
fclose (fp2);
combinator_ctx->dict1 = dictfile1;
combinator_ctx->dict2 = dictfile2;
if (words1_cnt >= words2_cnt)
{
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT;
@ -168,22 +316,11 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
user_options_extra->rule_len_r = tmpi;
}
}
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
// nothing to do
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
if (user_options->length_limit_disable == true)
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT;
}
else
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_RIGHT;
}

@ -313,8 +313,24 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
const u32 attack_mode = user_options->attack_mode;
const u32 attack_kern = user_options_extra->attack_kern;
if (attack_mode == ATTACK_MODE_BF)
if ((attack_mode == ATTACK_MODE_BF) || ((user_options->length_limit_disable == true) && (attack_mode == ATTACK_MODE_HYBRID2)))
{
if ((user_options->length_limit_disable == true) && (attack_mode == ATTACK_MODE_HYBRID2))
{
char *dictfile = straight_ctx->dict;
FILE *combs_fp = fopen (dictfile, "rb");
if (combs_fp == NULL)
{
event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno));
return -1;
}
device_param->combs_fp = combs_fp;
}
while (status_ctx->run_thread_level1 == true)
{
const u32 work = get_work (hashcat_ctx, device_param, -1u);

@ -1174,36 +1174,72 @@ int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
}
else if ((user_options->attack_mode == ATTACK_MODE_HYBRID1) || (user_options->attack_mode == ATTACK_MODE_HYBRID2))
{
mask_ctx->mask = mask_ctx->masks[mask_ctx->masks_pos];
if ((user_options->length_limit_disable == true) && (user_options->attack_mode == ATTACK_MODE_HYBRID2))
{
mask_ctx->mask = mask_ctx->masks[mask_ctx->masks_pos];
const int rc_mask_file = mask_ctx_parse_maskfile (hashcat_ctx);
const int rc_mask_file = mask_ctx_parse_maskfile (hashcat_ctx);
if (rc_mask_file == -1) return -1;
if (rc_mask_file == -1) return -1;
mask_ctx->css_buf = (cs_t *) hccalloc (256, sizeof (cs_t));
mask_ctx->css_buf = (cs_t *) hccalloc (256, sizeof (cs_t));
const int rc_gen_css = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, mask_ctx->css_buf, &mask_ctx->css_cnt);
const int rc_gen_css = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, mask_ctx->css_buf, &mask_ctx->css_cnt);
if (rc_gen_css == -1) return -1;
if (rc_gen_css == -1) return -1;
u32 uniq_tbls[SP_PW_MAX][CHARSIZ] = { { 0 } };
u32 uniq_tbls[SP_PW_MAX][CHARSIZ] = { { 0 } };
mp_css_to_uniq_tbl (hashcat_ctx, mask_ctx->css_cnt, mask_ctx->css_buf, uniq_tbls);
mp_css_to_uniq_tbl (hashcat_ctx, mask_ctx->css_cnt, mask_ctx->css_buf, uniq_tbls);
sp_tbl_to_css (mask_ctx->root_table_buf, mask_ctx->markov_table_buf, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, user_options->markov_threshold, uniq_tbls);
sp_tbl_to_css (mask_ctx->root_table_buf, mask_ctx->markov_table_buf, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, user_options->markov_threshold, uniq_tbls);
const int rc_get_sum = sp_get_sum (0, mask_ctx->css_cnt, mask_ctx->root_css_buf, &combinator_ctx->combs_cnt);
const int rc_get_sum = sp_get_sum (0, mask_ctx->css_cnt, mask_ctx->root_css_buf, &mask_ctx->bfs_cnt);
if (rc_get_sum == -1)
{
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of mask: %s", mask_ctx->mask);
if (rc_get_sum == -1)
{
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of mask: %s", mask_ctx->mask);
return -1;
return -1;
}
const int rc_update_mp = opencl_session_update_mp (hashcat_ctx);
if (rc_update_mp == -1) return -1;
}
else
{
mask_ctx->mask = mask_ctx->masks[mask_ctx->masks_pos];
const int rc_mask_file = mask_ctx_parse_maskfile (hashcat_ctx);
if (rc_mask_file == -1) return -1;
mask_ctx->css_buf = (cs_t *) hccalloc (256, sizeof (cs_t));
const int rc_gen_css = mp_gen_css (hashcat_ctx, mask_ctx->mask, strlen (mask_ctx->mask), mask_ctx->mp_sys, mask_ctx->mp_usr, mask_ctx->css_buf, &mask_ctx->css_cnt);
if (rc_gen_css == -1) return -1;
u32 uniq_tbls[SP_PW_MAX][CHARSIZ] = { { 0 } };
mp_css_to_uniq_tbl (hashcat_ctx, mask_ctx->css_cnt, mask_ctx->css_buf, uniq_tbls);
const int rc_update_mp = opencl_session_update_mp (hashcat_ctx);
sp_tbl_to_css (mask_ctx->root_table_buf, mask_ctx->markov_table_buf, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, user_options->markov_threshold, uniq_tbls);
if (rc_update_mp == -1) return -1;
const int rc_get_sum = sp_get_sum (0, mask_ctx->css_cnt, mask_ctx->root_css_buf, &combinator_ctx->combs_cnt);
if (rc_get_sum == -1)
{
event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of mask: %s", mask_ctx->mask);
return -1;
}
const int rc_update_mp = opencl_session_update_mp (hashcat_ctx);
if (rc_update_mp == -1) return -1;
}
}
const int rc_update_combinator = opencl_session_update_combinator (hashcat_ctx);

@ -1746,9 +1746,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
{
int CL_rc;
CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
const int CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
if (CL_rc == -1) return -1;
}
@ -1756,8 +1754,28 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
{
if (user_options->length_limit_disable == true)
{
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
const int CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
if (CL_rc == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
const int CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
if (CL_rc == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
const u64 off = device_param->words_off;
device_param->kernel_params_mp_buf64[3] = off;
const int CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, pws_cnt);
if (CL_rc == -1) return -1;
}
}
else
{
@ -1815,9 +1833,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
}
}
int CL_rc;
CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
const int CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, pws_cnt * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
if (CL_rc == -1) return -1;
}
@ -1828,9 +1844,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const
device_param->kernel_params_mp_l_buf64[3] = off;
int CL_rc;
CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP_L, pws_cnt);
const int CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP_L, pws_cnt);
if (CL_rc == -1) return -1;
}
@ -1900,7 +1914,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co
FILE *combs_fp = device_param->combs_fp;
if (user_options->attack_mode == ATTACK_MODE_COMBI)
if ((user_options->attack_mode == ATTACK_MODE_COMBI) || ((user_options->length_limit_disable == true) && (user_options->attack_mode == ATTACK_MODE_HYBRID2)))
{
rewind (combs_fp);
}
@ -1954,155 +1968,248 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co
continue;
}
// initialize amplifiers
// initialize and copy amplifiers
if (user_options->attack_mode == ATTACK_MODE_COMBI)
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
{
char *line_buf = combinator_ctx->scratch_buf;
u32 i = 0;
const int CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, innerloop_pos * sizeof (kernel_rule_t), 0, innerloop_left * sizeof (kernel_rule_t), 0, NULL, NULL);
while (i < innerloop_left)
if (CL_rc == -1) return -1;
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
if (user_options->length_limit_disable == true)
{
if (feof (combs_fp)) break;
if ((user_options->attack_mode == ATTACK_MODE_COMBI) || (user_options->attack_mode == ATTACK_MODE_HYBRID2))
{
char *line_buf = combinator_ctx->scratch_buf;
int line_len = fgetl (combs_fp, line_buf);
u32 i = 0;
line_len = convert_from_hex (hashcat_ctx, line_buf, line_len);
while (i < innerloop_left)
{
if (feof (combs_fp)) break;
if (line_len >= PW_MAX) continue;
int line_len = fgetl (combs_fp, line_buf);
char *line_buf_new = line_buf;
line_len = convert_from_hex (hashcat_ctx, line_buf, line_len);
char rule_buf_out[BLOCK_SIZE];
if (line_len >= PW_MAX) continue;
if (run_rule_engine (user_options_extra->rule_len_r, user_options->rule_buf_r))
{
if (line_len >= BLOCK_SIZE) continue;
char *line_buf_new = line_buf;
memset (rule_buf_out, 0, sizeof (rule_buf_out));
char rule_buf_out[BLOCK_SIZE];
const int rule_len_out = _old_apply_rule (user_options->rule_buf_r, user_options_extra->rule_len_r, line_buf, line_len, rule_buf_out);
if (run_rule_engine (user_options_extra->rule_len_r, user_options->rule_buf_r))
{
if (line_len >= BLOCK_SIZE) continue;
if (rule_len_out < 0)
{
status_ctx->words_progress_rejected[salt_pos] += pws_cnt;
memset (rule_buf_out, 0, sizeof (rule_buf_out));
const int rule_len_out = _old_apply_rule (user_options->rule_buf_r, user_options_extra->rule_len_r, line_buf, line_len, rule_buf_out);
if (rule_len_out < 0)
{
status_ctx->words_progress_rejected[salt_pos] += pws_cnt;
continue;
}
line_len = rule_len_out;
continue;
line_buf_new = rule_buf_out;
}
line_len = MIN (line_len, PW_MAX - 1);
u8 *ptr = (u8 *) device_param->combs_buf[i].i;
memcpy (ptr, line_buf_new, line_len);
memset (ptr + line_len, 0, PW_MAX - line_len);
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER)
{
uppercase (ptr, line_len);
}
if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT)
{
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80)
{
ptr[line_len] = 0x80;
}
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01)
{
ptr[line_len] = 0x01;
}
}
device_param->combs_buf[i].pw_len = line_len;
i++;
}
line_len = rule_len_out;
for (u32 j = i; j < innerloop_left; j++)
{
memset (&device_param->combs_buf[j], 0, sizeof (pw_t));
}
line_buf_new = rule_buf_out;
innerloop_left = i;
const int CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, innerloop_left * sizeof (pw_t), device_param->combs_buf, 0, NULL, NULL);
if (CL_rc == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
u64 off = innerloop_pos;
line_len = MIN (line_len, PW_MAX - 1);
device_param->kernel_params_mp_buf64[3] = off;
u8 *ptr = (u8 *) device_param->combs_buf[i].i;
int CL_rc;
memcpy (ptr, line_buf_new, line_len);
CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left);
memset (ptr + line_len, 0, PW_MAX - line_len);
if (CL_rc == -1) return -1;
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER)
{
uppercase (ptr, line_len);
}
CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (pw_t), 0, NULL, NULL);
if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT)
if (CL_rc == -1) return -1;
}
}
else
{
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80)
char *line_buf = combinator_ctx->scratch_buf;
u32 i = 0;
while (i < innerloop_left)
{
ptr[line_len] = 0x80;
if (feof (combs_fp)) break;
int line_len = fgetl (combs_fp, line_buf);
line_len = convert_from_hex (hashcat_ctx, line_buf, line_len);
if (line_len >= PW_MAX) continue;
char *line_buf_new = line_buf;
char rule_buf_out[BLOCK_SIZE];
if (run_rule_engine (user_options_extra->rule_len_r, user_options->rule_buf_r))
{
if (line_len >= BLOCK_SIZE) continue;
memset (rule_buf_out, 0, sizeof (rule_buf_out));
const int rule_len_out = _old_apply_rule (user_options->rule_buf_r, user_options_extra->rule_len_r, line_buf, line_len, rule_buf_out);
if (rule_len_out < 0)
{
status_ctx->words_progress_rejected[salt_pos] += pws_cnt;
continue;
}
line_len = rule_len_out;
line_buf_new = rule_buf_out;
}
line_len = MIN (line_len, PW_MAX - 1);
u8 *ptr = (u8 *) device_param->combs_buf[i].i;
memcpy (ptr, line_buf_new, line_len);
memset (ptr + line_len, 0, PW_MAX - line_len);
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER)
{
uppercase (ptr, line_len);
}
if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT)
{
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80)
{
ptr[line_len] = 0x80;
}
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01)
{
ptr[line_len] = 0x01;
}
}
device_param->combs_buf[i].pw_len = line_len;
i++;
}
if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01)
for (u32 j = i; j < innerloop_left; j++)
{
ptr[line_len] = 0x01;
memset (&device_param->combs_buf[j], 0, sizeof (pw_t));
}
}
device_param->combs_buf[i].pw_len = line_len;
innerloop_left = i;
i++;
}
const int CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, innerloop_left * sizeof (pw_t), device_param->combs_buf, 0, NULL, NULL);
for (u32 j = i; j < innerloop_left; j++)
{
device_param->combs_buf[j].i[0] = 0;
device_param->combs_buf[j].i[1] = 0;
device_param->combs_buf[j].i[2] = 0;
device_param->combs_buf[j].i[3] = 0;
device_param->combs_buf[j].i[4] = 0;
device_param->combs_buf[j].i[5] = 0;
device_param->combs_buf[j].i[6] = 0;
device_param->combs_buf[j].i[7] = 0;
device_param->combs_buf[j].pw_len = 0;
}
innerloop_left = i;
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
u64 off = innerloop_pos;
if (CL_rc == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
u64 off = innerloop_pos;
device_param->kernel_params_mp_r_buf64[3] = off;
device_param->kernel_params_mp_buf64[3] = off;
int CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP_R, innerloop_left);
int CL_rc;
if (CL_rc == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
u64 off = innerloop_pos;
CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left);
device_param->kernel_params_mp_buf64[3] = off;
if (CL_rc == -1) return -1;
int CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left);
CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (pw_t), 0, NULL, NULL);
if (CL_rc == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
u64 off = innerloop_pos;
if (CL_rc == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
u64 off = innerloop_pos;
device_param->kernel_params_mp_buf64[3] = off;
device_param->kernel_params_mp_buf64[3] = off;
int CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left);
int CL_rc;
if (CL_rc == -1) return -1;
}
CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left);
// copy amplifiers
if (CL_rc == -1) return -1;
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
int CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, innerloop_pos * sizeof (kernel_rule_t), 0, innerloop_left * sizeof (kernel_rule_t), 0, NULL, NULL);
CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (pw_t), 0, NULL, NULL);
if (CL_rc == -1) return -1;
if (CL_rc == -1) return -1;
}
}
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
{
int CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, innerloop_left * sizeof (pw_t), device_param->combs_buf, 0, NULL, NULL);
u64 off = innerloop_pos;
if (CL_rc == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
int CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bfs, device_param->d_bfs_c, 0, 0, innerloop_left * sizeof (bf_t), 0, NULL, NULL);
device_param->kernel_params_mp_r_buf64[3] = off;
if (CL_rc == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
int CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (pw_t), 0, NULL, NULL);
int CL_rc;
CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP_R, innerloop_left);
if (CL_rc == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
int CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (pw_t), 0, NULL, NULL);
CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bfs, device_param->d_bfs_c, 0, 0, innerloop_left * sizeof (bf_t), 0, NULL, NULL);
if (CL_rc == -1) return -1;
}
@ -4731,7 +4838,22 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx)
device_param->kernel_params_mp_buf32[7] = 0;
device_param->kernel_params_mp_buf32[8] = 0;
device_param->kernel_params_mp[0] = &device_param->d_combs;
if (user_options->length_limit_disable == true)
{
if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
device_param->kernel_params_mp[0] = &device_param->d_combs;
}
else
{
device_param->kernel_params_mp[0] = &device_param->d_pws_buf;
}
}
else
{
device_param->kernel_params_mp[0] = &device_param->d_combs;
}
device_param->kernel_params_mp[1] = &device_param->d_root_css_buf;
device_param->kernel_params_mp[2] = &device_param->d_markov_css_buf;
device_param->kernel_params_mp[3] = &device_param->kernel_params_mp_buf64[3];

@ -152,31 +152,60 @@ int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
pw_t pw;
if (user_options->length_limit_disable == true)
{
pw_t pw;
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
if (rc == -1) return -1;
if (rc == -1) return -1;
for (int i = 0; i < 64; i++)
{
plain_buf[i] = pw.i[i];
u64 off = device_param->kernel_params_mp_buf64[3] + gidvid;
u32 start = 0;
u32 stop = device_param->kernel_params_mp_buf32[4];
sp_exec (off, (char *) plain_ptr, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop);
plain_len = stop;
char *comb_buf = (char *) device_param->combs_buf[il_pos].i;
u32 comb_len = device_param->combs_buf[il_pos].pw_len;
memcpy (plain_ptr + plain_len, comb_buf, comb_len);
plain_len += comb_len;
if (plain_len > (int) hashconfig->pw_max) plain_len = (int) hashconfig->pw_max;
}
else
{
pw_t pw;
plain_len = (int) pw.pw_len;
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
u64 off = device_param->kernel_params_mp_buf64[3] + il_pos;
if (rc == -1) return -1;
u32 start = 0;
u32 stop = device_param->kernel_params_mp_buf32[4];
for (int i = 0; i < 64; i++)
{
plain_buf[i] = pw.i[i];
}
memmove (plain_ptr + stop, plain_ptr, plain_len);
plain_len = (int) pw.pw_len;
sp_exec (off, (char *) plain_ptr, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop);
u64 off = device_param->kernel_params_mp_buf64[3] + il_pos;
plain_len += start + stop;
u32 start = 0;
u32 stop = device_param->kernel_params_mp_buf32[4];
if (plain_len > (int) hashconfig->pw_max) plain_len = (int) hashconfig->pw_max;
memmove (plain_ptr + stop, plain_ptr, plain_len);
sp_exec (off, (char *) plain_ptr, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop);
plain_len += start + stop;
if (plain_len > (int) hashconfig->pw_max) plain_len = (int) hashconfig->pw_max;
}
}
if (user_options->attack_mode == ATTACK_MODE_BF)

@ -474,9 +474,18 @@ char *status_get_guess_base (const hashcat_ctx_t *hashcat_ctx)
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
if (user_options->length_limit_disable == true)
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
return strdup (straight_ctx->dict);
return strdup (mask_ctx->mask);
}
else
{
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
return strdup (straight_ctx->dict);
}
}
return NULL;
@ -510,9 +519,18 @@ int status_get_guess_base_offset (const hashcat_ctx_t *hashcat_ctx)
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
if (user_options->length_limit_disable == true)
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
return straight_ctx->dicts_pos + 1;
return mask_ctx->masks_pos + 1;
}
else
{
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
return straight_ctx->dicts_pos + 1;
}
}
return 0;
@ -546,9 +564,18 @@ int status_get_guess_base_count (const hashcat_ctx_t *hashcat_ctx)
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
if (user_options->length_limit_disable == true)
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
return straight_ctx->dicts_cnt;
return mask_ctx->masks_cnt;
}
else
{
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
return straight_ctx->dicts_cnt;
}
}
return 0;
@ -597,9 +624,18 @@ char *status_get_guess_mod (const hashcat_ctx_t *hashcat_ctx)
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
if (user_options->length_limit_disable == true)
{
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
return strdup (mask_ctx->mask);
return strdup (straight_ctx->dict);
}
else
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
return strdup (mask_ctx->mask);
}
}
return NULL;
@ -629,9 +665,18 @@ int status_get_guess_mod_offset (const hashcat_ctx_t *hashcat_ctx)
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
if (user_options->length_limit_disable == true)
{
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
return mask_ctx->masks_pos + 1;
return straight_ctx->dicts_pos + 1;
}
else
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
return mask_ctx->masks_pos + 1;
}
}
return 0;
@ -661,9 +706,18 @@ int status_get_guess_mod_count (const hashcat_ctx_t *hashcat_ctx)
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
if (user_options->length_limit_disable == true)
{
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
return mask_ctx->masks_cnt;
return straight_ctx->dicts_cnt;
}
else
{
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
return mask_ctx->masks_cnt;
}
}
return 0;

@ -888,31 +888,63 @@ void status_display (hashcat_ctx_t *hashcat_ctx)
case GUESS_MODE_HYBRID2:
event_log_info (hashcat_ctx,
"Guess.Base.......: File (%s), Right Side",
hashcat_status->guess_base);
event_log_info (hashcat_ctx,
"Guess.Mod........: Mask (%s) [%d], Left Side",
hashcat_status->guess_mod,
hashcat_status->guess_mask_length);
if (user_options->length_limit_disable == true)
{
event_log_info (hashcat_ctx,
"Guess.Base.......: Mask (%s) [%d], Left Side",
hashcat_status->guess_base,
hashcat_status->guess_mask_length);
event_log_info (hashcat_ctx,
"Guess.Mod........: File (%s), Right Side",
hashcat_status->guess_mod);
}
else
{
event_log_info (hashcat_ctx,
"Guess.Base.......: File (%s), Right Side",
hashcat_status->guess_base);
event_log_info (hashcat_ctx,
"Guess.Mod........: Mask (%s) [%d], Left Side",
hashcat_status->guess_mod,
hashcat_status->guess_mask_length);
}
break;
case GUESS_MODE_HYBRID2_CS:
event_log_info (hashcat_ctx,
"Guess.Base.......: File (%s), Right Side",
hashcat_status->guess_base);
event_log_info (hashcat_ctx,
"Guess.Mod........: Mask (%s) [%d], Left Side",
hashcat_status->guess_mod,
hashcat_status->guess_mask_length);
event_log_info (hashcat_ctx,
"Guess.Charset....: %s",
hashcat_status->guess_charset);
if (user_options->length_limit_disable == true)
{
event_log_info (hashcat_ctx,
"Guess.Base.......: Mask (%s) [%d], Left Side",
hashcat_status->guess_base,
hashcat_status->guess_mask_length);
event_log_info (hashcat_ctx,
"Guess.Mod........: File (%s), Right Side",
hashcat_status->guess_mod);
event_log_info (hashcat_ctx,
"Guess.Charset....: %s",
hashcat_status->guess_charset);
}
else
{
event_log_info (hashcat_ctx,
"Guess.Base.......: File (%s), Right Side",
hashcat_status->guess_base);
event_log_info (hashcat_ctx,
"Guess.Mod........: Mask (%s) [%d], Left Side",
hashcat_status->guess_mod,
hashcat_status->guess_mask_length);
event_log_info (hashcat_ctx,
"Guess.Charset....: %s",
hashcat_status->guess_charset);
}
break;
}

@ -262,6 +262,7 @@ int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64
{
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
user_options_t *user_options = hashcat_ctx->user_options;
wl_data_t *wl_data = hashcat_ctx->wl_data;
@ -320,9 +321,18 @@ int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
if (overflow_check_u64_mul (keyspace, combinator_ctx->combs_cnt) == false) return -1;
keyspace *= combinator_ctx->combs_cnt;
if ((user_options->length_limit_disable == true) && (user_options->attack_mode == ATTACK_MODE_HYBRID2))
{
if (overflow_check_u64_mul (keyspace, mask_ctx->bfs_cnt) == false) return -1;
keyspace *= mask_ctx->bfs_cnt;
}
else
{
if (overflow_check_u64_mul (keyspace, combinator_ctx->combs_cnt) == false) return -1;
keyspace *= combinator_ctx->combs_cnt;
}
}
cache_hit_t cache_hit;
@ -414,9 +424,18 @@ int count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile, u64
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
if (overflow_check_u64_add (cnt, combinator_ctx->combs_cnt) == false) return -1;
cnt += combinator_ctx->combs_cnt;
if ((user_options->length_limit_disable == true) && (user_options->attack_mode == ATTACK_MODE_HYBRID2))
{
if (overflow_check_u64_add (cnt, mask_ctx->bfs_cnt) == false) return -1;
cnt += mask_ctx->bfs_cnt;
}
else
{
if (overflow_check_u64_add (cnt, combinator_ctx->combs_cnt) == false) return -1;
cnt += combinator_ctx->combs_cnt;
}
}
}

Loading…
Cancel
Save