mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-22 08:08:10 +00:00
Finished refactoring to remove all global variables
This commit is contained in:
parent
d16b6228a6
commit
fb3e6bab0d
@ -6,8 +6,6 @@
|
||||
#ifndef _AUTOTUNE_H
|
||||
#define _AUTOTUNE_H
|
||||
|
||||
int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, status_ctx_t *status_ctx);
|
||||
|
||||
void *thread_autotune (void *p);
|
||||
|
||||
#endif // _AUTOTUNE_H
|
||||
|
@ -23,6 +23,7 @@
|
||||
#define _GNU_SOURCE
|
||||
#define _FILE_OFFSET_BITS 64
|
||||
|
||||
// don't try to simply change this, it will not work
|
||||
#define PW_MIN 0
|
||||
#define PW_MAX 54
|
||||
#define PW_MAX1 (PW_MAX + 1)
|
||||
|
@ -1,9 +0,0 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#ifndef _DATA_H
|
||||
#define _DATA_H
|
||||
|
||||
#endif // _DATA_H
|
@ -21,7 +21,7 @@ int sort_by_dictstat (const void *s1, const void *s2);
|
||||
|
||||
void dictstat_init (dictstat_ctx_t *dictstat_ctx, const user_options_t *user_options, const folder_config_t *folder_config);
|
||||
void dictstat_destroy (dictstat_ctx_t *dictstat_ctx);
|
||||
void dictstat_read (dictstat_ctx_t *dictstat_ctx);
|
||||
void dictstat_read (dictstat_ctx_t *dictstat_ctx, const int comptime);
|
||||
int dictstat_write (dictstat_ctx_t *dictstat_ctx);
|
||||
u64 dictstat_find (dictstat_ctx_t *dictstat_ctx, dictstat_t *d);
|
||||
void dictstat_append (dictstat_ctx_t *dictstat_ctx, dictstat_t *d);
|
||||
|
11
include/hashcat.h
Normal file
11
include/hashcat.h
Normal file
@ -0,0 +1,11 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#ifndef _HASHCAT_H
|
||||
#define _HASHCAT_H
|
||||
|
||||
int hashcat (hashcat_ctx_t *hashcat_ctx, int argc, char **argv);
|
||||
|
||||
#endif // _HASHCAT_H
|
@ -6,16 +6,16 @@
|
||||
#ifndef _HASH_MANAGEMENT_H
|
||||
#define _HASH_MANAGEMENT_H
|
||||
|
||||
int sort_by_digest_p0p1 (const void *v1, const void *v2);
|
||||
int sort_by_digest_p0p1 (const void *v1, const void *v2, void *v3);
|
||||
int sort_by_salt (const void *v1, const void *v2);
|
||||
int sort_by_hash (const void *v1, const void *v2);
|
||||
int sort_by_hash_no_salt (const void *v1, const void *v2);
|
||||
int sort_by_hash (const void *v1, const void *v2, void *v3);
|
||||
int sort_by_hash_no_salt (const void *v1, const void *v2, void *v3);
|
||||
|
||||
void save_hash (const user_options_t *user_options, const hashconfig_t *hashconfig, const hashes_t *hashes);
|
||||
|
||||
void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, plain_t *plain);
|
||||
void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain);
|
||||
|
||||
int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, status_ctx_t *status_ctx, const uint salt_pos);
|
||||
int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const uint salt_pos);
|
||||
|
||||
int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfile_ctx_t *potfile_ctx, outfile_ctx_t *outfile_ctx, user_options_t *user_options, char *hash_or_file);
|
||||
int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, user_options_t *user_options, status_ctx_t *status_ctx);
|
||||
|
@ -31,12 +31,12 @@ int run_kernel_bzero (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
|
||||
|
||||
int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const combinator_ctx_t *combinator_ctx, const uint pws_cnt);
|
||||
|
||||
int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx, const outfile_ctx_t *outfile_ctx, status_ctx_t *status_ctx, const uint pws_cnt);
|
||||
int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const uint pws_cnt);
|
||||
|
||||
int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options);
|
||||
void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx);
|
||||
|
||||
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options);
|
||||
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const int comptime);
|
||||
void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx);
|
||||
void opencl_ctx_devices_update_power (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, status_ctx_t *status_ctx);
|
||||
void opencl_ctx_devices_kernel_loops (opencl_ctx_t *opencl_ctx, const user_options_extra_t *user_options_extra, const hashconfig_t *hashconfig, const hashes_t *hashes, straight_ctx_t *straight_ctx, combinator_ctx_t *combinator_ctx, mask_ctx_t *mask_ctx);
|
||||
|
@ -7,15 +7,19 @@
|
||||
#define _POTFILE_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define INCR_POT 1000
|
||||
|
||||
int sort_by_pot (const void *v1, const void *v2);
|
||||
int sort_by_salt_buf (const void *v1, const void *v2);
|
||||
int sort_by_pot (const void *v1, const void *v2, void *v3);
|
||||
int sort_by_salt_buf (const void *v1, const void *v2, void *v3);
|
||||
int sort_by_hash_t_salt (const void *v1, const void *v2);
|
||||
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_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_format_plain (potfile_ctx_t *potfile_ctx, const unsigned char *plain_ptr, const uint plain_len);
|
||||
int potfile_read_open (potfile_ctx_t *potfile_ctx);
|
||||
@ -26,10 +30,10 @@ void potfile_write_close (potfile_ctx_t *potfile_ctx);
|
||||
void potfile_write_append (potfile_ctx_t *potfile_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len);
|
||||
void potfile_hash_alloc (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, const uint num);
|
||||
void potfile_hash_free (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig);
|
||||
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 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 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 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 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 (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 (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 (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 (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes);
|
||||
void potfile_destroy (potfile_ctx_t *potfile_ctx);
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <windows.h>
|
||||
#endif // _WIN
|
||||
|
||||
void welcome_screen (const user_options_t *user_options, const status_ctx_t *status_ctx);
|
||||
void welcome_screen (const user_options_t *user_options, const status_ctx_t *status_ctx, char *version_tag);
|
||||
void goodbye_screen (const user_options_t *user_options, const status_ctx_t *status_ctx);
|
||||
|
||||
int setup_console ();
|
||||
|
@ -40,6 +40,7 @@
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
#if defined (_WIN)
|
||||
|
||||
BOOL WINAPI sigHandler_default (DWORD sig);
|
||||
@ -53,6 +54,7 @@ void sigHandler_benchmark (int sig);
|
||||
void hc_signal (void (callback) (int));
|
||||
|
||||
#endif
|
||||
*/
|
||||
|
||||
void mycracked (status_ctx_t *status_ctx);
|
||||
void myabort (status_ctx_t *status_ctx);
|
||||
|
@ -55,6 +55,10 @@ typedef struct timeval hc_timer_t;
|
||||
|
||||
// thread
|
||||
|
||||
#if defined (_POSIX)
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#if defined (_WIN)
|
||||
typedef HANDLE hc_thread_t;
|
||||
typedef CRITICAL_SECTION hc_thread_mutex_t;
|
||||
@ -1330,6 +1334,8 @@ typedef struct
|
||||
combinator_ctx_t *combinator_ctx;
|
||||
cpt_ctx_t *cpt_ctx;
|
||||
debugfile_ctx_t *debugfile_ctx;
|
||||
dictstat_ctx_t *dictstat_ctx;
|
||||
folder_config_t *folder_config;
|
||||
hashconfig_t *hashconfig;
|
||||
hashes_t *hashes;
|
||||
hwmon_ctx_t *hwmon_ctx;
|
||||
@ -1347,7 +1353,16 @@ typedef struct
|
||||
tuning_db_t *tuning_db;
|
||||
user_options_extra_t *user_options_extra;
|
||||
user_options_t *user_options;
|
||||
wl_data_t *wl_data;
|
||||
|
||||
} hc_global_data_t;
|
||||
} hashcat_ctx_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 tid;
|
||||
|
||||
hashcat_ctx_t *hashcat_ctx;
|
||||
|
||||
} thread_param_t;
|
||||
|
||||
#endif // _TYPES_H
|
||||
|
@ -6,6 +6,6 @@
|
||||
#ifndef _WEAK_HASH_H
|
||||
#define _WEAK_HASH_H
|
||||
|
||||
void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, status_ctx_t *status_ctx, const uint salt_pos);
|
||||
void weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const uint salt_pos);
|
||||
|
||||
#endif // _WEAK_HASH_H
|
||||
|
37
src/Makefile
37
src/Makefile
@ -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 data debugfile dictstat dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder 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 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)
|
||||
|
||||
@ -257,8 +257,11 @@ uninstall:
|
||||
obj/%.NATIVE.o: src/%.c
|
||||
$(CC) $(CFLAGS_NATIVE) -c -o $@ $<
|
||||
|
||||
hashcat: src/hashcat.c $(NATIVE_OBJS)
|
||||
$(CC) $(CFLAGS_NATIVE) -o $(BINARY_NATIVE) $^ $(LFLAGS_NATIVE) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
|
||||
obj/hashcat.NATIVE.o: src/hashcat.c
|
||||
$(CC) $(CFLAGS_NATIVE) -c -o $@ $< -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
|
||||
|
||||
$(BINARY_NATIVE): src/main.c $(NATIVE_OBJS)
|
||||
$(CC) $(CFLAGS_NATIVE) -o $(BINARY_NATIVE) $^ $(LFLAGS_NATIVE)
|
||||
|
||||
##
|
||||
## cross compiled hashcat for binary release version
|
||||
@ -276,14 +279,26 @@ obj/%.WIN.32.o: src/%.c
|
||||
obj/%.WIN.64.o: src/%.c
|
||||
$(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -c -o $@ $<
|
||||
|
||||
hashcat32.bin: src/hashcat.c $(LINUX_32_OBJS)
|
||||
$(CC_LINUX_32) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
|
||||
obj/hashcat.LINUX.32.o: src/hashcat.c
|
||||
$(CC_LINUX_32) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) -c -o $@ $< -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
|
||||
|
||||
hashcat64.bin: src/hashcat.c $(LINUX_64_OBJS)
|
||||
$(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
|
||||
obj/hashcat.LINUX.64.o: src/hashcat.c
|
||||
$(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -c -o $@ $< -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
|
||||
|
||||
hashcat32.exe: src/hashcat.c $(WIN_32_OBJS)
|
||||
$(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\"
|
||||
obj/hashcat.WIN.32.o: src/hashcat.c
|
||||
$(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -c -o $@ $< -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\"
|
||||
|
||||
hashcat64.exe: src/hashcat.c $(WIN_64_OBJS)
|
||||
$(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\"
|
||||
obj/hashcat.WIN.64.o: src/hashcat.c
|
||||
$(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -c -o $@ $< -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\"
|
||||
|
||||
hashcat32.bin: src/main.c $(LINUX_32_OBJS)
|
||||
$(CC_LINUX_32) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_LINUX)
|
||||
|
||||
hashcat64.bin: src/main.c $(LINUX_64_OBJS)
|
||||
$(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_LINUX)
|
||||
|
||||
hashcat32.exe: src/main.c $(WIN_32_OBJS)
|
||||
$(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_WIN)
|
||||
|
||||
hashcat64.exe: src/main.c $(WIN_64_OBJS)
|
||||
$(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_WIN)
|
||||
|
@ -5,15 +5,12 @@
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "data.h"
|
||||
#include "logging.h"
|
||||
#include "opencl.h"
|
||||
#include "status.h"
|
||||
#include "terminal.h"
|
||||
#include "autotune.h"
|
||||
|
||||
extern hc_global_data_t data;
|
||||
|
||||
static double try_run (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options, status_ctx_t *status_ctx, const u32 kernel_accel, const u32 kernel_loops)
|
||||
{
|
||||
const u32 kernel_power_try = device_param->device_processors * device_param->kernel_threads * kernel_accel;
|
||||
@ -36,8 +33,15 @@ static double try_run (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param
|
||||
return exec_ms_prev;
|
||||
}
|
||||
|
||||
int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, status_ctx_t *status_ctx)
|
||||
static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
{
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
||||
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
const double target_ms = opencl_ctx->target_ms;
|
||||
|
||||
const u32 kernel_accel_min = device_param->kernel_accel_min;
|
||||
@ -295,18 +299,19 @@ int autotune (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashcon
|
||||
|
||||
void *thread_autotune (void *p)
|
||||
{
|
||||
hc_device_param_t *device_param = (hc_device_param_t *) p;
|
||||
thread_param_t *thread_param = (thread_param_t *) p;
|
||||
|
||||
hashcat_ctx_t *hashcat_ctx = thread_param->hashcat_ctx;
|
||||
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
|
||||
if (opencl_ctx->enabled == false) return NULL;
|
||||
|
||||
hc_device_param_t *device_param = opencl_ctx->devices_param + thread_param->tid;
|
||||
|
||||
if (device_param->skipped) return NULL;
|
||||
|
||||
user_options_t *user_options = data.user_options;
|
||||
user_options_extra_t *user_options_extra = data.user_options_extra;
|
||||
hashconfig_t *hashconfig = data.hashconfig;
|
||||
straight_ctx_t *straight_ctx = data.straight_ctx;
|
||||
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
|
||||
status_ctx_t *status_ctx = data.status_ctx;
|
||||
|
||||
autotune (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, straight_ctx, status_ctx);
|
||||
autotune (hashcat_ctx, device_param);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
10
src/data.c
10
src/data.c
@ -1,10 +0,0 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "data.h"
|
||||
|
||||
hc_global_data_t data;
|
@ -9,8 +9,6 @@
|
||||
#include "logging.h"
|
||||
#include "dictstat.h"
|
||||
|
||||
extern const int comptime;
|
||||
|
||||
int sort_by_dictstat (const void *s1, const void *s2)
|
||||
{
|
||||
dictstat_t *d1 = (dictstat_t *) s1;
|
||||
@ -63,7 +61,7 @@ void dictstat_destroy (dictstat_ctx_t *dictstat_ctx)
|
||||
myfree (dictstat_ctx);
|
||||
}
|
||||
|
||||
void dictstat_read (dictstat_ctx_t *dictstat_ctx)
|
||||
void dictstat_read (dictstat_ctx_t *dictstat_ctx, const int comptime)
|
||||
{
|
||||
if (dictstat_ctx->enabled == false) return;
|
||||
|
||||
|
@ -31,13 +31,10 @@
|
||||
#include "status.h"
|
||||
#include "dictstat.h"
|
||||
#include "wordlist.h"
|
||||
#include "data.h"
|
||||
#include "status.h"
|
||||
#include "shared.h"
|
||||
#include "dispatch.h"
|
||||
|
||||
extern hc_global_data_t data;
|
||||
|
||||
static void set_kernel_power_final (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const u64 kernel_power_final)
|
||||
{
|
||||
if (user_options->quiet == false)
|
||||
@ -109,23 +106,16 @@ static uint get_work (opencl_ctx_t *opencl_ctx, status_ctx_t *status_ctx, const
|
||||
return work;
|
||||
}
|
||||
|
||||
void *thread_calc_stdin (void *p)
|
||||
static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
{
|
||||
hc_device_param_t *device_param = (hc_device_param_t *) p;
|
||||
|
||||
if (device_param->skipped) return NULL;
|
||||
|
||||
user_options_t *user_options = data.user_options;
|
||||
user_options_extra_t *user_options_extra = data.user_options_extra;
|
||||
hashconfig_t *hashconfig = data.hashconfig;
|
||||
hashes_t *hashes = data.hashes;
|
||||
cpt_ctx_t *cpt_ctx = data.cpt_ctx;
|
||||
straight_ctx_t *straight_ctx = data.straight_ctx;
|
||||
combinator_ctx_t *combinator_ctx = data.combinator_ctx;
|
||||
mask_ctx_t *mask_ctx = data.mask_ctx;
|
||||
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
|
||||
outfile_ctx_t *outfile_ctx = data.outfile_ctx;
|
||||
status_ctx_t *status_ctx = data.status_ctx;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
||||
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
@ -216,7 +206,7 @@ void *thread_calc_stdin (void *p)
|
||||
{
|
||||
run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, combinator_ctx, pws_cnt);
|
||||
|
||||
run_cracker (opencl_ctx, device_param, hashconfig, hashes, cpt_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, status_ctx, pws_cnt);
|
||||
run_cracker (hashcat_ctx, device_param, pws_cnt);
|
||||
|
||||
device_param->pws_cnt = 0;
|
||||
|
||||
@ -238,27 +228,37 @@ void *thread_calc_stdin (void *p)
|
||||
device_param->kernel_loops = 0;
|
||||
|
||||
myfree (buf);
|
||||
}
|
||||
|
||||
void *thread_calc_stdin (void *p)
|
||||
{
|
||||
thread_param_t *thread_param = (thread_param_t *) p;
|
||||
|
||||
hashcat_ctx_t *hashcat_ctx = thread_param->hashcat_ctx;
|
||||
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
|
||||
if (opencl_ctx->enabled == false) return NULL;
|
||||
|
||||
hc_device_param_t *device_param = opencl_ctx->devices_param + thread_param->tid;
|
||||
|
||||
if (device_param->skipped) return NULL;
|
||||
|
||||
calc_stdin (hashcat_ctx, device_param);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *thread_calc (void *p)
|
||||
static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
|
||||
{
|
||||
hc_device_param_t *device_param = (hc_device_param_t *) p;
|
||||
|
||||
if (device_param->skipped) return NULL;
|
||||
|
||||
user_options_t *user_options = data.user_options;
|
||||
user_options_extra_t *user_options_extra = data.user_options_extra;
|
||||
hashconfig_t *hashconfig = data.hashconfig;
|
||||
hashes_t *hashes = data.hashes;
|
||||
cpt_ctx_t *cpt_ctx = data.cpt_ctx;
|
||||
straight_ctx_t *straight_ctx = data.straight_ctx;
|
||||
combinator_ctx_t *combinator_ctx = data.combinator_ctx;
|
||||
mask_ctx_t *mask_ctx = data.mask_ctx;
|
||||
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
|
||||
outfile_ctx_t *outfile_ctx = data.outfile_ctx;
|
||||
status_ctx_t *status_ctx = data.status_ctx;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
||||
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
const uint attack_mode = user_options->attack_mode;
|
||||
const uint attack_kern = user_options_extra->attack_kern;
|
||||
@ -282,7 +282,7 @@ void *thread_calc (void *p)
|
||||
{
|
||||
run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, combinator_ctx, pws_cnt);
|
||||
|
||||
run_cracker (opencl_ctx, device_param, hashconfig, hashes, cpt_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, status_ctx, pws_cnt);
|
||||
run_cracker (hashcat_ctx, device_param, pws_cnt);
|
||||
|
||||
device_param->pws_cnt = 0;
|
||||
|
||||
@ -321,7 +321,7 @@ void *thread_calc (void *p)
|
||||
{
|
||||
log_error ("ERROR: %s: %s", dictfile, strerror (errno));
|
||||
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
if (attack_mode == ATTACK_MODE_COMBI)
|
||||
@ -340,7 +340,7 @@ void *thread_calc (void *p)
|
||||
|
||||
fclose (fd);
|
||||
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
device_param->combs_fp = combs_fp;
|
||||
@ -357,7 +357,7 @@ void *thread_calc (void *p)
|
||||
|
||||
fclose (fd);
|
||||
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
device_param->combs_fp = combs_fp;
|
||||
@ -478,7 +478,7 @@ void *thread_calc (void *p)
|
||||
{
|
||||
run_copy (opencl_ctx, device_param, hashconfig, user_options, user_options_extra, combinator_ctx, pws_cnt);
|
||||
|
||||
run_cracker (opencl_ctx, device_param, hashconfig, hashes, cpt_ctx, user_options, user_options_extra, straight_ctx, combinator_ctx, mask_ctx, outfile_ctx, status_ctx, pws_cnt);
|
||||
run_cracker (hashcat_ctx, device_param, pws_cnt);
|
||||
|
||||
device_param->pws_cnt = 0;
|
||||
|
||||
@ -514,6 +514,23 @@ void *thread_calc (void *p)
|
||||
|
||||
device_param->kernel_accel = 0;
|
||||
device_param->kernel_loops = 0;
|
||||
}
|
||||
|
||||
void *thread_calc (void *p)
|
||||
{
|
||||
thread_param_t *thread_param = (thread_param_t *) p;
|
||||
|
||||
hashcat_ctx_t *hashcat_ctx = thread_param->hashcat_ctx;
|
||||
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
|
||||
if (opencl_ctx->enabled == false) return NULL;
|
||||
|
||||
hc_device_param_t *device_param = opencl_ctx->devices_param + thread_param->tid;
|
||||
|
||||
if (device_param->skipped) return NULL;
|
||||
|
||||
calc (hashcat_ctx, device_param);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
166
src/hashcat.c
166
src/hashcat.c
@ -53,20 +53,31 @@
|
||||
#include "weak_hash.h"
|
||||
#include "wordlist.h"
|
||||
|
||||
extern hc_global_data_t data;
|
||||
|
||||
extern bool SUPPRESS_OUTPUT;
|
||||
|
||||
extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_CNT;
|
||||
extern const u32 DEFAULT_BENCHMARK_ALGORITHMS_BUF[];
|
||||
|
||||
const int comptime = COMPTIME;
|
||||
const char *version_tag = VERSION_TAG;
|
||||
|
||||
// inner2_loop iterates through wordlists, then calls kernel execution
|
||||
|
||||
static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options, user_options_extra_t *user_options_extra, restore_ctx_t *restore_ctx, logfile_ctx_t *logfile_ctx, induct_ctx_t *induct_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx, hwmon_ctx_t *hwmon_ctx, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, wl_data_t *wl_data, straight_ctx_t *straight_ctx, combinator_ctx_t *combinator_ctx, mask_ctx_t *mask_ctx)
|
||||
static int inner2_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
|
||||
cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
|
||||
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
||||
induct_ctx_t *induct_ctx = hashcat_ctx->induct_ctx;
|
||||
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
|
||||
loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx;
|
||||
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
||||
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
wl_data_t *wl_data = hashcat_ctx->wl_data;
|
||||
|
||||
//status_ctx->run_main_level1 = true;
|
||||
//status_ctx->run_main_level2 = true;
|
||||
//status_ctx->run_main_level3 = true;
|
||||
@ -311,15 +322,20 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
|
||||
* create autotune threads
|
||||
*/
|
||||
|
||||
thread_param_t *threads_param = (thread_param_t *) mycalloc (opencl_ctx->devices_cnt, sizeof (thread_param_t));
|
||||
|
||||
hc_thread_t *c_threads = (hc_thread_t *) mycalloc (opencl_ctx->devices_cnt, sizeof (hc_thread_t));
|
||||
|
||||
status_ctx->devices_status = STATUS_AUTOTUNE;
|
||||
|
||||
for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
||||
{
|
||||
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
|
||||
thread_param_t *thread_param = threads_param + device_id;
|
||||
|
||||
hc_thread_create (c_threads[device_id], thread_autotune, device_param);
|
||||
thread_param->hashcat_ctx = hashcat_ctx;
|
||||
thread_param->tid = device_id;
|
||||
|
||||
hc_thread_create (c_threads[device_id], thread_autotune, thread_param);
|
||||
}
|
||||
|
||||
hc_thread_wait (opencl_ctx->devices_cnt, c_threads);
|
||||
@ -378,15 +394,18 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
|
||||
|
||||
for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
||||
{
|
||||
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
|
||||
thread_param_t *thread_param = threads_param + device_id;
|
||||
|
||||
thread_param->hashcat_ctx = hashcat_ctx;
|
||||
thread_param->tid = device_id;
|
||||
|
||||
if (user_options_extra->wordlist_mode == WL_MODE_STDIN)
|
||||
{
|
||||
hc_thread_create (c_threads[device_id], thread_calc_stdin, device_param);
|
||||
hc_thread_create (c_threads[device_id], thread_calc_stdin, thread_param);
|
||||
}
|
||||
else
|
||||
{
|
||||
hc_thread_create (c_threads[device_id], thread_calc, device_param);
|
||||
hc_thread_create (c_threads[device_id], thread_calc, thread_param);
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,6 +413,8 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
|
||||
|
||||
myfree (c_threads);
|
||||
|
||||
myfree (threads_param);
|
||||
|
||||
// calculate final status
|
||||
|
||||
if ((status_ctx->devices_status != STATUS_CRACKED)
|
||||
@ -479,7 +500,7 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
|
||||
{
|
||||
for (induct_ctx->induction_dictionaries_pos = 0; induct_ctx->induction_dictionaries_pos < induct_ctx->induction_dictionaries_cnt; induct_ctx->induction_dictionaries_pos++)
|
||||
{
|
||||
const int rc_inner2_loop = inner2_loop (status_ctx, user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, wl_data, straight_ctx, combinator_ctx, mask_ctx);
|
||||
const int rc_inner2_loop = inner2_loop (hashcat_ctx);
|
||||
|
||||
if (rc_inner2_loop == -1) return -1;
|
||||
|
||||
@ -499,8 +520,22 @@ static int inner2_loop (status_ctx_t *status_ctx, user_options_t *user_options,
|
||||
|
||||
// inner1_loop iterates through masks, then calls inner2_loop
|
||||
|
||||
static int inner1_loop (status_ctx_t *status_ctx, user_options_t *user_options, user_options_extra_t *user_options_extra, restore_ctx_t *restore_ctx, logfile_ctx_t *logfile_ctx, induct_ctx_t *induct_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx, hwmon_ctx_t *hwmon_ctx, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, wl_data_t *wl_data, straight_ctx_t *straight_ctx, combinator_ctx_t *combinator_ctx, mask_ctx_t *mask_ctx)
|
||||
static int inner1_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
|
||||
dictstat_ctx_t *dictstat_ctx = hashcat_ctx->dictstat_ctx;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
|
||||
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
||||
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
wl_data_t *wl_data = hashcat_ctx->wl_data;
|
||||
|
||||
//status_ctx->run_main_level1 = true;
|
||||
//status_ctx->run_main_level2 = true;
|
||||
status_ctx->run_main_level3 = true;
|
||||
@ -756,7 +791,7 @@ static int inner1_loop (status_ctx_t *status_ctx, user_options_t *user_options,
|
||||
* dictstat read
|
||||
*/
|
||||
|
||||
dictstat_read (dictstat_ctx);
|
||||
dictstat_read (dictstat_ctx, COMPTIME);
|
||||
|
||||
/**
|
||||
* dictionary pad
|
||||
@ -1154,7 +1189,7 @@ static int inner1_loop (status_ctx_t *status_ctx, user_options_t *user_options,
|
||||
|
||||
straight_ctx->dicts_pos = dicts_pos;
|
||||
|
||||
const int rc_inner2_loop = inner2_loop (status_ctx, user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, wl_data, straight_ctx, combinator_ctx, mask_ctx);
|
||||
const int rc_inner2_loop = inner2_loop (hashcat_ctx);
|
||||
|
||||
if (rc_inner2_loop == -1) return -1;
|
||||
|
||||
@ -1163,7 +1198,7 @@ static int inner1_loop (status_ctx_t *status_ctx, user_options_t *user_options,
|
||||
}
|
||||
else
|
||||
{
|
||||
const int rc_inner2_loop = inner2_loop (status_ctx, user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, wl_data, straight_ctx, combinator_ctx, mask_ctx);
|
||||
const int rc_inner2_loop = inner2_loop (hashcat_ctx);
|
||||
|
||||
if (rc_inner2_loop == -1) return -1;
|
||||
}
|
||||
@ -1173,8 +1208,21 @@ static int inner1_loop (status_ctx_t *status_ctx, user_options_t *user_options,
|
||||
|
||||
// outer_loop iterates through hash_modes (in benchmark mode)
|
||||
|
||||
static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, user_options_extra_t *user_options_extra, restore_ctx_t *restore_ctx, folder_config_t *folder_config, logfile_ctx_t *logfile_ctx, tuning_db_t *tuning_db, induct_ctx_t *induct_ctx, outcheck_ctx_t *outcheck_ctx, outfile_ctx_t *outfile_ctx, potfile_ctx_t *potfile_ctx, dictstat_ctx_t *dictstat_ctx, loopback_ctx_t *loopback_ctx, opencl_ctx_t *opencl_ctx, hwmon_ctx_t *hwmon_ctx)
|
||||
static int outer_loop (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
folder_config_t *folder_config = hashcat_ctx->folder_config;
|
||||
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
||||
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_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;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
tuning_db_t *tuning_db = hashcat_ctx->tuning_db;
|
||||
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
status_ctx->devices_status = STATUS_INIT;
|
||||
|
||||
//status_ctx->run_main_level1 = true;
|
||||
@ -1195,7 +1243,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
|
||||
hashconfig_t *hashconfig = (hashconfig_t *) mymalloc (sizeof (hashconfig_t));
|
||||
|
||||
data.hashconfig = hashconfig;
|
||||
hashcat_ctx->hashconfig = hashconfig;
|
||||
|
||||
const int rc_hashconfig = hashconfig_init (hashconfig, user_options);
|
||||
|
||||
@ -1209,15 +1257,11 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
{
|
||||
outfile_write_open (outfile_ctx);
|
||||
|
||||
SUPPRESS_OUTPUT = true;
|
||||
|
||||
potfile_read_open (potfile_ctx);
|
||||
|
||||
potfile_read_parse (potfile_ctx, hashconfig);
|
||||
|
||||
potfile_read_close (potfile_ctx);
|
||||
|
||||
SUPPRESS_OUTPUT = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1226,7 +1270,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
|
||||
hashes_t *hashes = (hashes_t *) mymalloc (sizeof (hashes_t));
|
||||
|
||||
data.hashes = hashes;
|
||||
hashcat_ctx->hashes = hashes;
|
||||
|
||||
const int rc_hashes_init_stage1 = hashes_init_stage1 (hashes, hashconfig, potfile_ctx, outfile_ctx, user_options, restore_ctx->argv[user_options_extra->optind]);
|
||||
|
||||
@ -1294,7 +1338,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
|
||||
bitmap_ctx_t *bitmap_ctx = (bitmap_ctx_t *) mymalloc (sizeof (bitmap_ctx_t));
|
||||
|
||||
data.bitmap_ctx = bitmap_ctx;
|
||||
hashcat_ctx->bitmap_ctx = bitmap_ctx;
|
||||
|
||||
bitmap_ctx_init (bitmap_ctx, user_options, hashconfig, hashes);
|
||||
|
||||
@ -1304,7 +1348,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
|
||||
cpt_ctx_t *cpt_ctx = (cpt_ctx_t *) mymalloc (sizeof (cpt_ctx_t));
|
||||
|
||||
data.cpt_ctx = cpt_ctx;
|
||||
hashcat_ctx->cpt_ctx = cpt_ctx;
|
||||
|
||||
cpt_ctx_init (cpt_ctx, user_options);
|
||||
|
||||
@ -1314,6 +1358,8 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
|
||||
wl_data_t *wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
|
||||
|
||||
hashcat_ctx->wl_data = wl_data;
|
||||
|
||||
wl_data_init (wl_data, user_options, hashconfig);
|
||||
|
||||
/**
|
||||
@ -1322,7 +1368,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
|
||||
straight_ctx_t *straight_ctx = (straight_ctx_t *) mymalloc (sizeof (straight_ctx_t));
|
||||
|
||||
data.straight_ctx = straight_ctx;
|
||||
hashcat_ctx->straight_ctx = straight_ctx;
|
||||
|
||||
const int rc_straight_init = straight_ctx_init (straight_ctx, user_options);
|
||||
|
||||
@ -1334,7 +1380,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
|
||||
combinator_ctx_t *combinator_ctx = (combinator_ctx_t *) mymalloc (sizeof (combinator_ctx_t));
|
||||
|
||||
data.combinator_ctx = combinator_ctx;
|
||||
hashcat_ctx->combinator_ctx = combinator_ctx;
|
||||
|
||||
const int rc_combinator_init = combinator_ctx_init (combinator_ctx, user_options);
|
||||
|
||||
@ -1346,7 +1392,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
|
||||
mask_ctx_t *mask_ctx = (mask_ctx_t *) mymalloc (sizeof (mask_ctx_t));
|
||||
|
||||
data.mask_ctx = mask_ctx;
|
||||
hashcat_ctx->mask_ctx = mask_ctx;
|
||||
|
||||
const int rc_mask_init = mask_ctx_init (mask_ctx, user_options, user_options_extra, folder_config, restore_ctx, hashconfig);
|
||||
|
||||
@ -1362,8 +1408,11 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
|
||||
/**
|
||||
* enable custom signal handler(s)
|
||||
* currently disabled, because man page says:
|
||||
* The effects of signal() in a multithreaded process are unspecified.
|
||||
*/
|
||||
|
||||
/*
|
||||
if (user_options->benchmark == false)
|
||||
{
|
||||
hc_signal (sigHandler_default);
|
||||
@ -1372,6 +1421,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
{
|
||||
hc_signal (sigHandler_benchmark);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* inform the user
|
||||
@ -1486,7 +1536,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
|
||||
for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
|
||||
{
|
||||
weak_hash_check (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, hashconfig, hashes, cpt_ctx, status_ctx, salt_pos);
|
||||
weak_hash_check (hashcat_ctx, device_param, salt_pos);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1506,13 +1556,13 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
|
||||
if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false)
|
||||
{
|
||||
hc_thread_create (inner_threads[inner_threads_cnt], thread_monitor, NULL);
|
||||
hc_thread_create (inner_threads[inner_threads_cnt], thread_monitor, hashcat_ctx);
|
||||
|
||||
inner_threads_cnt++;
|
||||
|
||||
if (outcheck_ctx->enabled == true)
|
||||
{
|
||||
hc_thread_create (inner_threads[inner_threads_cnt], thread_outfile_remove, NULL);
|
||||
hc_thread_create (inner_threads[inner_threads_cnt], thread_outfile_remove, hashcat_ctx);
|
||||
|
||||
inner_threads_cnt++;
|
||||
}
|
||||
@ -1556,7 +1606,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
|
||||
mask_ctx->masks_pos = masks_pos;
|
||||
|
||||
const int rc_inner1_loop = inner1_loop (status_ctx, user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, wl_data, straight_ctx, combinator_ctx, mask_ctx);
|
||||
const int rc_inner1_loop = inner1_loop (hashcat_ctx);
|
||||
|
||||
if (rc_inner1_loop == -1) return -1;
|
||||
|
||||
@ -1565,7 +1615,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
}
|
||||
else
|
||||
{
|
||||
const int rc_inner1_loop = inner1_loop (status_ctx, user_options, user_options_extra, restore_ctx, logfile_ctx, induct_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx, hashconfig, hashes, cpt_ctx, wl_data, straight_ctx, combinator_ctx, mask_ctx);
|
||||
const int rc_inner1_loop = inner1_loop (hashcat_ctx);
|
||||
|
||||
if (rc_inner1_loop == -1) return -1;
|
||||
}
|
||||
@ -1637,7 +1687,7 @@ static int outer_loop (status_ctx_t *status_ctx, user_options_t *user_options, u
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
int hashcat (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
|
||||
{
|
||||
/**
|
||||
* To help users a bit
|
||||
@ -1657,7 +1707,7 @@ int main (int argc, char **argv)
|
||||
|
||||
status_ctx_t *status_ctx = (status_ctx_t *) mymalloc (sizeof (status_ctx_t));
|
||||
|
||||
data.status_ctx = status_ctx;
|
||||
hashcat_ctx->status_ctx = status_ctx;
|
||||
|
||||
const int rc_status_init = status_ctx_init (status_ctx);
|
||||
|
||||
@ -1680,6 +1730,8 @@ int main (int argc, char **argv)
|
||||
|
||||
folder_config_t *folder_config = (folder_config_t *) mymalloc (sizeof (folder_config_t));
|
||||
|
||||
hashcat_ctx->folder_config = folder_config;
|
||||
|
||||
folder_config_init (folder_config, install_folder, shared_folder);
|
||||
|
||||
/**
|
||||
@ -1688,7 +1740,7 @@ int main (int argc, char **argv)
|
||||
|
||||
user_options_t *user_options = (user_options_t *) mymalloc (sizeof (user_options_t));
|
||||
|
||||
data.user_options = user_options;
|
||||
hashcat_ctx->user_options = user_options;
|
||||
|
||||
user_options_init (user_options);
|
||||
|
||||
@ -1720,7 +1772,7 @@ int main (int argc, char **argv)
|
||||
|
||||
restore_ctx_t *restore_ctx = (restore_ctx_t *) mymalloc (sizeof (restore_ctx_t));
|
||||
|
||||
data.restore_ctx = restore_ctx;
|
||||
hashcat_ctx->restore_ctx = restore_ctx;
|
||||
|
||||
const int rc_restore_init = restore_ctx_init (restore_ctx, user_options, folder_config, argc, argv);
|
||||
|
||||
@ -1732,7 +1784,7 @@ int main (int argc, char **argv)
|
||||
|
||||
user_options_extra_t *user_options_extra = (user_options_extra_t *) mymalloc (sizeof (user_options_extra_t));
|
||||
|
||||
data.user_options_extra = user_options_extra;
|
||||
hashcat_ctx->user_options_extra = user_options_extra;
|
||||
|
||||
const int rc_user_options_extra_init = user_options_extra_init (user_options, restore_ctx, user_options_extra);
|
||||
|
||||
@ -1753,7 +1805,7 @@ int main (int argc, char **argv)
|
||||
* - this is giving us a visual header before preparations start, so we do not need to clear them afterwards
|
||||
*/
|
||||
|
||||
welcome_screen (user_options, status_ctx);
|
||||
welcome_screen (user_options, status_ctx, VERSION_TAG);
|
||||
|
||||
/**
|
||||
* logfile init
|
||||
@ -1761,7 +1813,7 @@ int main (int argc, char **argv)
|
||||
|
||||
logfile_ctx_t *logfile_ctx = (logfile_ctx_t *) mymalloc (sizeof (logfile_ctx_t));
|
||||
|
||||
data.logfile_ctx = logfile_ctx;
|
||||
hashcat_ctx->logfile_ctx = logfile_ctx;
|
||||
|
||||
logfile_init (logfile_ctx, user_options, folder_config);
|
||||
|
||||
@ -1777,7 +1829,7 @@ int main (int argc, char **argv)
|
||||
|
||||
tuning_db_t *tuning_db = (tuning_db_t *) mymalloc (sizeof (tuning_db_t));
|
||||
|
||||
data.tuning_db = tuning_db;
|
||||
hashcat_ctx->tuning_db = tuning_db;
|
||||
|
||||
const int rc_tuning_db = tuning_db_init (tuning_db, user_options, folder_config);
|
||||
|
||||
@ -1789,7 +1841,7 @@ int main (int argc, char **argv)
|
||||
|
||||
induct_ctx_t *induct_ctx = (induct_ctx_t *) mymalloc (sizeof (induct_ctx_t));
|
||||
|
||||
data.induct_ctx = induct_ctx;
|
||||
hashcat_ctx->induct_ctx = induct_ctx;
|
||||
|
||||
const int rc_induct_ctx_init = induct_ctx_init (induct_ctx, user_options, folder_config, status_ctx);
|
||||
|
||||
@ -1801,7 +1853,7 @@ int main (int argc, char **argv)
|
||||
|
||||
outcheck_ctx_t *outcheck_ctx = (outcheck_ctx_t *) mymalloc (sizeof (outcheck_ctx_t));
|
||||
|
||||
data.outcheck_ctx = outcheck_ctx;
|
||||
hashcat_ctx->outcheck_ctx = outcheck_ctx;
|
||||
|
||||
const int rc_outcheck_ctx_init = outcheck_ctx_init (outcheck_ctx, user_options, folder_config);
|
||||
|
||||
@ -1813,7 +1865,7 @@ int main (int argc, char **argv)
|
||||
|
||||
outfile_ctx_t *outfile_ctx = mymalloc (sizeof (outfile_ctx_t));
|
||||
|
||||
data.outfile_ctx = outfile_ctx;
|
||||
hashcat_ctx->outfile_ctx = outfile_ctx;
|
||||
|
||||
outfile_init (outfile_ctx, user_options);
|
||||
|
||||
@ -1833,7 +1885,7 @@ int main (int argc, char **argv)
|
||||
|
||||
potfile_ctx_t *potfile_ctx = mymalloc (sizeof (potfile_ctx_t));
|
||||
|
||||
data.potfile_ctx = potfile_ctx;
|
||||
hashcat_ctx->potfile_ctx = potfile_ctx;
|
||||
|
||||
potfile_init (potfile_ctx, user_options, folder_config);
|
||||
|
||||
@ -1843,6 +1895,8 @@ int main (int argc, char **argv)
|
||||
|
||||
dictstat_ctx_t *dictstat_ctx = mymalloc (sizeof (dictstat_ctx_t));
|
||||
|
||||
hashcat_ctx->dictstat_ctx = dictstat_ctx;
|
||||
|
||||
dictstat_init (dictstat_ctx, user_options, folder_config);
|
||||
|
||||
/**
|
||||
@ -1851,7 +1905,7 @@ int main (int argc, char **argv)
|
||||
|
||||
loopback_ctx_t *loopback_ctx = mymalloc (sizeof (loopback_ctx_t));
|
||||
|
||||
data.loopback_ctx = loopback_ctx;
|
||||
hashcat_ctx->loopback_ctx = loopback_ctx;
|
||||
|
||||
loopback_init (loopback_ctx, user_options);
|
||||
|
||||
@ -1861,7 +1915,7 @@ int main (int argc, char **argv)
|
||||
|
||||
debugfile_ctx_t *debugfile_ctx = mymalloc (sizeof (debugfile_ctx_t));
|
||||
|
||||
data.debugfile_ctx = debugfile_ctx;
|
||||
hashcat_ctx->debugfile_ctx = debugfile_ctx;
|
||||
|
||||
debugfile_init (debugfile_ctx, user_options);
|
||||
|
||||
@ -1880,7 +1934,7 @@ int main (int argc, char **argv)
|
||||
|
||||
opencl_ctx_t *opencl_ctx = (opencl_ctx_t *) mymalloc (sizeof (opencl_ctx_t));
|
||||
|
||||
data.opencl_ctx = opencl_ctx;
|
||||
hashcat_ctx->opencl_ctx = opencl_ctx;
|
||||
|
||||
const int rc_opencl_init = opencl_ctx_init (opencl_ctx, user_options);
|
||||
|
||||
@ -1895,7 +1949,7 @@ int main (int argc, char **argv)
|
||||
* Init OpenCL devices
|
||||
*/
|
||||
|
||||
const int rc_devices_init = opencl_ctx_devices_init (opencl_ctx, user_options);
|
||||
const int rc_devices_init = opencl_ctx_devices_init (opencl_ctx, user_options, COMPTIME);
|
||||
|
||||
if (rc_devices_init == -1)
|
||||
{
|
||||
@ -1910,7 +1964,7 @@ int main (int argc, char **argv)
|
||||
|
||||
hwmon_ctx_t *hwmon_ctx = (hwmon_ctx_t *) mymalloc (sizeof (hwmon_ctx_t));
|
||||
|
||||
data.hwmon_ctx = hwmon_ctx;
|
||||
hashcat_ctx->hwmon_ctx = hwmon_ctx;
|
||||
|
||||
const int rc_hwmon_init = hwmon_ctx_init (hwmon_ctx, user_options, opencl_ctx);
|
||||
|
||||
@ -1935,7 +1989,7 @@ int main (int argc, char **argv)
|
||||
{
|
||||
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
|
||||
{
|
||||
hc_thread_create (outer_threads[outer_threads_cnt], thread_keypress, NULL);
|
||||
hc_thread_create (outer_threads[outer_threads_cnt], thread_keypress, hashcat_ctx);
|
||||
|
||||
outer_threads_cnt++;
|
||||
}
|
||||
@ -1951,7 +2005,7 @@ int main (int argc, char **argv)
|
||||
|
||||
if (user_options->hash_mode_chgd == true)
|
||||
{
|
||||
const int rc = outer_loop (status_ctx, user_options, user_options_extra, restore_ctx, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx);
|
||||
const int rc = outer_loop (hashcat_ctx);
|
||||
|
||||
if (rc == -1) return -1;
|
||||
}
|
||||
@ -1961,7 +2015,7 @@ int main (int argc, char **argv)
|
||||
{
|
||||
user_options->hash_mode = DEFAULT_BENCHMARK_ALGORITHMS_BUF[algorithm_pos];
|
||||
|
||||
const int rc = outer_loop (status_ctx, user_options, user_options_extra, restore_ctx, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx);
|
||||
const int rc = outer_loop (hashcat_ctx);
|
||||
|
||||
if (rc == -1) return -1;
|
||||
|
||||
@ -1971,7 +2025,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
else
|
||||
{
|
||||
const int rc = outer_loop (status_ctx, user_options, user_options_extra, restore_ctx, folder_config, logfile_ctx, tuning_db, induct_ctx, outcheck_ctx, outfile_ctx, potfile_ctx, dictstat_ctx, loopback_ctx, opencl_ctx, hwmon_ctx);
|
||||
const int rc = outer_loop (hashcat_ctx);
|
||||
|
||||
if (rc == -1) return -1;
|
||||
}
|
||||
|
69
src/hashes.c
69
src/hashes.c
@ -9,7 +9,6 @@
|
||||
#include "logging.h"
|
||||
#include "hashes.h"
|
||||
|
||||
#include "data.h"
|
||||
#include "debugfile.h"
|
||||
#include "filehandling.h"
|
||||
#include "hlfmt.h"
|
||||
@ -26,17 +25,17 @@
|
||||
#include "thread.h"
|
||||
#include "timer.h"
|
||||
|
||||
extern hc_global_data_t data;
|
||||
|
||||
int sort_by_digest_p0p1 (const void *v1, const void *v2)
|
||||
int sort_by_digest_p0p1 (const void *v1, const void *v2, void *v3)
|
||||
{
|
||||
const u32 *d1 = (const u32 *) v1;
|
||||
const u32 *d2 = (const u32 *) v2;
|
||||
|
||||
const uint dgst_pos0 = data.hashconfig->dgst_pos0;
|
||||
const uint dgst_pos1 = data.hashconfig->dgst_pos1;
|
||||
const uint dgst_pos2 = data.hashconfig->dgst_pos2;
|
||||
const uint dgst_pos3 = data.hashconfig->dgst_pos3;
|
||||
hashconfig_t *hashconfig = (hashconfig_t *) v3;
|
||||
|
||||
const uint dgst_pos0 = hashconfig->dgst_pos0;
|
||||
const uint dgst_pos1 = hashconfig->dgst_pos1;
|
||||
const uint dgst_pos2 = hashconfig->dgst_pos2;
|
||||
const uint dgst_pos3 = hashconfig->dgst_pos3;
|
||||
|
||||
if (d1[dgst_pos3] > d2[dgst_pos3]) return 1;
|
||||
if (d1[dgst_pos3] < d2[dgst_pos3]) return -1;
|
||||
@ -84,12 +83,14 @@ int sort_by_salt (const void *v1, const void *v2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sort_by_hash (const void *v1, const void *v2)
|
||||
int sort_by_hash (const void *v1, const void *v2, void *v3)
|
||||
{
|
||||
const hash_t *h1 = (const hash_t *) v1;
|
||||
const hash_t *h2 = (const hash_t *) v2;
|
||||
|
||||
if (data.hashconfig->is_salted)
|
||||
hashconfig_t *hashconfig = (hashconfig_t *) v3;
|
||||
|
||||
if (hashconfig->is_salted)
|
||||
{
|
||||
const salt_t *s1 = h1->salt;
|
||||
const salt_t *s2 = h2->salt;
|
||||
@ -102,10 +103,10 @@ int sort_by_hash (const void *v1, const void *v2)
|
||||
const void *d1 = h1->digest;
|
||||
const void *d2 = h2->digest;
|
||||
|
||||
return sort_by_digest_p0p1 (d1, d2);
|
||||
return sort_by_digest_p0p1 (d1, d2, v3);
|
||||
}
|
||||
|
||||
int sort_by_hash_no_salt (const void *v1, const void *v2)
|
||||
int sort_by_hash_no_salt (const void *v1, const void *v2, void *v3)
|
||||
{
|
||||
const hash_t *h1 = (const hash_t *) v1;
|
||||
const hash_t *h2 = (const hash_t *) v2;
|
||||
@ -113,7 +114,7 @@ int sort_by_hash_no_salt (const void *v1, const void *v2)
|
||||
const void *d1 = h1->digest;
|
||||
const void *d2 = h2->digest;
|
||||
|
||||
return sort_by_digest_p0p1 (d1, d2);
|
||||
return sort_by_digest_p0p1 (d1, d2, v3);
|
||||
}
|
||||
|
||||
void save_hash (const user_options_t *user_options, const hashconfig_t *hashconfig, const hashes_t *hashes)
|
||||
@ -210,17 +211,21 @@ void save_hash (const user_options_t *user_options, const hashconfig_t *hashconf
|
||||
unlink (old_hashfile);
|
||||
}
|
||||
|
||||
void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, plain_t *plain)
|
||||
void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain)
|
||||
{
|
||||
debugfile_ctx_t *debugfile_ctx = data.debugfile_ctx;
|
||||
loopback_ctx_t *loopback_ctx = data.loopback_ctx;
|
||||
outfile_ctx_t *outfile_ctx = data.outfile_ctx;
|
||||
potfile_ctx_t *potfile_ctx = data.potfile_ctx;
|
||||
mask_ctx_t *mask_ctx = data.mask_ctx;
|
||||
status_ctx_t *status_ctx = data.status_ctx;
|
||||
|
||||
hashconfig_t *hashconfig = data.hashconfig;
|
||||
hashes_t *hashes = data.hashes;
|
||||
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
|
||||
debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
loopback_ctx_t *loopback_ctx = hashcat_ctx->loopback_ctx;
|
||||
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_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;
|
||||
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
|
||||
const u32 salt_pos = plain->salt_pos;
|
||||
const u32 digest_pos = plain->digest_pos; // relative
|
||||
@ -493,8 +498,14 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, cons
|
||||
}
|
||||
}
|
||||
|
||||
int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, status_ctx_t *status_ctx, const uint salt_pos)
|
||||
int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const uint salt_pos)
|
||||
{
|
||||
cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
salt_t *salt_buf = &hashes->salts_buf[salt_pos];
|
||||
|
||||
u32 num_cracked;
|
||||
@ -557,7 +568,7 @@ int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, co
|
||||
|
||||
if (hashes->salts_done == hashes->salts_cnt) mycracked (status_ctx);
|
||||
|
||||
check_hash (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, &cracked[i]);
|
||||
check_hash (hashcat_ctx, device_param, &cracked[i]);
|
||||
}
|
||||
|
||||
hc_thread_mutex_unlock (status_ctx->mux_display);
|
||||
@ -1216,11 +1227,11 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
|
||||
|
||||
if (hashconfig->is_salted)
|
||||
{
|
||||
qsort (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash);
|
||||
hc_qsort_r (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash, (void *) hashconfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
qsort (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt);
|
||||
hc_qsort_r (hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt, (void *) hashconfig);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1245,12 +1256,12 @@ int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, user_o
|
||||
{
|
||||
if (sort_by_salt (hashes_buf[hashes_pos].salt, hashes_buf[hashes_pos - 1].salt) == 0)
|
||||
{
|
||||
if (sort_by_digest_p0p1 (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest) == 0) continue;
|
||||
if (sort_by_digest_p0p1 (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest, (void *) hashconfig) == 0) continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sort_by_digest_p0p1 (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest) == 0) continue;
|
||||
if (sort_by_digest_p0p1 (hashes_buf[hashes_pos].digest, hashes_buf[hashes_pos - 1].digest, (void *) hashconfig) == 0) continue;
|
||||
}
|
||||
|
||||
if (hashes_pos > hashes_cnt)
|
||||
|
22
src/main.c
Normal file
22
src/main.c
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Author......: See docs/credits.txt
|
||||
* License.....: MIT
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "common.h"
|
||||
#include "types.h"
|
||||
#include "hashcat.h"
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
hashcat_ctx_t *hashcat_ctx = malloc (sizeof (hashcat_ctx_t));
|
||||
|
||||
const int rc = hashcat (hashcat_ctx, argc, argv);
|
||||
|
||||
free (hashcat_ctx);
|
||||
|
||||
return rc;
|
||||
}
|
@ -26,28 +26,25 @@
|
||||
#include "potfile.h"
|
||||
#include "debugfile.h"
|
||||
#include "loopback.h"
|
||||
#include "data.h"
|
||||
#include "status.h"
|
||||
#include "shared.h"
|
||||
#include "terminal.h"
|
||||
#include "monitor.h"
|
||||
|
||||
extern hc_global_data_t data;
|
||||
|
||||
void *thread_monitor (void *p)
|
||||
static void monitor (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
combinator_ctx_t *combinator_ctx = data.combinator_ctx;
|
||||
cpt_ctx_t *cpt_ctx = data.cpt_ctx;
|
||||
hashconfig_t *hashconfig = data.hashconfig;
|
||||
hashes_t *hashes = data.hashes;
|
||||
hwmon_ctx_t *hwmon_ctx = data.hwmon_ctx;
|
||||
mask_ctx_t *mask_ctx = data.mask_ctx;
|
||||
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
|
||||
restore_ctx_t *restore_ctx = data.restore_ctx;
|
||||
status_ctx_t *status_ctx = data.status_ctx;
|
||||
straight_ctx_t *straight_ctx = data.straight_ctx;
|
||||
user_options_extra_t *user_options_extra = data.user_options_extra;
|
||||
user_options_t *user_options = data.user_options;
|
||||
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
|
||||
cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
||||
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
||||
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
bool runtime_check = false;
|
||||
bool remove_check = false;
|
||||
@ -87,7 +84,7 @@ void *thread_monitor (void *p)
|
||||
|
||||
if ((runtime_check == false) && (remove_check == false) && (status_check == false) && (restore_check == false) && (hwmon_check == false))
|
||||
{
|
||||
return (p);
|
||||
return;
|
||||
}
|
||||
|
||||
// these variables are mainly used for fan control
|
||||
@ -362,8 +359,13 @@ void *thread_monitor (void *p)
|
||||
|
||||
myfree (temp_diff_old);
|
||||
myfree (temp_diff_sum);
|
||||
|
||||
p = NULL;
|
||||
|
||||
return (p);
|
||||
}
|
||||
|
||||
void *thread_monitor (void *p)
|
||||
{
|
||||
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p;
|
||||
|
||||
monitor (hashcat_ctx);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
19
src/opencl.c
19
src/opencl.c
@ -26,8 +26,6 @@
|
||||
#include "cpu_md5.h"
|
||||
#include "opencl.h"
|
||||
|
||||
extern const int comptime;
|
||||
|
||||
static const u32 full01 = 0x01010101;
|
||||
static const u32 full80 = 0x80808080;
|
||||
|
||||
@ -989,8 +987,19 @@ int run_copy (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashcon
|
||||
return 0;
|
||||
}
|
||||
|
||||
int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, const mask_ctx_t *mask_ctx, const outfile_ctx_t *outfile_ctx, status_ctx_t *status_ctx, const uint pws_cnt)
|
||||
int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const uint pws_cnt)
|
||||
{
|
||||
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
|
||||
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
|
||||
|
||||
// init speed timer
|
||||
@ -1276,7 +1285,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
|
||||
|
||||
if (user_options->benchmark == false)
|
||||
{
|
||||
check_cracked (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, hashconfig, hashes, cpt_ctx, status_ctx, salt_pos);
|
||||
check_cracked (hashcat_ctx, device_param, salt_pos);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1527,7 +1536,7 @@ void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx)
|
||||
myfree (opencl_ctx);
|
||||
}
|
||||
|
||||
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options)
|
||||
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const int comptime)
|
||||
{
|
||||
if (opencl_ctx->enabled == false) return 0;
|
||||
|
||||
|
@ -10,24 +10,21 @@
|
||||
#include "outfile_check.h"
|
||||
|
||||
#include "convert.h"
|
||||
#include "data.h"
|
||||
#include "folder.h"
|
||||
#include "hashes.h"
|
||||
#include "interface.h"
|
||||
#include "shared.h"
|
||||
#include "thread.h"
|
||||
|
||||
extern hc_global_data_t data;
|
||||
|
||||
void *thread_outfile_remove (void *p)
|
||||
static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
// some hash-dependent constants
|
||||
|
||||
hashconfig_t *hashconfig = data.hashconfig;
|
||||
hashes_t *hashes = data.hashes;
|
||||
outcheck_ctx_t *outcheck_ctx = data.outcheck_ctx;
|
||||
status_ctx_t *status_ctx = data.status_ctx;
|
||||
user_options_t *user_options = data.user_options;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
uint dgst_size = hashconfig->dgst_size;
|
||||
uint is_salted = hashconfig->is_salted;
|
||||
@ -249,7 +246,7 @@ void *thread_outfile_remove (void *p)
|
||||
|
||||
memcpy (digest_buf, digests_buf_ptr + (hashes->salts_buf[salt_pos].digests_offset * dgst_size) + (digest_pos * dgst_size), dgst_size);
|
||||
|
||||
cracked = (sort_by_digest_p0p1 (digest_buf, hash_buf.digest) == 0);
|
||||
cracked = (sort_by_digest_p0p1 (digest_buf, hash_buf.digest, hashconfig) == 0);
|
||||
}
|
||||
|
||||
if (cracked == 1)
|
||||
@ -312,10 +309,15 @@ void *thread_outfile_remove (void *p)
|
||||
myfree (out_info);
|
||||
|
||||
myfree (out_files);
|
||||
}
|
||||
|
||||
p = NULL;
|
||||
void *thread_outfile_remove (void *p)
|
||||
{
|
||||
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p;
|
||||
|
||||
return (p);
|
||||
outfile_remove (hashcat_ctx);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int outcheck_ctx_init (outcheck_ctx_t *outcheck_ctx, const user_options_t *user_options, const folder_config_t *folder_config)
|
||||
|
101
src/potfile.c
101
src/potfile.c
@ -14,11 +14,11 @@
|
||||
#include "potfile.h"
|
||||
|
||||
// get rid of this later
|
||||
int sort_by_hash (const void *v1, const void *v2);
|
||||
int sort_by_hash_no_salt (const void *v1, const void *v2);
|
||||
int sort_by_hash (const void *v1, const void *v2, void *v3);
|
||||
int sort_by_hash_no_salt (const void *v1, const void *v2, void *v3);
|
||||
// get rid of this later
|
||||
|
||||
int sort_by_pot (const void *v1, const void *v2)
|
||||
int sort_by_pot (const void *v1, const void *v2, void *v3)
|
||||
{
|
||||
const pot_t *p1 = (const pot_t *) v1;
|
||||
const pot_t *p2 = (const pot_t *) v2;
|
||||
@ -26,11 +26,13 @@ int sort_by_pot (const void *v1, const void *v2)
|
||||
const hash_t *h1 = &p1->hash;
|
||||
const hash_t *h2 = &p2->hash;
|
||||
|
||||
return sort_by_hash (h1, h2);
|
||||
return sort_by_hash (h1, h2, v3);
|
||||
}
|
||||
|
||||
int sort_by_salt_buf (const void *v1, const void *v2)
|
||||
int sort_by_salt_buf (const void *v1, const void *v2, void *v3)
|
||||
{
|
||||
if (v3 == NULL) v3 = NULL; // make compiler happy
|
||||
|
||||
const pot_t *p1 = (const pot_t *) v1;
|
||||
const pot_t *p2 = (const pot_t *) v2;
|
||||
|
||||
@ -106,15 +108,74 @@ int sort_by_hash_t_salt_hccap (const void *v1, const void *v2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void hc_qsort_r (void *base, size_t nmemb, size_t size, int (*compar) (const void *, const void *, void *), void *arg)
|
||||
{
|
||||
/*
|
||||
** ssort() -- Fast, small, qsort()-compatible Shell sort
|
||||
**
|
||||
** by Ray Gardner, public domain 5/90
|
||||
* slightly modified to work with hashcat by Jens Steube
|
||||
*/
|
||||
|
||||
size_t wnel, gap, wgap, i, j, k;
|
||||
char *a, *b, tmp;
|
||||
|
||||
wnel = size * nmemb;
|
||||
for (gap = 0; ++gap < nmemb;)
|
||||
gap *= 3;
|
||||
while ((gap /= 3) != 0) {
|
||||
wgap = size * gap;
|
||||
for (i = wgap; i < wnel; i += size) {
|
||||
for (j = i - wgap; ;j -= wgap) {
|
||||
a = j + (char *)base;
|
||||
b = a + wgap;
|
||||
if ((*compar)(a, b, arg) <= 0)
|
||||
break;
|
||||
k = size;
|
||||
do {
|
||||
tmp = *a;
|
||||
*a++ = *b;
|
||||
*b++ = tmp;
|
||||
} while (--k);
|
||||
if (j < wgap)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
for (size_t l = 0, r = nmemb; r; r >>= 1)
|
||||
{
|
||||
const size_t m = r >> 1;
|
||||
|
||||
const size_t c = l + m;
|
||||
|
||||
const void *next = base + (c * size);
|
||||
|
||||
const int cmp = (*compar) (key, next, arg);
|
||||
|
||||
if (cmp > 0)
|
||||
{
|
||||
l += m + 1;
|
||||
|
||||
r--;
|
||||
}
|
||||
|
||||
if (cmp == 0) return ((void *) next);
|
||||
}
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
void potfile_init (potfile_ctx_t *potfile_ctx, const user_options_t *user_options, const folder_config_t *folder_config)
|
||||
{
|
||||
potfile_ctx->enabled = false;
|
||||
|
||||
if (user_options->benchmark == true) return;
|
||||
if (user_options->keyspace == true) return;
|
||||
if (user_options->left == true) return;
|
||||
if (user_options->opencl_info == true) return;
|
||||
if (user_options->show == true) return;
|
||||
if (user_options->stdout_flag == true) return;
|
||||
if (user_options->usage == true) return;
|
||||
if (user_options->version == true) return;
|
||||
@ -315,7 +376,7 @@ void potfile_read_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashcon
|
||||
|
||||
myfree (line_buf);
|
||||
|
||||
qsort (potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot);
|
||||
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)
|
||||
@ -421,7 +482,7 @@ void potfile_hash_free (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashconf
|
||||
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 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 *))
|
||||
{
|
||||
if (potfile_ctx->enabled == false) return;
|
||||
|
||||
@ -430,7 +491,7 @@ void potfile_show_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashc
|
||||
pot_key.hash.salt = hashes_buf->salt;
|
||||
pot_key.hash.digest = hashes_buf->digest;
|
||||
|
||||
pot_t *pot_ptr = (pot_t *) bsearch (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot);
|
||||
pot_t *pot_ptr = (pot_t *) hc_bsearch_r (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
|
||||
|
||||
if (pot_ptr)
|
||||
{
|
||||
@ -460,7 +521,7 @@ void potfile_show_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashc
|
||||
}
|
||||
}
|
||||
|
||||
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 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 *))
|
||||
{
|
||||
if (potfile_ctx->enabled == false) return;
|
||||
|
||||
@ -468,7 +529,7 @@ void potfile_left_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashc
|
||||
|
||||
memcpy (&pot_key.hash, hashes_buf, sizeof (hash_t));
|
||||
|
||||
pot_t *pot_ptr = (pot_t *) bsearch (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot);
|
||||
pot_t *pot_ptr = (pot_t *) hc_bsearch_r (&pot_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
|
||||
|
||||
if (pot_ptr == NULL)
|
||||
{
|
||||
@ -480,7 +541,7 @@ void potfile_left_request (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashc
|
||||
}
|
||||
}
|
||||
|
||||
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 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 *))
|
||||
{
|
||||
if (potfile_ctx->enabled == false) return;
|
||||
|
||||
@ -491,7 +552,7 @@ void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
|
||||
pot_left_key.hash.salt = hash_left->salt;
|
||||
pot_left_key.hash.digest = hash_left->digest;
|
||||
|
||||
pot_t *pot_left_ptr = (pot_t *) bsearch (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot);
|
||||
pot_t *pot_left_ptr = (pot_t *) hc_bsearch_r (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
|
||||
|
||||
// right
|
||||
|
||||
@ -502,7 +563,7 @@ void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
|
||||
pot_right_key.hash.salt = hash_right->salt;
|
||||
pot_right_key.hash.digest = hash_right->digest;
|
||||
|
||||
pot_t *pot_right_ptr = (pot_t *) bsearch (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot);
|
||||
pot_t *pot_right_ptr = (pot_t *) hc_bsearch_r (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
|
||||
|
||||
if (pot_right_ptr == NULL)
|
||||
{
|
||||
@ -602,7 +663,7 @@ void potfile_show_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
|
||||
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 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 *))
|
||||
{
|
||||
if (potfile_ctx->enabled == false) return;
|
||||
|
||||
@ -612,7 +673,7 @@ void potfile_left_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
|
||||
|
||||
memcpy (&pot_left_key.hash, hash_left, sizeof (hash_t));
|
||||
|
||||
pot_t *pot_left_ptr = (pot_t *) bsearch (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot);
|
||||
pot_t *pot_left_ptr = (pot_t *) hc_bsearch_r (&pot_left_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
|
||||
|
||||
// right
|
||||
|
||||
@ -620,7 +681,7 @@ void potfile_left_request_lm (potfile_ctx_t *potfile_ctx, const hashconfig_t *ha
|
||||
|
||||
memcpy (&pot_right_key.hash, hash_right, sizeof (hash_t));
|
||||
|
||||
pot_t *pot_right_ptr = (pot_t *) bsearch (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot);
|
||||
pot_t *pot_right_ptr = (pot_t *) hc_bsearch_r (&pot_right_key, potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
|
||||
|
||||
uint weak_hash_found = 0;
|
||||
|
||||
@ -853,11 +914,11 @@ int potfile_remove_parse (potfile_ctx_t *potfile_ctx, const hashconfig_t *hashco
|
||||
{
|
||||
if (hashconfig->is_salted)
|
||||
{
|
||||
found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash);
|
||||
found = (hash_t *) hc_bsearch_r (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash, (void *) hashconfig);
|
||||
}
|
||||
else
|
||||
{
|
||||
found = (hash_t *) bsearch (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt);
|
||||
found = (hash_t *) hc_bsearch_r (&hash_buf, hashes_buf, hashes_cnt, sizeof (hash_t), sort_by_hash_no_salt, (void *) hashconfig);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,18 +25,13 @@
|
||||
#include "potfile.h"
|
||||
#include "debugfile.h"
|
||||
#include "loopback.h"
|
||||
#include "data.h"
|
||||
#include "status.h"
|
||||
#include "shared.h"
|
||||
#include "terminal.h"
|
||||
|
||||
extern hc_global_data_t data;
|
||||
|
||||
extern const char *version_tag;
|
||||
|
||||
const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint [q]uit => ";
|
||||
|
||||
void welcome_screen (const user_options_t *user_options, const status_ctx_t *status_ctx)
|
||||
void welcome_screen (const user_options_t *user_options, const status_ctx_t *status_ctx, char *version_tag)
|
||||
{
|
||||
if (user_options->quiet == true) return;
|
||||
if (user_options->keyspace == true) return;
|
||||
@ -131,23 +126,24 @@ void clear_prompt ()
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
void *thread_keypress (void *p)
|
||||
static void keypress (hashcat_ctx_t *hashcat_ctx)
|
||||
{
|
||||
status_ctx_t *status_ctx = data.status_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
|
||||
// this is required, because some of the variables down there are not initialized at that point
|
||||
while (status_ctx->devices_status == STATUS_INIT) hc_sleep_ms (100);
|
||||
|
||||
combinator_ctx_t *combinator_ctx = data.combinator_ctx;
|
||||
cpt_ctx_t *cpt_ctx = data.cpt_ctx;
|
||||
hashconfig_t *hashconfig = data.hashconfig;
|
||||
hashes_t *hashes = data.hashes;
|
||||
hwmon_ctx_t *hwmon_ctx = data.hwmon_ctx;
|
||||
mask_ctx_t *mask_ctx = data.mask_ctx;
|
||||
opencl_ctx_t *opencl_ctx = data.opencl_ctx;
|
||||
restore_ctx_t *restore_ctx = data.restore_ctx;
|
||||
straight_ctx_t *straight_ctx = data.straight_ctx;
|
||||
user_options_extra_t *user_options_extra = data.user_options_extra;
|
||||
user_options_t *user_options = data.user_options;
|
||||
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
|
||||
cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
|
||||
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
|
||||
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
||||
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
const bool quiet = user_options->quiet;
|
||||
|
||||
@ -252,8 +248,15 @@ void *thread_keypress (void *p)
|
||||
}
|
||||
|
||||
tty_fix ();
|
||||
}
|
||||
|
||||
return (p);
|
||||
void *thread_keypress (void *p)
|
||||
{
|
||||
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p;
|
||||
|
||||
keypress (hashcat_ctx);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if defined (_WIN)
|
||||
|
20
src/thread.c
20
src/thread.c
@ -11,8 +11,7 @@
|
||||
#include "shared.h"
|
||||
#include "thread.h"
|
||||
|
||||
extern hc_global_data_t data;
|
||||
|
||||
/*
|
||||
#if defined (_WIN)
|
||||
|
||||
BOOL WINAPI sigHandler_default (DWORD sig)
|
||||
@ -21,13 +20,13 @@ BOOL WINAPI sigHandler_default (DWORD sig)
|
||||
{
|
||||
case CTRL_CLOSE_EVENT:
|
||||
|
||||
/*
|
||||
*
|
||||
* special case see: https://stackoverflow.com/questions/3640633/c-setconsolectrlhandler-routine-issue/5610042#5610042
|
||||
* if the user interacts w/ the user-interface (GUI/cmd), we need to do the finalization job within this signal handler
|
||||
* function otherwise it is too late (e.g. after returning from this function)
|
||||
*/
|
||||
*
|
||||
|
||||
myabort (data.status_ctx);
|
||||
myabort (hashcat_ctx->status_ctx);
|
||||
|
||||
SetConsoleCtrlHandler (NULL, TRUE);
|
||||
|
||||
@ -39,7 +38,7 @@ BOOL WINAPI sigHandler_default (DWORD sig)
|
||||
case CTRL_LOGOFF_EVENT:
|
||||
case CTRL_SHUTDOWN_EVENT:
|
||||
|
||||
myabort (data.status_ctx);
|
||||
myabort (hashcat_ctx->status_ctx);
|
||||
|
||||
SetConsoleCtrlHandler (NULL, TRUE);
|
||||
|
||||
@ -55,7 +54,7 @@ BOOL WINAPI sigHandler_benchmark (DWORD sig)
|
||||
{
|
||||
case CTRL_CLOSE_EVENT:
|
||||
|
||||
myquit (data.status_ctx);
|
||||
myquit (hashcat_ctx->status_ctx);
|
||||
|
||||
SetConsoleCtrlHandler (NULL, TRUE);
|
||||
|
||||
@ -67,7 +66,7 @@ BOOL WINAPI sigHandler_benchmark (DWORD sig)
|
||||
case CTRL_LOGOFF_EVENT:
|
||||
case CTRL_SHUTDOWN_EVENT:
|
||||
|
||||
myquit (data.status_ctx);
|
||||
myquit (hashcat_ctx->status_ctx);
|
||||
|
||||
SetConsoleCtrlHandler (NULL, TRUE);
|
||||
|
||||
@ -93,14 +92,14 @@ void hc_signal (BOOL WINAPI (callback) (DWORD))
|
||||
|
||||
void sigHandler_default (int sig)
|
||||
{
|
||||
myabort (data.status_ctx);
|
||||
myabort (hashcat_ctx->status_ctx);
|
||||
|
||||
signal (sig, NULL);
|
||||
}
|
||||
|
||||
void sigHandler_benchmark (int sig)
|
||||
{
|
||||
myquit (data.status_ctx);
|
||||
myquit (hashcat_ctx->status_ctx);
|
||||
|
||||
signal (sig, NULL);
|
||||
}
|
||||
@ -115,6 +114,7 @@ void hc_signal (void (callback) (int))
|
||||
}
|
||||
|
||||
#endif
|
||||
*/
|
||||
|
||||
void mycracked (status_ctx_t *status_ctx)
|
||||
{
|
||||
|
@ -10,8 +10,15 @@
|
||||
#include "hashes.h"
|
||||
#include "weak_hash.h"
|
||||
|
||||
void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, hashconfig_t *hashconfig, hashes_t *hashes, cpt_ctx_t *cpt_ctx, status_ctx_t *status_ctx, const uint salt_pos)
|
||||
void weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const uint salt_pos)
|
||||
{
|
||||
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
||||
hashes_t *hashes = hashcat_ctx->hashes;
|
||||
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
|
||||
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
||||
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
|
||||
user_options_t *user_options = hashcat_ctx->user_options;
|
||||
|
||||
salt_t *salt_buf = &hashes->salts_buf[salt_pos];
|
||||
|
||||
device_param->kernel_params_buf32[27] = salt_pos;
|
||||
@ -60,7 +67,7 @@ void weak_hash_check (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param,
|
||||
* result
|
||||
*/
|
||||
|
||||
check_cracked (opencl_ctx, device_param, user_options, user_options_extra, straight_ctx, combinator_ctx, hashconfig, hashes, cpt_ctx, status_ctx, salt_pos);
|
||||
check_cracked (hashcat_ctx, device_param, salt_pos);
|
||||
|
||||
/**
|
||||
* cleanup
|
||||
|
@ -263,7 +263,7 @@ void pw_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len
|
||||
|
||||
u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const user_options_extra_t *user_options_extra, const straight_ctx_t *straight_ctx, const combinator_ctx_t *combinator_ctx, FILE *fd, const char *dictfile, dictstat_ctx_t *dictstat_ctx)
|
||||
{
|
||||
hc_signal (NULL);
|
||||
//hc_signal (NULL);
|
||||
|
||||
dictstat_t d;
|
||||
|
||||
@ -311,7 +311,7 @@ u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const u
|
||||
if (user_options->quiet == false) log_info ("Cache-hit dictionary stats %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, d.stat.st_size, cached_cnt, keyspace);
|
||||
if (user_options->quiet == false) log_info ("");
|
||||
|
||||
hc_signal (sigHandler_default);
|
||||
//hc_signal (sigHandler_default);
|
||||
|
||||
return (keyspace);
|
||||
}
|
||||
@ -395,7 +395,7 @@ u64 count_words (wl_data_t *wl_data, const user_options_t *user_options, const u
|
||||
|
||||
dictstat_append (dictstat_ctx, &d);
|
||||
|
||||
hc_signal (sigHandler_default);
|
||||
//hc_signal (sigHandler_default);
|
||||
|
||||
return (cnt);
|
||||
}
|
||||
@ -408,7 +408,7 @@ void wl_data_init (wl_data_t *wl_data, const user_options_t *user_options, const
|
||||
if (user_options->keyspace == true) return;
|
||||
if (user_options->left == true) return;
|
||||
if (user_options->opencl_info == true) return;
|
||||
if (user_options->show == true) return;
|
||||
// if (user_options->show == true) return;
|
||||
if (user_options->usage == true) return;
|
||||
if (user_options->version == true) return;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user