1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-26 01:50:10 +00:00

Make use of EVENT_CRACKER_HASH_CRACKED, do not print a cracked hash to stdout directly, let the client do it

This commit is contained in:
jsteube 2016-10-12 11:27:10 +02:00
parent 20832d29d6
commit 386efb7fb5
10 changed files with 112 additions and 153 deletions

View File

@ -9,10 +9,10 @@
#include <stdio.h>
#include <stdarg.h>
int event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len);
void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len);
#define EVENT(id) { const int rc_event = event_call ((id), hashcat_ctx, NULL, 0); if (rc_event == -1) return -1; }
#define EVENT_DATA(id,buf,len) { const int rc_event = event_call ((id), hashcat_ctx, (buf), (len)); if (rc_event == -1) return -1; }
#define EVENT(id) event_call ((id), hashcat_ctx, NULL, 0)
#define EVENT_DATA(id,buf,len) event_call ((id), hashcat_ctx, (buf), (len))
size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);

View File

@ -8,7 +8,7 @@
int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime);
void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (const u32, struct hashcat_ctx *, const void *, const size_t));
void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t));
void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _HASHCAT_H

View File

@ -18,7 +18,7 @@ int outfile_init (hashcat_ctx_t *hashcat_ctx);
void outfile_destroy (hashcat_ctx_t *hashcat_ctx);
int outfile_write_open (hashcat_ctx_t *hashcat_ctx);
void outfile_write_close (hashcat_ctx_t *hashcat_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);
int 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, char tmp_buf[HCBUFSIZ_LARGE]);
int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx);
#endif // _OUTFILE_H

View File

@ -1435,7 +1435,7 @@ typedef struct hashcat_ctx
user_options_t *user_options;
wl_data_t *wl_data;
int (*event) (const u32, struct hashcat_ctx *, const void *, const size_t);
void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t);
} hashcat_ctx_t;

View File

@ -8,7 +8,7 @@
#include "thread.h"
#include "event.h"
int event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
{
bool need_mux = true;
@ -26,7 +26,7 @@ int event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const
hc_thread_mutex_lock (event_ctx->mux_event);
}
const int rc = hashcat_ctx->event (id, hashcat_ctx, buf, len);
hashcat_ctx->event (id, hashcat_ctx, buf, len);
if (need_mux == true)
{
@ -34,8 +34,6 @@ int event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const
hc_thread_mutex_unlock (event_ctx->mux_event);
}
return rc;
}
static int event_log (const char *fmt, va_list ap, char *s, const size_t sz)

View File

@ -55,7 +55,7 @@
extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_CNT;
extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_BUF[];
void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (const u32, struct hashcat_ctx *, const void *, const size_t))
void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t))
{
if (event == NULL)
{

View File

@ -272,10 +272,14 @@ void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl
if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt ();
outfile_write (hashcat_ctx, out_buf, plain_ptr, plain_len, crackpos, NULL, 0);
char tmp_buf[HCBUFSIZ_LARGE];
const int tmp_len = outfile_write (hashcat_ctx, out_buf, plain_ptr, plain_len, crackpos, NULL, 0, tmp_buf);
outfile_write_close (hashcat_ctx);
EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len);
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
if ((status_ctx->devices_status != STATUS_CRACKED) && (user_options->status != true))

View File

@ -60,36 +60,30 @@ static void main_log (hashcat_ctx_t *hashcat_ctx, const char *buf, const size_t
fflush (fp);
}
static int main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
main_log (hashcat_ctx, buf, len, stdout);
return 0;
}
static int main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
static const char PREFIX_WARNING[] = "WARNING: ";
fwrite (PREFIX_WARNING, sizeof (PREFIX_WARNING), 1, stdout);
main_log (hashcat_ctx, buf, len, stdout);
return 0;
}
static int main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
static const char PREFIX_ERROR[] = "ERROR: ";
fwrite (PREFIX_ERROR, sizeof (PREFIX_ERROR), 1, stderr);
main_log (hashcat_ctx, buf, len, stderr);
return 0;
}
static int main_welcome_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_welcome_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
// sets dos window size (windows only)
@ -100,22 +94,18 @@ static int main_welcome_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_U
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
welcome_screen (hashcat_ctx, status_ctx->proc_start, VERSION_TAG);
return 0;
}
static int main_goodbye_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_goodbye_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
// Inform user we're done
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
goodbye_screen (hashcat_ctx, status_ctx->proc_start, status_ctx->proc_stop);
return 0;
}
static int main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
@ -144,11 +134,9 @@ static int main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY
hashcat_user->outer_threads_cnt++;
}
}
return 0;
}
static int main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
@ -165,16 +153,14 @@ static int main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY
hcfree (hashcat_user->outer_threads);
hashcat_user->outer_threads_cnt = 0;
return 0;
}
static int main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
// Tell the user we're about to start
@ -190,11 +176,9 @@ static int main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE
event_log_info (hashcat_ctx, "Starting attack in stdin mode...");
event_log_info (hashcat_ctx, "");
}
return 0;
}
static int main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const hashes_t *hashes = hashcat_ctx->hashes;
const user_options_t *user_options = hashcat_ctx->user_options;
@ -232,62 +216,52 @@ static int main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE
}
}
}
return 0;
}
static int main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const hashes_t *hashes = hashcat_ctx->hashes;
const user_options_t *user_options = hashcat_ctx->user_options;
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
if (hashes == NULL) hashes = NULL;
if (user_options == NULL) user_options = NULL;
if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile
return 0;
fwrite (buf, len, 1, stdout);
fwrite (EOL, sizeof (EOL), 1, stdout);
}
static int main_calculated_words_base (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_calculated_words_base (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->keyspace == true)
{
event_log_info (hashcat_ctx, "%" PRIu64 "", status_ctx->words_base);
}
if (user_options->keyspace == false) return;
return 0;
event_log_info (hashcat_ctx, "%" PRIu64 "", status_ctx->words_base);
}
static int main_potfile_remove_parse_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_potfile_remove_parse_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Comparing hashes with potfile entries...");
return 0;
}
static int main_potfile_remove_parse_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_potfile_remove_parse_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Compared hashes with potfile entries...");
return 0;
}
static int main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const hashes_t *hashes = hashcat_ctx->hashes;
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
const int potfile_remove_cracks = hashes->digests_done;
@ -304,23 +278,19 @@ static int main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA
event_log_info (hashcat_ctx, "");
}
}
return 0;
}
static int main_potfile_all_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_potfile_all_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
event_log_info (hashcat_ctx, "INFO: All hashes found in potfile! You can use --show to display them.");
event_log_info (hashcat_ctx, "");
return 0;
}
static int main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx;
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
@ -344,7 +314,7 @@ static int main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M
}
}
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
event_log_info (hashcat_ctx, "Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt);
event_log_info (hashcat_ctx, "Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2);
@ -402,81 +372,67 @@ static int main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, M
#if defined (DEBUG)
if (user_options->benchmark == true) event_log_info (hashcat_ctx, "Hashmode: %d", hashconfig->hash_mode);
#endif
return 0;
}
static int main_opencl_session_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_opencl_session_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Initializing device kernels and memory...");
return 0;
}
static int main_opencl_session_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_opencl_session_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Initialized device kernels and memory...");
return 0;
}
static int main_weak_hash_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_weak_hash_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Checking for weak hashes...");
return 0;
}
static int main_weak_hash_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_weak_hash_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Checked for weak hashes...");
return 0;
}
static int main_bitmap_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_bitmap_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Generating bitmap tables...");
return 0;
}
static int main_bitmap_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_bitmap_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Generated bitmap tables...");
return 0;
}
static int main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
static void main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return 0;
if (user_options->quiet == true) return;
clear_prompt ();
@ -484,55 +440,45 @@ static int main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx,
event_log_info (hashcat_ctx, "");
send_prompt ();
return 0;
}
int event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
{
int rc = 0;
switch (id)
{
case EVENT_LOG_INFO: rc = main_log_info (hashcat_ctx, buf, len); break;
case EVENT_LOG_WARNING: rc = main_log_warning (hashcat_ctx, buf, len); break;
case EVENT_LOG_ERROR: rc = main_log_error (hashcat_ctx, buf, len); break;
case EVENT_WELCOME_SCREEN: rc = main_welcome_screen (hashcat_ctx, buf, len); break;
case EVENT_GOODBYE_SCREEN: rc = main_goodbye_screen (hashcat_ctx, buf, len); break;
case EVENT_OUTERLOOP_STARTING: rc = main_outerloop_starting (hashcat_ctx, buf, len); break;
case EVENT_OUTERLOOP_FINISHED: rc = main_outerloop_finished (hashcat_ctx, buf, len); break;
case EVENT_OUTERLOOP_MAINSCREEN: rc = main_outerloop_mainscreen (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_STARTING: rc = main_cracker_starting (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_FINISHED: rc = main_cracker_finished (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_HASH_CRACKED: rc = main_cracker_hash_cracked (hashcat_ctx, buf, len); break;
case EVENT_CALCULATED_WORDS_BASE: rc = main_calculated_words_base (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_REMOVE_PARSE_PRE: rc = main_potfile_remove_parse_pre (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_REMOVE_PARSE_POST: rc = main_potfile_remove_parse_post (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_NUM_CRACKED: rc = main_potfile_num_cracked (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_ALL_CRACKED: rc = main_potfile_all_cracked (hashcat_ctx, buf, len); break;
case EVENT_OPENCL_SESSION_PRE: rc = main_opencl_session_pre (hashcat_ctx, buf, len); break;
case EVENT_OPENCL_SESSION_POST: rc = main_opencl_session_post (hashcat_ctx, buf, len); break;
case EVENT_BITMAP_INIT_PRE: rc = main_bitmap_init_pre (hashcat_ctx, buf, len); break;
case EVENT_BITMAP_INIT_POST: rc = main_bitmap_init_post (hashcat_ctx, buf, len); break;
case EVENT_WEAK_HASH_PRE: rc = main_weak_hash_pre (hashcat_ctx, buf, len); break;
case EVENT_WEAK_HASH_POST: rc = main_weak_hash_post (hashcat_ctx, buf, len); break;
case EVENT_SET_KERNEL_POWER_FINAL: rc = main_set_kernel_power_final (hashcat_ctx, buf, len); break;
case EVENT_LOG_INFO: main_log_info (hashcat_ctx, buf, len); break;
case EVENT_LOG_WARNING: main_log_warning (hashcat_ctx, buf, len); break;
case EVENT_LOG_ERROR: main_log_error (hashcat_ctx, buf, len); break;
case EVENT_WELCOME_SCREEN: main_welcome_screen (hashcat_ctx, buf, len); break;
case EVENT_GOODBYE_SCREEN: main_goodbye_screen (hashcat_ctx, buf, len); break;
case EVENT_OUTERLOOP_STARTING: main_outerloop_starting (hashcat_ctx, buf, len); break;
case EVENT_OUTERLOOP_FINISHED: main_outerloop_finished (hashcat_ctx, buf, len); break;
case EVENT_OUTERLOOP_MAINSCREEN: main_outerloop_mainscreen (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_STARTING: main_cracker_starting (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_FINISHED: main_cracker_finished (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_HASH_CRACKED: main_cracker_hash_cracked (hashcat_ctx, buf, len); break;
case EVENT_CALCULATED_WORDS_BASE: main_calculated_words_base (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_REMOVE_PARSE_PRE: main_potfile_remove_parse_pre (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_REMOVE_PARSE_POST: main_potfile_remove_parse_post (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_NUM_CRACKED: main_potfile_num_cracked (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_ALL_CRACKED: main_potfile_all_cracked (hashcat_ctx, buf, len); break;
case EVENT_OPENCL_SESSION_PRE: main_opencl_session_pre (hashcat_ctx, buf, len); break;
case EVENT_OPENCL_SESSION_POST: main_opencl_session_post (hashcat_ctx, buf, len); break;
case EVENT_BITMAP_INIT_PRE: main_bitmap_init_pre (hashcat_ctx, buf, len); break;
case EVENT_BITMAP_INIT_POST: main_bitmap_init_post (hashcat_ctx, buf, len); break;
case EVENT_WEAK_HASH_PRE: main_weak_hash_pre (hashcat_ctx, buf, len); break;
case EVENT_WEAK_HASH_POST: main_weak_hash_post (hashcat_ctx, buf, len); break;
case EVENT_SET_KERNEL_POWER_FINAL: main_set_kernel_power_final (hashcat_ctx, buf, len); break;
}
return rc;
}
#else
int event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
{
int rc = 0;
switch (id)
{
}
return rc;
}
#endif

View File

@ -262,17 +262,8 @@ int 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->fp = NULL;
outfile_ctx->filename = user_options->outfile;
outfile_ctx->outfile_format = user_options->outfile_format;
outfile_ctx->outfile_autohex = user_options->outfile_autohex;
@ -312,18 +303,17 @@ 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 == NULL) return;
fclose (outfile_ctx->fp);
}
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)
int 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, char tmp_buf[HCBUFSIZ_LARGE])
{
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
const outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
char tmp_buf[HCBUFSIZ_LARGE];
int tmp_len = 0;
int tmp_len = 0;
if (outfile_ctx->outfile_format & OUTFILE_FMT_HASH)
{
@ -412,7 +402,12 @@ void outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsig
tmp_buf[tmp_len] = 0;
fprintf (outfile_ctx->fp, "%s" EOL, tmp_buf);
if (outfile_ctx->fp)
{
fprintf (outfile_ctx->fp, "%s" EOL, tmp_buf);
}
return tmp_len;
}
int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx)

View File

@ -523,7 +523,11 @@ void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu
// do output the line
outfile_write (hashcat_ctx, input_buf, (const unsigned char *) pot_ptr->plain_buf, pot_ptr->plain_len, 0, username, user_len);
char tmp_buf[HCBUFSIZ_LARGE];
const int tmp_len = outfile_write (hashcat_ctx, input_buf, (const unsigned char *) pot_ptr->plain_buf, pot_ptr->plain_len, 0, username, user_len, tmp_buf);
EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len);
}
}
@ -546,7 +550,11 @@ void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int inpu
input_buf[input_len] = 0;
outfile_write (hashcat_ctx, input_buf, NULL, 0, 0, NULL, 0);
char tmp_buf[HCBUFSIZ_LARGE];
const int tmp_len = outfile_write (hashcat_ctx, input_buf, NULL, 0, 0, NULL, 0, tmp_buf);
EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len);
}
}
@ -667,7 +675,11 @@ void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
// do output the line
outfile_write (hashcat_ctx, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len);
char tmp_buf[HCBUFSIZ_LARGE];
const int tmp_len = outfile_write (hashcat_ctx, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len, tmp_buf);
EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len);
if (weak_hash_found == 1) hcfree (pot_right_ptr);
@ -753,7 +765,11 @@ void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int i
hash_output[user_len + 16] = 0;
}
outfile_write (hashcat_ctx, hash_output, NULL, 0, 0, NULL, 0);
char tmp_buf[HCBUFSIZ_LARGE];
const int tmp_len = outfile_write (hashcat_ctx, hash_output, NULL, 0, 0, NULL, 0, tmp_buf);
EVENT_DATA (EVENT_CRACKER_HASH_CRACKED, tmp_buf, tmp_len);
hcfree (hash_output);