1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 16:18:09 +00:00

Move functions from filenames.c to opencl.c and shared.c

This commit is contained in:
jsteube 2016-09-24 21:44:43 +02:00
parent d6cfa58dbc
commit 59ebe10b07
10 changed files with 155 additions and 194 deletions

View File

@ -1,21 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _FILENAMES_H
#define _FILENAMES_H
#include <stdio.h>
void generate_dictstat_filename (char *profile_dir, char *dictstat_filename);
void generate_source_kernel_filename (const uint attack_exec, const uint attack_kern, const uint kern_type, char *shared_dir, char *source_file);
void generate_cached_kernel_filename (const uint attack_exec, const uint attack_kern, const uint kern_type, char *profile_dir, const char *device_name_chksum, char *cached_file);
void generate_source_kernel_mp_filename (const uint opti_type, const uint opts_type, char *shared_dir, char *source_file);
void generate_cached_kernel_mp_filename (const uint opti_type, const uint opts_type, char *profile_dir, const char *device_name_chksum, char *cached_file);
void generate_source_kernel_amp_filename (const uint attack_kern, char *shared_dir, char *source_file);
void generate_cached_kernel_amp_filename (const uint attack_kern, char *profile_dir, const char *device_name_chksum, char *cached_file);
char *filename_from_filepath (char *filepath);
#endif // _FILENAMES_H

View File

@ -18,18 +18,6 @@ static const char CL_VENDOR_MESA[] = "Mesa";
static const char CL_VENDOR_NV[] = "NVIDIA Corporation";
static const char CL_VENDOR_POCL[] = "The pocl project";
static const char ST_0000[] = "Initializing";
static const char ST_0001[] = "Autotuning";
static const char ST_0002[] = "Running";
static const char ST_0003[] = "Paused";
static const char ST_0004[] = "Exhausted";
static const char ST_0005[] = "Cracked";
static const char ST_0006[] = "Aborted";
static const char ST_0007[] = "Quit";
static const char ST_0008[] = "Bypass";
char *strstatus (const uint devices_status);
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);

View File

@ -17,6 +17,8 @@ u32 get_random_num (const u32 min, const u32 max);
u32 mydivc32 (const u32 dividend, const u32 divisor);
u64 mydivc64 (const u64 dividend, const u64 divisor);
char *filename_from_filepath (char *filepath);
void naive_replace (char *s, const u8 key_char, const u8 replace_char);
void naive_escape (char *s, size_t s_max, const u8 key_char, const u8 escape_char);

View File

@ -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 dispatch 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 monitor mpsp opencl outfile_check outfile potfile powertune remove restore rp rp_cpu rp_kernel_on_cpu runtime shared status stdout terminal thread timer tuningdb usage user_options 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 dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hash_management hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile powertune remove restore rp rp_cpu rp_kernel_on_cpu runtime shared status stdout terminal thread timer tuningdb usage user_options version weak_hash wordlist
NATIVE_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.o)

View File

@ -6,7 +6,6 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "filenames.h"
#include "logging.h"
#include "dictstat.h"
@ -40,7 +39,7 @@ void dictstat_init (dictstat_ctx_t *dictstat_ctx, const user_options_t *user_opt
dictstat_ctx->cnt = 0;
dictstat_ctx->enabled = true;
generate_dictstat_filename (folder_config->profile_dir, dictstat_ctx->filename);
snprintf (dictstat_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.dictstat", folder_config->profile_dir);
}
void dictstat_destroy (dictstat_ctx_t *dictstat_ctx)

View File

@ -1,100 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
#include "types.h"
#include "interface.h"
#include "filenames.h"
void generate_dictstat_filename (char *profile_dir, char *dictstat_filename)
{
snprintf (dictstat_filename, HCBUFSIZ_TINY - 1, "%s/hashcat.dictstat", profile_dir);
}
void generate_source_kernel_filename (const uint attack_exec, const uint attack_kern, const uint kern_type, char *shared_dir, char *source_file)
{
if (attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
if (attack_kern == ATTACK_KERN_STRAIGHT)
snprintf (source_file, 255, "%s/OpenCL/m%05d_a0.cl", shared_dir, (int) kern_type);
else if (attack_kern == ATTACK_KERN_COMBI)
snprintf (source_file, 255, "%s/OpenCL/m%05d_a1.cl", shared_dir, (int) kern_type);
else if (attack_kern == ATTACK_KERN_BF)
snprintf (source_file, 255, "%s/OpenCL/m%05d_a3.cl", shared_dir, (int) kern_type);
}
else
snprintf (source_file, 255, "%s/OpenCL/m%05d.cl", shared_dir, (int) kern_type);
}
void generate_cached_kernel_filename (const uint attack_exec, const uint attack_kern, const uint kern_type, char *profile_dir, const char *device_name_chksum, char *cached_file)
{
if (attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
if (attack_kern == ATTACK_KERN_STRAIGHT)
snprintf (cached_file, 255, "%s/kernels/m%05d_a0.%s.kernel", profile_dir, (int) kern_type, device_name_chksum);
else if (attack_kern == ATTACK_KERN_COMBI)
snprintf (cached_file, 255, "%s/kernels/m%05d_a1.%s.kernel", profile_dir, (int) kern_type, device_name_chksum);
else if (attack_kern == ATTACK_KERN_BF)
snprintf (cached_file, 255, "%s/kernels/m%05d_a3.%s.kernel", profile_dir, (int) kern_type, device_name_chksum);
}
else
{
snprintf (cached_file, 255, "%s/kernels/m%05d.%s.kernel", profile_dir, (int) kern_type, device_name_chksum);
}
}
void generate_source_kernel_mp_filename (const uint opti_type, const uint opts_type, char *shared_dir, char *source_file)
{
if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
{
snprintf (source_file, 255, "%s/OpenCL/markov_be.cl", shared_dir);
}
else
{
snprintf (source_file, 255, "%s/OpenCL/markov_le.cl", shared_dir);
}
}
void generate_cached_kernel_mp_filename (const uint opti_type, const uint opts_type, char *profile_dir, const char *device_name_chksum, char *cached_file)
{
if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
{
snprintf (cached_file, 255, "%s/kernels/markov_be.%s.kernel", profile_dir, device_name_chksum);
}
else
{
snprintf (cached_file, 255, "%s/kernels/markov_le.%s.kernel", profile_dir, device_name_chksum);
}
}
void generate_source_kernel_amp_filename (const uint attack_kern, char *shared_dir, char *source_file)
{
snprintf (source_file, 255, "%s/OpenCL/amp_a%d.cl", shared_dir, attack_kern);
}
void generate_cached_kernel_amp_filename (const uint attack_kern, char *profile_dir, const char *device_name_chksum, char *cached_file)
{
snprintf (cached_file, 255, "%s/kernels/amp_a%d.%s.kernel", profile_dir, attack_kern, device_name_chksum);
}
char *filename_from_filepath (char *filepath)
{
char *ptr = NULL;
if ((ptr = strrchr (filepath, '/')) != NULL)
{
ptr++;
}
else if ((ptr = strrchr (filepath, '\\')) != NULL)
{
ptr++;
}
else
{
ptr = filepath;
}
return ptr;
}

View File

@ -23,68 +23,67 @@
#endif // _POSIX
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "affinity.h"
#include "attack_mode.h"
#include "autotune.h"
#include "benchmark.h"
#include "bitmap.h"
#include "bitops.h"
#include "memory.h"
#include "folder.h"
#include "convert.h"
#include "logging.h"
#include "logfile.h"
#include "ext_OpenCL.h"
#include "ext_ADL.h"
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
#include "cpu_aes.h"
#include "cpu_crc32.h"
#include "cpu_des.h"
#include "cpu_md5.h"
#include "cpu_sha1.h"
#include "cpu_sha256.h"
#include "data.h"
#include "debugfile.h"
#include "dictstat.h"
#include "dispatch.h"
#include "ext_ADL.h"
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_OpenCL.h"
#include "ext_xnvctrl.h"
#include "filehandling.h"
#include "tuningdb.h"
#include "thread.h"
#include "opencl.h"
#include "hwmon.h"
#include "restore.h"
#include "folder.h"
#include "hash_management.h"
#include "locking.h"
#include "rp.h"
#include "rp_cpu.h"
#include "rp_kernel_on_cpu.h"
#include "terminal.h"
#include "hlfmt.h"
#include "hwmon.h"
#include "inc_hash_constants.h"
#include "shared.h"
#include "induct.h"
#include "interface.h"
#include "locking.h"
#include "logfile.h"
#include "logging.h"
#include "loopback.h"
#include "memory.h"
#include "monitor.h"
#include "mpsp.h"
#include "opencl.h"
#include "outfile_check.h"
#include "outfile.h"
#include "potfile.h"
#include "debugfile.h"
#include "loopback.h"
#include "data.h"
#include "affinity.h"
#include "bitmap.h"
#include "usage.h"
#include "status.h"
#include "hlfmt.h"
#include "filenames.h"
#include "stdout.h"
#include "dictstat.h"
#include "wordlist.h"
#include "version.h"
#include "benchmark.h"
#include "outfile_check.h"
#include "weak_hash.h"
#include "remove.h"
#include "runtime.h"
#include "attack_mode.h"
#include "powertune.h"
#include "autotune.h"
#include "induct.h"
#include "dispatch.h"
#include "monitor.h"
#include "remove.h"
#include "restore.h"
#include "rp_cpu.h"
#include "rp.h"
#include "rp_kernel_on_cpu.h"
#include "runtime.h"
#include "session.h"
#include "shared.h"
#include "status.h"
#include "stdout.h"
#include "terminal.h"
#include "thread.h"
#include "timer.h"
#include "tuningdb.h"
#include "usage.h"
#include "user_options.h"
#include "version.h"
#include "weak_hash.h"
#include "wordlist.h"
extern hc_global_data_t data;

View File

@ -30,7 +30,6 @@
#include "potfile.h"
#include "debugfile.h"
#include "loopback.h"
#include "filenames.h"
#include "data.h"
#include "shared.h"
#include "filehandling.h"
@ -46,22 +45,70 @@ extern const int comptime;
static double TARGET_MS_PROFILE[4] = { 2, 12, 96, 480 };
char *strstatus (const uint devices_status)
static void generate_source_kernel_filename (const uint attack_exec, const uint attack_kern, const uint kern_type, char *shared_dir, char *source_file)
{
switch (devices_status)
if (attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
case STATUS_INIT: return ((char *) ST_0000);
case STATUS_AUTOTUNE: return ((char *) ST_0001);
case STATUS_RUNNING: return ((char *) ST_0002);
case STATUS_PAUSED: return ((char *) ST_0003);
case STATUS_EXHAUSTED: return ((char *) ST_0004);
case STATUS_CRACKED: return ((char *) ST_0005);
case STATUS_ABORTED: return ((char *) ST_0006);
case STATUS_QUIT: return ((char *) ST_0007);
case STATUS_BYPASS: return ((char *) ST_0008);
if (attack_kern == ATTACK_KERN_STRAIGHT)
snprintf (source_file, 255, "%s/OpenCL/m%05d_a0.cl", shared_dir, (int) kern_type);
else if (attack_kern == ATTACK_KERN_COMBI)
snprintf (source_file, 255, "%s/OpenCL/m%05d_a1.cl", shared_dir, (int) kern_type);
else if (attack_kern == ATTACK_KERN_BF)
snprintf (source_file, 255, "%s/OpenCL/m%05d_a3.cl", shared_dir, (int) kern_type);
}
else
snprintf (source_file, 255, "%s/OpenCL/m%05d.cl", shared_dir, (int) kern_type);
}
return ((char *) "Uninitialized! Bug!");
static void generate_cached_kernel_filename (const uint attack_exec, const uint attack_kern, const uint kern_type, char *profile_dir, const char *device_name_chksum, char *cached_file)
{
if (attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
if (attack_kern == ATTACK_KERN_STRAIGHT)
snprintf (cached_file, 255, "%s/kernels/m%05d_a0.%s.kernel", profile_dir, (int) kern_type, device_name_chksum);
else if (attack_kern == ATTACK_KERN_COMBI)
snprintf (cached_file, 255, "%s/kernels/m%05d_a1.%s.kernel", profile_dir, (int) kern_type, device_name_chksum);
else if (attack_kern == ATTACK_KERN_BF)
snprintf (cached_file, 255, "%s/kernels/m%05d_a3.%s.kernel", profile_dir, (int) kern_type, device_name_chksum);
}
else
{
snprintf (cached_file, 255, "%s/kernels/m%05d.%s.kernel", profile_dir, (int) kern_type, device_name_chksum);
}
}
static void generate_source_kernel_mp_filename (const uint opti_type, const uint opts_type, char *shared_dir, char *source_file)
{
if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
{
snprintf (source_file, 255, "%s/OpenCL/markov_be.cl", shared_dir);
}
else
{
snprintf (source_file, 255, "%s/OpenCL/markov_le.cl", shared_dir);
}
}
static void generate_cached_kernel_mp_filename (const uint opti_type, const uint opts_type, char *profile_dir, const char *device_name_chksum, char *cached_file)
{
if ((opti_type & OPTI_TYPE_BRUTE_FORCE) && (opts_type & OPTS_TYPE_PT_GENERATE_BE))
{
snprintf (cached_file, 255, "%s/kernels/markov_be.%s.kernel", profile_dir, device_name_chksum);
}
else
{
snprintf (cached_file, 255, "%s/kernels/markov_le.%s.kernel", profile_dir, device_name_chksum);
}
}
static void generate_source_kernel_amp_filename (const uint attack_kern, char *shared_dir, char *source_file)
{
snprintf (source_file, 255, "%s/OpenCL/amp_a%d.cl", shared_dir, attack_kern);
}
static void generate_cached_kernel_amp_filename (const uint attack_kern, char *profile_dir, const char *device_name_chksum, char *cached_file)
{
snprintf (cached_file, 255, "%s/kernels/amp_a%d.%s.kernel", profile_dir, attack_kern, device_name_chksum);
}
static uint setup_opencl_platforms_filter (const char *opencl_platforms)

View File

@ -37,6 +37,26 @@ u64 mydivc64 (const u64 dividend, const u64 divisor)
return quotient;
}
char *filename_from_filepath (char *filepath)
{
char *ptr = NULL;
if ((ptr = strrchr (filepath, '/')) != NULL)
{
ptr++;
}
else if ((ptr = strrchr (filepath, '\\')) != NULL)
{
ptr++;
}
else
{
ptr = filepath;
}
return ptr;
}
void naive_replace (char *s, const u8 key_char, const u8 replace_char)
{
const size_t len = strlen (s);

View File

@ -35,6 +35,16 @@ extern hc_thread_mutex_t mux_hwmon;
hc_thread_mutex_t mux_display;
static const char ST_0000[] = "Initializing";
static const char ST_0001[] = "Autotuning";
static const char ST_0002[] = "Running";
static const char ST_0003[] = "Paused";
static const char ST_0004[] = "Exhausted";
static const char ST_0005[] = "Cracked";
static const char ST_0006[] = "Aborted";
static const char ST_0007[] = "Quit";
static const char ST_0008[] = "Bypass";
static void format_timer_display (struct tm *tm, char *buf, size_t len)
{
const char *time_entities_s[] = { "year", "day", "hour", "min", "sec" };
@ -110,6 +120,23 @@ static void format_speed_display (double val, char *buf, size_t len)
}
}
static char *strstatus (const uint devices_status)
{
switch (devices_status)
{
case STATUS_INIT: return ((char *) ST_0000);
case STATUS_AUTOTUNE: return ((char *) ST_0001);
case STATUS_RUNNING: return ((char *) ST_0002);
case STATUS_PAUSED: return ((char *) ST_0003);
case STATUS_EXHAUSTED: return ((char *) ST_0004);
case STATUS_CRACKED: return ((char *) ST_0005);
case STATUS_ABORTED: return ((char *) ST_0006);
case STATUS_QUIT: return ((char *) ST_0007);
case STATUS_BYPASS: return ((char *) ST_0008);
}
return ((char *) "Uninitialized! Bug!");
}
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;