mirror of
https://github.com/hashcat/hashcat
synced 2024-11-13 17:28:58 +01:00
Get rid of global get_next_word_func function pointer variable
This commit is contained in:
parent
97d9a5d9cc
commit
3664f02670
@ -736,6 +736,8 @@ typedef struct
|
|||||||
u32 cnt;
|
u32 cnt;
|
||||||
u32 pos;
|
u32 pos;
|
||||||
|
|
||||||
|
void (*func) (char *, u32, u32 *, u32 *);
|
||||||
|
|
||||||
} wl_data_t;
|
} wl_data_t;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -1015,14 +1017,15 @@ typedef struct
|
|||||||
char *custom_charset_3;
|
char *custom_charset_3;
|
||||||
char *custom_charset_4;
|
char *custom_charset_4;
|
||||||
|
|
||||||
hashconfig_t *hashconfig;
|
hashconfig_t *hashconfig;
|
||||||
hashes_t *hashes;
|
hashes_t *hashes;
|
||||||
|
user_options_t *user_options;
|
||||||
outfile_ctx_t *outfile_ctx;
|
user_options_extra_t *user_options_extra;
|
||||||
potfile_ctx_t *potfile_ctx;
|
outfile_ctx_t *outfile_ctx;
|
||||||
loopback_ctx_t *loopback_ctx;
|
potfile_ctx_t *potfile_ctx;
|
||||||
debugfile_ctx_t *debugfile_ctx;
|
loopback_ctx_t *loopback_ctx;
|
||||||
session_ctx_t *session_ctx;
|
debugfile_ctx_t *debugfile_ctx;
|
||||||
|
session_ctx_t *session_ctx;
|
||||||
|
|
||||||
u32 gpu_temp_disable;
|
u32 gpu_temp_disable;
|
||||||
u32 gpu_temp_abort;
|
u32 gpu_temp_abort;
|
||||||
|
@ -20,4 +20,7 @@ void pw_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len
|
|||||||
|
|
||||||
u64 count_words (wl_data_t *wl_data, FILE *fd, const char *dictfile, dictstat_ctx_t *dictstat_ctx);
|
u64 count_words (wl_data_t *wl_data, FILE *fd, const char *dictfile, dictstat_ctx_t *dictstat_ctx);
|
||||||
|
|
||||||
|
void wl_data_init (wl_data_t *wl_data, const user_options_t *user_options, const hashconfig_t *hashconfig);
|
||||||
|
void wl_data_destroy (wl_data_t *wl_data);
|
||||||
|
|
||||||
#endif // _WORDLIST_H
|
#endif // _WORDLIST_H
|
||||||
|
@ -241,10 +241,10 @@ void *thread_calc (void *p)
|
|||||||
|
|
||||||
if (device_param->skipped) return NULL;
|
if (device_param->skipped) return NULL;
|
||||||
|
|
||||||
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
|
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
|
||||||
|
user_options_t *user_options = data.user_options;
|
||||||
hashconfig_t *hashconfig = data.hashconfig;
|
hashconfig_t *hashconfig = data.hashconfig;
|
||||||
hashes_t *hashes = data.hashes;
|
hashes_t *hashes = data.hashes;
|
||||||
|
|
||||||
const uint attack_mode = data.attack_mode;
|
const uint attack_mode = data.attack_mode;
|
||||||
const uint attack_kern = data.attack_kern;
|
const uint attack_kern = data.attack_kern;
|
||||||
@ -287,8 +287,6 @@ void *thread_calc (void *p)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const uint segment_size = data.segment_size;
|
|
||||||
|
|
||||||
char *dictfile = data.dictfile;
|
char *dictfile = data.dictfile;
|
||||||
|
|
||||||
if (attack_mode == ATTACK_MODE_COMBI)
|
if (attack_mode == ATTACK_MODE_COMBI)
|
||||||
@ -350,11 +348,7 @@ void *thread_calc (void *p)
|
|||||||
|
|
||||||
wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
|
wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
|
||||||
|
|
||||||
wl_data->buf = (char *) mymalloc (segment_size);
|
wl_data_init (wl_data, user_options, hashconfig);
|
||||||
wl_data->avail = segment_size;
|
|
||||||
wl_data->incr = segment_size;
|
|
||||||
wl_data->cnt = 0;
|
|
||||||
wl_data->pos = 0;
|
|
||||||
|
|
||||||
u64 words_cur = 0;
|
u64 words_cur = 0;
|
||||||
|
|
||||||
@ -495,8 +489,7 @@ void *thread_calc (void *p)
|
|||||||
fclose (device_param->combs_fp);
|
fclose (device_param->combs_fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
free (wl_data->buf);
|
wl_data_destroy (wl_data);
|
||||||
free (wl_data);
|
|
||||||
|
|
||||||
fclose (fd);
|
fclose (fd);
|
||||||
}
|
}
|
||||||
|
@ -93,8 +93,6 @@ extern int SUPPRESS_OUTPUT;
|
|||||||
extern hc_thread_mutex_t mux_hwmon;
|
extern hc_thread_mutex_t mux_hwmon;
|
||||||
extern hc_thread_mutex_t mux_display;
|
extern hc_thread_mutex_t mux_display;
|
||||||
|
|
||||||
extern void (*get_next_word_func) (char *, u32, u32 *, u32 *);
|
|
||||||
|
|
||||||
extern const unsigned int full01;
|
extern const unsigned int full01;
|
||||||
extern const unsigned int full80;
|
extern const unsigned int full80;
|
||||||
|
|
||||||
@ -102,16 +100,8 @@ extern const int DEFAULT_BENCHMARK_ALGORITHMS_BUF[];
|
|||||||
|
|
||||||
const int comptime = COMPTIME;
|
const int comptime = COMPTIME;
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
static void setup_environment_variables ()
|
||||||
{
|
{
|
||||||
#if defined (_WIN)
|
|
||||||
SetConsoleWindowSize (132);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* To help users a bit
|
|
||||||
*/
|
|
||||||
|
|
||||||
char *compute = getenv ("COMPUTE");
|
char *compute = getenv ("COMPUTE");
|
||||||
|
|
||||||
if (compute)
|
if (compute)
|
||||||
@ -142,8 +132,26 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
if (getenv ("POCL_KERNEL_CACHE") == NULL)
|
if (getenv ("POCL_KERNEL_CACHE") == NULL)
|
||||||
putenv ((char *) "POCL_KERNEL_CACHE=0");
|
putenv ((char *) "POCL_KERNEL_CACHE=0");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void setup_umask ()
|
||||||
|
{
|
||||||
umask (077);
|
umask (077);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main (int argc, char **argv)
|
||||||
|
{
|
||||||
|
#if defined (_WIN)
|
||||||
|
SetConsoleWindowSize (132);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To help users a bit
|
||||||
|
*/
|
||||||
|
|
||||||
|
setup_environment_variables ();
|
||||||
|
|
||||||
|
setup_umask ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Real init
|
* Real init
|
||||||
@ -194,6 +202,8 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
user_options_t *user_options = (user_options_t *) mymalloc (sizeof (user_options_t));
|
user_options_t *user_options = (user_options_t *) mymalloc (sizeof (user_options_t));
|
||||||
|
|
||||||
|
data.user_options = user_options;
|
||||||
|
|
||||||
user_options_init (user_options, argc, argv);
|
user_options_init (user_options, argc, argv);
|
||||||
|
|
||||||
const int rc_user_options_parse1 = user_options_parse (user_options, argc, argv);
|
const int rc_user_options_parse1 = user_options_parse (user_options, argc, argv);
|
||||||
@ -254,6 +264,8 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
user_options_extra_t *user_options_extra = (user_options_extra_t *) mymalloc (sizeof (user_options_extra_t));
|
user_options_extra_t *user_options_extra = (user_options_extra_t *) mymalloc (sizeof (user_options_extra_t));
|
||||||
|
|
||||||
|
data.user_options_extra = user_options_extra;
|
||||||
|
|
||||||
const int rc_user_options_extra_init = user_options_extra_init (user_options, myargc, myargv, user_options_extra);
|
const int rc_user_options_extra_init = user_options_extra_init (user_options, myargc, myargv, user_options_extra);
|
||||||
|
|
||||||
if (rc_user_options_extra_init == -1) return -1;
|
if (rc_user_options_extra_init == -1) return -1;
|
||||||
@ -855,22 +867,6 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* choose dictionary parser
|
|
||||||
*/
|
|
||||||
|
|
||||||
get_next_word_func = get_next_word_std;
|
|
||||||
|
|
||||||
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER)
|
|
||||||
{
|
|
||||||
get_next_word_func = get_next_word_uc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hashconfig->hash_type == HASH_TYPE_LM) // yes that's fine that way
|
|
||||||
{
|
|
||||||
get_next_word_func = get_next_word_lm;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dictstat
|
* dictstat
|
||||||
*/
|
*/
|
||||||
@ -1872,11 +1868,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
|
wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
|
||||||
|
|
||||||
wl_data->buf = (char *) mymalloc (user_options->segment_size);
|
wl_data_init (wl_data, user_options, hashconfig);
|
||||||
wl_data->avail = user_options->segment_size;
|
|
||||||
wl_data->incr = user_options->segment_size;
|
|
||||||
wl_data->cnt = 0;
|
|
||||||
wl_data->pos = 0;
|
|
||||||
|
|
||||||
cs_t *css_buf = NULL;
|
cs_t *css_buf = NULL;
|
||||||
uint css_cnt = 0;
|
uint css_cnt = 0;
|
||||||
@ -4069,12 +4061,11 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
loopback_destroy (loopback_ctx);
|
loopback_destroy (loopback_ctx);
|
||||||
|
|
||||||
|
wl_data_destroy (wl_data);
|
||||||
|
|
||||||
local_free (all_kernel_rules_cnt);
|
local_free (all_kernel_rules_cnt);
|
||||||
local_free (all_kernel_rules_buf);
|
local_free (all_kernel_rules_buf);
|
||||||
|
|
||||||
local_free (wl_data->buf);
|
|
||||||
local_free (wl_data);
|
|
||||||
|
|
||||||
local_free (bitmap_s1_a);
|
local_free (bitmap_s1_a);
|
||||||
local_free (bitmap_s1_b);
|
local_free (bitmap_s1_b);
|
||||||
local_free (bitmap_s1_c);
|
local_free (bitmap_s1_c);
|
||||||
|
@ -37,8 +37,6 @@
|
|||||||
|
|
||||||
extern hc_global_data_t data;
|
extern hc_global_data_t data;
|
||||||
|
|
||||||
void (*get_next_word_func) (char *, u32, u32 *, u32 *);
|
|
||||||
|
|
||||||
uint convert_from_hex (char *line_buf, const uint line_len)
|
uint convert_from_hex (char *line_buf, const uint line_len)
|
||||||
{
|
{
|
||||||
if (line_len & 1) return (line_len); // not in hex
|
if (line_len & 1) return (line_len); // not in hex
|
||||||
@ -212,7 +210,7 @@ void get_next_word (wl_data_t *wl_data, FILE *fd, char **out_buf, uint *out_len)
|
|||||||
|
|
||||||
char *ptr = wl_data->buf + wl_data->pos;
|
char *ptr = wl_data->buf + wl_data->pos;
|
||||||
|
|
||||||
get_next_word_func (ptr, wl_data->cnt - wl_data->pos, &len, &off);
|
wl_data->func (ptr, wl_data->cnt - wl_data->pos, &len, &off);
|
||||||
|
|
||||||
wl_data->pos += off;
|
wl_data->pos += off;
|
||||||
|
|
||||||
@ -363,7 +361,7 @@ u64 count_words (wl_data_t *wl_data, FILE *fd, const char *dictfile, dictstat_ct
|
|||||||
u32 len;
|
u32 len;
|
||||||
u32 off;
|
u32 off;
|
||||||
|
|
||||||
get_next_word_func (wl_data->buf + i, wl_data->cnt - i, &len, &off);
|
wl_data->func (wl_data->buf + i, wl_data->cnt - i, &len, &off);
|
||||||
|
|
||||||
if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
|
if (run_rule_engine (data.rule_len_l, data.rule_buf_l))
|
||||||
{
|
{
|
||||||
@ -425,3 +423,42 @@ u64 count_words (wl_data_t *wl_data, FILE *fd, const char *dictfile, dictstat_ct
|
|||||||
|
|
||||||
return (cnt);
|
return (cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wl_data_init (wl_data_t *wl_data, const user_options_t *user_options, const hashconfig_t *hashconfig)
|
||||||
|
{
|
||||||
|
wl_data->buf = (char *) mymalloc (user_options->segment_size);
|
||||||
|
wl_data->avail = user_options->segment_size;
|
||||||
|
wl_data->incr = user_options->segment_size;
|
||||||
|
wl_data->cnt = 0;
|
||||||
|
wl_data->pos = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* choose dictionary parser
|
||||||
|
*/
|
||||||
|
|
||||||
|
wl_data->func = get_next_word_std;
|
||||||
|
|
||||||
|
if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER)
|
||||||
|
{
|
||||||
|
wl_data->func = get_next_word_uc;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hashconfig->hash_type == HASH_TYPE_LM) // yes that's fine that way
|
||||||
|
{
|
||||||
|
wl_data->func = get_next_word_lm;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void wl_data_destroy (wl_data_t *wl_data)
|
||||||
|
{
|
||||||
|
myfree (wl_data->buf);
|
||||||
|
|
||||||
|
wl_data->func = NULL;
|
||||||
|
wl_data->buf = NULL;
|
||||||
|
wl_data->avail = 0;
|
||||||
|
wl_data->incr = 0;
|
||||||
|
wl_data->cnt = 0;
|
||||||
|
wl_data->pos = 0;
|
||||||
|
|
||||||
|
myfree (wl_data);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user