mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 16:18:09 +00:00
Start context-related logging with goal to get rid of logging.c
This commit is contained in:
parent
f469694030
commit
42677df2a6
28
include/event.h
Normal file
28
include/event.h
Normal file
@ -0,0 +1,28 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#ifndef _EVENT_H
|
||||
#define _EVENT_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
int 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; }
|
||||
|
||||
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, ...);
|
||||
size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
|
||||
|
||||
size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
|
||||
size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
|
||||
size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
|
||||
|
||||
int event_ctx_init (hashcat_ctx_t *hashcat_ctx);
|
||||
void event_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
#endif // _EVENT_H
|
@ -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) (hashcat_ctx_t *, const u32));
|
||||
void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (const u32, struct hashcat_ctx *, const void *, const size_t));
|
||||
void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
|
||||
|
||||
#endif // _HASHCAT_H
|
||||
|
@ -12,8 +12,6 @@
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#define EVENT_SEND(id) { const int rc_event = hashcat_ctx->event (hashcat_ctx, (id)); if (rc_event == -1) return -1; }
|
||||
|
||||
bool is_power_of_2 (const u32 v);
|
||||
|
||||
u32 get_random_num (const u32 min, const u32 max);
|
||||
|
@ -83,6 +83,9 @@ typedef struct stat64 hc_stat;
|
||||
|
||||
typedef enum event_identifier
|
||||
{
|
||||
EVENT_LOG_INFO = 0x00000001,
|
||||
EVENT_LOG_WARNING = 0x00000002,
|
||||
EVENT_LOG_ERROR = 0x00000003,
|
||||
EVENT_WELCOME_SCREEN = 0x00000011,
|
||||
EVENT_GOODBYE_SCREEN = 0x00000012,
|
||||
EVENT_LOGFILE_TOP_INITIALIZE = 0x00000021,
|
||||
@ -1397,6 +1400,14 @@ typedef struct hashcat_user
|
||||
|
||||
} hashcat_user_t;
|
||||
|
||||
typedef struct event_ctx
|
||||
{
|
||||
int last_len;
|
||||
|
||||
hc_thread_mutex_t mux_event;
|
||||
|
||||
} event_ctx_t;
|
||||
|
||||
typedef struct hashcat_ctx
|
||||
{
|
||||
bitmap_ctx_t *bitmap_ctx;
|
||||
@ -1404,6 +1415,7 @@ typedef struct hashcat_ctx
|
||||
cpt_ctx_t *cpt_ctx;
|
||||
debugfile_ctx_t *debugfile_ctx;
|
||||
dictstat_ctx_t *dictstat_ctx;
|
||||
event_ctx_t *event_ctx;
|
||||
folder_config_t *folder_config;
|
||||
hashcat_user_t *hashcat_user;
|
||||
hashconfig_t *hashconfig;
|
||||
@ -1425,7 +1437,7 @@ typedef struct hashcat_ctx
|
||||
user_options_t *user_options;
|
||||
wl_data_t *wl_data;
|
||||
|
||||
int (*event) (struct hashcat_ctx *, const u32);
|
||||
int (*event) (const u32, struct hashcat_ctx *, const void *, const size_t);
|
||||
|
||||
} hashcat_ctx_t;
|
||||
|
||||
|
@ -163,7 +163,7 @@ LFLAGS_CROSS_WIN := -lpsapi
|
||||
## Objects
|
||||
##
|
||||
|
||||
OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 debugfile dictstat dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hashcat hashes hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile restore rp rp_cpu rp_kernel_on_cpu shared status stdout straight terminal thread timer tuningdb usage user_options weak_hash wordlist
|
||||
OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 debugfile dictstat dispatch dynloader event ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hashcat hashes hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile restore rp rp_cpu rp_kernel_on_cpu shared status stdout straight terminal thread timer tuningdb usage user_options weak_hash wordlist
|
||||
|
||||
NATIVE_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.o)
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "filehandling.h"
|
||||
#include "interface.h"
|
||||
#include "timer.h"
|
||||
#include "logging.h"
|
||||
#include "ext_OpenCL.h"
|
||||
#include "ext_ADL.h"
|
||||
#include "ext_nvapi.h"
|
||||
@ -33,11 +32,12 @@
|
||||
#include "wordlist.h"
|
||||
#include "status.h"
|
||||
#include "shared.h"
|
||||
#include "event.h"
|
||||
#include "dispatch.h"
|
||||
|
||||
static int set_kernel_power_final (hashcat_ctx_t *hashcat_ctx, const u32 kernel_power_final)
|
||||
{
|
||||
EVENT_SEND (EVENT_SET_KERNEL_POWER_FINAL);
|
||||
EVENT (EVENT_SET_KERNEL_POWER_FINAL);
|
||||
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
|
||||
@ -314,7 +314,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
|
||||
if (fd == NULL)
|
||||
{
|
||||
log_error ("ERROR: %s: %s", dictfile, strerror (errno));
|
||||
event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfile, strerror (errno));
|
||||
|
||||
return;
|
||||
}
|
||||
@ -331,7 +331,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
|
||||
if (combs_fp == NULL)
|
||||
{
|
||||
log_error ("ERROR: %s: %s", combinator_ctx->dict2, strerror (errno));
|
||||
event_log_error (hashcat_ctx, "ERROR: %s: %s", combinator_ctx->dict2, strerror (errno));
|
||||
|
||||
fclose (fd);
|
||||
|
||||
@ -348,7 +348,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
|
||||
if (combs_fp == NULL)
|
||||
{
|
||||
log_error ("ERROR: %s: %s", dictfilec, strerror (errno));
|
||||
event_log_error (hashcat_ctx, "ERROR: %s: %s", dictfilec, strerror (errno));
|
||||
|
||||
fclose (fd);
|
||||
|
||||
|
205
src/event.c
Normal file
205
src/event.c
Normal file
@ -0,0 +1,205 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "thread.h"
|
||||
#include "event.h"
|
||||
|
||||
int event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
bool need_mux = true;
|
||||
|
||||
switch (id)
|
||||
{
|
||||
case EVENT_LOG_INFO: need_mux = false;
|
||||
case EVENT_LOG_WARNING: need_mux = false;
|
||||
case EVENT_LOG_ERROR: need_mux = false;
|
||||
}
|
||||
|
||||
if (need_mux == true)
|
||||
{
|
||||
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
|
||||
|
||||
hc_thread_mutex_lock (event_ctx->mux_event);
|
||||
}
|
||||
|
||||
const int rc = hashcat_ctx->event (id, hashcat_ctx, buf, len);
|
||||
|
||||
if (need_mux == true)
|
||||
{
|
||||
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
|
||||
|
||||
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)
|
||||
{
|
||||
return vsnprintf (s, sz, fmt, ap);
|
||||
}
|
||||
|
||||
size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, fmt);
|
||||
|
||||
char buf[BUFSIZ];
|
||||
|
||||
const size_t len = event_log (fmt, ap, buf, sizeof (buf));
|
||||
|
||||
va_end (ap);
|
||||
|
||||
event_call (EVENT_LOG_INFO, hashcat_ctx, buf, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, fmt);
|
||||
|
||||
char buf[BUFSIZ];
|
||||
|
||||
const size_t len = event_log (fmt, ap, buf, sizeof (buf));
|
||||
|
||||
va_end (ap);
|
||||
|
||||
event_call (EVENT_LOG_WARNING, hashcat_ctx, buf, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, fmt);
|
||||
|
||||
char buf[BUFSIZ];
|
||||
|
||||
const size_t len = event_log (fmt, ap, buf, sizeof (buf));
|
||||
|
||||
va_end (ap);
|
||||
|
||||
event_call (EVENT_LOG_ERROR, hashcat_ctx, buf, len);
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, fmt);
|
||||
|
||||
char buf[BUFSIZ];
|
||||
|
||||
const size_t len = event_log (fmt, ap, buf, sizeof (buf));
|
||||
|
||||
va_end (ap);
|
||||
|
||||
#if defined (_WIN)
|
||||
|
||||
buf[len + 0] = '\r';
|
||||
buf[len + 1] = '\n';
|
||||
|
||||
event_call (EVENT_LOG_INFO, hashcat_ctx, buf, len + 2);
|
||||
|
||||
#else
|
||||
|
||||
buf[len] = '\n';
|
||||
|
||||
event_call (EVENT_LOG_INFO, hashcat_ctx, buf, len + 1);
|
||||
|
||||
#endif
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, fmt);
|
||||
|
||||
char buf[BUFSIZ];
|
||||
|
||||
const size_t len = event_log (fmt, ap, buf, sizeof (buf));
|
||||
|
||||
va_end (ap);
|
||||
|
||||
#if defined (_WIN)
|
||||
|
||||
buf[len + 0] = '\r';
|
||||
buf[len + 1] = '\n';
|
||||
|
||||
event_call (EVENT_LOG_WARNING, hashcat_ctx, buf, len + 2);
|
||||
|
||||
#else
|
||||
|
||||
buf[len] = '\n';
|
||||
|
||||
event_call (EVENT_LOG_WARNING, hashcat_ctx, buf, len + 1);
|
||||
|
||||
#endif
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start (ap, fmt);
|
||||
|
||||
char buf[BUFSIZ];
|
||||
|
||||
const size_t len = event_log (fmt, ap, buf, sizeof (buf));
|
||||
|
||||
va_end (ap);
|
||||
|
||||
#if defined (_WIN)
|
||||
|
||||
buf[len + 0] = '\r';
|
||||
buf[len + 1] = '\n';
|
||||
|
||||
event_call (EVENT_LOG_ERROR, hashcat_ctx, buf, len + 2);
|
||||
|
||||
#else
|
||||
|
||||
buf[len] = '\n';
|
||||
|
||||
event_call (EVENT_LOG_ERROR, hashcat_ctx, buf, len + 1);
|
||||
|
||||
#endif
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
int event_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
|
||||
|
||||
hc_thread_mutex_init (event_ctx->mux_event);
|
||||
|
||||
event_ctx->last_len = 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void event_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
|
||||
|
||||
hc_thread_mutex_delete (event_ctx->mux_event);
|
||||
|
||||
event_ctx->last_len = 0;
|
||||
}
|
@ -14,7 +14,6 @@
|
||||
#include "types.h"
|
||||
#include "folder.h"
|
||||
#include "locking.h"
|
||||
#include "logging.h"
|
||||
#include "memory.h"
|
||||
#include "shared.h"
|
||||
#include "thread.h"
|
||||
@ -30,6 +29,7 @@
|
||||
#include "debugfile.h"
|
||||
#include "dictstat.h"
|
||||
#include "dispatch.h"
|
||||
#include "event.h"
|
||||
#include "hashes.h"
|
||||
#include "hwmon.h"
|
||||
#include "induct.h"
|
||||
@ -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) (hashcat_ctx_t *, const u32))
|
||||
void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (const u32, struct hashcat_ctx *, const void *, const size_t))
|
||||
{
|
||||
if (event == NULL)
|
||||
{
|
||||
@ -71,6 +71,7 @@ void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx, int (*event) (hashcat_ctx_t *
|
||||
hashcat_ctx->cpt_ctx = (cpt_ctx_t *) mymalloc (sizeof (cpt_ctx_t));
|
||||
hashcat_ctx->debugfile_ctx = (debugfile_ctx_t *) mymalloc (sizeof (debugfile_ctx_t));
|
||||
hashcat_ctx->dictstat_ctx = (dictstat_ctx_t *) mymalloc (sizeof (dictstat_ctx_t));
|
||||
hashcat_ctx->event_ctx = (event_ctx_t *) mymalloc (sizeof (event_ctx_t));
|
||||
hashcat_ctx->folder_config = (folder_config_t *) mymalloc (sizeof (folder_config_t));
|
||||
hashcat_ctx->hashcat_user = (hashcat_user_t *) mymalloc (sizeof (hashcat_user_t));
|
||||
hashcat_ctx->hashconfig = (hashconfig_t *) mymalloc (sizeof (hashconfig_t));
|
||||
@ -100,6 +101,7 @@ void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
|
||||
myfree (hashcat_ctx->cpt_ctx);
|
||||
myfree (hashcat_ctx->debugfile_ctx);
|
||||
myfree (hashcat_ctx->dictstat_ctx);
|
||||
myfree (hashcat_ctx->event_ctx);
|
||||
myfree (hashcat_ctx->folder_config);
|
||||
myfree (hashcat_ctx->hashconfig);
|
||||
myfree (hashcat_ctx->hashes);
|
||||
@ -144,7 +146,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
status_ctx->devices_status = STATUS_INIT;
|
||||
|
||||
EVENT_SEND (EVENT_LOGFILE_SUB_INITIALIZE);
|
||||
EVENT (EVENT_LOGFILE_SUB_INITIALIZE);
|
||||
|
||||
status_progress_reset (hashcat_ctx);
|
||||
|
||||
@ -188,7 +190,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
status_ctx->words_base = status_ctx->words_cnt / user_options_extra_amplifier (hashcat_ctx);
|
||||
|
||||
EVENT_SEND (EVENT_CALCULATED_WORDS_BASE);
|
||||
EVENT (EVENT_CALCULATED_WORDS_BASE);
|
||||
|
||||
if (user_options->keyspace == true) return 0;
|
||||
|
||||
@ -196,7 +198,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (status_ctx->words_cur > status_ctx->words_base)
|
||||
{
|
||||
log_error ("ERROR: Restore value greater keyspace");
|
||||
event_log_error (hashcat_ctx, "ERROR: Restore value greater keyspace");
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -223,7 +225,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
* create autotune threads
|
||||
*/
|
||||
|
||||
EVENT_SEND (EVENT_AUTOTUNE_STARTING);
|
||||
EVENT (EVENT_AUTOTUNE_STARTING);
|
||||
|
||||
thread_param_t *threads_param = (thread_param_t *) mycalloc (opencl_ctx->devices_cnt, sizeof (thread_param_t));
|
||||
|
||||
@ -243,7 +245,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
hc_thread_wait (opencl_ctx->devices_cnt, c_threads);
|
||||
|
||||
EVENT_SEND (EVENT_AUTOTUNE_FINISHED);
|
||||
EVENT (EVENT_AUTOTUNE_FINISHED);
|
||||
|
||||
/**
|
||||
* autotune modified kernel_accel, which modifies opencl_ctx->kernel_power_all
|
||||
@ -278,7 +280,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
* create cracker threads
|
||||
*/
|
||||
|
||||
EVENT_SEND (EVENT_CRACKER_STARTING);
|
||||
EVENT (EVENT_CRACKER_STARTING);
|
||||
|
||||
status_ctx->devices_status = STATUS_RUNNING;
|
||||
|
||||
@ -313,7 +315,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
status_ctx->devices_status = STATUS_EXHAUSTED;
|
||||
}
|
||||
|
||||
EVENT_SEND (EVENT_CRACKER_FINISHED);
|
||||
EVENT (EVENT_CRACKER_FINISHED);
|
||||
|
||||
// update some timer
|
||||
|
||||
@ -328,7 +330,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
time (&status_ctx->prepare_start);
|
||||
|
||||
EVENT_SEND (EVENT_CRACKER_FINAL_STATS);
|
||||
EVENT (EVENT_CRACKER_FINAL_STATS);
|
||||
|
||||
// no more skip and restore from here
|
||||
|
||||
@ -344,7 +346,7 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
loopback_write_close (hashcat_ctx);
|
||||
}
|
||||
|
||||
EVENT_SEND (EVENT_LOGFILE_SUB_FINALIZE);
|
||||
EVENT (EVENT_LOGFILE_SUB_FINALIZE);
|
||||
|
||||
// New induction folder check
|
||||
|
||||
@ -392,7 +394,7 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
* loop through wordlists
|
||||
*/
|
||||
|
||||
EVENT_SEND (EVENT_INNERLOOP2_STARTING);
|
||||
EVENT (EVENT_INNERLOOP2_STARTING);
|
||||
|
||||
restore_data_t *rd = restore_ctx->rd;
|
||||
|
||||
@ -418,7 +420,7 @@ static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
if (rc_inner2_loop == -1) return -1;
|
||||
}
|
||||
|
||||
EVENT_SEND (EVENT_INNERLOOP2_FINISHED);
|
||||
EVENT (EVENT_INNERLOOP2_FINISHED);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -484,7 +486,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
if (hashes->hashes_cnt == 0)
|
||||
{
|
||||
log_error ("ERROR: No hashes loaded");
|
||||
event_log_error (hashcat_ctx, "ERROR: No hashes loaded");
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -509,7 +511,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (user_options->potfile_disable == 0)
|
||||
{
|
||||
EVENT_SEND (EVENT_POTFILE_REMOVE_PARSE);
|
||||
EVENT (EVENT_POTFILE_REMOVE_PARSE);
|
||||
|
||||
potfile_remove_parse (hashcat_ctx);
|
||||
}
|
||||
@ -530,7 +532,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (status_ctx->devices_status == STATUS_CRACKED)
|
||||
{
|
||||
EVENT_SEND (EVENT_POTFILE_ALL_CRACKED);
|
||||
EVENT (EVENT_POTFILE_ALL_CRACKED);
|
||||
|
||||
hashes_destroy (hashcat_ctx);
|
||||
|
||||
@ -555,11 +557,11 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
* bitmaps
|
||||
*/
|
||||
|
||||
EVENT_SEND (EVENT_BITMAP_INIT_PRE);
|
||||
EVENT (EVENT_BITMAP_INIT_PRE);
|
||||
|
||||
bitmap_ctx_init (hashcat_ctx);
|
||||
|
||||
EVENT_SEND (EVENT_BITMAP_INIT_POST);
|
||||
EVENT (EVENT_BITMAP_INIT_POST);
|
||||
|
||||
/**
|
||||
* cracks-per-time allocate buffer
|
||||
@ -605,7 +607,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
if ((mask_ctx->masks_cnt > 1) || (straight_ctx->dicts_cnt > 1))
|
||||
{
|
||||
log_error ("ERROR: --skip/--limit are not supported with --increment or mask files");
|
||||
event_log_error (hashcat_ctx, "ERROR: --skip/--limit are not supported with --increment or mask files");
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -619,7 +621,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
if ((mask_ctx->masks_cnt > 1) || (straight_ctx->dicts_cnt > 1))
|
||||
{
|
||||
log_error ("ERROR: --keyspace is not supported with --increment or mask files");
|
||||
event_log_error (hashcat_ctx, "ERROR: --keyspace is not supported with --increment or mask files");
|
||||
|
||||
return -1;
|
||||
}
|
||||
@ -637,17 +639,17 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
* main screen
|
||||
*/
|
||||
|
||||
EVENT_SEND (EVENT_OUTERLOOP_MAINSCREEN);
|
||||
EVENT (EVENT_OUTERLOOP_MAINSCREEN);
|
||||
|
||||
/**
|
||||
* inform the user
|
||||
*/
|
||||
|
||||
EVENT_SEND (EVENT_OPENCL_SESSION_PRE);
|
||||
EVENT (EVENT_OPENCL_SESSION_PRE);
|
||||
|
||||
opencl_session_begin (hashcat_ctx);
|
||||
|
||||
EVENT_SEND (EVENT_OPENCL_SESSION_POST);
|
||||
EVENT (EVENT_OPENCL_SESSION_POST);
|
||||
|
||||
/**
|
||||
* weak hash check is the first to write to potfile, so open it for writing from here
|
||||
@ -674,14 +676,14 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
break;
|
||||
}
|
||||
|
||||
EVENT_SEND (EVENT_WEAK_HASH_PRE);
|
||||
EVENT (EVENT_WEAK_HASH_PRE);
|
||||
|
||||
for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
|
||||
{
|
||||
weak_hash_check (hashcat_ctx, device_param, salt_pos);
|
||||
}
|
||||
|
||||
EVENT_SEND (EVENT_WEAK_HASH_POST);
|
||||
EVENT (EVENT_WEAK_HASH_POST);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -716,11 +718,11 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
* Tell user about cracked hashes by potfile
|
||||
*/
|
||||
|
||||
EVENT_SEND (EVENT_POTFILE_NUM_CRACKED);
|
||||
EVENT (EVENT_POTFILE_NUM_CRACKED);
|
||||
|
||||
// main call
|
||||
|
||||
EVENT_SEND (EVENT_INNERLOOP1_STARTING);
|
||||
EVENT (EVENT_INNERLOOP1_STARTING);
|
||||
|
||||
if (mask_ctx->masks_cnt)
|
||||
{
|
||||
@ -762,7 +764,7 @@ static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
myfree (inner_threads);
|
||||
|
||||
EVENT_SEND (EVENT_INNERLOOP1_FINISHED);
|
||||
EVENT (EVENT_INNERLOOP1_FINISHED);
|
||||
|
||||
// finalize potfile
|
||||
|
||||
@ -801,6 +803,14 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
/**
|
||||
* event init (needed for logging so should be first)
|
||||
*/
|
||||
|
||||
const int rc_event_init = event_ctx_init (hashcat_ctx);
|
||||
|
||||
if (rc_event_init == -1) return -1;
|
||||
|
||||
/**
|
||||
* status init
|
||||
*/
|
||||
@ -809,7 +819,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
|
||||
|
||||
if (rc_status_init == -1) return -1;
|
||||
|
||||
EVENT_SEND (EVENT_WELCOME_SCREEN);
|
||||
EVENT (EVENT_WELCOME_SCREEN);
|
||||
|
||||
/**
|
||||
* folder
|
||||
@ -837,7 +847,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
|
||||
|
||||
// from here all user configuration is pre-processed so we can start logging
|
||||
|
||||
EVENT_SEND (EVENT_LOGFILE_TOP_INITIALIZE);
|
||||
EVENT (EVENT_LOGFILE_TOP_INITIALIZE);
|
||||
|
||||
/**
|
||||
* To help users a bit
|
||||
@ -965,7 +975,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
|
||||
* outer loop
|
||||
*/
|
||||
|
||||
EVENT_SEND (EVENT_OUTERLOOP_STARTING);
|
||||
EVENT (EVENT_OUTERLOOP_STARTING);
|
||||
|
||||
if (user_options->benchmark == true)
|
||||
{
|
||||
@ -998,7 +1008,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
|
||||
if (rc == -1) return -1;
|
||||
}
|
||||
|
||||
EVENT_SEND (EVENT_OUTERLOOP_FINISHED);
|
||||
EVENT (EVENT_OUTERLOOP_FINISHED);
|
||||
|
||||
if (user_options->benchmark == true)
|
||||
{
|
||||
@ -1046,7 +1056,7 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
|
||||
logfile_top_uint (status_ctx->proc_start);
|
||||
logfile_top_uint (status_ctx->proc_stop);
|
||||
|
||||
EVENT_SEND (EVENT_LOGFILE_TOP_FINALIZE);
|
||||
EVENT (EVENT_LOGFILE_TOP_FINALIZE);
|
||||
|
||||
user_options_extra_destroy (hashcat_ctx);
|
||||
|
||||
@ -1059,7 +1069,9 @@ int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_fold
|
||||
if (status_ctx->devices_status == STATUS_EXHAUSTED) rc_final = 1;
|
||||
if (status_ctx->devices_status == STATUS_CRACKED) rc_final = 0;
|
||||
|
||||
EVENT_SEND (EVENT_GOODBYE_SCREEN);
|
||||
EVENT (EVENT_GOODBYE_SCREEN);
|
||||
|
||||
event_ctx_destroy (hashcat_ctx);
|
||||
|
||||
status_ctx_destroy (hashcat_ctx);
|
||||
|
||||
|
255
src/main.c
255
src/main.c
@ -19,13 +19,73 @@
|
||||
|
||||
#include "memory.h"
|
||||
#include "terminal.h"
|
||||
#include "logging.h"
|
||||
#include "logfile.h"
|
||||
#include "thread.h"
|
||||
#include "status.h"
|
||||
#include "interface.h"
|
||||
#include "event.h"
|
||||
|
||||
static int event_welcome_screen (hashcat_ctx_t *hashcat_ctx)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
|
||||
static void main_log (hashcat_ctx_t *hashcat_ctx, const char *buf, const size_t len, FILE *fp)
|
||||
{
|
||||
if (len == 0) return;
|
||||
|
||||
// handle last_len
|
||||
|
||||
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
|
||||
|
||||
if (event_ctx->last_len)
|
||||
{
|
||||
fputc ('\r', fp);
|
||||
|
||||
for (int i = 0; i < event_ctx->last_len; i++)
|
||||
{
|
||||
fputc (' ', fp);
|
||||
}
|
||||
|
||||
fputc ('\r', fp);
|
||||
}
|
||||
|
||||
if (buf[len - 1] == '\n')
|
||||
{
|
||||
event_ctx->last_len = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
event_ctx->last_len = len;
|
||||
}
|
||||
|
||||
// finally, print
|
||||
|
||||
fwrite (buf, len, 1, fp);
|
||||
|
||||
fflush (fp);
|
||||
}
|
||||
|
||||
static int main_log_info (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
main_log (hashcat_ctx, buf, len, stdout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int main_log_warning (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
main_log (hashcat_ctx, buf, len, stdout);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int main_log_error (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
main_log (hashcat_ctx, buf, len, stderr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int main_welcome_screen (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
// sets dos window size (windows only)
|
||||
|
||||
@ -40,7 +100,7 @@ static int event_welcome_screen (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_goodbye_screen (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_goodbye_screen (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
// Inform user we're done
|
||||
|
||||
@ -51,7 +111,7 @@ static int event_goodbye_screen (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_logfile_top_initialize (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_logfile_top_initialize (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
|
||||
|
||||
@ -72,7 +132,7 @@ static int event_logfile_top_initialize (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_logfile_top_finalize (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_logfile_top_finalize (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
|
||||
|
||||
@ -83,7 +143,7 @@ static int event_logfile_top_finalize (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_logfile_sub_initialize (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_logfile_sub_initialize (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
|
||||
|
||||
@ -94,7 +154,7 @@ static int event_logfile_sub_initialize (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_logfile_sub_finalize (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_logfile_sub_finalize (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
|
||||
|
||||
@ -103,7 +163,7 @@ static int event_logfile_sub_finalize (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_outerloop_starting (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_outerloop_starting (hashcat_ctx_t *hashcat_ctx, const void *buf, 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;
|
||||
@ -136,7 +196,7 @@ static int event_outerloop_starting (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_outerloop_finished (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_outerloop_finished (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
@ -157,7 +217,7 @@ static int event_outerloop_finished (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_cracker_starting (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_cracker_starting (hashcat_ctx_t *hashcat_ctx, const void *buf, 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;
|
||||
@ -175,14 +235,14 @@ static int event_cracker_starting (hashcat_ctx_t *hashcat_ctx)
|
||||
}
|
||||
else if (user_options_extra->wordlist_mode == WL_MODE_STDIN)
|
||||
{
|
||||
log_info ("Starting attack in stdin mode...");
|
||||
log_info ("");
|
||||
event_log_info (hashcat_ctx, "Starting attack in stdin mode...");
|
||||
event_log_info (hashcat_ctx, "");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_cracker_finished (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_cracker_finished (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
|
||||
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
@ -192,7 +252,7 @@ static int event_cracker_finished (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_cracker_final_stats (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const hashes_t *hashes = hashcat_ctx->hashes;
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
@ -205,7 +265,7 @@ static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (user_options->machine_readable == false)
|
||||
{
|
||||
log_info ("");
|
||||
event_log_info (hashcat_ctx, "");
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -214,11 +274,11 @@ static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
clear_prompt ();
|
||||
|
||||
if (hashes->digests_saved != hashes->digests_done) log_info ("");
|
||||
if (hashes->digests_saved != hashes->digests_done) event_log_info (hashcat_ctx, "");
|
||||
|
||||
status_display (hashcat_ctx);
|
||||
|
||||
log_info ("");
|
||||
event_log_info (hashcat_ctx, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -226,7 +286,7 @@ static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
status_display (hashcat_ctx);
|
||||
|
||||
log_info ("");
|
||||
event_log_info (hashcat_ctx, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -234,7 +294,7 @@ static int event_cracker_final_stats (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const hashes_t *hashes = hashcat_ctx->hashes;
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
@ -245,31 +305,31 @@ static int event_cracker_hash_cracked (hashcat_ctx_t *hashcat_ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_calculated_words_base (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_calculated_words_base (hashcat_ctx_t *hashcat_ctx, const void *buf, 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)
|
||||
{
|
||||
log_info ("%" PRIu64 "", status_ctx->words_base);
|
||||
event_log_info (hashcat_ctx, "%" PRIu64 "", status_ctx->words_base);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_potfile_remove_parse (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
if (user_options->quiet == true) return 0;
|
||||
|
||||
log_info_nn ("Comparing hashes with potfile entries...");
|
||||
event_log_info (hashcat_ctx, "Comparing hashes with potfile entries...");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_potfile_num_cracked (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_potfile_num_cracked (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
const hashes_t *hashes = hashcat_ctx->hashes;
|
||||
@ -282,34 +342,34 @@ static int event_potfile_num_cracked (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
if (potfile_remove_cracks == 1)
|
||||
{
|
||||
log_info ("INFO: Removed 1 hash found in potfile");
|
||||
log_info ("");
|
||||
event_log_info (hashcat_ctx, "INFO: Removed 1 hash found in potfile");
|
||||
event_log_info (hashcat_ctx, "");
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info ("INFO: Removed %d hashes found in potfile", potfile_remove_cracks);
|
||||
log_info ("");
|
||||
event_log_info (hashcat_ctx, "INFO: Removed %d hashes found in potfile", potfile_remove_cracks);
|
||||
event_log_info (hashcat_ctx, "");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_potfile_all_cracked (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_potfile_all_cracked (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
if (user_options->quiet == true) return 0;
|
||||
|
||||
log_info ("INFO: All hashes found in potfile! You can use --show to display them.");
|
||||
log_info ("");
|
||||
log_info ("INFO: No more hashes left to crack, exiting...");
|
||||
log_info ("");
|
||||
event_log_info (hashcat_ctx, "INFO: All hashes found in potfile! You can use --show to display them.");
|
||||
event_log_info (hashcat_ctx, "");
|
||||
event_log_info (hashcat_ctx, "INFO: No more hashes left to crack, exiting...");
|
||||
event_log_info (hashcat_ctx, "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_outerloop_mainscreen (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_outerloop_mainscreen (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx;
|
||||
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
@ -328,37 +388,36 @@ static int event_outerloop_mainscreen (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug
|
||||
|
||||
log_info ("Hashtype: %s", hash_type);
|
||||
log_info ("");
|
||||
event_log_info (hashcat_ctx, "Hashtype: %s", hash_type);
|
||||
event_log_info (hashcat_ctx, "");
|
||||
}
|
||||
}
|
||||
|
||||
if (user_options->quiet == true) return 0;
|
||||
|
||||
log_info ("Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt);
|
||||
|
||||
log_info ("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);
|
||||
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);
|
||||
|
||||
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
|
||||
{
|
||||
log_info ("Rules: %u", straight_ctx->kernel_rules_cnt);
|
||||
event_log_info (hashcat_ctx, "Rules: %u", straight_ctx->kernel_rules_cnt);
|
||||
}
|
||||
|
||||
if (user_options->quiet == false) log_info ("");
|
||||
if (user_options->quiet == false) event_log_info (hashcat_ctx, "");
|
||||
|
||||
if (hashconfig->opti_type)
|
||||
{
|
||||
log_info ("Applicable Optimizers:");
|
||||
event_log_info (hashcat_ctx, "Applicable Optimizers:");
|
||||
|
||||
for (u32 i = 0; i < 32; i++)
|
||||
{
|
||||
const u32 opti_bit = 1u << i;
|
||||
|
||||
if (hashconfig->opti_type & opti_bit) log_info ("* %s", stroptitype (opti_bit));
|
||||
if (hashconfig->opti_type & opti_bit) event_log_info (hashcat_ctx, "* %s", stroptitype (opti_bit));
|
||||
}
|
||||
}
|
||||
|
||||
log_info ("");
|
||||
event_log_info (hashcat_ctx, "");
|
||||
|
||||
/**
|
||||
* Watchdog and Temperature balance
|
||||
@ -366,103 +425,103 @@ static int event_outerloop_mainscreen (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false)
|
||||
{
|
||||
log_info ("Watchdog: Hardware Monitoring Interface not found on your system");
|
||||
event_log_info (hashcat_ctx, "Watchdog: Hardware Monitoring Interface not found on your system");
|
||||
}
|
||||
|
||||
if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0)
|
||||
{
|
||||
log_info ("Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort);
|
||||
event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info ("Watchdog: Temperature abort trigger disabled");
|
||||
event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger disabled");
|
||||
}
|
||||
|
||||
if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0)
|
||||
{
|
||||
log_info ("Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain);
|
||||
event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain);
|
||||
}
|
||||
else
|
||||
{
|
||||
log_info ("Watchdog: Temperature retain trigger disabled");
|
||||
event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger disabled");
|
||||
}
|
||||
|
||||
log_info ("");
|
||||
event_log_info (hashcat_ctx, "");
|
||||
|
||||
#if defined (DEBUG)
|
||||
if (user_options->benchmark == true) log_info ("Hashmode: %d", hashconfig->hash_mode);
|
||||
if (user_options->benchmark == true) event_log_info (hashcat_ctx, "Hashmode: %d", hashconfig->hash_mode);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_opencl_session_pre (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_opencl_session_pre (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
if (user_options->quiet == true) return 0;
|
||||
|
||||
log_info_nn ("Initializing device kernels and memory...");
|
||||
event_log_info_nn (hashcat_ctx, "Initializing device kernels and memory...");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_opencl_session_post (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_opencl_session_post (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
if (user_options->quiet == true) return 0;
|
||||
|
||||
log_info_nn ("Initialized device kernels and memory...");
|
||||
event_log_info_nn (hashcat_ctx, "Initialized device kernels and memory...");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_weak_hash_pre (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_weak_hash_pre (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
if (user_options->quiet == true) return 0;
|
||||
|
||||
log_info_nn ("Checking for weak hashes...");
|
||||
event_log_info_nn (hashcat_ctx, "Checking for weak hashes...");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_weak_hash_post (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_weak_hash_post (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
if (user_options->quiet == true) return 0;
|
||||
|
||||
log_info_nn ("Checked for weak hashes...");
|
||||
event_log_info_nn (hashcat_ctx, "Checked for weak hashes...");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_bitmap_init_pre (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_bitmap_init_pre (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
if (user_options->quiet == true) return 0;
|
||||
|
||||
log_info_nn ("Generating bitmap tables...");
|
||||
event_log_info_nn (hashcat_ctx, "Generating bitmap tables...");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_bitmap_init_post (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_bitmap_init_post (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
if (user_options->quiet == true) return 0;
|
||||
|
||||
log_info_nn ("Generated bitmap tables...");
|
||||
event_log_info_nn (hashcat_ctx, "Generated bitmap tables...");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int event_set_kernel_power_final (hashcat_ctx_t *hashcat_ctx)
|
||||
static int main_set_kernel_power_final (hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
const user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
@ -470,45 +529,47 @@ static int event_set_kernel_power_final (hashcat_ctx_t *hashcat_ctx)
|
||||
|
||||
clear_prompt ();
|
||||
|
||||
log_info ("INFO: approaching final keyspace, workload adjusted");
|
||||
log_info ("");
|
||||
event_log_info (hashcat_ctx, "INFO: approaching final keyspace, workload adjusted");
|
||||
event_log_info (hashcat_ctx, "");
|
||||
|
||||
send_prompt ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int event (hashcat_ctx_t *hashcat_ctx, const u32 event)
|
||||
int event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
switch (event)
|
||||
switch (id)
|
||||
{
|
||||
case EVENT_WELCOME_SCREEN: rc = event_welcome_screen (hashcat_ctx); break;
|
||||
case EVENT_GOODBYE_SCREEN: rc = event_goodbye_screen (hashcat_ctx); break;
|
||||
case EVENT_LOGFILE_TOP_INITIALIZE: rc = event_logfile_top_initialize (hashcat_ctx); break;
|
||||
case EVENT_LOGFILE_TOP_FINALIZE: rc = event_logfile_top_finalize (hashcat_ctx); break;
|
||||
case EVENT_LOGFILE_SUB_INITIALIZE: rc = event_logfile_sub_initialize (hashcat_ctx); break;
|
||||
case EVENT_LOGFILE_SUB_FINALIZE: rc = event_logfile_sub_finalize (hashcat_ctx); break;
|
||||
case EVENT_OUTERLOOP_STARTING: rc = event_outerloop_starting (hashcat_ctx); break;
|
||||
case EVENT_OUTERLOOP_FINISHED: rc = event_outerloop_finished (hashcat_ctx); break;
|
||||
case EVENT_OUTERLOOP_MAINSCREEN: rc = event_outerloop_mainscreen (hashcat_ctx); break;
|
||||
case EVENT_CRACKER_STARTING: rc = event_cracker_starting (hashcat_ctx); break;
|
||||
case EVENT_CRACKER_FINISHED: rc = event_cracker_finished (hashcat_ctx); break;
|
||||
case EVENT_CRACKER_FINAL_STATS: rc = event_cracker_final_stats (hashcat_ctx); break;
|
||||
case EVENT_CRACKER_HASH_CRACKED: rc = event_cracker_hash_cracked (hashcat_ctx); break;
|
||||
case EVENT_CALCULATED_WORDS_BASE: rc = event_calculated_words_base (hashcat_ctx); break;
|
||||
case EVENT_POTFILE_REMOVE_PARSE: rc = event_potfile_remove_parse (hashcat_ctx); break;
|
||||
case EVENT_POTFILE_NUM_CRACKED: rc = event_potfile_num_cracked (hashcat_ctx); break;
|
||||
case EVENT_POTFILE_ALL_CRACKED: rc = event_potfile_all_cracked (hashcat_ctx); break;
|
||||
case EVENT_OPENCL_SESSION_PRE: rc = event_opencl_session_pre (hashcat_ctx); break;
|
||||
case EVENT_OPENCL_SESSION_POST: rc = event_opencl_session_post (hashcat_ctx); break;
|
||||
case EVENT_BITMAP_INIT_PRE: rc = event_bitmap_init_pre (hashcat_ctx); break;
|
||||
case EVENT_BITMAP_INIT_POST: rc = event_bitmap_init_post (hashcat_ctx); break;
|
||||
case EVENT_WEAK_HASH_PRE: rc = event_weak_hash_pre (hashcat_ctx); break;
|
||||
case EVENT_WEAK_HASH_POST: rc = event_weak_hash_post (hashcat_ctx); break;
|
||||
case EVENT_SET_KERNEL_POWER_FINAL: rc = event_set_kernel_power_final (hashcat_ctx); break;
|
||||
|
||||
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_LOGFILE_TOP_INITIALIZE: rc = main_logfile_top_initialize (hashcat_ctx, buf, len); break;
|
||||
case EVENT_LOGFILE_TOP_FINALIZE: rc = main_logfile_top_finalize (hashcat_ctx, buf, len); break;
|
||||
case EVENT_LOGFILE_SUB_INITIALIZE: rc = main_logfile_sub_initialize (hashcat_ctx, buf, len); break;
|
||||
case EVENT_LOGFILE_SUB_FINALIZE: rc = main_logfile_sub_finalize (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_FINAL_STATS: rc = main_cracker_final_stats (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: rc = main_potfile_remove_parse (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;
|
||||
}
|
||||
|
||||
return rc;
|
||||
@ -516,13 +577,11 @@ int event (hashcat_ctx_t *hashcat_ctx, const u32 event)
|
||||
|
||||
#else
|
||||
|
||||
int event (hashcat_ctx_t *hashcat_ctx, const u32 event)
|
||||
int event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
|
||||
{
|
||||
if (hashcat_ctx == NULL) hashcat_ctx = NULL;
|
||||
|
||||
int rc = 0;
|
||||
|
||||
switch (event)
|
||||
switch (id)
|
||||
{
|
||||
}
|
||||
|
||||
@ -531,6 +590,8 @@ int event (hashcat_ctx_t *hashcat_ctx, const u32 event)
|
||||
|
||||
#endif
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
// hashcat main context
|
||||
|
519
src/opencl.c
519
src/opencl.c
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user