Move wordlist folder scan to straight.c and combinator.c init functions

pull/526/head
jsteube 8 years ago
parent 5b2fcc4a18
commit fb5d840cf8

@ -9,7 +9,7 @@
#include <stdio.h>
#include <errno.h>
int combinator_ctx_init (combinator_ctx_t *combinator_ctx, const user_options_t *user_options);
int combinator_ctx_init (combinator_ctx_t *combinator_ctx, user_options_t *user_options, user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, dictstat_ctx_t *dictstat_ctx, wl_data_t *wl_data);
void combinator_ctx_destroy (combinator_ctx_t *combinator_ctx);
#endif // _COMBINATOR_H

@ -1513,8 +1513,6 @@ int hashconfig_init (hashconfig_t *hashconfig, const user_
void hashconfig_destroy (hashconfig_t *hashconfig);
u32 hashconfig_enforce_kernel_threads (const hashconfig_t *hashconfig, const hc_device_param_t *device_param);
u32 hashconfig_enforce_kernel_loops (const hashconfig_t *hashconfig, const user_options_t *user_options);
uint hashconfig_general_pw_min (hashconfig_t *hashconfig);
uint hashconfig_general_pw_max (hashconfig_t *hashconfig);
void hashconfig_general_defaults (hashconfig_t *hashconfig, hashes_t *hashes, const user_options_t *user_options);
void hashconfig_benchmark_defaults (const hashconfig_t *hashconfig, salt_t *salt, void *esalt);
char *hashconfig_benchmark_mask (const hashconfig_t *hashconfig);

@ -10,7 +10,7 @@
#define INCR_DICTS 1000
int straight_ctx_init (straight_ctx_t *straight_ctx, const user_options_t *user_options);
int straight_ctx_init (straight_ctx_t *straight_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, hashconfig_t *hashconfig);
void straight_ctx_destroy (straight_ctx_t *straight_ctx);
void straight_append_dict (straight_ctx_t *straight_ctx, const char *dict);

@ -10,7 +10,7 @@
#include "combinator.h"
#include "wordlist.h"
int combinator_ctx_init (combinator_ctx_t *combinator_ctx, const user_options_t *user_options)
int combinator_ctx_init (combinator_ctx_t *combinator_ctx, user_options_t *user_options, user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, dictstat_ctx_t *dictstat_ctx, wl_data_t *wl_data)
{
combinator_ctx->enabled = false;
@ -26,6 +26,148 @@ int combinator_ctx_init (combinator_ctx_t *combinator_ctx, const user_options_t
combinator_ctx->enabled = true;
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
// nothing to do
}
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];
// find the bigger dictionary and use as base
FILE *fp1 = NULL;
FILE *fp2 = NULL;
struct stat tmp_stat;
if ((fp1 = fopen (dictfile1, "rb")) == NULL)
{
log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
return -1;
}
if (stat (dictfile1, &tmp_stat) == -1)
{
log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
fclose (fp1);
return -1;
}
if (S_ISDIR (tmp_stat.st_mode))
{
log_error ("ERROR: %s must be a regular file", dictfile1, strerror (errno));
fclose (fp1);
return -1;
}
if ((fp2 = fopen (dictfile2, "rb")) == NULL)
{
log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
fclose (fp1);
return -1;
}
if (stat (dictfile2, &tmp_stat) == -1)
{
log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
fclose (fp1);
fclose (fp2);
return -1;
}
if (S_ISDIR (tmp_stat.st_mode))
{
log_error ("ERROR: %s must be a regular file", dictfile2, strerror (errno));
fclose (fp1);
fclose (fp2);
return -1;
}
combinator_ctx->combs_cnt = 1;
const u64 words1_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fp1, dictfile1, dictstat_ctx);
if (words1_cnt == 0)
{
log_error ("ERROR: %s: empty file", dictfile1);
fclose (fp1);
fclose (fp2);
return -1;
}
combinator_ctx->combs_cnt = 1;
const u64 words2_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fp2, dictfile2, dictstat_ctx);
if (words2_cnt == 0)
{
log_error ("ERROR: %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;
combinator_ctx->combs_cnt = words2_cnt;
}
else
{
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_RIGHT;
combinator_ctx->combs_cnt = words1_cnt;
// we also have to switch wordlist related rules!
char *tmpc = user_options->rule_buf_l;
user_options->rule_buf_l = user_options->rule_buf_r;
user_options->rule_buf_r = tmpc;
u32 tmpi = user_options_extra->rule_len_l;
user_options_extra->rule_len_l = user_options_extra->rule_len_r;
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)
{
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_RIGHT;
}
return 0;
}

@ -256,6 +256,10 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
return 0;
}
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
logfile_sub_string (mask_ctx->mask);
}
else if ((user_options->attack_mode == ATTACK_MODE_HYBRID1) || (user_options->attack_mode == ATTACK_MODE_HYBRID2))
{
if (induct_ctx->induction_dictionaries_cnt)
@ -290,10 +294,6 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
return 0;
}
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
logfile_sub_string (mask_ctx->mask);
}
u64 words_base = status_ctx->words_cnt;
@ -360,12 +360,6 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
}
}
/*
* Update dictionary statistic
*/
dictstat_write (dictstat_ctx);
/**
* limit kernel loops by the amplification count we have from:
* - straight_ctx, combinator_ctx or mask_ctx for fast hashes
@ -579,7 +573,6 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
{
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
hashes_t *hashes = hashcat_ctx->hashes;
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
@ -590,7 +583,6 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
straight_ctx_t *straight_ctx = hashcat_ctx->straight_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;
//status_ctx->run_main_level1 = true;
//status_ctx->run_main_level2 = true;
@ -599,55 +591,30 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
status_ctx->run_thread_level2 = true;
/**
* word len
* Update pw_min and pw_max according to next mask
*/
u32 pw_min = hashconfig_general_pw_min (hashconfig);
u32 pw_max = hashconfig_general_pw_max (hashconfig);
u32 pw_min = hashconfig->pw_min;
u32 pw_max = hashconfig->pw_max;
/**
* If we have a NOOP rule then we can process words from wordlists > length 32 for slow hashes
*/
const bool has_noop = kernel_rules_has_noop (straight_ctx->kernel_rules_buf, straight_ctx->kernel_rules_cnt);
if (has_noop == false)
{
switch (user_options_extra->attack_kern)
{
case ATTACK_KERN_STRAIGHT: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
break;
case ATTACK_KERN_COMBI: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
break;
}
}
else
if (user_options->benchmark == true)
{
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
switch (user_options_extra->attack_kern)
{
case ATTACK_KERN_STRAIGHT: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
break;
case ATTACK_KERN_COMBI: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
break;
}
}
else
{
// in this case we can process > 32
}
pw_min = mp_get_length (mask_ctx->mask);
pw_max = pw_min;
}
hashconfig->pw_min = pw_min;
hashconfig->pw_max = pw_max;
/**
* Update attack-mode specific stuff
* Update mask in attack-mode specific stuff
*/
if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
// nothing yet
}
else if ((user_options->attack_mode == ATTACK_MODE_HYBRID1) || (user_options->attack_mode == ATTACK_MODE_HYBRID2))
{
@ -672,9 +639,9 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
if (rc_update_mp == -1) return -1;
}
//const int rc_update_combinator = opencl_session_update_combinator (opencl_ctx, hashconfig, combinator_ctx);
const int rc_update_combinator = opencl_session_update_combinator (opencl_ctx, hashconfig, combinator_ctx);
//if (rc_update_combinator == -1) return -1;
if (rc_update_combinator == -1) return -1;
}
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
{
@ -710,8 +677,8 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
// check if mask is not too large or too small for pw_min/pw_max (*2 if unicode)
u32 mask_min = pw_min;
u32 mask_max = pw_max;
u32 mask_min = hashconfig->pw_min;
u32 mask_max = hashconfig->pw_max;
if (hashconfig->opts_type & OPTS_TYPE_PT_UNICODE)
{
@ -844,389 +811,7 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
}
/**
* dictstat read
*/
dictstat_read (dictstat_ctx);
/**
* dictionary pad
*/
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
if (user_options_extra->wordlist_mode == WL_MODE_FILE)
{
for (int i = 0; i < user_options_extra->hc_workc; i++)
{
char *l0_filename = user_options_extra->hc_workv[i];
struct stat l0_stat;
if (stat (l0_filename, &l0_stat) == -1)
{
log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
return -1;
}
if (S_ISDIR (l0_stat.st_mode))
{
char **dictionary_files = NULL;
dictionary_files = scan_directory (l0_filename);
if (dictionary_files != NULL)
{
qsort (dictionary_files, (size_t) count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
for (int d = 0; dictionary_files[d] != NULL; d++)
{
char *l1_filename = dictionary_files[d];
struct stat l1_stat;
if (stat (l1_filename, &l1_stat) == -1)
{
log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
return -1;
}
if (S_ISREG (l1_stat.st_mode))
{
straight_append_dict (straight_ctx, l1_filename);
}
}
}
myfree (dictionary_files);
}
else
{
straight_append_dict (straight_ctx, l0_filename);
}
}
if (straight_ctx->dicts_cnt == 0)
{
log_error ("ERROR: No usable dictionary file found.");
return -1;
}
}
}
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];
// find the bigger dictionary and use as base
FILE *fp1 = NULL;
FILE *fp2 = NULL;
struct stat tmp_stat;
if ((fp1 = fopen (dictfile1, "rb")) == NULL)
{
log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
return -1;
}
if (stat (dictfile1, &tmp_stat) == -1)
{
log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
fclose (fp1);
return -1;
}
if (S_ISDIR (tmp_stat.st_mode))
{
log_error ("ERROR: %s must be a regular file", dictfile1, strerror (errno));
fclose (fp1);
return -1;
}
if ((fp2 = fopen (dictfile2, "rb")) == NULL)
{
log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
fclose (fp1);
return -1;
}
if (stat (dictfile2, &tmp_stat) == -1)
{
log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
fclose (fp1);
fclose (fp2);
return -1;
}
if (S_ISDIR (tmp_stat.st_mode))
{
log_error ("ERROR: %s must be a regular file", dictfile2, strerror (errno));
fclose (fp1);
fclose (fp2);
return -1;
}
combinator_ctx->combs_cnt = 1;
const u64 words1_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fp1, dictfile1, dictstat_ctx);
if (words1_cnt == 0)
{
log_error ("ERROR: %s: empty file", dictfile1);
fclose (fp1);
fclose (fp2);
return -1;
}
combinator_ctx->combs_cnt = 1;
const u64 words2_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fp2, dictfile2, dictstat_ctx);
if (words2_cnt == 0)
{
log_error ("ERROR: %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;
combinator_ctx->combs_cnt = words2_cnt;
}
else
{
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_RIGHT;
combinator_ctx->combs_cnt = words1_cnt;
// we also have to switch wordlist related rules!
char *tmpc = user_options->rule_buf_l;
user_options->rule_buf_l = user_options->rule_buf_r;
user_options->rule_buf_r = tmpc;
u32 tmpi = user_options_extra->rule_len_l;
user_options_extra->rule_len_l = user_options_extra->rule_len_r;
user_options_extra->rule_len_r = tmpi;
}
const int rc_update_combinator = opencl_session_update_combinator (opencl_ctx, hashconfig, combinator_ctx);
if (rc_update_combinator == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
if (user_options->benchmark == true)
{
pw_min = mp_get_length (mask_ctx->mask);
pw_max = pw_min;
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT;
// mod -- moved to mpsp.c
// base
for (int i = 0; i < user_options_extra->hc_workc - 1; i++)
{
char *l0_filename = user_options_extra->hc_workv[i];
struct stat l0_stat;
if (stat (l0_filename, &l0_stat) == -1)
{
log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
return -1;
}
if (S_ISDIR (l0_stat.st_mode))
{
char **dictionary_files = NULL;
dictionary_files = scan_directory (l0_filename);
if (dictionary_files != NULL)
{
qsort (dictionary_files, (size_t) count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
for (int d = 0; dictionary_files[d] != NULL; d++)
{
char *l1_filename = dictionary_files[d];
struct stat l1_stat;
if (stat (l1_filename, &l1_stat) == -1)
{
log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
return -1;
}
if (S_ISREG (l1_stat.st_mode))
{
straight_append_dict (straight_ctx, l1_filename);
}
}
}
myfree (dictionary_files);
}
else
{
straight_append_dict (straight_ctx, l0_filename);
}
}
if (straight_ctx->dicts_cnt == 0)
{
log_error ("ERROR: No usable dictionary file found.");
return -1;
}
const int rc_update_combinator = opencl_session_update_combinator (opencl_ctx, hashconfig, combinator_ctx);
if (rc_update_combinator == -1) return -1;
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_RIGHT;
// mod -- moved to mpsp.c
// base
for (int i = 1; i < user_options_extra->hc_workc; i++)
{
char *l0_filename = user_options_extra->hc_workv[i];
struct stat l0_stat;
if (stat (l0_filename, &l0_stat) == -1)
{
log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
return -1;
}
if (S_ISDIR (l0_stat.st_mode))
{
char **dictionary_files = NULL;
dictionary_files = scan_directory (l0_filename);
if (dictionary_files != NULL)
{
qsort (dictionary_files, (size_t) count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
for (int d = 0; dictionary_files[d] != NULL; d++)
{
char *l1_filename = dictionary_files[d];
struct stat l1_stat;
if (stat (l1_filename, &l1_stat) == -1)
{
log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
return -1;
}
if (S_ISREG (l1_stat.st_mode))
{
straight_append_dict (straight_ctx, l1_filename);
}
}
}
myfree (dictionary_files);
}
else
{
straight_append_dict (straight_ctx, l0_filename);
}
}
if (straight_ctx->dicts_cnt == 0)
{
log_error ("ERROR: No usable dictionary file found.");
return -1;
}
const int rc_update_combinator = opencl_session_update_combinator (opencl_ctx, hashconfig, combinator_ctx);
if (rc_update_combinator == -1) return -1;
}
hashconfig->pw_min = pw_min;
hashconfig->pw_max = pw_max;
/**
* prevent the user from using --skip/--limit together w/ maskfile and or dictfile
*/
if (user_options->skip != 0 || user_options->limit != 0)
{
if ((mask_ctx->masks_cnt > 1) || (straight_ctx->dicts_cnt > 1))
{
log_error ("ERROR: --skip/--limit are not supported with --increment or mask files");
return -1;
}
}
/**
* prevent the user from using --keyspace together w/ maskfile and or dictfile
*/
if (user_options->keyspace == true)
{
if ((mask_ctx->masks_cnt > 1) || (straight_ctx->dicts_cnt > 1))
{
log_error ("ERROR: --keyspace is not supported with --increment or mask files");
return -1;
}
}
/**
* main inner loop
* loop through wordlists
*/
restore_data_t *rd = restore_ctx->rd;
@ -1263,6 +848,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx;
cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
folder_config_t *folder_config = hashcat_ctx->folder_config;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
hashes_t *hashes = hashcat_ctx->hashes;
@ -1404,7 +990,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
* straight mode init
*/
const int rc_straight_init = straight_ctx_init (straight_ctx, user_options);
const int rc_straight_init = straight_ctx_init (straight_ctx, user_options, user_options_extra, hashconfig);
if (rc_straight_init == -1) return -1;
@ -1412,7 +998,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
* straight mode init
*/
const int rc_combinator_init = combinator_ctx_init (combinator_ctx, user_options);
const int rc_combinator_init = combinator_ctx_init (combinator_ctx, user_options, user_options_extra, straight_ctx, dictstat_ctx, wl_data);
if (rc_combinator_init == -1) return -1;
@ -1424,6 +1010,34 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
if (rc_mask_init == -1) return -1;
/**
* prevent the user from using --skip/--limit together w/ maskfile and or dictfile
*/
if (user_options->skip != 0 || user_options->limit != 0)
{
if ((mask_ctx->masks_cnt > 1) || (straight_ctx->dicts_cnt > 1))
{
log_error ("ERROR: --skip/--limit are not supported with --increment or mask files");
return -1;
}
}
/**
* prevent the user from using --keyspace together w/ maskfile and or dictfile
*/
if (user_options->keyspace == true)
{
if ((mask_ctx->masks_cnt > 1) || (straight_ctx->dicts_cnt > 1))
{
log_error ("ERROR: --keyspace is not supported with --increment or mask files");
return -1;
}
}
/**
* status progress init; needs hashes that's why we have to do it here and separate from status_ctx_init
*/
@ -1844,6 +1458,8 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
dictstat_init (dictstat_ctx, user_options, folder_config);
dictstat_read (dictstat_ctx);
/**
* loopback init
*/
@ -1975,6 +1591,10 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
user_options->quiet = false;
}
// Update dictionary statistic
dictstat_write (dictstat_ctx);
// free memory
debugfile_destroy (debugfile_ctx);

@ -19836,6 +19836,10 @@ int hashconfig_init (hashconfig_t *hashconfig, const user_options_t *user_option
hashconfig->is_salted = is_salted;
// esalt_size
hashconfig->esalt_size = 0;
switch (hashconfig->hash_mode)
{
case 2500: hashconfig->esalt_size = sizeof (wpa_t); break;
@ -19913,6 +19917,10 @@ int hashconfig_init (hashconfig_t *hashconfig, const user_options_t *user_option
case 13800: hashconfig->esalt_size = sizeof (win8phone_t); break;
}
// tmp_size
hashconfig->tmp_size = 4;
switch (hashconfig->hash_mode)
{
case 400: hashconfig->tmp_size = sizeof (phpass_tmp_t); break;
@ -19995,14 +20003,101 @@ int hashconfig_init (hashconfig_t *hashconfig, const user_options_t *user_option
case 13761: hashconfig->tmp_size = sizeof (tc_tmp_t); break;
case 13762: hashconfig->tmp_size = sizeof (tc_tmp_t); break;
case 13763: hashconfig->tmp_size = sizeof (tc_tmp_t); break;
default : hashconfig->tmp_size = 4; break;
};
// hook_size
hashconfig->hook_size = 4;
switch (hashconfig->hash_mode)
{
default : hashconfig->hook_size = 4; break;
};
// pw_min
hashconfig->pw_max = PW_MIN;
switch (hashconfig->hash_mode)
{
case 2500: hashconfig->pw_min = 8;
break;
case 9710: hashconfig->pw_min = 5;
break;
case 9810: hashconfig->pw_min = 5;
break;
case 10410: hashconfig->pw_min = 5;
break;
case 14000: hashconfig->pw_min = 8;
break;
case 14100: hashconfig->pw_min = 24;
break;
}
// pw_max
hashconfig->pw_max = PW_MAX;
switch (hashconfig->hash_mode)
{
case 125: hashconfig->pw_max = 32;
break;
case 400: hashconfig->pw_max = 40;
break;
case 500: hashconfig->pw_max = 16;
break;
case 1500: hashconfig->pw_max = 8;
break;
case 1600: hashconfig->pw_max = 16;
break;
case 1800: hashconfig->pw_max = 16;
break;
case 2100: hashconfig->pw_max = 16;
break;
case 3000: hashconfig->pw_max = 7;
break;
case 5200: hashconfig->pw_max = 24;
break;
case 5800: hashconfig->pw_max = 16;
break;
case 6300: hashconfig->pw_max = 16;
break;
case 7400: hashconfig->pw_max = 16;
break;
case 7700: hashconfig->pw_max = 8;
break;
case 7900: hashconfig->pw_max = 48;
break;
case 8500: hashconfig->pw_max = 8;
break;
case 8600: hashconfig->pw_max = 16;
break;
case 9710: hashconfig->pw_max = 5;
break;
case 9810: hashconfig->pw_max = 5;
break;
case 10410: hashconfig->pw_max = 5;
break;
case 10300: hashconfig->pw_max = 40;
break;
case 10500: hashconfig->pw_max = 40;
break;
case 10700: hashconfig->pw_max = 16;
break;
case 11300: hashconfig->pw_max = 40;
break;
case 11600: hashconfig->pw_max = 32;
break;
case 12500: hashconfig->pw_max = 20;
break;
case 12800: hashconfig->pw_max = 24;
break;
case 14000: hashconfig->pw_max = 8;
break;
case 14100: hashconfig->pw_max = 24;
break;
}
return 0;
}
@ -20086,96 +20181,6 @@ u32 hashconfig_enforce_kernel_loops (const hashconfig_t *hashconfig, const user_
return kernel_loops_fixed;
}
uint hashconfig_general_pw_min (hashconfig_t *hashconfig)
{
uint pw_min = PW_MIN;
switch (hashconfig->hash_mode)
{
case 2500: pw_min = 8;
break;
case 9710: pw_min = 5;
break;
case 9810: pw_min = 5;
break;
case 10410: pw_min = 5;
break;
case 14000: pw_min = 8;
break;
case 14100: pw_min = 24;
break;
}
return pw_min;
}
uint hashconfig_general_pw_max (hashconfig_t *hashconfig)
{
uint pw_max = PW_MAX;
switch (hashconfig->hash_mode)
{
case 125: pw_max = 32;
break;
case 400: pw_max = 40;
break;
case 500: pw_max = 16;
break;
case 1500: pw_max = 8;
break;
case 1600: pw_max = 16;
break;
case 1800: pw_max = 16;
break;
case 2100: pw_max = 16;
break;
case 3000: pw_max = 7;
break;
case 5200: pw_max = 24;
break;
case 5800: pw_max = 16;
break;
case 6300: pw_max = 16;
break;
case 7400: pw_max = 16;
break;
case 7700: pw_max = 8;
break;
case 7900: pw_max = 48;
break;
case 8500: pw_max = 8;
break;
case 8600: pw_max = 16;
break;
case 9710: pw_max = 5;
break;
case 9810: pw_max = 5;
break;
case 10410: pw_max = 5;
break;
case 10300: pw_max = 40;
break;
case 10500: pw_max = 40;
break;
case 10700: pw_max = 16;
break;
case 11300: pw_max = 40;
break;
case 11600: pw_max = 32;
break;
case 12500: pw_max = 20;
break;
case 12800: pw_max = 24;
break;
case 14000: pw_max = 8;
break;
case 14100: pw_max = 24;
break;
}
return pw_max;
}
void hashconfig_general_defaults (hashconfig_t *hashconfig, hashes_t *hashes, const user_options_t *user_options)
{
salt_t *salts_buf = hashes->salts_buf;

@ -13,11 +13,12 @@
#include "logging.h"
#include "shared.h"
#include "filehandling.h"
#include "folder.h"
#include "rp.h"
#include "rp_cpu.h"
#include "straight.h"
int straight_ctx_init (straight_ctx_t *straight_ctx, const user_options_t *user_options)
int straight_ctx_init (straight_ctx_t *straight_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, hashconfig_t *hashconfig)
{
straight_ctx->enabled = false;
@ -31,6 +32,10 @@ int straight_ctx_init (straight_ctx_t *straight_ctx, const user_options_t *user_
straight_ctx->enabled = true;
/**
* generate NOP rules
*/
if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0))
{
straight_ctx->kernel_rules_buf = (kernel_rule_t *) mymalloc (sizeof (kernel_rule_t));
@ -55,10 +60,239 @@ int straight_ctx_init (straight_ctx_t *straight_ctx, const user_options_t *user_
}
}
// If we have a NOOP rule then we can process words from wordlists > length 32 for slow hashes
u32 pw_min = hashconfig->pw_min;
u32 pw_max = hashconfig->pw_max;
const bool has_noop = kernel_rules_has_noop (straight_ctx->kernel_rules_buf, straight_ctx->kernel_rules_cnt);
if (has_noop == false)
{
switch (user_options_extra->attack_kern)
{
case ATTACK_KERN_STRAIGHT: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
break;
case ATTACK_KERN_COMBI: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
break;
}
}
else
{
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
switch (user_options_extra->attack_kern)
{
case ATTACK_KERN_STRAIGHT: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
break;
case ATTACK_KERN_COMBI: if (pw_max > PW_DICTMAX) pw_max = PW_DICTMAX1;
break;
}
}
else
{
// in this case we can process > 32
}
}
hashconfig->pw_min = pw_min;
hashconfig->pw_max = pw_max;
/**
* generate NOP rules
* wordlist based work
*/
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
if (user_options_extra->wordlist_mode == WL_MODE_FILE)
{
for (int i = 0; i < user_options_extra->hc_workc; i++)
{
char *l0_filename = user_options_extra->hc_workv[i];
struct stat l0_stat;
if (stat (l0_filename, &l0_stat) == -1)
{
log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
return -1;
}
if (S_ISDIR (l0_stat.st_mode))
{
char **dictionary_files = NULL;
dictionary_files = scan_directory (l0_filename);
if (dictionary_files != NULL)
{
qsort (dictionary_files, (size_t) count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
for (int d = 0; dictionary_files[d] != NULL; d++)
{
char *l1_filename = dictionary_files[d];
struct stat l1_stat;
if (stat (l1_filename, &l1_stat) == -1)
{
log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
return -1;
}
if (S_ISREG (l1_stat.st_mode))
{
straight_append_dict (straight_ctx, l1_filename);
}
}
}
myfree (dictionary_files);
}
else
{
straight_append_dict (straight_ctx, l0_filename);
}
}
if (straight_ctx->dicts_cnt == 0)
{
log_error ("ERROR: No usable dictionary file found.");
return -1;
}
}
}
else if (user_options->attack_mode == ATTACK_MODE_COMBI)
{
}
else if (user_options->attack_mode == ATTACK_MODE_BF)
{
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID1)
{
for (int i = 0; i < user_options_extra->hc_workc - 1; i++)
{
char *l0_filename = user_options_extra->hc_workv[i];
struct stat l0_stat;
if (stat (l0_filename, &l0_stat) == -1)
{
log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
return -1;
}
if (S_ISDIR (l0_stat.st_mode))
{
char **dictionary_files = NULL;
dictionary_files = scan_directory (l0_filename);
if (dictionary_files != NULL)
{
qsort (dictionary_files, (size_t) count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
for (int d = 0; dictionary_files[d] != NULL; d++)
{
char *l1_filename = dictionary_files[d];
struct stat l1_stat;
if (stat (l1_filename, &l1_stat) == -1)
{
log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
return -1;
}
if (S_ISREG (l1_stat.st_mode))
{
straight_append_dict (straight_ctx, l1_filename);
}
}
}
myfree (dictionary_files);
}
else
{
straight_append_dict (straight_ctx, l0_filename);
}
}
if (straight_ctx->dicts_cnt == 0)
{
log_error ("ERROR: No usable dictionary file found.");
return -1;
}
}
else if (user_options->attack_mode == ATTACK_MODE_HYBRID2)
{
for (int i = 1; i < user_options_extra->hc_workc; i++)
{
char *l0_filename = user_options_extra->hc_workv[i];
struct stat l0_stat;
if (stat (l0_filename, &l0_stat) == -1)
{
log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
return -1;
}
if (S_ISDIR (l0_stat.st_mode))
{
char **dictionary_files = NULL;
dictionary_files = scan_directory (l0_filename);
if (dictionary_files != NULL)
{
qsort (dictionary_files, (size_t) count_dictionaries (dictionary_files), sizeof (char *), sort_by_stringptr);
for (int d = 0; dictionary_files[d] != NULL; d++)
{
char *l1_filename = dictionary_files[d];
struct stat l1_stat;
if (stat (l1_filename, &l1_stat) == -1)
{
log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
return -1;
}
if (S_ISREG (l1_stat.st_mode))
{
straight_append_dict (straight_ctx, l1_filename);
}
}
}
myfree (dictionary_files);
}
else
{
straight_append_dict (straight_ctx, l0_filename);
}
}
if (straight_ctx->dicts_cnt == 0)
{
log_error ("ERROR: No usable dictionary file found.");
return -1;
}
}
return 0;
}

Loading…
Cancel
Save