1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-05-05 16:39:19 +00:00

Update outfile.c and potfile.c function parameters

This commit is contained in:
jsteube 2016-10-06 15:40:27 +02:00
parent 0579f93402
commit 9b8092abf9
6 changed files with 204 additions and 153 deletions

View File

@ -14,12 +14,11 @@ void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para
void build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u64 *out_pos); void build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u64 *out_pos);
void build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u8 *debug_rule_buf, int *debug_rule_len, u8 *debug_plain_ptr, int *debug_plain_len); void build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u8 *debug_rule_buf, int *debug_rule_len, u8 *debug_plain_ptr, int *debug_plain_len);
void outfile_init (outfile_ctx_t *outfile_ctx, const user_options_t *user_options); void outfile_init (hashcat_ctx_t *hashcat_ctx);
void outfile_destroy (outfile_ctx_t *outfile_ctx); void outfile_destroy (hashcat_ctx_t *hashcat_ctx);
void outfile_format_plain (outfile_ctx_t *outfile_ctx, const unsigned char *plain_ptr, const u32 plain_len); void outfile_write_open (hashcat_ctx_t *hashcat_ctx);
void outfile_write_open (outfile_ctx_t *outfile_ctx); void outfile_write_close (hashcat_ctx_t *hashcat_ctx);
void outfile_write_close (outfile_ctx_t *outfile_ctx); void outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len);
void outfile_write (outfile_ctx_t *outfile_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, const hashconfig_t *hashconfig); int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx);
int outfile_and_hashfile (outfile_ctx_t *outfile_ctx, const char *hashfile);
#endif // _OUTFILE_H #endif // _OUTFILE_H

View File

@ -20,21 +20,20 @@ int sort_by_hash_t_salt_hccap (const void *v1, const void *v2);
void hc_qsort_r (void *base, size_t nmemb, size_t size, int (*compar) (const void *, const void *, void *), void *arg); void hc_qsort_r (void *base, size_t nmemb, size_t size, int (*compar) (const void *, const void *, void *), void *arg);
void *hc_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size, int (*compar) (const void *, const void *, void *), void *arg); void *hc_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size, int (*compar) (const void *, const void *, void *), void *arg);
void potfile_init (potfile_ctx_t *potfile_ctx, const user_options_t *user_options, const folder_config_t *folder_config); void potfile_init (hashcat_ctx_t *hashcat_ctx);
void potfile_format_plain (potfile_ctx_t *potfile_ctx, const unsigned char *plain_ptr, const u32 plain_len); int potfile_read_open (hashcat_ctx_t *hashcat_ctx);
int potfile_read_open (potfile_ctx_t *potfile_ctx); void potfile_read_parse (hashcat_ctx_t *hashcat_ctx);
void potfile_read_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig); void potfile_read_close (hashcat_ctx_t *hashcat_ctx);
void potfile_read_close (potfile_ctx_t *potfile_ctx); int potfile_write_open (hashcat_ctx_t *hashcat_ctx);
int potfile_write_open (potfile_ctx_t *potfile_ctx); void potfile_write_close (hashcat_ctx_t *hashcat_ctx);
void potfile_write_close (potfile_ctx_t *potfile_ctx); void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len);
void potfile_write_append (potfile_ctx_t *potfile_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len); void potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num);
void potfile_hash_alloc (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, const u32 num); void potfile_hash_free (hashcat_ctx_t *hashcat_ctx);
void potfile_hash_free (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig); 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_show_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_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 *));
void potfile_left_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *)); void 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 *));
void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_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_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_left_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_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);
int potfile_remove_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes); void potfile_destroy (hashcat_ctx_t *hashcat_ctx);
void potfile_destroy (potfile_ctx_t *potfile_ctx);
#endif // _POTFILE_H #endif // _POTFILE_H

View File

@ -763,8 +763,6 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx; outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx;
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
@ -799,13 +797,11 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
if (user_options->show == true || user_options->left == true) if (user_options->show == true || user_options->left == true)
{ {
outfile_write_open (outfile_ctx); outfile_write_open (hashcat_ctx);
potfile_read_open (potfile_ctx); potfile_read_open (hashcat_ctx);
potfile_read_parse (hashcat_ctx);
potfile_read_parse (potfile_ctx, hashconfig); potfile_read_close (hashcat_ctx);
potfile_read_close (potfile_ctx);
} }
/** /**
@ -832,9 +828,9 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
if (user_options->show == true || user_options->left == true) if (user_options->show == true || user_options->left == true)
{ {
outfile_write_close (outfile_ctx); outfile_write_close (hashcat_ctx);
potfile_hash_free (potfile_ctx, hashconfig); potfile_hash_free (hashcat_ctx);
return 0; return 0;
} }
@ -849,7 +845,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
{ {
if (user_options->quiet == false) log_info_nn ("Comparing hashes with potfile entries..."); if (user_options->quiet == false) log_info_nn ("Comparing hashes with potfile entries...");
potfile_remove_cracks = potfile_remove_parse (potfile_ctx, hashconfig, hashes); potfile_remove_cracks = potfile_remove_parse (hashcat_ctx);
} }
/** /**
@ -880,7 +876,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
hashconfig_destroy (hashconfig); hashconfig_destroy (hashconfig);
potfile_destroy (potfile_ctx); potfile_destroy (hashcat_ctx);
return 0; return 0;
} }
@ -1080,7 +1076,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
* weak hash check is the first to write to potfile, so open it for writing from here * weak hash check is the first to write to potfile, so open it for writing from here
*/ */
const int rc_potfile_write = potfile_write_open (potfile_ctx); const int rc_potfile_write = potfile_write_open (hashcat_ctx);
if (rc_potfile_write == -1) return -1; if (rc_potfile_write == -1) return -1;
@ -1208,7 +1204,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
opencl_session_destroy (hashcat_ctx); opencl_session_destroy (hashcat_ctx);
potfile_write_close (potfile_ctx); potfile_write_close (hashcat_ctx);
bitmap_ctx_destroy (hashcat_ctx); bitmap_ctx_destroy (hashcat_ctx);
@ -1249,8 +1245,6 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx; logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx; loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx;
outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx; outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx;
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx; restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
tuning_db_t *tuning_db = hashcat_ctx->tuning_db; tuning_db_t *tuning_db = hashcat_ctx->tuning_db;
@ -1333,13 +1327,13 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
* outfile itself * outfile itself
*/ */
outfile_init (outfile_ctx, user_options); outfile_init (hashcat_ctx);
/** /**
* Sanity check for hashfile vs outfile (should not point to the same physical file) * Sanity check for hashfile vs outfile (should not point to the same physical file)
*/ */
const int rc_outfile_and_hashfile = outfile_and_hashfile (outfile_ctx, user_options_extra->hc_hash); const int rc_outfile_and_hashfile = outfile_and_hashfile (hashcat_ctx);
if (rc_outfile_and_hashfile == -1) return -1; if (rc_outfile_and_hashfile == -1) return -1;
@ -1349,7 +1343,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
* plus it depends on hash_mode, so we continue using it in outer_loop * plus it depends on hash_mode, so we continue using it in outer_loop
*/ */
potfile_init (potfile_ctx, user_options, folder_config); potfile_init (hashcat_ctx);
/** /**
* dictstat init * dictstat init
@ -1508,11 +1502,11 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
dictstat_destroy (dictstat_ctx); dictstat_destroy (dictstat_ctx);
potfile_destroy (potfile_ctx); potfile_destroy (hashcat_ctx);
induct_ctx_destroy (induct_ctx); induct_ctx_destroy (induct_ctx);
outfile_destroy (outfile_ctx); outfile_destroy (hashcat_ctx);
outcheck_ctx_destroy (outcheck_ctx); outcheck_ctx_destroy (outcheck_ctx);

View File

@ -222,7 +222,6 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl
hashes_t *hashes = hashcat_ctx->hashes; hashes_t *hashes = hashcat_ctx->hashes;
loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx; loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx;
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx; outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
user_options_t *user_options = hashcat_ctx->user_options; user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
@ -263,19 +262,19 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl
// no need for locking, we're in a mutex protected function // no need for locking, we're in a mutex protected function
potfile_write_append (potfile_ctx, out_buf, plain_ptr, plain_len); potfile_write_append (hashcat_ctx, out_buf, plain_ptr, plain_len);
// outfile, can be either to file or stdout // outfile, can be either to file or stdout
// if an error occurs opening the file, send to stdout as fallback // if an error occurs opening the file, send to stdout as fallback
// the fp gets opened for each cracked hash so that the user can modify (move) the outfile while hashcat runs // the fp gets opened for each cracked hash so that the user can modify (move) the outfile while hashcat runs
outfile_write_open (outfile_ctx); outfile_write_open (hashcat_ctx);
if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt (); if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt ();
outfile_write (outfile_ctx, out_buf, plain_ptr, plain_len, crackpos, NULL, 0, hashconfig); outfile_write (hashcat_ctx, out_buf, plain_ptr, plain_len, crackpos, NULL, 0);
outfile_write_close (outfile_ctx); outfile_write_close (hashcat_ctx);
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{ {
@ -438,8 +437,6 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
{ {
hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
hashes_t *hashes = hashcat_ctx->hashes; hashes_t *hashes = hashcat_ctx->hashes;
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
user_options_t *user_options = hashcat_ctx->user_options; user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
@ -783,8 +780,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
tmp_salt->salt_len += 1 + 12 + 1 + 12; tmp_salt->salt_len += 1 + 12 + 1 + 12;
} }
if (user_options->show == true) potfile_show_request (potfile_ctx, hashconfig, outfile_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->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 (potfile_ctx, hashconfig, outfile_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++; hashes_cnt++;
} }
@ -831,8 +828,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
if ((lm_hash_left != NULL) && (lm_hash_right != NULL)) if ((lm_hash_left != NULL) && (lm_hash_right != NULL))
{ {
if (user_options->show == true) potfile_show_request_lm (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, lm_hash_left, lm_hash_right, sort_by_pot); 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 (potfile_ctx, hashconfig, outfile_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 else
@ -841,8 +838,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
if (parser_status == PARSER_OK) if (parser_status == PARSER_OK)
{ {
if (user_options->show == true) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot); 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 (potfile_ctx, hashconfig, outfile_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) if (parser_status == PARSER_OK)
@ -861,8 +858,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
if (parser_status == PARSER_OK) if (parser_status == PARSER_OK)
{ {
if (user_options->show == true) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, input_buf, input_len, &hashes_buf[hashes_cnt], sort_by_pot); 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 (potfile_ctx, hashconfig, outfile_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) if (parser_status == PARSER_OK)
@ -992,8 +989,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
// show / left // show / left
if (user_options->show == true) potfile_show_request_lm (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, lm_hash_left, lm_hash_right, sort_by_pot); 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 (potfile_ctx, hashconfig, outfile_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 else
{ {
@ -1008,8 +1005,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100); if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
if (user_options->show == true) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot); 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 (potfile_ctx, hashconfig, outfile_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++; hashes_cnt++;
} }
@ -1027,8 +1024,8 @@ int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx)
if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100); if (user_options->quiet == false) if ((hashes_cnt % 0x20000) == 0) log_info_nn ("Parsed Hashes: %u/%u (%0.2f%%)", hashes_cnt, hashes_avail, ((double) hashes_cnt / hashes_avail) * 100);
if (user_options->show == true) potfile_show_request (potfile_ctx, hashconfig, outfile_ctx, line_buf, line_len, &hashes_buf[hashes_cnt], sort_by_pot); 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 (potfile_ctx, hashconfig, outfile_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++; hashes_cnt++;
} }

View File

@ -256,30 +256,10 @@ void build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para
} }
} }
void outfile_init (outfile_ctx_t *outfile_ctx, const user_options_t *user_options) static void outfile_format_plain (hashcat_ctx_t *hashcat_ctx, const unsigned char *plain_ptr, const u32 plain_len)
{ {
if (user_options->outfile == NULL) outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
{
outfile_ctx->fp = stdout;
outfile_ctx->filename = NULL;
}
else
{
outfile_ctx->fp = NULL;
outfile_ctx->filename = user_options->outfile;
}
outfile_ctx->outfile_format = user_options->outfile_format;
outfile_ctx->outfile_autohex = user_options->outfile_autohex;
}
void outfile_destroy (outfile_ctx_t *outfile_ctx)
{
memset (outfile_ctx, 0, sizeof (outfile_ctx_t));
}
void outfile_format_plain (outfile_ctx_t *outfile_ctx, const unsigned char *plain_ptr, const u32 plain_len)
{
bool needs_hexify = false; bool needs_hexify = false;
if (outfile_ctx->outfile_autohex == true) if (outfile_ctx->outfile_autohex == true)
@ -319,8 +299,37 @@ void outfile_format_plain (outfile_ctx_t *outfile_ctx, const unsigned char *plai
} }
} }
void outfile_write_open (outfile_ctx_t *outfile_ctx) void outfile_init (hashcat_ctx_t *hashcat_ctx)
{ {
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->outfile == NULL)
{
outfile_ctx->fp = stdout;
outfile_ctx->filename = NULL;
}
else
{
outfile_ctx->fp = NULL;
outfile_ctx->filename = user_options->outfile;
}
outfile_ctx->outfile_format = user_options->outfile_format;
outfile_ctx->outfile_autohex = user_options->outfile_autohex;
}
void outfile_destroy (hashcat_ctx_t *hashcat_ctx)
{
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
memset (outfile_ctx, 0, sizeof (outfile_ctx_t));
}
void outfile_write_open (hashcat_ctx_t *hashcat_ctx)
{
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
if (outfile_ctx->filename == NULL) return; if (outfile_ctx->filename == NULL) return;
outfile_ctx->fp = fopen (outfile_ctx->filename, "ab"); outfile_ctx->fp = fopen (outfile_ctx->filename, "ab");
@ -334,15 +343,20 @@ void outfile_write_open (outfile_ctx_t *outfile_ctx)
} }
} }
void outfile_write_close (outfile_ctx_t *outfile_ctx) void outfile_write_close (hashcat_ctx_t *hashcat_ctx)
{ {
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
if (outfile_ctx->fp == stdout) return; if (outfile_ctx->fp == stdout) return;
fclose (outfile_ctx->fp); fclose (outfile_ctx->fp);
} }
void outfile_write (outfile_ctx_t *outfile_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, const hashconfig_t *hashconfig) void outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len)
{ {
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
if (outfile_ctx->outfile_format & OUTFILE_FMT_HASH) if (outfile_ctx->outfile_format & OUTFILE_FMT_HASH)
{ {
fprintf (outfile_ctx->fp, "%s", out_buf); fprintf (outfile_ctx->fp, "%s", out_buf);
@ -370,7 +384,7 @@ void outfile_write (outfile_ctx_t *outfile_ctx, const char *out_buf, const unsig
if (outfile_ctx->outfile_format & OUTFILE_FMT_PLAIN) if (outfile_ctx->outfile_format & OUTFILE_FMT_PLAIN)
{ {
outfile_format_plain (outfile_ctx, plain_ptr, plain_len); outfile_format_plain (hashcat_ctx, plain_ptr, plain_len);
if (outfile_ctx->outfile_format & (OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS)) if (outfile_ctx->outfile_format & (OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS))
{ {
@ -399,8 +413,13 @@ void outfile_write (outfile_ctx_t *outfile_ctx, const char *out_buf, const unsig
fputs (EOL, outfile_ctx->fp); fputs (EOL, outfile_ctx->fp);
} }
int outfile_and_hashfile (outfile_ctx_t *outfile_ctx, const char *hashfile) int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx)
{ {
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
char *hashfile = user_options_extra->hc_hash;
if (hashfile == NULL) return 0; if (hashfile == NULL) return 0;
char *outfile = outfile_ctx->filename; char *outfile = outfile_ctx->filename;

View File

@ -146,48 +146,10 @@ void *hc_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size
return (NULL); return (NULL);
} }
void potfile_init (potfile_ctx_t *potfile_ctx, const user_options_t *user_options, const folder_config_t *folder_config) static void potfile_format_plain (hashcat_ctx_t *hashcat_ctx, const unsigned char *plain_ptr, const u32 plain_len)
{ {
potfile_ctx->enabled = false; potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (user_options->benchmark == true) return;
if (user_options->keyspace == true) return;
if (user_options->opencl_info == true) return;
if (user_options->stdout_flag == true) return;
if (user_options->usage == true) return;
if (user_options->version == true) return;
if (user_options->potfile_disable == true) return;
potfile_ctx->enabled = true;
if (user_options->potfile_path == NULL)
{
potfile_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY);
potfile_ctx->fp = NULL;
snprintf (potfile_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.potfile", folder_config->profile_dir);
}
else
{
potfile_ctx->filename = mystrdup (user_options->potfile_path);
potfile_ctx->fp = NULL;
}
potfile_ctx->pot = NULL;
potfile_ctx->pot_cnt = 0;
potfile_ctx->pot_avail = 0;
potfile_ctx->pot_hashes_avail = 0;
}
void potfile_destroy (potfile_ctx_t *potfile_ctx)
{
if (potfile_ctx->enabled == false) return;
memset (potfile_ctx, 0, sizeof (potfile_ctx_t));
}
void potfile_format_plain (potfile_ctx_t *potfile_ctx, const unsigned char *plain_ptr, const u32 plain_len)
{
if (potfile_ctx->enabled == false) return; if (potfile_ctx->enabled == false) return;
bool needs_hexify = false; bool needs_hexify = false;
@ -226,8 +188,56 @@ void potfile_format_plain (potfile_ctx_t *potfile_ctx, const unsigned char *plai
} }
} }
int potfile_read_open (potfile_ctx_t *potfile_ctx) void potfile_init (hashcat_ctx_t *hashcat_ctx)
{ {
folder_config_t *folder_config = hashcat_ctx->folder_config;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
user_options_t *user_options = hashcat_ctx->user_options;
potfile_ctx->enabled = false;
if (user_options->benchmark == true) return;
if (user_options->keyspace == true) return;
if (user_options->opencl_info == true) return;
if (user_options->stdout_flag == true) return;
if (user_options->usage == true) return;
if (user_options->version == true) return;
if (user_options->potfile_disable == true) return;
potfile_ctx->enabled = true;
if (user_options->potfile_path == NULL)
{
potfile_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY);
potfile_ctx->fp = NULL;
snprintf (potfile_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.potfile", folder_config->profile_dir);
}
else
{
potfile_ctx->filename = mystrdup (user_options->potfile_path);
potfile_ctx->fp = NULL;
}
potfile_ctx->pot = NULL;
potfile_ctx->pot_cnt = 0;
potfile_ctx->pot_avail = 0;
potfile_ctx->pot_hashes_avail = 0;
}
void potfile_destroy (hashcat_ctx_t *hashcat_ctx)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return;
memset (potfile_ctx, 0, sizeof (potfile_ctx_t));
}
int potfile_read_open (hashcat_ctx_t *hashcat_ctx)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return 0; if (potfile_ctx->enabled == false) return 0;
potfile_ctx->fp = fopen (potfile_ctx->filename, "rb"); potfile_ctx->fp = fopen (potfile_ctx->filename, "rb");
@ -242,8 +252,11 @@ int potfile_read_open (potfile_ctx_t *potfile_ctx)
return 0; return 0;
} }
void potfile_read_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig) void potfile_read_parse (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; if (potfile_ctx->enabled == false) return;
if (potfile_ctx->fp == NULL) return; if (potfile_ctx->fp == NULL) return;
@ -269,7 +282,7 @@ void potfile_read_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashcon
if (potfile_ctx->pot_cnt == potfile_ctx->pot_hashes_avail) if (potfile_ctx->pot_cnt == potfile_ctx->pot_hashes_avail)
{ {
potfile_hash_alloc (potfile_ctx, hashconfig, INCR_POT); potfile_hash_alloc (hashcat_ctx, INCR_POT);
} }
int parser_status; int parser_status;
@ -349,8 +362,10 @@ void potfile_read_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashcon
hc_qsort_r (potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig); hc_qsort_r (potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
} }
void potfile_read_close (potfile_ctx_t *potfile_ctx) 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->enabled == false) return;
if (potfile_ctx->fp == NULL) return; if (potfile_ctx->fp == NULL) return;
@ -358,8 +373,10 @@ void potfile_read_close (potfile_ctx_t *potfile_ctx)
fclose (potfile_ctx->fp); fclose (potfile_ctx->fp);
} }
int potfile_write_open (potfile_ctx_t *potfile_ctx) int potfile_write_open (hashcat_ctx_t *hashcat_ctx)
{ {
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return 0; if (potfile_ctx->enabled == false) return 0;
potfile_ctx->fp = fopen (potfile_ctx->filename, "ab"); potfile_ctx->fp = fopen (potfile_ctx->filename, "ab");
@ -374,30 +391,37 @@ int potfile_write_open (potfile_ctx_t *potfile_ctx)
return 0; return 0;
} }
void potfile_write_close (potfile_ctx_t *potfile_ctx) void potfile_write_close (hashcat_ctx_t *hashcat_ctx)
{ {
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return; if (potfile_ctx->enabled == false) return;
fclose (potfile_ctx->fp); fclose (potfile_ctx->fp);
} }
void potfile_write_append (potfile_ctx_t *potfile_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len) void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len)
{ {
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return; if (potfile_ctx->enabled == false) return;
FILE *fp = potfile_ctx->fp; FILE *fp = potfile_ctx->fp;
fprintf (fp, "%s:", out_buf); fprintf (fp, "%s:", out_buf);
potfile_format_plain (potfile_ctx, plain_ptr, plain_len); potfile_format_plain (hashcat_ctx, plain_ptr, plain_len);
fputc ('\n', fp); fputc ('\n', fp);
fflush (fp); fflush (fp);
} }
void potfile_hash_alloc (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, const u32 num) void 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; if (potfile_ctx->enabled == false) return;
u32 pos = 0; u32 pos = 0;
@ -426,8 +450,11 @@ void potfile_hash_alloc (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashcon
} }
} }
void potfile_hash_free (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig) 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; if (potfile_ctx->enabled == false) return;
for (u32 i = 0; i < potfile_ctx->pot_cnt; i++) for (u32 i = 0; i < potfile_ctx->pot_cnt; i++)
@ -452,8 +479,11 @@ void potfile_hash_free (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconf
myfree (potfile_ctx->pot); myfree (potfile_ctx->pot);
} }
void potfile_show_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_ctx, char *input_buf, int input_len, hash_t *hashes_buf, 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 *))
{ {
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return; if (potfile_ctx->enabled == false) return;
pot_t pot_key; pot_t pot_key;
@ -487,12 +517,15 @@ void potfile_show_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashc
// do output the line // do output the line
outfile_write (outfile_ctx, input_buf, (const unsigned char *) pot_ptr->plain_buf, pot_ptr->plain_len, 0, username, user_len, hashconfig); outfile_write (hashcat_ctx, input_buf, (const unsigned char *) pot_ptr->plain_buf, pot_ptr->plain_len, 0, username, user_len);
} }
} }
void potfile_left_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_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 *))
{ {
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return; if (potfile_ctx->enabled == false) return;
pot_t pot_key; pot_t pot_key;
@ -507,12 +540,15 @@ void potfile_left_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashc
input_buf[input_len] = 0; input_buf[input_len] = 0;
outfile_write (outfile_ctx, input_buf, NULL, 0, 0, NULL, 0, hashconfig); outfile_write (hashcat_ctx, input_buf, NULL, 0, 0, NULL, 0);
} }
} }
void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_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_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 *))
{ {
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return; if (potfile_ctx->enabled == false) return;
// left // left
@ -625,7 +661,7 @@ void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
// do output the line // do output the line
outfile_write (outfile_ctx, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len, hashconfig); outfile_write (hashcat_ctx, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len);
if (weak_hash_found == 1) myfree (pot_right_ptr); if (weak_hash_found == 1) myfree (pot_right_ptr);
@ -633,8 +669,11 @@ void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
if (right_part_masked == 1) myfree (pot_right_ptr); if (right_part_masked == 1) myfree (pot_right_ptr);
} }
void potfile_left_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, outfile_ctx_t *outfile_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_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 *))
{ {
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return; if (potfile_ctx->enabled == false) return;
// left // left
@ -708,15 +747,19 @@ void potfile_left_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
hash_output[user_len + 16] = 0; hash_output[user_len + 16] = 0;
} }
outfile_write (outfile_ctx, hash_output, NULL, 0, 0, NULL, 0, hashconfig); outfile_write (hashcat_ctx, hash_output, NULL, 0, 0, NULL, 0);
myfree (hash_output); myfree (hash_output);
if (weak_hash_found == 1) myfree (pot_right_ptr); if (weak_hash_found == 1) myfree (pot_right_ptr);
} }
int potfile_remove_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes) int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
{ {
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
hashes_t *hashes = hashcat_ctx->hashes;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return 0; if (potfile_ctx->enabled == false) return 0;
hash_t *hashes_buf = hashes->hashes_buf; hash_t *hashes_buf = hashes->hashes_buf;
@ -754,7 +797,7 @@ int potfile_remove_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashco
hash_buf.esalt = mymalloc (hashconfig->esalt_size); hash_buf.esalt = mymalloc (hashconfig->esalt_size);
} }
const int rc = potfile_read_open (potfile_ctx); const int rc = potfile_read_open (hashcat_ctx);
if (rc == -1) return 0; if (rc == -1) return 0;
@ -909,7 +952,7 @@ int potfile_remove_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashco
myfree (line_buf); myfree (line_buf);
potfile_read_close (potfile_ctx); potfile_read_close (hashcat_ctx);
if (hashconfig->esalt_size) if (hashconfig->esalt_size)
{ {