1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-12-22 14:48:12 +00:00

Handling --show and --left need to be refactored, do not use those flags atm

This commit is contained in:
jsteube 2016-10-18 20:42:34 +02:00
parent 0fd48b228f
commit f6334b5f90
6 changed files with 214 additions and 288 deletions

View File

@ -20,6 +20,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx);
int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx);
int hashes_init_stage3 (hashcat_ctx_t *hashcat_ctx);
int hashes_init_stage4 (hashcat_ctx_t *hashcat_ctx);
void hashes_destroy (hashcat_ctx_t *hashcat_ctx);

View File

@ -22,18 +22,18 @@ void *hc_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size
int potfile_init (hashcat_ctx_t *hashcat_ctx);
int potfile_read_open (hashcat_ctx_t *hashcat_ctx);
int potfile_read_parse (hashcat_ctx_t *hashcat_ctx);
//int potfile_read_parse (hashcat_ctx_t *hashcat_ctx);
void potfile_read_close (hashcat_ctx_t *hashcat_ctx);
int potfile_write_open (hashcat_ctx_t *hashcat_ctx);
void potfile_write_close (hashcat_ctx_t *hashcat_ctx);
void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len);
int potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num);
void potfile_hash_free (hashcat_ctx_t *hashcat_ctx);
void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *));
void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *));
int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *));
int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *));
//void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *));
//void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *));
//int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *));
//int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *));
int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx);
void potfile_destroy (hashcat_ctx_t *hashcat_ctx);
int potfile_handle_show (hashcat_ctx_t *hashcat_ctx);
int potfile_handle_left (hashcat_ctx_t *hashcat_ctx);
#endif // _POTFILE_H

View File

@ -989,12 +989,6 @@ typedef struct potfile_ctx
FILE *fp;
char *filename;
pot_t *pot;
u32 pot_cnt;
u32 pot_avail;
u32 pot_hashes_avail;
} potfile_ctx_t;
typedef struct restore_data

View File

@ -395,23 +395,6 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
if (rc_hashconfig == -1) return -1;
/**
* potfile show/left depends on hash_mode, so it's called here first time
*/
if (user_options->show == true || user_options->left == true)
{
outfile_write_open (hashcat_ctx);
potfile_read_open (hashcat_ctx);
const int rc = potfile_read_parse (hashcat_ctx);
if (rc == -1) return -1;
potfile_read_close (hashcat_ctx);
}
/**
* load hashes, stage 1
*/
@ -430,32 +413,6 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
}
}
/**
* potfile show/left final
*/
if (user_options->show == true || user_options->left == true)
{
outfile_write_close (hashcat_ctx);
potfile_hash_free (hashcat_ctx);
return 0;
}
/**
* potfile removes
*/
if (user_options->potfile_disable == 0)
{
EVENT (EVENT_POTFILE_REMOVE_PARSE_PRE);
potfile_remove_parse (hashcat_ctx);
EVENT (EVENT_POTFILE_REMOVE_PARSE_POST);
}
/**
* load hashes, stage 2, remove duplicates, build base structure
*/
@ -467,29 +424,77 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
if (rc_hashes_init_stage2 == -1) return -1;
/**
* load hashes, stage 2: at this point we can check for all hashes cracked (by potfile)
* potfile removes
*/
if (user_options->potfile_disable == false)
{
EVENT (EVENT_POTFILE_REMOVE_PARSE_PRE);
potfile_remove_parse (hashcat_ctx);
EVENT (EVENT_POTFILE_REMOVE_PARSE_POST);
}
/**
* load hashes, stage 3, update cracked results from potfile
*/
const int rc_hashes_init_stage3 = hashes_init_stage3 (hashcat_ctx);
if (rc_hashes_init_stage3 == -1) return -1;
/**
* potfile show/left handling
*/
if (user_options->show == true)
{
outfile_write_open (hashcat_ctx);
const int rc = potfile_handle_show (hashcat_ctx);
if (rc == -1) return -1;
outfile_write_close (hashcat_ctx);
return 0;
}
else if (user_options->left == true)
{
outfile_write_open (hashcat_ctx);
const int rc = potfile_handle_left (hashcat_ctx);
if (rc == -1) return -1;
outfile_write_close (hashcat_ctx);
return 0;
}
/**
* maybe all hashes were cracked, we can exit here
*/
if (status_ctx->devices_status == STATUS_CRACKED)
{
EVENT (EVENT_POTFILE_ALL_CRACKED);
hashes_destroy (hashcat_ctx);
hashconfig_destroy (hashcat_ctx);
potfile_destroy (hashcat_ctx);
return 0;
}
/**
* load hashes, stage 3, automatic Optimizers
* load hashes, stage 4, automatic Optimizers
*/
const int rc_hashes_init_stage3 = hashes_init_stage3 (hashcat_ctx);
const int rc_hashes_init_stage4 = hashes_init_stage4 (hashcat_ctx);
if (rc_hashes_init_stage3 == -1) return -1;
if (rc_hashes_init_stage4 == -1) return -1;
/**
* Done loading hashes, log results
*/
hashes_logger (hashcat_ctx);

View File

@ -726,50 +726,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
continue;
}
// hack: append MAC1 and MAC2 s.t. in --show and --left the line matches with the .pot file format (i.e. ESSID:MAC1:MAC2)
if ((user_options->show == true) || (user_options->left == true))
{
salt_t *tmp_salt = hashes_buf[hashes_cnt].salt;
char *salt_ptr = (char *) tmp_salt->salt_buf;
int cur_pos = tmp_salt->salt_len;
int rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos;
wpa_t *wpa = (wpa_t *) hashes_buf[hashes_cnt].esalt;
// do the appending task
snprintf (salt_ptr + cur_pos,
rem_len,
":%02x%02x%02x%02x%02x%02x:%02x%02x%02x%02x%02x%02x",
wpa->orig_mac1[0],
wpa->orig_mac1[1],
wpa->orig_mac1[2],
wpa->orig_mac1[3],
wpa->orig_mac1[4],
wpa->orig_mac1[5],
wpa->orig_mac2[0],
wpa->orig_mac2[1],
wpa->orig_mac2[2],
wpa->orig_mac2[3],
wpa->orig_mac2[4],
wpa->orig_mac2[5]);
// memset () the remaining part of the salt
cur_pos = tmp_salt->salt_len + 1 + 12 + 1 + 12;
rem_len = sizeof (hashes_buf[hashes_cnt].salt->salt_buf) - cur_pos;
if (rem_len > 0) memset (salt_ptr + cur_pos, 0, rem_len);
tmp_salt->salt_len += 1 + 12 + 1 + 12;
}
if (user_options->show == true) potfile_show_request (hashcat_ctx, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf);
if (user_options->left == true) potfile_left_request (hashcat_ctx, (char *) hashes_buf[hashes_cnt].salt->salt_buf, hashes_buf[hashes_cnt].salt->salt_len, &hashes_buf[hashes_cnt], sort_by_salt_buf);
hashes_cnt++;
}
@ -783,12 +739,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
{
parser_status = hashconfig->parse_func (hash_buf, 16, &hashes_buf[hashes_cnt], hashconfig);
hash_t *lm_hash_left = NULL;
if (parser_status == PARSER_OK)
{
lm_hash_left = &hashes_buf[hashes_cnt];
hashes_cnt++;
}
else
@ -798,37 +750,19 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
parser_status = hashconfig->parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt], hashconfig);
hash_t *lm_hash_right = NULL;
if (parser_status == PARSER_OK)
{
lm_hash_right = &hashes_buf[hashes_cnt];
hashes_cnt++;
}
else
{
event_log_warning (hashcat_ctx, "Hash '%s': %s", input_buf, strparser (parser_status));
}
// show / left
if ((lm_hash_left != NULL) && (lm_hash_right != NULL))
{
if (user_options->show == true) potfile_show_request_lm (hashcat_ctx, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot);
if (user_options->left == true) potfile_left_request_lm (hashcat_ctx, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot);
}
}
else
{
parser_status = hashconfig->parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt], hashconfig);
if (parser_status == PARSER_OK)
{
if (user_options->show == true) potfile_show_request (hashcat_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (user_options->left == true) potfile_left_request (hashcat_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
}
if (parser_status == PARSER_OK)
{
hashes_cnt++;
@ -843,12 +777,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
{
parser_status = hashconfig->parse_func (hash_buf, hash_len, &hashes_buf[hashes_cnt], hashconfig);
if (parser_status == PARSER_OK)
{
if (user_options->show == true) potfile_show_request (hashcat_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (user_options->left == true) potfile_left_request (hashcat_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot);
}
if (parser_status == PARSER_OK)
{
hashes_cnt++;
@ -955,8 +883,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
continue;
}
hash_t *lm_hash_left = &hashes_buf[hashes_cnt];
hashes_cnt++;
parser_status = hashconfig->parse_func (hash_buf + 16, 16, &hashes_buf[hashes_cnt], hashconfig);
@ -968,16 +894,9 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
continue;
}
hash_t *lm_hash_right = &hashes_buf[hashes_cnt];
if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
hashes_cnt++;
// show / left
if (user_options->show == true) potfile_show_request_lm (hashcat_ctx, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot);
if (user_options->left == true) potfile_left_request_lm (hashcat_ctx, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot);
}
else
{
@ -992,9 +911,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
if (user_options->show == true) potfile_show_request (hashcat_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (user_options->left == true) potfile_left_request (hashcat_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
hashes_cnt++;
}
}
@ -1011,9 +927,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) event_log_info_nn (hashcat_ctx, "Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
if (user_options->show == true) potfile_show_request (hashcat_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
if (user_options->left == true) potfile_left_request (hashcat_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot);
hashes_cnt++;
}
}
@ -1062,9 +975,9 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Removing duplicate hashes...");
hashes_cnt = 1;
u32 hashes_cnt_new = 1;
for (u32 hashes_pos = 1; hashes_pos < hashes->hashes_cnt; hashes_pos++)
for (u32 hashes_pos = 1; hashes_pos < hashes_cnt; hashes_pos++)
{
if (hashconfig->is_salted)
{
@ -1078,14 +991,22 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
if (sort_by_digest_p0p1 (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest, (void *) hashconfig) == 0) continue;
}
if (hashes_pos > hashes_cnt)
{
memcpy (&hashes_buf[hashes_cnt], &hashes_buf[hashes_pos], sizeof (hash_t));
}
hash_t tmp;
hashes_cnt++;
memcpy (&tmp, &hashes_buf[hashes_pos], sizeof (hash_t));
memcpy (&hashes_buf[hashes_cnt_new], &tmp, sizeof (hash_t));
hashes_cnt_new++;
}
for (u32 i = hashes_cnt_new; i < hashes->hashes_cnt; i++)
{
memset (&hashes_buf[i], 0, sizeof (hash_t));
}
hashes_cnt = hashes_cnt_new;
hashes->hashes_cnt = hashes_cnt;
/**
@ -1133,7 +1054,7 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
for (user_pos = 0; user_pos < hashes_cnt; user_pos++)
{
hash_info[user_pos] = (hashinfo_t *) hccalloc (hashcat_ctx, hashes_cnt, sizeof (hashinfo_t)); VERIFY_PTR (hash_info[user_pos]);
hash_info[user_pos] = (hashinfo_t *) hcmalloc (hashcat_ctx, sizeof (hashinfo_t)); VERIFY_PTR (hash_info[user_pos]);
hash_info[user_pos]->user = (user_t *) hcmalloc (hashcat_ctx, sizeof (user_t)); VERIFY_PTR (hash_info[user_pos]->user);
}
@ -1151,9 +1072,15 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
memcpy (salt_buf, hashes_buf[0].salt, sizeof (salt_t));
hashes_buf[0].salt = salt_buf;
if (hashconfig->esalt_size)
{
memcpy (((char *) esalts_buf_new) + (salts_cnt * hashconfig->esalt_size), hashes_buf[0].esalt, hashconfig->esalt_size);
char *esalts_buf_new_ptr = ((char *) esalts_buf_new) + (salts_cnt * hashconfig->esalt_size);
memcpy (esalts_buf_new_ptr, hashes_buf[0].esalt, hashconfig->esalt_size);
hashes_buf[0].esalt = esalts_buf_new_ptr;
}
salt_buf->digests_cnt = 0;
@ -1163,18 +1090,13 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
salts_cnt++;
}
if (hashes_buf[0].cracked == 1)
{
digests_shown[0] = 1;
digests_done++;
salt_buf->digests_done++;
}
salt_buf->digests_cnt++;
memcpy (((char *) digests_buf_new) + (0 * hashconfig->dgst_size), hashes_buf[0].digest, hashconfig->dgst_size);
char *digests_buf_new_ptr = ((char *) digests_buf_new) + (0 * hashconfig->dgst_size);
memcpy (digests_buf_new_ptr, hashes_buf[0].digest, hashconfig->dgst_size);
hashes_buf[0].digest = digests_buf_new_ptr;
if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY))
{
@ -1193,9 +1115,15 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
memcpy (salt_buf, hashes_buf[hashes_pos].salt, sizeof (salt_t));
hashes_buf[hashes_pos].salt = salt_buf;
if (hashconfig->esalt_size)
{
memcpy (((char *) esalts_buf_new) + (salts_cnt * hashconfig->esalt_size), hashes_buf[hashes_pos].esalt, hashconfig->esalt_size);
char *esalts_buf_new_ptr = ((char *) esalts_buf_new) + (salts_cnt * hashconfig->esalt_size);
memcpy (esalts_buf_new_ptr, hashes_buf[hashes_pos].esalt, hashconfig->esalt_size);
hashes_buf[hashes_pos].esalt = esalts_buf_new_ptr;
}
salt_buf->digests_cnt = 0;
@ -1206,18 +1134,13 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
}
}
if (hashes_buf[hashes_pos].cracked == 1)
{
digests_shown[hashes_pos] = 1;
digests_done++;
salt_buf->digests_done++;
}
salt_buf->digests_cnt++;
memcpy (((char *) digests_buf_new) + (hashes_pos * hashconfig->dgst_size), hashes_buf[hashes_pos].digest, hashconfig->dgst_size);
digests_buf_new_ptr = ((char *) digests_buf_new) + (hashes_pos * hashconfig->dgst_size);
memcpy (digests_buf_new_ptr, hashes_buf[hashes_pos].digest, hashconfig->dgst_size);
hashes_buf[hashes_pos].digest = digests_buf_new_ptr;
if ((user_options->username && (user_options->remove || user_options->show)) || (hashconfig->opts_type & OPTS_TYPE_HASH_COPY))
{
@ -1225,24 +1148,9 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
}
}
for (u32 salt_pos = 0; salt_pos < salts_cnt; salt_pos++)
{
salt_t *salt_buf = &salts_buf_new[salt_pos];
if (salt_buf->digests_done == salt_buf->digests_cnt)
{
salts_shown[salt_pos] = 1;
salts_done++;
}
if (salts_done == salts_cnt) mycracked (hashcat_ctx);
}
hcfree (hashes->digests_buf);
hcfree (hashes->salts_buf);
hcfree (hashes->esalts_buf);
hcfree (hashes->hashes_buf);
hashes->digests_cnt = digests_cnt;
hashes->digests_done = digests_done;
@ -1257,15 +1165,72 @@ int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx)
hashes->esalts_buf = esalts_buf_new;
hashes->hashes_cnt = 0;
hashes->hashes_buf = NULL;
hashes->hash_info = hash_info;
return 0;
}
int hashes_init_stage3 (hashcat_ctx_t *hashcat_ctx)
{
hashes_t *hashes = hashcat_ctx->hashes;
u32 digests_done = hashes->digests_done;
u32 *digests_shown = hashes->digests_shown;
u32 salts_cnt = hashes->salts_cnt;
u32 salts_done = hashes->salts_done;
u32 *salts_shown = hashes->salts_shown;
hash_t *hashes_buf = hashes->hashes_buf;
salt_t *salts_buf = hashes->salts_buf;
for (u32 salt_idx = 0; salt_idx < salts_cnt; salt_idx++)
{
salt_t *salt_buf = salts_buf + salt_idx;
u32 digests_cnt = salt_buf->digests_cnt;
for (u32 digest_idx = 0; digest_idx < digests_cnt; digest_idx++)
{
const u32 hashes_idx = salt_buf->digests_offset + digest_idx;
if (hashes_buf[hashes_idx].cracked == 1)
{
digests_shown[hashes_idx] = 1;
digests_done++;
salt_buf->digests_done++;
}
}
if (salt_buf->digests_done == salt_buf->digests_cnt)
{
salts_shown[salt_idx] = 1;
salts_done++;
}
if (salts_done == salts_cnt) mycracked (hashcat_ctx);
}
hashes->digests_done = digests_done;
hashes->salts_cnt = salts_cnt;
hashes->salts_done = salts_done;
// at this point we no longer need hash_t* structure
hcfree (hashes_buf);
hashes->hashes_cnt = 0;
hashes->hashes_buf = NULL;
return 0;
}
int hashes_init_stage4 (hashcat_ctx_t *hashcat_ctx)
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
hashes_t *hashes = hashcat_ctx->hashes;

View File

@ -182,11 +182,6 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx)
potfile_write_close (hashcat_ctx);
potfile_ctx->pot = NULL;
potfile_ctx->pot_cnt = 0;
potfile_ctx->pot_avail = 0;
potfile_ctx->pot_hashes_avail = 0;
return 0;
}
@ -209,7 +204,7 @@ int potfile_read_open (hashcat_ctx_t *hashcat_ctx)
if (potfile_ctx->fp == NULL)
{
//log_error ("%s: %s", potfile_ctx->filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", potfile_ctx->filename, strerror (errno));
return -1;
}
@ -217,6 +212,18 @@ int potfile_read_open (hashcat_ctx_t *hashcat_ctx)
return 0;
}
void potfile_read_close (hashcat_ctx_t *hashcat_ctx)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return;
if (potfile_ctx->fp == NULL) return;
fclose (potfile_ctx->fp);
}
/*
int potfile_read_parse (hashcat_ctx_t *hashcat_ctx)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
@ -330,17 +337,7 @@ int potfile_read_parse (hashcat_ctx_t *hashcat_ctx)
return 0;
}
void potfile_read_close (hashcat_ctx_t *hashcat_ctx)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return;
if (potfile_ctx->fp == NULL) return;
fclose (potfile_ctx->fp);
}
*/
int potfile_write_open (hashcat_ctx_t *hashcat_ctx)
{
@ -423,70 +420,7 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *
fflush (potfile_ctx->fp);
}
int potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
if (potfile_ctx->enabled == false) return 0;
u32 pos = 0;
for (pos = 0; pos < num; pos++)
{
if ((potfile_ctx->pot_cnt + pos) >= potfile_ctx->pot_avail) break;
pot_t *tmp_pot = &potfile_ctx->pot[potfile_ctx->pot_cnt + pos];
hash_t *tmp_hash = &tmp_pot->hash;
tmp_hash->digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); VERIFY_PTR (tmp_hash->digest);
if (hashconfig->is_salted)
{
tmp_hash->salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); VERIFY_PTR (tmp_hash->salt);
}
if (hashconfig->esalt_size)
{
tmp_hash->esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); VERIFY_PTR (tmp_hash->esalt);
}
potfile_ctx->pot_hashes_avail++;
}
return 0;
}
void potfile_hash_free (hashcat_ctx_t *hashcat_ctx)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
if (potfile_ctx->enabled == false) return;
for (u32 i = 0; i < potfile_ctx->pot_cnt; i++)
{
pot_t *pot_ptr = &potfile_ctx->pot[i];
hash_t *hashes_buf = &pot_ptr->hash;
hcfree (hashes_buf->digest);
if (hashconfig->is_salted)
{
hcfree (hashes_buf->salt);
}
if (hashconfig->esalt_size)
{
hcfree (hashes_buf->esalt);
}
}
hcfree (potfile_ctx->pot);
}
/*
void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *))
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
@ -499,7 +433,9 @@ void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu
pot_key.hash.salt = hashes_buf->salt;
pot_key.hash.digest = hashes_buf->digest;
pot_t *pot_ptr = (pot_t *) hc_bsearch_r (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
//pot_t *pot_ptr = (pot_t *) hc_bsearch_r (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
pot_t *pot_ptr = NULL;
if (pot_ptr)
{
@ -544,7 +480,9 @@ void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu
memcpy (&pot_key.hash, hashes_buf, sizeof (hash_t));
pot_t *pot_ptr = (pot_t *) hc_bsearch_r (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
//pot_t *pot_ptr = (pot_t *) hc_bsearch_r (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
pot_t *pot_ptr = NULL;
if (pot_ptr == NULL)
{
@ -574,7 +512,9 @@ int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int in
pot_left_key.hash.salt = hash_left->salt;
pot_left_key.hash.digest = hash_left->digest;
pot_t *pot_left_ptr = (pot_t *) hc_bsearch_r (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
//pot_t *pot_left_ptr = (pot_t *) hc_bsearch_r (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
pot_t *pot_left_ptr = NULL;
// right
@ -585,7 +525,9 @@ int potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int in
pot_right_key.hash.salt = hash_right->salt;
pot_right_key.hash.digest = hash_right->digest;
pot_t *pot_right_ptr = (pot_t *) hc_bsearch_r (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
//pot_t *pot_right_ptr = (pot_t *) hc_bsearch_r (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
pot_t *pot_right_ptr = NULL;
if (pot_right_ptr == NULL)
{
@ -708,7 +650,9 @@ int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int in
memcpy (&pot_left_key.hash, hash_left, sizeof (hash_t));
pot_t *pot_left_ptr = (pot_t *) hc_bsearch_r (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
//pot_t *pot_left_ptr = (pot_t *) hc_bsearch_r (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
pot_t *pot_left_ptr = NULL;
// right
@ -716,7 +660,9 @@ int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int in
memcpy (&pot_right_key.hash, hash_right, sizeof (hash_t));
pot_t *pot_right_ptr = (pot_t *) hc_bsearch_r (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
//pot_t *pot_right_ptr = (pot_t *) hc_bsearch_r (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
pot_t *pot_right_ptr = NULL;
u32 weak_hash_found = 0;
@ -785,6 +731,7 @@ int potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int in
return 0;
}
*/
int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
{
@ -991,3 +938,17 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
return 0;
}
int potfile_handle_show (hashcat_ctx_t *hashcat_ctx)
{
return 0;
}
int potfile_handle_left (hashcat_ctx_t *hashcat_ctx)
{
return 0;
}