Update wordlist.c function parameters

pull/533/head
jsteube 8 years ago
parent a97e31881c
commit a5e83c27c3

@ -9,21 +9,18 @@
#include <time.h>
#include <inttypes.h>
u32 convert_from_hex (char *line_buf, const u32 line_len, const user_options_t *user_options);
u32 convert_from_hex (hashcat_ctx_t *hashcat_ctx, char *line_buf, const u32 line_len);
void load_segment (wl_data_t *wl_data, FILE *fd);
void pw_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len);
void get_next_word_lm (char *buf, u64 sz, u64 *len, u64 *off);
void get_next_word_uc (char *buf, u64 sz, u64 *len, u64 *off);
void get_next_word_std (char *buf, u64 sz, u64 *len, u64 *off);
void get_next_word (wl_data_t *wl_data, const user_options_t *user_options, const user_options_extra_t *user_options_extra, FILE *fd, char **out_buf, u32 *out_len);
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, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, 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);
void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *out_len);
void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd);
u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile);
void wl_data_init (hashcat_ctx_t *hashcat_ctx);
void wl_data_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _WORDLIST_H

@ -13,11 +13,8 @@
int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
{
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_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;
combinator_ctx->enabled = false;
@ -109,7 +106,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
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);
const u64 words1_cnt = count_words (hashcat_ctx, fp1, dictfile1);
if (words1_cnt == 0)
{
@ -123,7 +120,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
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);
const u64 words2_cnt = count_words (hashcat_ctx, fp2, dictfile2);
if (words2_cnt == 0)
{

@ -140,7 +140,7 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa
u32 line_len = (u32) in_superchop (line_buf);
line_len = convert_from_hex (line_buf, line_len, user_options);
line_len = convert_from_hex (hashcat_ctx, line_buf, line_len);
// post-process rule engine
@ -362,9 +362,39 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
}
}
wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
wl_data_init (wl_data, user_options, hashconfig);
hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) mymalloc (sizeof (hashcat_ctx_t));
/*
hashcat_ctx_tmp->bitmap_ctx = hashcat_ctx->bitmap_ctx;
hashcat_ctx_tmp->combinator_ctx = hashcat_ctx->combinator_ctx;
hashcat_ctx_tmp->cpt_ctx = hashcat_ctx->cpt_ctx;
hashcat_ctx_tmp->debugfile_ctx = hashcat_ctx->debugfile_ctx;
hashcat_ctx_tmp->dictstat_ctx = hashcat_ctx->dictstat_ctx;
hashcat_ctx_tmp->folder_config = hashcat_ctx->folder_config;
hashcat_ctx_tmp->hashconfig = hashcat_ctx->hashconfig;
hashcat_ctx_tmp->hashes = hashcat_ctx->hashes;
hashcat_ctx_tmp->hwmon_ctx = hashcat_ctx->hwmon_ctx;
hashcat_ctx_tmp->induct_ctx = hashcat_ctx->induct_ctx;
hashcat_ctx_tmp->logfile_ctx = hashcat_ctx->logfile_ctx;
hashcat_ctx_tmp->loopback_ctx = hashcat_ctx->loopback_ctx;
hashcat_ctx_tmp->mask_ctx = hashcat_ctx->mask_ctx;
hashcat_ctx_tmp->opencl_ctx = hashcat_ctx->opencl_ctx;
hashcat_ctx_tmp->outcheck_ctx = hashcat_ctx->outcheck_ctx;
hashcat_ctx_tmp->outfile_ctx = hashcat_ctx->outfile_ctx;
hashcat_ctx_tmp->potfile_ctx = hashcat_ctx->potfile_ctx;
hashcat_ctx_tmp->restore_ctx = hashcat_ctx->restore_ctx;
hashcat_ctx_tmp->status_ctx = hashcat_ctx->status_ctx;
hashcat_ctx_tmp->straight_ctx = hashcat_ctx->straight_ctx;
hashcat_ctx_tmp->tuning_db = hashcat_ctx->tuning_db;
hashcat_ctx_tmp->user_options_extra = hashcat_ctx->user_options_extra;
hashcat_ctx_tmp->user_options = hashcat_ctx->user_options;
*/
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 *) mymalloc (sizeof (wl_data_t));
wl_data_init (hashcat_ctx_tmp);
u64 words_cur = 0;
@ -389,13 +419,13 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
char *line_buf;
u32 line_len;
for ( ; words_cur < words_off; words_cur++) get_next_word (wl_data, user_options, user_options_extra, fd, &line_buf, &line_len);
for ( ; words_cur < words_off; words_cur++) get_next_word (hashcat_ctx_tmp, fd, &line_buf, &line_len);
for ( ; words_cur < words_fin; words_cur++)
{
get_next_word (wl_data, user_options, user_options_extra, fd, &line_buf, &line_len);
get_next_word (hashcat_ctx_tmp, fd, &line_buf, &line_len);
line_len = convert_from_hex (line_buf, line_len, user_options);
line_len = convert_from_hex (hashcat_ctx, line_buf, line_len);
// post-process rule engine
@ -505,7 +535,11 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
fclose (device_param->combs_fp);
}
wl_data_destroy (wl_data);
wl_data_destroy (hashcat_ctx_tmp);
myfree (hashcat_ctx_tmp->wl_data);
myfree (hashcat_ctx_tmp);
fclose (fd);
}

@ -117,7 +117,6 @@ void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
{
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
hashes_t *hashes = hashcat_ctx->hashes;
induct_ctx_t *induct_ctx = hashcat_ctx->induct_ctx;
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
@ -129,7 +128,6 @@ static int inner2_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;
@ -200,7 +198,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
return -1;
}
status_ctx->words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, straight_ctx->dict, dictstat_ctx);
status_ctx->words_cnt = count_words (hashcat_ctx, fd2, straight_ctx->dict);
fclose (fd2);
@ -228,7 +226,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
return -1;
}
status_ctx->words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, combinator_ctx->dict1, dictstat_ctx);
status_ctx->words_cnt = count_words (hashcat_ctx, fd2, combinator_ctx->dict1);
fclose (fd2);
}
@ -243,7 +241,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
return -1;
}
status_ctx->words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, combinator_ctx->dict2, dictstat_ctx);
status_ctx->words_cnt = count_words (hashcat_ctx, fd2, combinator_ctx->dict2);
fclose (fd2);
}
@ -282,7 +280,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
return -1;
}
status_ctx->words_cnt = count_words (wl_data, user_options, user_options_extra, straight_ctx, combinator_ctx, fd2, straight_ctx->dict, dictstat_ctx);
status_ctx->words_cnt = count_words (hashcat_ctx, fd2, straight_ctx->dict);
fclose (fd2);
@ -767,7 +765,6 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
user_options_t *user_options = hashcat_ctx->user_options;
wl_data_t *wl_data = hashcat_ctx->wl_data;
status_ctx->devices_status = STATUS_INIT;
@ -907,7 +904,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
* Wordlist allocate buffer
*/
wl_data_init (wl_data, user_options, hashconfig);
wl_data_init (hashcat_ctx);
/**
* straight mode init
@ -1218,7 +1215,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
hashconfig_destroy (hashcat_ctx);
wl_data_destroy (wl_data);
wl_data_destroy (hashcat_ctx);
cpt_ctx_destroy (hashcat_ctx);

@ -1147,7 +1147,7 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co
if (line_len >= PW_MAX1) continue;
line_len = convert_from_hex (line_buf, line_len, user_options);
line_len = convert_from_hex (hashcat_ctx, line_buf, line_len);
char *line_buf_new = line_buf;

@ -13,8 +13,10 @@
#include "rp_cpu.h"
#include "wordlist.h"
u32 convert_from_hex (char *line_buf, const u32 line_len, const user_options_t *user_options)
u32 convert_from_hex (hashcat_ctx_t *hashcat_ctx, char *line_buf, const u32 line_len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (line_len & 1) return (line_len); // not in hex
if (user_options->hex_wordlist == true)
@ -56,8 +58,10 @@ u32 convert_from_hex (char *line_buf, const u32 line_len, const user_options_t *
return (line_len);
}
void load_segment (wl_data_t *wl_data, FILE *fd)
void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd)
{
wl_data_t *wl_data = hashcat_ctx->wl_data;
// NOTE: use (never changing) ->incr here instead of ->avail otherwise the buffer gets bigger and bigger
wl_data->pos = 0;
@ -177,8 +181,12 @@ void get_next_word_std (char *buf, u64 sz, u64 *len, u64 *off)
*len = sz;
}
void get_next_word (wl_data_t *wl_data, const user_options_t *user_options, const user_options_extra_t *user_options_extra, FILE *fd, char **out_buf, u32 *out_len)
void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *out_len)
{
user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
wl_data_t *wl_data = hashcat_ctx->wl_data;
while (wl_data->pos < wl_data->cnt)
{
u64 off;
@ -232,9 +240,9 @@ void get_next_word (wl_data_t *wl_data, const user_options_t *user_options, cons
return;
}
load_segment (wl_data, fd);
load_segment (hashcat_ctx, fd);
get_next_word (wl_data, user_options, user_options_extra, fd, out_buf, out_len);
get_next_word (hashcat_ctx, fd, out_buf, out_len);
}
void pw_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len)
@ -261,8 +269,15 @@ 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, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, FILE *fd, const char *dictfile, dictstat_ctx_t *dictstat_ctx)
u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile)
{
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_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;
//hc_signal (NULL);
dictstat_t d;
@ -326,7 +341,7 @@ u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const u
while (!feof (fd))
{
load_segment (wl_data, fd);
load_segment (hashcat_ctx, fd);
comp += wl_data->cnt;
@ -400,15 +415,18 @@ u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const u
return (cnt);
}
void wl_data_init (wl_data_t *wl_data, const user_options_t *user_options, const hashconfig_t *hashconfig)
void wl_data_init (hashcat_ctx_t *hashcat_ctx)
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
user_options_t *user_options = hashcat_ctx->user_options;
wl_data_t *wl_data = hashcat_ctx->wl_data;
wl_data->enabled = false;
if (user_options->benchmark == true) return;
if (user_options->keyspace == true) return;
if (user_options->left == true) return;
if (user_options->opencl_info == true) return;
// if (user_options->show == true) return;
if (user_options->usage == true) return;
if (user_options->version == true) return;
@ -437,8 +455,10 @@ void wl_data_init (wl_data_t *wl_data, const user_options_t *user_options, const
}
}
void wl_data_destroy (wl_data_t *wl_data)
void wl_data_destroy (hashcat_ctx_t *hashcat_ctx)
{
wl_data_t *wl_data = hashcat_ctx->wl_data;
if (wl_data->enabled == false) return;
myfree (wl_data->buf);

Loading…
Cancel
Save