Move tons of functions from hashcat.c into hash_management, interface, opencl, restore, status and weak_hash sources

pull/506/head
jsteube 8 years ago
parent 0fa43d52b8
commit bc75ba70a1

@ -6,4 +6,12 @@
#ifndef _HASH_MANAGEMENT_H
#define _HASH_MANAGEMENT_H
#define USERNAME 0
void save_hash ();
void check_hash (hc_device_param_t *device_param, plain_t *plain);
int check_cracked (hc_device_param_t *device_param, const uint salt_pos, hashconfig_t *hashconfig);
#endif // _HASH_MANAGEMENT_H

@ -1658,6 +1658,7 @@ int opencart_parse_hash (char *input_buf, uint input_len, hash_t *hash
* output functions
*/
char *stroptitype (const uint opti_type);
char *strhashtype (const uint hash_mode);
char *strparser (const uint parser_status);

@ -1,9 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _KERNEL_H
#define _KERNEL_H
#endif // _KERNEL_H

@ -11,6 +11,18 @@
#define PARAMCNT 64
#define KERNEL_ACCEL 0
#define KERNEL_LOOPS 0
#define KERNEL_RULES 1024
#define KERNEL_COMBS 1024
#define KERNEL_BFS 1024
#define KERNEL_THREADS_MAX 256
#define KERNEL_THREADS_MAX_CPU 1
#define WORKLOAD_PROFILE 2
#define SCRYPT_TMTO 0
#define NVIDIA_SPIN_DAMP 100
static const char CL_VENDOR_AMD[] = "Advanced Micro Devices, Inc.";
static const char CL_VENDOR_AMD_USE_INTEL[] = "GenuineIntel";
static const char CL_VENDOR_APPLE[] = "Apple";
@ -222,6 +234,16 @@ cl_device_type setup_device_types_filter (char *opencl_device_types);
void load_kernel (const char *kernel_file, int num_devices, size_t *kernel_lengths, const u8 **kernel_sources);
void writeProgramBin (char *dst, u8 *binary, size_t binary_size);
double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries);
int gidd_to_pw_t (hc_device_param_t *device_param, const u64 gidd, pw_t *pw);
int choose_kernel (hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint attack_exec, const uint attack_mode, const uint opts_type, const salt_t *salt_buf, const uint highest_pw_len, const uint pws_cnt, const uint fast_iteration);
int run_kernel (const uint kern_run, hc_device_param_t *device_param, const uint num, const uint event_update, const uint iteration, hashconfig_t *hashconfig);
int run_kernel_mp (const uint kern_run, hc_device_param_t *device_param, const uint num);
int run_kernel_tm (hc_device_param_t *device_param);
int run_kernel_amp (hc_device_param_t *device_param, const uint num);
int run_kernel_memset (hc_device_param_t *device_param, cl_mem buf, const uint value, const uint num);
int run_kernel_bzero (hc_device_param_t *device_param, cl_mem buf, const size_t size);
int run_copy (hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint pws_cnt);
int run_cracker (hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint pws_cnt);

@ -57,4 +57,8 @@ void write_restore (const char *new_restore_file, restore_data_t *rd);
void cycle_restore ();
void check_checkpoint ();
void stop_at_checkpoint ();
#endif // _RESTORE_H

@ -29,6 +29,8 @@ typedef enum status_rc
} status_rc_t;
double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries);
void status_display_machine_readable ();
void status_display ();
void status_benchmark_automate ();

@ -6,4 +6,8 @@
#ifndef _WEAK_HASH_H
#define _WEAK_HASH_H
#define WEAK_HASH_THRESHOLD 100
void weak_hash_check (hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint salt_pos);
#endif // _WEAK_HASH_H

@ -163,7 +163,7 @@ LFLAGS_CROSS_WIN := -lpsapi
## Objects
##
OBJS_ALL := affinity attack_mode autotune benchmark bitmap bitops common convert cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 data debugfile dictstat dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling filenames folder hash_management hlfmt hwmon induct interface kernel locking logfile logging loopback memory mpsp opencl outfile_check outfile potfile powertune remove restore rp_cpu rp_kernel_on_cpu runtime shared status stdout terminal thread timer tuningdb usage version weak_hash wordlist
OBJS_ALL := affinity attack_mode autotune benchmark bitmap bitops common convert cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 data debugfile dictstat dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling filenames folder hash_management hlfmt hwmon induct interface locking logfile logging loopback memory mpsp opencl outfile_check outfile potfile powertune remove restore rp_cpu rp_kernel_on_cpu runtime shared status stdout terminal thread timer tuningdb usage version weak_hash wordlist
NATIVE_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.o)

@ -6,6 +6,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "ext_OpenCL.h"
#include "ext_ADL.h"
@ -13,7 +14,6 @@
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "interface.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"

@ -4,4 +4,547 @@
*/
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "memory.h"
#include "logging.h"
#include "ext_OpenCL.h"
#include "ext_ADL.h"
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "opencl.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
#include "loopback.h"
#include "data.h"
#include "terminal.h"
#include "status.h"
#include "thread.h"
#include "rp_kernel_on_cpu.h"
#include "hash_management.h"
extern hc_global_data_t data;
extern hc_thread_mutex_t mux_display;
void save_hash ()
{
hashconfig_t *hashconfig = data.hashconfig;
void *digests_buf = data.digests_buf;
salt_t *salts_buf = data.salts_buf;
void *esalts_buf = data.esalts_buf;
hashinfo_t **hash_info = data.hash_info;
char *hashfile = data.hashfile;
char new_hashfile[256] = { 0 };
char old_hashfile[256] = { 0 };
snprintf (new_hashfile, 255, "%s.new", hashfile);
snprintf (old_hashfile, 255, "%s.old", hashfile);
unlink (new_hashfile);
char separator = hashconfig->separator;
FILE *fp = fopen (new_hashfile, "wb");
if (fp == NULL)
{
log_error ("ERROR: %s: %s", new_hashfile, strerror (errno));
exit (-1);
}
for (uint salt_pos = 0; salt_pos < data.salts_cnt; salt_pos++)
{
if (data.salts_shown[salt_pos] == 1) continue;
salt_t *salt_buf = &data.salts_buf[salt_pos];
for (uint digest_pos = 0; digest_pos < salt_buf->digests_cnt; digest_pos++)
{
uint idx = salt_buf->digests_offset + digest_pos;
if (data.digests_shown[idx] == 1) continue;
if (hashconfig->hash_mode != 2500)
{
if (data.username == 1)
{
user_t *user = data.hash_info[idx]->user;
uint i;
for (i = 0; i < user->user_len; i++) fputc (user->user_name[i], fp);
fputc (separator, fp);
}
char out_buf[HCBUFSIZ_LARGE]; // scratch buffer
out_buf[0] = 0;
ascii_digest (out_buf, salt_pos, digest_pos, hashconfig, digests_buf, salts_buf, esalts_buf, hash_info, hashfile);
fputs (out_buf, fp);
fputc ('\n', fp);
}
else
{
hccap_t hccap;
to_hccap_t (&hccap, salt_pos, digest_pos, hashconfig, digests_buf, salts_buf, esalts_buf);
fwrite (&hccap, sizeof (hccap_t), 1, fp);
}
}
}
fflush (fp);
fclose (fp);
unlink (old_hashfile);
if (rename (hashfile, old_hashfile) != 0)
{
log_error ("ERROR: Rename file '%s' to '%s': %s", hashfile, old_hashfile, strerror (errno));
exit (-1);
}
unlink (hashfile);
if (rename (new_hashfile, hashfile) != 0)
{
log_error ("ERROR: Rename file '%s' to '%s': %s", new_hashfile, hashfile, strerror (errno));
exit (-1);
}
unlink (old_hashfile);
}
void check_hash (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;
uint quiet = data.quiet;
// debugfile
u8 debug_rule_buf[BLOCK_SIZE] = { 0 };
u32 debug_rule_len = 0; // -1 error
u8 debug_plain_ptr[BLOCK_SIZE] = { 0 };
u32 debug_plain_len = 0;
// hash
char out_buf[HCBUFSIZ_LARGE] = { 0 };
const u32 salt_pos = plain->salt_pos;
const u32 digest_pos = plain->digest_pos; // relative
const u32 gidvid = plain->gidvid;
const u32 il_pos = plain->il_pos;
hashconfig_t *hashconfig = data.hashconfig;
void *digests_buf = data.digests_buf;
salt_t *salts_buf = data.salts_buf;
void *esalts_buf = data.esalts_buf;
hashinfo_t **hash_info = data.hash_info;
char *hashfile = data.hashfile;
ascii_digest (out_buf, salt_pos, digest_pos, hashconfig, digests_buf, salts_buf, esalts_buf, hash_info, hashfile);
// plain
u64 crackpos = device_param->words_off;
uint plain_buf[16] = { 0 };
u8 *plain_ptr = (u8 *) plain_buf;
unsigned int plain_len = 0;
if (data.attack_mode == ATTACK_MODE_STRAIGHT)
{
pw_t pw;
gidd_to_pw_t (device_param, gidvid, &pw);
for (int i = 0; i < 16; i++)
{
plain_buf[i] = pw.i[i];
}
plain_len = pw.pw_len;
const uint off = device_param->innerloop_pos + il_pos;
const uint debug_mode = debugfile_ctx->mode;
if (debug_mode > 0)
{
debug_rule_len = 0;
// save rule
if ((debug_mode == 1) || (debug_mode == 3) || (debug_mode == 4))
{
memset (debug_rule_buf, 0, sizeof (debug_rule_buf));
debug_rule_len = kernel_rule_to_cpu_rule ((char *) debug_rule_buf, &data.kernel_rules_buf[off]);
}
// save plain
if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4))
{
memset (debug_plain_ptr, 0, sizeof (debug_plain_ptr));
memcpy (debug_plain_ptr, plain_ptr, plain_len);
debug_plain_len = plain_len;
}
}
plain_len = apply_rules (data.kernel_rules_buf[off].cmds, &plain_buf[0], &plain_buf[4], plain_len);
crackpos += gidvid;
crackpos *= data.kernel_rules_cnt;
crackpos += device_param->innerloop_pos + il_pos;
if (plain_len > data.pw_max) plain_len = data.pw_max;
}
else if (data.attack_mode == ATTACK_MODE_COMBI)
{
pw_t pw;
gidd_to_pw_t (device_param, gidvid, &pw);
for (int i = 0; i < 16; i++)
{
plain_buf[i] = pw.i[i];
}
plain_len = pw.pw_len;
char *comb_buf = (char *) device_param->combs_buf[il_pos].i;
uint comb_len = device_param->combs_buf[il_pos].pw_len;
if (data.combs_mode == COMBINATOR_MODE_BASE_LEFT)
{
memcpy (plain_ptr + plain_len, comb_buf, comb_len);
}
else
{
memmove (plain_ptr + comb_len, plain_ptr, plain_len);
memcpy (plain_ptr, comb_buf, comb_len);
}
plain_len += comb_len;
crackpos += gidvid;
crackpos *= data.combs_cnt;
crackpos += device_param->innerloop_pos + il_pos;
if (data.pw_max != PW_DICTMAX1)
{
if (plain_len > data.pw_max) plain_len = data.pw_max;
}
}
else if (data.attack_mode == ATTACK_MODE_BF)
{
u64 l_off = device_param->kernel_params_mp_l_buf64[3] + gidvid;
u64 r_off = device_param->kernel_params_mp_r_buf64[3] + il_pos;
uint l_start = device_param->kernel_params_mp_l_buf32[5];
uint r_start = device_param->kernel_params_mp_r_buf32[5];
uint l_stop = device_param->kernel_params_mp_l_buf32[4];
uint r_stop = device_param->kernel_params_mp_r_buf32[4];
sp_exec (l_off, (char *) plain_ptr + l_start, data.root_css_buf, data.markov_css_buf, l_start, l_start + l_stop);
sp_exec (r_off, (char *) plain_ptr + r_start, data.root_css_buf, data.markov_css_buf, r_start, r_start + r_stop);
plain_len = data.css_cnt;
crackpos += gidvid;
crackpos *= data.bfs_cnt;
crackpos += device_param->innerloop_pos + il_pos;
}
else if (data.attack_mode == ATTACK_MODE_HYBRID1)
{
pw_t pw;
gidd_to_pw_t (device_param, gidvid, &pw);
for (int i = 0; i < 16; i++)
{
plain_buf[i] = pw.i[i];
}
plain_len = pw.pw_len;
u64 off = device_param->kernel_params_mp_buf64[3] + il_pos;
uint start = 0;
uint stop = device_param->kernel_params_mp_buf32[4];
sp_exec (off, (char *) plain_ptr + plain_len, data.root_css_buf, data.markov_css_buf, start, start + stop);
plain_len += start + stop;
crackpos += gidvid;
crackpos *= data.combs_cnt;
crackpos += device_param->innerloop_pos + il_pos;
if (data.pw_max != PW_DICTMAX1)
{
if (plain_len > data.pw_max) plain_len = data.pw_max;
}
}
else if (data.attack_mode == ATTACK_MODE_HYBRID2)
{
pw_t pw;
gidd_to_pw_t (device_param, gidvid, &pw);
for (int i = 0; i < 16; i++)
{
plain_buf[i] = pw.i[i];
}
plain_len = pw.pw_len;
u64 off = device_param->kernel_params_mp_buf64[3] + il_pos;
uint start = 0;
uint stop = device_param->kernel_params_mp_buf32[4];
memmove (plain_ptr + stop, plain_ptr, plain_len);
sp_exec (off, (char *) plain_ptr, data.root_css_buf, data.markov_css_buf, start, start + stop);
plain_len += start + stop;
crackpos += gidvid;
crackpos *= data.combs_cnt;
crackpos += device_param->innerloop_pos + il_pos;
if (data.pw_max != PW_DICTMAX1)
{
if (plain_len > data.pw_max) plain_len = data.pw_max;
}
}
if (data.attack_mode == ATTACK_MODE_BF)
{
if (hashconfig->opti_type & OPTI_TYPE_BRUTE_FORCE) // lots of optimizations can happen here
{
if (hashconfig->opti_type & OPTI_TYPE_SINGLE_HASH)
{
if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT)
{
plain_len = plain_len - data.salts_buf[0].salt_len;
}
}
if (hashconfig->opts_type & OPTS_TYPE_PT_UNICODE)
{
for (uint i = 0, j = 0; i < plain_len; i += 2, j += 1)
{
plain_ptr[j] = plain_ptr[i];
}
plain_len = plain_len / 2;
}
}
}
// if enabled, update also the potfile
// no need for locking, we're in a mutex protected function
if (potfile_ctx->fp != NULL)
{
potfile_write_append (potfile_ctx, out_buf, plain_ptr, plain_len);
}
// outfile, can be either to file or stdout
// if an error occurs opening the file, send to stdout as fallback
// the fp gets opened for each cracked hash so that the user can modify (move) the outfile while hashcat runs
outfile_write_open (outfile_ctx);
if (outfile_ctx->filename == NULL) if (quiet == 0) clear_prompt ();
outfile_write (outfile_ctx, out_buf, plain_ptr, plain_len, crackpos, NULL, 0, hashconfig);
outfile_write_close (outfile_ctx);
if ((data.wordlist_mode == WL_MODE_FILE) || (data.wordlist_mode == WL_MODE_MASK))
{
if ((data.devices_status != STATUS_CRACKED) && (data.status != 1))
{
if (outfile_ctx->filename == NULL) if (quiet == 0) send_prompt ();
}
}
// if enabled, update also the loopback file
if (loopback_ctx->fp != NULL)
{
loopback_write_append (loopback_ctx, plain_ptr, plain_len);
}
// if enabled, update also the (rule) debug file
if (debugfile_ctx->fp != NULL)
{
// the next check implies that:
// - (data.attack_mode == ATTACK_MODE_STRAIGHT)
// - debug_mode > 0
if ((debug_plain_len > 0) || (debug_rule_len > 0))
{
debugfile_write_append (debugfile_ctx, debug_rule_buf, debug_rule_len, debug_plain_ptr, debug_plain_len, plain_ptr, plain_len);
}
}
}
int check_cracked (hc_device_param_t *device_param, const uint salt_pos, hashconfig_t *hashconfig)
{
salt_t *salt_buf = &data.salts_buf[salt_pos];
u32 num_cracked;
cl_int CL_err;
CL_err = hc_clEnqueueReadBuffer (data.ocl, device_param->command_queue, device_param->d_result, CL_TRUE, 0, sizeof (u32), &num_cracked, 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{
log_error ("ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err));
return -1;
}
if (num_cracked)
{
// display hack (for weak hashes etc, it could be that there is still something to clear on the current line)
log_info_nn ("");
plain_t *cracked = (plain_t *) mycalloc (num_cracked, sizeof (plain_t));
CL_err = hc_clEnqueueReadBuffer (data.ocl, device_param->command_queue, device_param->d_plain_bufs, CL_TRUE, 0, num_cracked * sizeof (plain_t), cracked, 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{
log_error ("ERROR: clEnqueueReadBuffer(): %s\n", val2cstr_cl (CL_err));
return -1;
}
uint cpt_cracked = 0;
hc_thread_mutex_lock (mux_display);
for (uint i = 0; i < num_cracked; i++)
{
const uint hash_pos = cracked[i].hash_pos;
if (data.digests_shown[hash_pos] == 1) continue;
if ((hashconfig->opts_type & OPTS_TYPE_PT_NEVERCRACK) == 0)
{
data.digests_shown[hash_pos] = 1;
data.digests_done++;
cpt_cracked++;
salt_buf->digests_done++;
if (salt_buf->digests_done == salt_buf->digests_cnt)
{
data.salts_shown[salt_pos] = 1;
data.salts_done++;
}
}
if (data.salts_done == data.salts_cnt) data.devices_status = STATUS_CRACKED;
check_hash (device_param, &cracked[i]);
}
hc_thread_mutex_unlock (mux_display);
myfree (cracked);
if (cpt_cracked > 0)
{
hc_thread_mutex_lock (mux_display);
data.cpt_buf[data.cpt_pos].timestamp = time (NULL);
data.cpt_buf[data.cpt_pos].cracked = cpt_cracked;
data.cpt_pos++;
data.cpt_total += cpt_cracked;
if (data.cpt_pos == CPT_BUF) data.cpt_pos = 0;
hc_thread_mutex_unlock (mux_display);
}
if (hashconfig->opts_type & OPTS_TYPE_PT_NEVERCRACK)
{
// we need to reset cracked state on the device
// otherwise host thinks again and again the hash was cracked
// and returns invalid password each time
memset (data.digests_shown_tmp, 0, salt_buf->digests_cnt * sizeof (uint));
CL_err = hc_clEnqueueWriteBuffer (data.ocl, device_param->command_queue, device_param->d_digests_shown, CL_TRUE, salt_buf->digests_offset * sizeof (uint), salt_buf->digests_cnt * sizeof (uint), &data.digests_shown_tmp[salt_buf->digests_offset], 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{
log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err));
return -1;
}
}
num_cracked = 0;
CL_err = hc_clEnqueueWriteBuffer (data.ocl, device_param->command_queue, device_param->d_result, CL_TRUE, 0, sizeof (u32), &num_cracked, 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{
log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err));
return -1;
}
}
return 0;
}

File diff suppressed because it is too large Load Diff

@ -6,6 +6,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "bitops.h"
#include "memory.h"
@ -23,7 +24,6 @@
#include "filehandling.h"
#include "rp_cpu.h"
#include "inc_hash_constants.h"
#include "interface.h"
#include "shared.h"
#include "hwmon.h"
#include "mpsp.h"

@ -6,6 +6,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "memory.h"
#include "logging.h"
@ -15,7 +16,6 @@
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "interface.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"

@ -23,6 +23,26 @@
#include "cpu_sha256.h"
#include "interface.h"
static const char OPTI_STR_ZERO_BYTE[] = "Zero-Byte";
static const char OPTI_STR_PRECOMPUTE_INIT[] = "Precompute-Init";
static const char OPTI_STR_PRECOMPUTE_MERKLE[] = "Precompute-Merkle-Demgard";
static const char OPTI_STR_PRECOMPUTE_PERMUT[] = "Precompute-Final-Permutation";
static const char OPTI_STR_MEET_IN_MIDDLE[] = "Meet-In-The-Middle";
static const char OPTI_STR_EARLY_SKIP[] = "Early-Skip";
static const char OPTI_STR_NOT_SALTED[] = "Not-Salted";
static const char OPTI_STR_NOT_ITERATED[] = "Not-Iterated";
static const char OPTI_STR_PREPENDED_SALT[] = "Prepended-Salt";
static const char OPTI_STR_APPENDED_SALT[] = "Appended-Salt";
static const char OPTI_STR_SINGLE_HASH[] = "Single-Hash";
static const char OPTI_STR_SINGLE_SALT[] = "Single-Salt";
static const char OPTI_STR_BRUTE_FORCE[] = "Brute-Force";
static const char OPTI_STR_RAW_HASH[] = "Raw-Hash";
static const char OPTI_STR_SLOW_HASH_SIMD[] = "Slow-Hash-SIMD";
static const char OPTI_STR_USES_BITS_8[] = "Uses-8-Bit";
static const char OPTI_STR_USES_BITS_16[] = "Uses-16-Bit";
static const char OPTI_STR_USES_BITS_32[] = "Uses-32-Bit";
static const char OPTI_STR_USES_BITS_64[] = "Uses-64-Bit";
static const char PA_000[] = "OK";
static const char PA_001[] = "Ignored due to comment";
static const char PA_002[] = "Ignored due to zero length";
@ -12821,6 +12841,34 @@ int win8phone_parse_hash (char *input_buf, uint input_len, hash_t *hash_buf, con
* output
*/
char *stroptitype (const uint opti_type)
{
switch (opti_type)
{
case OPTI_TYPE_ZERO_BYTE: return ((char *) OPTI_STR_ZERO_BYTE);
case OPTI_TYPE_PRECOMPUTE_INIT: return ((char *) OPTI_STR_PRECOMPUTE_INIT);
case OPTI_TYPE_PRECOMPUTE_MERKLE: return ((char *) OPTI_STR_PRECOMPUTE_MERKLE);
case OPTI_TYPE_PRECOMPUTE_PERMUT: return ((char *) OPTI_STR_PRECOMPUTE_PERMUT);
case OPTI_TYPE_MEET_IN_MIDDLE: return ((char *) OPTI_STR_MEET_IN_MIDDLE);
case OPTI_TYPE_EARLY_SKIP: return ((char *) OPTI_STR_EARLY_SKIP);
case OPTI_TYPE_NOT_SALTED: return ((char *) OPTI_STR_NOT_SALTED);
case OPTI_TYPE_NOT_ITERATED: return ((char *) OPTI_STR_NOT_ITERATED);
case OPTI_TYPE_PREPENDED_SALT: return ((char *) OPTI_STR_PREPENDED_SALT);
case OPTI_TYPE_APPENDED_SALT: return ((char *) OPTI_STR_APPENDED_SALT);
case OPTI_TYPE_SINGLE_HASH: return ((char *) OPTI_STR_SINGLE_HASH);
case OPTI_TYPE_SINGLE_SALT: return ((char *) OPTI_STR_SINGLE_SALT);
case OPTI_TYPE_BRUTE_FORCE: return ((char *) OPTI_STR_BRUTE_FORCE);
case OPTI_TYPE_RAW_HASH: return ((char *) OPTI_STR_RAW_HASH);
case OPTI_TYPE_SLOW_HASH_SIMD: return ((char *) OPTI_STR_SLOW_HASH_SIMD);
case OPTI_TYPE_USES_BITS_8: return ((char *) OPTI_STR_USES_BITS_8);
case OPTI_TYPE_USES_BITS_16: return ((char *) OPTI_STR_USES_BITS_16);
case OPTI_TYPE_USES_BITS_32: return ((char *) OPTI_STR_USES_BITS_32);
case OPTI_TYPE_USES_BITS_64: return ((char *) OPTI_STR_USES_BITS_64);
}
return (NULL);
}
char *strhashtype (const uint hash_mode)
{
switch (hash_mode)

@ -1,7 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
#include "kernel.h"

@ -10,6 +10,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "ext_OpenCL.h"
#include "ext_ADL.h"
@ -20,7 +21,6 @@
#include "memory.h"
#include "hwmon.h"
#include "rp_cpu.h"
#include "interface.h"
#include "mpsp.h"
#include "opencl.h"
#include "restore.h"

@ -10,6 +10,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "memory.h"
#include "logging.h"
@ -22,7 +23,6 @@
#include "filehandling.h"
#include "thread.h"
#include "hwmon.h"
#include "interface.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "opencl.h"

File diff suppressed because it is too large Load Diff

@ -6,6 +6,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "memory.h"
#include "logging.h"
@ -17,7 +18,6 @@
#include "thread.h"
#include "rp_cpu.h"
#include "hwmon.h"
#include "interface.h"
#include "mpsp.h"
#include "opencl.h"
#include "restore.h"
@ -25,6 +25,7 @@
#include "potfile.h"
#include "debugfile.h"
#include "loopback.h"
#include "status.h"
#include "data.h"
extern hc_global_data_t data;
@ -300,3 +301,55 @@ void cycle_restore ()
log_info ("WARN: Rename file '%s' to '%s': %s", new_restore_file, eff_restore_file, strerror (errno));
}
}
void check_checkpoint ()
{
// if (data.restore_disable == 1) break; (this is already implied by previous checks)
u64 words_cur = get_lowest_words_done ();
if (words_cur != data.checkpoint_cur_words)
{
myabort ();
}
}
void stop_at_checkpoint ()
{
if (data.devices_status != STATUS_STOP_AT_CHECKPOINT)
{
if (data.devices_status != STATUS_RUNNING) return;
}
// this feature only makes sense if --restore-disable was not specified
if (data.restore_disable == 1)
{
log_info ("WARNING: This feature is disabled when --restore-disable is specified");
return;
}
// check if monitoring of Restore Point updates should be enabled or disabled
if (data.devices_status != STATUS_STOP_AT_CHECKPOINT)
{
data.devices_status = STATUS_STOP_AT_CHECKPOINT;
// save the current restore point value
data.checkpoint_cur_words = get_lowest_words_done ();
log_info ("Checkpoint enabled: Will quit at next Restore Point update");
}
else
{
data.devices_status = STATUS_RUNNING;
// reset the global value for checkpoint checks
data.checkpoint_cur_words = 0;
log_info ("Checkpoint disabled: Restore Point updates will no longer be monitored");
}
}

@ -10,6 +10,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "memory.h"
#include "logging.h"
@ -23,7 +24,6 @@
#include "rp_cpu.h"
#include "terminal.h"
#include "hwmon.h"
#include "interface.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "opencl.h"

@ -6,6 +6,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "memory.h"
#include "logging.h"
@ -18,11 +19,9 @@
#include "rp_cpu.h"
#include "terminal.h"
#include "hwmon.h"
#include "interface.h"
#include "mpsp.h"
#include "opencl.h"
#include "restore.h"
#include "interface.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
@ -47,6 +46,7 @@ extern hc_global_data_t data;
extern hc_thread_mutex_t mux_hwmon;
hc_thread_mutex_t mux_display;
hc_thread_mutex_t mux_counter;
static void format_timer_display (struct tm *tm, char *buf, size_t len)
{
@ -143,6 +143,33 @@ static char *strstatus (const uint devices_status)
return ((char *) "Unknown");
}
double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries)
{
int exec_pos = (int) device_param->exec_pos - last_num_entries;
if (exec_pos < 0) exec_pos += EXEC_CACHE;
double exec_ms_sum = 0;
int exec_ms_cnt = 0;
for (int i = 0; i < last_num_entries; i++)
{
double exec_ms = device_param->exec_ms[(exec_pos + i) % EXEC_CACHE];
if (exec_ms > 0)
{
exec_ms_sum += exec_ms;
exec_ms_cnt++;
}
}
if (exec_ms_cnt == 0) return 0;
return exec_ms_sum / exec_ms_cnt;
}
void status_display_machine_readable ()
{
FILE *out = stdout;

@ -6,6 +6,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "memory.h"
#include "convert.h"
@ -21,10 +22,8 @@
#include "locking.h"
#include "rp_cpu.h"
#include "rp_kernel_on_cpu.h"
#include "interface.h"
#include "shared.h"
#include "hwmon.h"
#include "interface.h"
#include "mpsp.h"
#include "restore.h"
#include "outfile.h"

@ -6,6 +6,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "ext_OpenCL.h"
#include "ext_ADL.h"
@ -16,7 +17,6 @@
#include "thread.h"
#include "rp_cpu.h"
#include "terminal.h"
#include "interface.h"
#include "hwmon.h"
#include "mpsp.h"
#include "restore.h"

@ -6,6 +6,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "logging.h"
#include "memory.h"

@ -4,4 +4,110 @@
*/
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "logging.h"
#include "ext_OpenCL.h"
#include "ext_ADL.h"
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "hwmon.h"
#include "mpsp.h"
#include "rp_cpu.h"
#include "restore.h"
#include "opencl.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
#include "loopback.h"
#include "data.h"
#include "hash_management.h"
#include "weak_hash.h"
extern hc_global_data_t data;
void weak_hash_check (hc_device_param_t *device_param, hashconfig_t *hashconfig, const uint salt_pos)
{
if (device_param == NULL)
{
log_error ("ERROR: %s : Invalid argument", __func__);
exit (-1);
}
salt_t *salt_buf = &data.salts_buf[salt_pos];
device_param->kernel_params_buf32[27] = salt_pos;
device_param->kernel_params_buf32[30] = 1;
device_param->kernel_params_buf32[31] = salt_buf->digests_cnt;
device_param->kernel_params_buf32[32] = salt_buf->digests_offset;
device_param->kernel_params_buf32[33] = 0;
device_param->kernel_params_buf32[34] = 1;
char *dictfile_old = data.dictfile;
const char *weak_hash_check = "weak-hash-check";
data.dictfile = (char *) weak_hash_check;
uint cmd0_rule_old = data.kernel_rules_buf[0].cmds[0];
data.kernel_rules_buf[0].cmds[0] = 0;
/**
* run the kernel
*/
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
run_kernel (KERN_RUN_1, device_param, 1, false, 0, hashconfig);
}
else
{
run_kernel (KERN_RUN_1, device_param, 1, false, 0, hashconfig);
uint loop_step = 16;
const uint iter = salt_buf->salt_iter;
for (uint loop_pos = 0; loop_pos < iter; loop_pos += loop_step)
{
uint loop_left = iter - loop_pos;
loop_left = MIN (loop_left, loop_step);
device_param->kernel_params_buf32[28] = loop_pos;
device_param->kernel_params_buf32[29] = loop_left;
run_kernel (KERN_RUN_2, device_param, 1, false, 0, hashconfig);
}
run_kernel (KERN_RUN_3, device_param, 1, false, 0, hashconfig);
}
/**
* result
*/
check_cracked (device_param, salt_pos, hashconfig);
/**
* cleanup
*/
device_param->kernel_params_buf32[27] = 0;
device_param->kernel_params_buf32[28] = 0;
device_param->kernel_params_buf32[29] = 0;
device_param->kernel_params_buf32[30] = 0;
device_param->kernel_params_buf32[31] = 0;
device_param->kernel_params_buf32[32] = 0;
device_param->kernel_params_buf32[33] = 0;
device_param->kernel_params_buf32[34] = 0;
data.dictfile = dictfile_old;
data.kernel_rules_buf[0].cmds[0] = cmd0_rule_old;
}

@ -6,6 +6,7 @@
#include "common.h"
#include "types_int.h"
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "memory.h"
#include "convert.h"
@ -21,7 +22,6 @@
#include "locking.h"
#include "rp_cpu.h"
#include "rp_kernel_on_cpu.h"
#include "interface.h"
#include "shared.h"
#include "hwmon.h"
#include "thread.h"

Loading…
Cancel
Save