1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-01-11 16:21:12 +00:00

Merge pull request #544 from hashcat/hashcat-as-library

Hashcat as library
This commit is contained in:
Jens Steube 2016-10-21 16:41:33 +02:00 committed by GitHub
commit f558a64ab4
93 changed files with 9912 additions and 8699 deletions

View File

@ -89,9 +89,15 @@
#if KERN_TYPE == 6223
#undef _unroll
#endif
#if KERN_TYPE == 6400
#undef _unroll
#endif
#if KERN_TYPE == 6500
#undef _unroll
#endif
#if KERN_TYPE == 6800
#undef _unroll
#endif
#if KERN_TYPE == 7100
#undef _unroll
#endif
@ -104,6 +110,9 @@
#if KERN_TYPE == 8200
#undef _unroll
#endif
#if KERN_TYPE == 8900
#undef _unroll
#endif
#if KERN_TYPE == 10400
#undef _unroll
#endif
@ -113,12 +122,18 @@
#if KERN_TYPE == 10700
#undef _unroll
#endif
#if KERN_TYPE == 10900
#undef _unroll
#endif
#if KERN_TYPE == 12300
#undef _unroll
#endif
#if KERN_TYPE == 12400
#undef _unroll
#endif
#if KERN_TYPE == 12900
#undef _unroll
#endif
#if KERN_TYPE == 13721
#undef _unroll
#endif
@ -128,6 +143,15 @@
#if KERN_TYPE == 13723
#undef _unroll
#endif
#if KERN_TYPE == 13751
#undef _unroll
#endif
#if KERN_TYPE == 13752
#undef _unroll
#endif
#if KERN_TYPE == 13753
#undef _unroll
#endif
#if KERN_TYPE == 14000
#undef _unroll
#endif

View File

@ -58,7 +58,7 @@ __constant u64 k_sha512[80] =
SHA512C4c, SHA512C4d, SHA512C4e, SHA512C4f,
};
void sha512_transform (const u64 w[16], u64 digest[8])
void sha512_transform (const u64 *w, u64 *digest)
{
u64 w0_t = w[ 0];
u64 w1_t = w[ 1];

View File

@ -54,7 +54,7 @@ __constant u32 k_sha256[64] =
SHA256C3c, SHA256C3d, SHA256C3e, SHA256C3f,
};
void sha256_transform (const u32 w0[4], const u32 w1[4], const u32 w2[4], const u32 w3[4], u32 digest[8])
void sha256_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest)
{
u32 a = digest[0];
u32 b = digest[1];
@ -166,7 +166,7 @@ __constant u64 k_sha384[80] =
SHA384C4c, SHA384C4d, SHA384C4e, SHA384C4f,
};
void sha384_transform (const u64 w0[4], const u64 w1[4], const u64 w2[4], const u64 w3[4], u64 digest[8])
void sha384_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest)
{
u64 a = digest[0];
u64 b = digest[1];
@ -278,7 +278,7 @@ __constant u64 k_sha512[80] =
SHA384C4c, SHA384C4d, SHA384C4e, SHA384C4f,
};
void sha512_transform (const u64 w0[4], const u64 w1[4], const u64 w2[4], const u64 w3[4], u64 digest[8])
void sha512_transform (const u32 *w0, const u32 *w1, const u32 *w2, const u32 *w3, u32 *digest)
{
u64 a = digest[0];
u64 b = digest[1];

View File

@ -4,6 +4,7 @@
## Improvements
##
- Added support for --speed-only: quickly shows expected speed per device based on the users hash(es) and option selected
- Added the current first and last password candidate test queued for execution per device on status view
- Use .gitmodules to handle OpenCL headers depency
- Allow loading of bcrypt hashes with signature $2b$ (February 2014)
@ -13,6 +14,8 @@
- Added docs/team.txt
- Allow words of length > 32 in wordlists for -a 0 for slow hashes if no rules are in use or a : rule is in the rulefile
- Reduce max. number of allowed function calls per rule from 256 to 32 to save GPU memory
- Status display shows what's the base and modifier keyspace currently in use
- Added a workaround for some OpenCL kernel to compile with amd-gpu-pro
##
## Algorithms

View File

@ -188,7 +188,7 @@ _hashcat ()
local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s'
local SHORT_OPTS="-m -a -V -v -h -b -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l"
local LONG_OPTS="--hash-type --attack-mode --version --help --eula --quiet --benchmark --benchmark-repeats --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --loopback --weak-hash-threshold --markov-hcstat --markov-disable --markov-classic --markov-threshold --runtime --session --restore --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-info --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-disable --gpu-temp-abort --gpu-temp-retain --powertune-enable --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --rules-cleanup --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --truecrypt-keyfiles"
local LONG_OPTS="--hash-type --attack-mode --version --help --eula --quiet --benchmark --benchmark-repeats --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --loopback --weak-hash-threshold --markov-hcstat --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --restore --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-info --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-disable --gpu-temp-abort --gpu-temp-retain --powertune-enable --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --rules-cleanup --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --truecrypt-keyfiles"
local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --benchmark-repeats --status-timer --weak-hash-threshold --markov-hcstat --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-abort --gpu-temp-retain -disable --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --truecrypt-keyfiles"
COMPREPLY=()

View File

@ -17,12 +17,13 @@
#if defined (__APPLE__)
#include <mach-o/dyld.h>
#include <mach/mach.h>
#include <mach/thread_policy.h>
#endif // __APPLE__
#if defined (_WIN)
#include <windows.h>
#endif // _WIN
void set_cpu_affinity (char *cpu_affinity);
int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx);
#endif // _AFFINITY_H

View File

@ -8,7 +8,7 @@
#include <string.h>
void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx);
int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx);
void bitmap_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _BITMAP_H

View File

@ -87,4 +87,6 @@ but this is nededed for VS compiler which doesn't have inline keyword but has __
#define EOL "\n"
#endif
#define MAYBE_UNUSED __attribute__((unused))
#endif // _COMMON_H

View File

@ -9,6 +9,6 @@
#include <stdio.h>
#include <errno.h>
void cpu_crc32 (const char *filename, u8 keytab[64]);
int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64]);
#endif // _CPU_CRC32_H

View File

@ -34,11 +34,11 @@ void *hc_dlsym (void *module, const char *symbol);
if (noerr != -1) { \
if (!ptr->name) { \
if (noerr == 1) { \
log_error ("ERROR: %s is missing from %s shared library.", #name, #libname); \
exit (-1); \
} else { \
log_info ("WARNING: %s is missing from %s shared library.", #name, #libname); \
event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \
return -1; \
} else { \
event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \
return 0; \
} \
} \
}
@ -48,11 +48,11 @@ void *hc_dlsym (void *module, const char *symbol);
if (noerr != -1) { \
if (!ptr->name) { \
if (noerr == 1) { \
log_error ("ERROR: %s is missing from %s shared library.", #name, #libname); \
exit (-1); \
} else { \
log_info ("WARNING: %s is missing from %s shared library.", #name, #libname); \
event_log_error (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \
return -1; \
} else { \
event_log_warning (hashcat_ctx, "%s is missing from %s shared library.", #name, #libname); \
return 0; \
} \
} \
}
@ -61,13 +61,12 @@ void *hc_dlsym (void *module, const char *symbol);
ptr->name = (type) (*ptr->func) (addr); \
if (!ptr->name) { \
if (noerr == 1) { \
log_error ("ERROR: %s at address %08x is missing from %s shared library.", #name, addr, #libname); \
exit (-1); \
} else { \
log_error ("WARNING: %s at address %08x is missing from %s shared library.", #name, addr, #libname); \
event_log_error (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \
return -1; \
} else { \
event_log_warning (hashcat_ctx, "%s at address %08x is missing from %s shared library.", #name, addr, #libname); \
return 0; \
} \
}
#endif // _DYNALOADER_H

28
include/event.h Normal file
View File

@ -0,0 +1,28 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _EVENT_H
#define _EVENT_H
#include <stdio.h>
#include <stdarg.h>
void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len);
#define EVENT(id) event_call ((id), hashcat_ctx, NULL, 0)
#define EVENT_DATA(id,buf,len) event_call ((id), hashcat_ctx, (buf), (len))
size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...);
int event_ctx_init (hashcat_ctx_t *hashcat_ctx);
void event_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _EVENT_H

View File

@ -7,6 +7,11 @@
#define _EXT_ADL_H
#include <string.h>
#include <stdlib.h>
#if defined (_WIN)
#include <windows.h>
#endif // _WIN
/**
* Declarations from adl_sdk.h and subheaders
@ -352,44 +357,6 @@ typedef struct hm_adl_lib
typedef hm_adl_lib_t ADL_PTR;
int adl_init (ADL_PTR *lib);
void adl_close (ADL_PTR *lib);
void *HC_API_CALL ADL_Main_Memory_Alloc (const int iSize);
int hm_ADL_Main_Control_Destroy (ADL_PTR *adl);
int hm_ADL_Main_Control_Create (ADL_PTR *adl, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters);
int hm_ADL_Adapter_NumberOfAdapters_Get (ADL_PTR *adl, int *lpNumAdapters);
int hm_ADL_Adapter_AdapterInfo_Get (ADL_PTR *adl, LPAdapterInfo lpInfo, int iInputSize);
int hm_ADL_Display_DisplayInfo_Get (ADL_PTR *adl, int iAdapterIndex, int *iNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect);
int hm_ADL_Overdrive5_Temperature_Get (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature);
int hm_ADL_Overdrive6_Temperature_Get (ADL_PTR *adl, int iAdapterIndex, int *iTemperature);
int hm_ADL_Overdrive_CurrentActivity_Get (ADL_PTR *adl, int iAdapterIndex, ADLPMActivity *lpActivity);
int hm_ADL_Overdrive_ThermalDevices_Enum (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo);
int hm_ADL_Adapter_ID_Get (ADL_PTR *adl, int iAdapterIndex, int *lpAdapterID);
int hm_ADL_Adapter_VideoBiosInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLBiosInfo *lpBiosInfo);
int hm_ADL_Overdrive5_FanSpeedInfo_Get (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo);
int hm_ADL_Overdrive5_FanSpeed_Get (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue);
int hm_ADL_Overdrive6_FanSpeed_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo);
int hm_ADL_Overdrive5_FanSpeed_Set (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue);
int hm_ADL_Overdrive6_FanSpeed_Set (ADL_PTR *adl, int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue);
int hm_ADL_Overdrive5_FanSpeedToDefault_Set (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex);
int hm_ADL_Overdrive_ODParameters_Get (ADL_PTR *adl, int iAdapterIndex, ADLODParameters *lpOdParameters);
int hm_ADL_Overdrive_ODPerformanceLevels_Get (ADL_PTR *adl, int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels);
int hm_ADL_Overdrive_ODPerformanceLevels_Set (ADL_PTR *adl, int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels);
int hm_ADL_Overdrive_PowerControlInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6PowerControlInfo *);
int hm_ADL_Overdrive_PowerControl_Get (ADL_PTR *adl, int iAdapterIndex, int *level);
int hm_ADL_Overdrive_PowerControl_Set (ADL_PTR *adl, int iAdapterIndex, int level);
int hm_ADL_Adapter_Active_Get (ADL_PTR *adl, int iAdapterIndex, int *lpStatus);
//int hm_ADL_DisplayEnable_Set (ADL_PTR *adl, int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly);
int hm_ADL_Overdrive_Caps (ADL_PTR *adl, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version);
int hm_ADL_Overdrive_CurrentStatus_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6CurrentStatus *status);
int hm_ADL_Overdrive_StateInfo_Get (ADL_PTR *adl, int iAdapterIndex, int type, ADLOD6MemClockState *state);
int hm_ADL_Overdrive_Capabilities_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6Capabilities *caps);
int hm_ADL_Overdrive_State_Set (ADL_PTR *adl, int iAdapterIndex, int type, ADLOD6StateInfo *state);
int hm_ADL_Overdrive6_PowerControl_Caps (ADL_PTR *adl, int iAdapterIndex, int *lpSupported);
int hm_ADL_Overdrive6_TargetTemperatureData_Get (ADL_PTR *adl, int iAdapterIndex, int *cur_temp, int *default_temp);
int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo);
int hm_ADL_Overdrive6_FanSpeed_Reset (ADL_PTR *adl, int iAdapterIndex);
#endif // _EXT_ADL_H

View File

@ -109,40 +109,4 @@ typedef hc_opencl_lib_t OCL_PTR;
const char *val2cstr_cl (cl_int CL_err);
int ocl_init (OCL_PTR *ocl);
void ocl_close (OCL_PTR *ocl);
cl_int hc_clBuildProgram (OCL_PTR *ocl, cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify) (cl_program program, void *user_data), void *user_data);
cl_int hc_clCreateBuffer (OCL_PTR *ocl, cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_mem *mem);
cl_int hc_clCreateCommandQueue (OCL_PTR *ocl, cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_command_queue *command_queue);
cl_int hc_clCreateContext (OCL_PTR *ocl, cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify) (const char *, const void *, size_t, void *), void *user_data, cl_context *context);
cl_int hc_clCreateKernel (OCL_PTR *ocl, cl_program program, const char *kernel_name, cl_kernel *kernel);
cl_int hc_clCreateProgramWithBinary (OCL_PTR *ocl, cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_program *program);
cl_int hc_clCreateProgramWithSource (OCL_PTR *ocl, cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_program *program);
cl_int hc_clEnqueueCopyBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
cl_int hc_clEnqueueMapBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event, void **buf);
cl_int hc_clEnqueueNDRangeKernel (OCL_PTR *ocl, cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
cl_int hc_clEnqueueReadBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
cl_int hc_clEnqueueUnmapMemObject (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
cl_int hc_clEnqueueWriteBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
cl_int hc_clFinish (OCL_PTR *ocl, cl_command_queue command_queue);
cl_int hc_clFlush (OCL_PTR *ocl, cl_command_queue command_queue);
cl_int hc_clGetDeviceIDs (OCL_PTR *ocl, cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices);
cl_int hc_clGetDeviceInfo (OCL_PTR *ocl, cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
cl_int hc_clGetEventInfo (OCL_PTR *ocl, cl_event event, cl_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
cl_int hc_clGetEventProfilingInfo (OCL_PTR *ocl, cl_event event, cl_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
cl_int hc_clGetKernelWorkGroupInfo (OCL_PTR *ocl, cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
cl_int hc_clGetPlatformIDs (OCL_PTR *ocl, cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms);
cl_int hc_clGetPlatformInfo (OCL_PTR *ocl, cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
cl_int hc_clGetProgramBuildInfo (OCL_PTR *ocl, cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
cl_int hc_clGetProgramInfo (OCL_PTR *ocl, cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t * param_value_size_ret);
cl_int hc_clReleaseCommandQueue (OCL_PTR *ocl, cl_command_queue command_queue);
cl_int hc_clReleaseContext (OCL_PTR *ocl, cl_context context);
cl_int hc_clReleaseEvent (OCL_PTR *ocl, cl_event event);
cl_int hc_clReleaseKernel (OCL_PTR *ocl, cl_kernel kernel);
cl_int hc_clReleaseMemObject (OCL_PTR *ocl, cl_mem mem);
cl_int hc_clReleaseProgram (OCL_PTR *ocl, cl_program program);
cl_int hc_clSetKernelArg (OCL_PTR *ocl, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value);
cl_int hc_clWaitForEvents (OCL_PTR *ocl, cl_uint num_events, const cl_event *event_list);
#endif // _EXT_OPENCL_H

View File

@ -255,18 +255,4 @@ typedef struct hm_nvapi_lib
typedef hm_nvapi_lib_t NVAPI_PTR;
int nvapi_init (NVAPI_PTR *nvapi);
void nvapi_close (NVAPI_PTR *nvapi);
int hm_NvAPI_QueryInterface (NVAPI_PTR *nvapi, unsigned int offset);
int hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, NvAPI_Status nr, NvAPI_ShortString szDesc);
NvAPI_Status hm_NvAPI_Initialize (NVAPI_PTR *nvapi);
NvAPI_Status hm_NvAPI_Unload (NVAPI_PTR *nvapi);
NvAPI_Status hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount);
NvAPI_Status hm_NvAPI_GPU_GetPerfPoliciesInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info);
NvAPI_Status hm_NvAPI_GPU_GetPerfPoliciesStatus (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status);
NvAPI_Status hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels);
NvAPI_Status hm_NvAPI_GPU_RestoreCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex);
#endif // _EXT_NVAPI_H

View File

@ -168,6 +168,7 @@ typedef nvmlDevice_t HM_ADAPTER_NVML;
typedef const char * (*NVML_API_CALL NVML_ERROR_STRING) (nvmlReturn_t);
typedef int (*NVML_API_CALL NVML_INIT) (void);
typedef int (*NVML_API_CALL NVML_SHUTDOWN) (void);
typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_GET_COUNT) (unsigned int *);
typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_GET_NAME) (nvmlDevice_t, char *, unsigned int);
typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_GET_HANDLE_BY_INDEX) (unsigned int, nvmlDevice_t *);
typedef nvmlReturn_t (*NVML_API_CALL NVML_DEVICE_GET_TEMPERATURE) (nvmlDevice_t, nvmlTemperatureSensors_t, unsigned int *);
@ -199,6 +200,7 @@ typedef struct hm_nvml_lib
NVML_ERROR_STRING nvmlErrorString;
NVML_INIT nvmlInit;
NVML_SHUTDOWN nvmlShutdown;
NVML_DEVICE_GET_COUNT nvmlDeviceGetCount;
NVML_DEVICE_GET_NAME nvmlDeviceGetName;
NVML_DEVICE_GET_HANDLE_BY_INDEX nvmlDeviceGetHandleByIndex;
NVML_DEVICE_GET_TEMPERATURE nvmlDeviceGetTemperature;
@ -221,28 +223,4 @@ typedef struct hm_nvml_lib
typedef hm_nvml_lib_t NVML_PTR;
int nvml_init (NVML_PTR *lib);
void nvml_close (NVML_PTR *lib);
const char * hm_NVML_nvmlErrorString (NVML_PTR *nvml, nvmlReturn_t nvml_rc);
nvmlReturn_t hm_NVML_nvmlInit (NVML_PTR *nvml);
nvmlReturn_t hm_NVML_nvmlShutdown (NVML_PTR *nvml);
nvmlReturn_t hm_NVML_nvmlDeviceGetName (NVML_PTR *nvml, int, nvmlDevice_t device, char *name, unsigned int length);
nvmlReturn_t hm_NVML_nvmlDeviceGetHandleByIndex (NVML_PTR *nvml, int, unsigned int index, nvmlDevice_t *device);
nvmlReturn_t hm_NVML_nvmlDeviceGetTemperature (NVML_PTR *nvml, int, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp);
nvmlReturn_t hm_NVML_nvmlDeviceGetFanSpeed (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned int *speed);
nvmlReturn_t hm_NVML_nvmlDeviceGetPowerUsage (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned int *power);
nvmlReturn_t hm_NVML_nvmlDeviceGetUtilizationRates (NVML_PTR *nvml, int, nvmlDevice_t device, nvmlUtilization_t *utilization);
nvmlReturn_t hm_NVML_nvmlDeviceGetClockInfo (NVML_PTR *nvml, int, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock);
nvmlReturn_t hm_NVML_nvmlDeviceGetTemperatureThreshold (NVML_PTR *nvml, int, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp);
nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned int *currLinkGen);
nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned int *currLinkWidth);
nvmlReturn_t hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned long long *clocksThrottleReasons);
nvmlReturn_t hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons);
nvmlReturn_t hm_NVML_nvmlDeviceSetComputeMode (NVML_PTR *nvml, int, nvmlDevice_t device, nvmlComputeMode_t mode);
nvmlReturn_t hm_NVML_nvmlDeviceSetGpuOperationMode (NVML_PTR *nvml, int, nvmlDevice_t device, nvmlGpuOperationMode_t mode);
nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (NVML_PTR *nvml, int, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit);
nvmlReturn_t hm_NVML_nvmlDeviceSetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int limit);
nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *limit);
#endif // _NVML_H

View File

@ -72,19 +72,4 @@ typedef struct hm_xnvctrl_lib
typedef hm_xnvctrl_lib_t XNVCTRL_PTR;
int xnvctrl_init (XNVCTRL_PTR *xnvctrl);
void xnvctrl_close (XNVCTRL_PTR *xnvctrl);
int hm_XNVCTRL_XOpenDisplay (XNVCTRL_PTR *xnvctrl);
void hm_XNVCTRL_XCloseDisplay (XNVCTRL_PTR *xnvctrl);
int get_core_threshold (XNVCTRL_PTR *xnvctrl, int gpu, int *val);
int get_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int *val);
int set_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int val);
int get_fan_speed_current (XNVCTRL_PTR *xnvctrl, int gpu, int *val);
int get_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int *val);
int set_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int val);
#endif // _EXT_XNVCTRL_H

View File

@ -10,7 +10,7 @@
#include <string.h>
#include <errno.h>
u64 count_lines (FILE *fd);
u64 count_lines (hashcat_ctx_t *hashcat_ctx, FILE *fd);
int fgetl (FILE *fp, char *line_buf);

View File

@ -29,16 +29,11 @@
int sort_by_stringptr (const void *p1, const void *p2);
char *get_exec_path (void);
char *get_install_dir (const char *progname);
char *get_profile_dir (const char *homedir);
char *get_session_dir (const char *profile_dir);
int count_dictionaries (char **dictionary_files);
char **scan_directory (const char *path);
char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path);
int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder, const char *shared_folder);
int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *install_folder, MAYBE_UNUSED const char *shared_folder);
void folder_config_destroy (hashcat_ctx_t *hashcat_ctx);
int hc_mkdir (const char *name, int mode);
int hc_mkdir (const char *name, MAYBE_UNUSED const int mode);

View File

@ -6,9 +6,17 @@
#ifndef _HASHCAT_H
#define _HASHCAT_H
int hashcat (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime);
int hashcat_init (hashcat_ctx_t *hashcat_ctx, void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t));
void hashcat_destroy (hashcat_ctx_t *hashcat_ctx);
void hashcat_ctx_init (hashcat_ctx_t *hashcat_ctx);
void hashcat_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
int hashcat_session_run (hashcat_ctx_t *hashcat_ctx, char *install_folder, char *shared_folder, int argc, char **argv, const int comptime);
int hashcat_session_pause (hashcat_ctx_t *hashcat_ctx);
int hashcat_session_resume (hashcat_ctx_t *hashcat_ctx);
int hashcat_session_bypass (hashcat_ctx_t *hashcat_ctx);
int hashcat_session_checkpoint (hashcat_ctx_t *hashcat_ctx);
int hashcat_session_quit (hashcat_ctx_t *hashcat_ctx);
char *hashcat_get_log (hashcat_ctx_t *hashcat_ctx);
int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_status);
#endif // _HASHCAT_H

View File

@ -11,7 +11,7 @@ int sort_by_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 (hashcat_ctx_t *hashcat_ctx);
int save_hash (hashcat_ctx_t *hashcat_ctx);
void check_hash (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain);
@ -20,6 +20,7 @@ int check_cracked (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param,
int hashes_init_stage1 (hashcat_ctx_t *hashcat_ctx);
int hashes_init_stage2 (hashcat_ctx_t *hashcat_ctx);
int hashes_init_stage3 (hashcat_ctx_t *hashcat_ctx);
int hashes_init_stage4 (hashcat_ctx_t *hashcat_ctx);
void hashes_destroy (hashcat_ctx_t *hashcat_ctx);

View File

@ -1340,162 +1340,162 @@ typedef enum rounds_count
* input functions
*/
int bcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int cisco4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int dcc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int dcc2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int descrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int des_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int episerver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int ipb2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int joomla_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int postgresql_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int netscreen_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int keccak_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int lm_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int md4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int md4s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int md5s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int md5half_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int md5md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int md5pix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int md5asa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int md5apr1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int md5crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int mssql2000_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int mssql2005_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int netntlmv1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int netntlmv2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int oracleh_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int oracles_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int oraclet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int osc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int arubaos_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int osx1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int osx512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int phpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha1b64_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha1b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha1s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha256s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha384_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha512s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha512crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int smf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int vb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int vb30_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int wpa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int psafe2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int psafe3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int ikepsk_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int ikepsk_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int androidpin_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int ripemd160_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int whirlpool_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int truecrypt_parse_hash_1k (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int truecrypt_parse_hash_2k (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int md5aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha256aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha512aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int agilekey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha1aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int lastpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int gost_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha256crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int mssql2012_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha512osx_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int episerver4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha512grub_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha512b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int hmacsha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int hmacsha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int hmacsha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int hmacmd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int krb5pa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int krb5tgs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sapb_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sapg_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int drupal7_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sybasease_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int mysql323_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int rakp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int netscaler_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int chap_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int cloudkey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int nsec3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int wbb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int racf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int lotus5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int lotus6_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int lotus8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int hmailserver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int phps_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int mediawiki_b_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int peoplesoft_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int skype_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int androidfde_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int scrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int juniper_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int cisco8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int cisco9_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int office2007_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int office2010_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int office2013_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int oldoffice01_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int oldoffice01cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int oldoffice01cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int oldoffice34_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int oldoffice34cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int oldoffice34cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int radmin2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int djangosha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int djangopbkdf2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int siphash_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int crammd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int saph_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int redmine_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int pdf11_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int pdf11cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int pdf11cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int pdf14_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int pdf17l3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int pdf17l8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int pbkdf2_sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int prestashop_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int postgresql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int mysql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int bitcoin_wallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int crc32_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int seven_zip_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int gost2012sbog_256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int gost2012sbog_512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int pbkdf2_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int pbkdf2_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int pbkdf2_sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int ecryptfs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int bsdicrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int rar3hp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int rar5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int cf10_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int mywallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int ms_drsr_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int androidfde_samsung_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int sha1axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int keepass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int pstoken_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int zip2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int veracrypt_parse_hash_200000 (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int veracrypt_parse_hash_500000 (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int veracrypt_parse_hash_327661 (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int veracrypt_parse_hash_655331 (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int win8phone_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int opencart_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, const hashconfig_t *hashconfig);
int bcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int cisco4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int dcc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int dcc2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int descrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int des_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int episerver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int ipb2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int joomla_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int postgresql_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int netscreen_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int keccak_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int lm_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int md4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int md4s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int md5s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int md5half_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int md5md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int md5pix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int md5asa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int md5apr1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int md5crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int mssql2000_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int mssql2005_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int netntlmv1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int netntlmv2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int oracleh_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int oracles_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int oraclet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int osc_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int arubaos_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int osx1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int osx512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int phpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha1b64_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha1b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha1s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha256s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha384_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha512s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha512crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int smf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int vb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int vb30_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int wpa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int psafe2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int psafe3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int ikepsk_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int ikepsk_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int androidpin_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int ripemd160_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int whirlpool_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int truecrypt_parse_hash_1k (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int truecrypt_parse_hash_2k (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int md5aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha256aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha512aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int agilekey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha1aix_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int lastpass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int gost_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha256crypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int mssql2012_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha512osx_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int episerver4_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha512grub_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha512b64s_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int hmacsha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int hmacsha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int hmacsha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int hmacmd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int krb5pa_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int krb5tgs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sapb_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sapg_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int drupal7_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sybasease_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int mysql323_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int rakp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int netscaler_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int chap_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int cloudkey_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int nsec3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int wbb3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int racf_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int lotus5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int lotus6_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int lotus8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int hmailserver_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int phps_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int mediawiki_b_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int peoplesoft_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int skype_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int androidfde_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int scrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int juniper_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int cisco8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int cisco9_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int office2007_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int office2010_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int office2013_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int oldoffice01_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int oldoffice01cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int oldoffice01cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int oldoffice34_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int oldoffice34cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int oldoffice34cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int radmin2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int djangosha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int djangopbkdf2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int siphash_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int crammd5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int saph_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int redmine_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int pdf11_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int pdf11cm1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int pdf11cm2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int pdf14_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int pdf17l3_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int pdf17l8_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int pbkdf2_sha256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int prestashop_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int postgresql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int mysql_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int bitcoin_wallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sip_auth_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int crc32_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int seven_zip_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int gost2012sbog_256_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int gost2012sbog_512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int pbkdf2_md5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int pbkdf2_sha1_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int pbkdf2_sha512_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int ecryptfs_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int bsdicrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int rar3hp_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int rar5_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int cf10_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int mywallet_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int ms_drsr_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int androidfde_samsung_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int sha1axcrypt_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int keepass_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int pstoken_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int zip2_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int veracrypt_parse_hash_200000 (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int veracrypt_parse_hash_500000 (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int veracrypt_parse_hash_327661 (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int veracrypt_parse_hash_655331 (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int win8phone_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
int opencart_parse_hash (char *input_buf, u32 input_len, hash_t *hash_buf, MAYBE_UNUSED const hashconfig_t *hashconfig);
/**
* output functions
@ -1505,15 +1505,15 @@ char *stroptitype (const u32 opti_type);
char *strhashtype (const u32 hash_mode);
char *strparser (const u32 parser_status);
void to_hccap_t (hccap_t *hccap, const u32 salt_pos, const u32 digest_pos, const hashconfig_t *hashconfig, const hashes_t *hashes);
void to_hccap_t (hashcat_ctx_t *hashcat_ctx, hccap_t *hccap, const u32 salt_pos, const u32 digest_pos);
void ascii_digest (char *out_buf, const u32 salt_pos, const u32 digest_pos, const hashconfig_t *hashconfig, const hashes_t *hashes);
int ascii_digest (hashcat_ctx_t *hashcat_ctx, char *out_buf, const u32 salt_pos, const u32 digest_pos);
int hashconfig_init (hashcat_ctx_t *hashcat_ctx);
void hashconfig_destroy (hashcat_ctx_t *hashcat_ctx);
u32 hashconfig_enforce_kernel_threads (hashcat_ctx_t *hashcat_ctx, const hc_device_param_t *device_param);
u32 hashconfig_enforce_kernel_loops (hashcat_ctx_t *hashcat_ctx);
void hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx);
int hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx);
void hashconfig_benchmark_defaults (hashcat_ctx_t *hashcat_ctx, salt_t *salt, void *esalt);
char *hashconfig_benchmark_mask (hashcat_ctx_t *hashcat_ctx);

View File

@ -15,13 +15,13 @@
#if defined (F_SETLKW)
void lock_file (FILE *fp);
int lock_file (FILE *fp);
void unlock_file (FILE *fp);
#else
#define lock_file(dummy) {}
#define unlock_file(dummy) {}
#define lock_file(dummy) 0
#define unlock_file(dummy)
#endif

View File

@ -1,20 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#ifndef _LOGGING_H
#define _LOGGING_H
#include <stdio.h>
#include <stdarg.h>
int log_out_nn (FILE *fp, const char *fmt, ...);
int log_info_nn (const char *fmt, ...);
int log_error_nn (const char *fmt, ...);
int log_out (FILE *fp, const char *fmt, ...);
int log_info (const char *fmt, ...);
int log_error (const char *fmt, ...);
#endif // _LOGGING_H

View File

@ -6,15 +6,18 @@
#ifndef _MEMORY_H
#define _MEMORY_H
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define MSG_ENOMEM "Insufficient memory available"
void *mycalloc (size_t nmemb, size_t size);
void myfree (void *ptr);
void *mymalloc (size_t size);
void *myrealloc (void *ptr, size_t oldsz, size_t add);
char *mystrdup (const char *s);
#define VERIFY_PTR(v) if ((v) == NULL) return -1;
void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz);
void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz);
void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, const size_t addsz);
char *hcstrdup (hashcat_ctx_t *hashcat_ctx, const char *s);
void hcfree (void *ptr);
#endif // _MEMORY_H

View File

@ -6,6 +6,8 @@
#ifndef _MONITOR_H
#define _MONITOR_H
int get_runtime_left (const hashcat_ctx_t *hashcat_ctx);
void *thread_monitor (void *p);
#endif // _MONITOR_H

View File

@ -20,26 +20,7 @@
#define INCR_MASKS 1000
void mp_css_split_cnt (const mask_ctx_t *mask_ctx, const hashconfig_t *hashconfig, const u32 css_cnt_orig, u32 css_cnt_rl[2]);
void mp_css_append_salt (mask_ctx_t *mask_ctx, salt_t *salt_buf);
void mp_css_unicode_expand (mask_ctx_t *mask_ctx);
void mp_css_to_uniq_tbl (u32 css_cnt, cs_t *css, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]);
void mp_cut_at (char *mask, u32 max);
u32 mp_get_length (char *mask);
void mp_exec (u64 val, char *buf, cs_t *css, int css_cnt);
cs_t *mp_gen_css (char *mask_buf, size_t mask_len, cs_t *mp_sys, cs_t *mp_usr, u32 *css_cnt, const hashconfig_t *hashconfig, const user_options_t *user_options);
u64 mp_get_sum (u32 css_cnt, cs_t *css);
void mp_setup_sys (cs_t *mp_sys);
void mp_setup_usr (cs_t *mp_sys, cs_t *mp_usr, char *buf, u32 index, const hashconfig_t *hashconfig, const user_options_t *user_options);
void mp_reset_usr (cs_t *mp_usr, u32 index);
u64 sp_get_sum (u32 start, u32 stop, cs_t *root_css_buf);
void sp_exec (u64 ctx, char *pw_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 start, u32 stop);
int sp_comp_val (const void *p1, const void *p2);
void sp_setup_tbl (const char *install_dir, char *hcstat, u32 disable, u32 classic, hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf);
void sp_tbl_to_css (hcstat_table_t *root_table_buf, hcstat_table_t *markov_table_buf, cs_t *root_css_buf, cs_t *markov_css_buf, u32 threshold, u32 uniq_tbls[SP_PW_MAX][CHARSIZ]);
void sp_stretch_markov (hcstat_table_t *in, hcstat_table_t *out);
void sp_stretch_root (hcstat_table_t *in, hcstat_table_t *out);
int mask_ctx_update_loop (hashcat_ctx_t *hashcat_ctx);
int mask_ctx_init (hashcat_ctx_t *hashcat_ctx);

View File

@ -18,6 +18,42 @@ static const char CL_VENDOR_MESA[] = "Mesa";
static const char CL_VENDOR_NV[] = "NVIDIA Corporation";
static const char CL_VENDOR_POCL[] = "The pocl project";
int ocl_init (hashcat_ctx_t *hashcat_ctx);
void ocl_close (hashcat_ctx_t *hashcat_ctx);
int hc_clBuildProgram (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify) (cl_program program, void *user_data), void *user_data);
int hc_clCreateBuffer (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_mem *mem);
int hc_clCreateCommandQueue (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_command_queue *command_queue);
int hc_clCreateContext (hashcat_ctx_t *hashcat_ctx, cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify) (const char *, const void *, size_t, void *), void *user_data, cl_context *context);
int hc_clCreateKernel (hashcat_ctx_t *hashcat_ctx, cl_program program, const char *kernel_name, cl_kernel *kernel);
int hc_clCreateProgramWithBinary (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_program *program);
int hc_clCreateProgramWithSource (hashcat_ctx_t *hashcat_ctx, cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_program *program);
int hc_clEnqueueCopyBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
int hc_clEnqueueMapBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event, void **buf);
int hc_clEnqueueNDRangeKernel (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
int hc_clEnqueueReadBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
int hc_clEnqueueUnmapMemObject (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
int hc_clEnqueueWriteBuffer (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event);
int hc_clFinish (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue);
int hc_clFlush (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue);
int hc_clGetDeviceIDs (hashcat_ctx_t *hashcat_ctx, cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices);
int hc_clGetDeviceInfo (hashcat_ctx_t *hashcat_ctx, cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
int hc_clGetEventInfo (hashcat_ctx_t *hashcat_ctx, cl_event event, cl_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
int hc_clGetEventProfilingInfo (hashcat_ctx_t *hashcat_ctx, cl_event event, cl_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
int hc_clGetKernelWorkGroupInfo (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
int hc_clGetPlatformIDs (hashcat_ctx_t *hashcat_ctx, cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms);
int hc_clGetPlatformInfo (hashcat_ctx_t *hashcat_ctx, cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
int hc_clGetProgramBuildInfo (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret);
int hc_clGetProgramInfo (hashcat_ctx_t *hashcat_ctx, cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t * param_value_size_ret);
int hc_clReleaseCommandQueue (hashcat_ctx_t *hashcat_ctx, cl_command_queue command_queue);
int hc_clReleaseContext (hashcat_ctx_t *hashcat_ctx, cl_context context);
int hc_clReleaseEvent (hashcat_ctx_t *hashcat_ctx, cl_event event);
int hc_clReleaseKernel (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel);
int hc_clReleaseMemObject (hashcat_ctx_t *hashcat_ctx, cl_mem mem);
int hc_clReleaseProgram (hashcat_ctx_t *hashcat_ctx, cl_program program);
int hc_clSetKernelArg (hashcat_ctx_t *hashcat_ctx, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value);
int hc_clWaitForEvents (hashcat_ctx_t *hashcat_ctx, cl_uint num_events, const cl_event *event_list);
int gidd_to_pw_t (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 gidd, pw_t *pw);
int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 highest_pw_len, const u32 pws_cnt, const u32 fast_iteration, const u32 salt_pos);
int run_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kern_run, const u32 num, const u32 event_update, const u32 iteration);

View File

@ -10,15 +10,15 @@
#include <time.h>
#include <inttypes.h>
void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u32 *plain_buf, int *out_len);
void build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u64 *out_pos);
void build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u8 *debug_rule_buf, int *debug_rule_len, u8 *debug_plain_ptr, int *debug_plain_len);
int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u32 *plain_buf, int *out_len);
int build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u64 *out_pos);
int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u8 *debug_rule_buf, int *debug_rule_len, u8 *debug_plain_ptr, int *debug_plain_len);
int outfile_init (hashcat_ctx_t *hashcat_ctx);
void outfile_destroy (hashcat_ctx_t *hashcat_ctx);
int outfile_write_open (hashcat_ctx_t *hashcat_ctx);
void outfile_write_close (hashcat_ctx_t *hashcat_ctx);
void outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len);
int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, char tmp_buf[HCBUFSIZ_LARGE]);
int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx);
#endif // _OUTFILE_H

View File

@ -12,8 +12,8 @@
#define INCR_POT 1000
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_pot (const void *v1, const void *v2, MAYBE_UNUSED void *v3);
int sort_by_salt_buf (const void *v1, const void *v2, MAYBE_UNUSED 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);
@ -22,18 +22,13 @@ void *hc_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size
int potfile_init (hashcat_ctx_t *hashcat_ctx);
int potfile_read_open (hashcat_ctx_t *hashcat_ctx);
void potfile_read_parse (hashcat_ctx_t *hashcat_ctx);
void potfile_read_close (hashcat_ctx_t *hashcat_ctx);
int potfile_write_open (hashcat_ctx_t *hashcat_ctx);
void potfile_write_close (hashcat_ctx_t *hashcat_ctx);
void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *plain_ptr, unsigned int plain_len);
void potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num);
void potfile_hash_free (hashcat_ctx_t *hashcat_ctx);
void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *));
void potfile_left_request (hashcat_ctx_t *hashcat_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 (hashcat_ctx_t *hashcat_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 (hashcat_ctx_t *hashcat_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 (hashcat_ctx_t *hashcat_ctx);
void potfile_destroy (hashcat_ctx_t *hashcat_ctx);
int potfile_handle_show (hashcat_ctx_t *hashcat_ctx);
int potfile_handle_left (hashcat_ctx_t *hashcat_ctx);
#endif // _POTFILE_H

View File

@ -23,20 +23,10 @@
#define RESTORE_VERSION_MIN 320
#define RESTORE_VERSION_CUR 320
u64 get_lowest_words_done (hashcat_ctx_t *hashcat_ctx);
void init_restore (hashcat_ctx_t *hashcat_ctx);
void read_restore (hashcat_ctx_t *hashcat_ctx);
void write_restore (hashcat_ctx_t *hashcat_ctx);
void cycle_restore (hashcat_ctx_t *hashcat_ctx);
int cycle_restore (hashcat_ctx_t *hashcat_ctx);
void unlink_restore (hashcat_ctx_t *hashcat_ctx);
void stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx);
int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv);
void restore_ctx_destroy (hashcat_ctx_t *hashcat_ctx);

View File

@ -24,8 +24,8 @@ char *filename_from_filepath (char *filepath);
void naive_replace (char *s, const char key_char, const char replace_char);
void naive_escape (char *s, size_t s_max, const char key_char, const char escape_char);
void hc_sleep_ms (const u32 msec);
void hc_sleep (const u32 sec);
void hc_sleep_msec (const u32 msec);
void hc_sleep (const u32 sec);
void setup_environment_variables ();
void setup_umask ();

View File

@ -12,16 +12,72 @@
double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries);
void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx);
void status_display (hashcat_ctx_t *hashcat_ctx);
void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx);
void status_benchmark (hashcat_ctx_t *hashcat_ctx);
// should be static after refactoring
void format_timer_display (struct tm *tm, char *buf, size_t len);
void format_speed_display (double val, char *buf, size_t len);
int status_progress_init (hashcat_ctx_t *hashcat_ctx);
void status_progress_destroy (hashcat_ctx_t *hashcat_ctx);
void status_progress_reset (hashcat_ctx_t *hashcat_ctx);
int status_get_device_info_cnt (const hashcat_ctx_t *hashcat_ctx);
int status_get_device_info_active (const hashcat_ctx_t *hashcat_ctx);
bool status_get_skipped_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id);
char *status_get_session (const hashcat_ctx_t *hashcat_ctx);
char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx);
int status_get_status_number (const hashcat_ctx_t *hashcat_ctx);
int status_get_input_mode (const hashcat_ctx_t *hashcat_ctx);
char *status_get_input_base (const hashcat_ctx_t *hashcat_ctx);
char *status_get_input_mod (const hashcat_ctx_t *hashcat_ctx);
char *status_get_input_charset (const hashcat_ctx_t *hashcat_ctx);
char *status_get_input_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id);
char *status_get_hash_type (const hashcat_ctx_t *hashcat_ctx);
char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx);
int status_get_digests_done (const hashcat_ctx_t *hashcat_ctx);
int status_get_digests_cnt (const hashcat_ctx_t *hashcat_ctx);
double status_get_digests_percent (const hashcat_ctx_t *hashcat_ctx);
int status_get_salts_done (const hashcat_ctx_t *hashcat_ctx);
int status_get_salts_cnt (const hashcat_ctx_t *hashcat_ctx);
double status_get_salts_percent (const hashcat_ctx_t *hashcat_ctx);
double status_get_msec_running (const hashcat_ctx_t *hashcat_ctx);
double status_get_msec_paused (const hashcat_ctx_t *hashcat_ctx);
double status_get_msec_real (const hashcat_ctx_t *hashcat_ctx);
char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx);
char *status_get_time_started_relative (const hashcat_ctx_t *hashcat_ctx);
char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx);
char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx);
u64 status_get_restore_point (const hashcat_ctx_t *hashcat_ctx);
u64 status_get_restore_total (const hashcat_ctx_t *hashcat_ctx);
double status_get_restore_percent (const hashcat_ctx_t *hashcat_ctx);
int status_get_progress_mode (const hashcat_ctx_t *hashcat_ctx);
double status_get_progress_finished_percent (const hashcat_ctx_t *hashcat_ctx);
u64 status_get_progress_done (const hashcat_ctx_t *hashcat_ctx);
u64 status_get_progress_rejected (const hashcat_ctx_t *hashcat_ctx);
double status_get_progress_rejected_percent (const hashcat_ctx_t *hashcat_ctx);
u64 status_get_progress_restored (const hashcat_ctx_t *hashcat_ctx);
u64 status_get_progress_cur (const hashcat_ctx_t *hashcat_ctx);
u64 status_get_progress_end (const hashcat_ctx_t *hashcat_ctx);
u64 status_get_progress_ignore (const hashcat_ctx_t *hashcat_ctx);
u64 status_get_progress_skip (const hashcat_ctx_t *hashcat_ctx);
u64 status_get_progress_cur_relative_skip (const hashcat_ctx_t *hashcat_ctx);
u64 status_get_progress_end_relative_skip (const hashcat_ctx_t *hashcat_ctx);
double status_get_hashes_msec_all (const hashcat_ctx_t *hashcat_ctx);
double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id);
double status_get_hashes_msec_dev_benchmark (const hashcat_ctx_t *hashcat_ctx, const int device_id);
double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx);
double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id);
char *status_get_speed_sec_all (const hashcat_ctx_t *hashcat_ctx);
char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id);
int status_get_cpt_cur_min (const hashcat_ctx_t *hashcat_ctx);
int status_get_cpt_cur_hour (const hashcat_ctx_t *hashcat_ctx);
int status_get_cpt_cur_day (const hashcat_ctx_t *hashcat_ctx);
double status_get_cpt_avg_min (const hashcat_ctx_t *hashcat_ctx);
double status_get_cpt_avg_hour (const hashcat_ctx_t *hashcat_ctx);
double status_get_cpt_avg_day (const hashcat_ctx_t *hashcat_ctx);
char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx);
char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id);
int status_ctx_init (hashcat_ctx_t *hashcat_ctx);
void status_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
int status_progress_init (hashcat_ctx_t *hashcat_ctx);
void status_progress_destroy (hashcat_ctx_t *hashcat_ctx);
void status_progress_reset (hashcat_ctx_t *hashcat_ctx);
int status_ctx_init (hashcat_ctx_t *hashcat_ctx);
void status_ctx_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _STATUS_H

View File

@ -20,6 +20,6 @@
#include <pwd.h>
#endif // _POSIX
void process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt);
int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt);
#endif // _STDOUT_H

View File

@ -26,7 +26,7 @@
void welcome_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const char *version_tag);
void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const time_t proc_stop);
int setup_console ();
int setup_console (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx);
void send_prompt ();
void clear_prompt ();
@ -42,3 +42,8 @@ int tty_getchar();
int tty_fix();
#endif // _TERMINAL_H
void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx);
void status_display (hashcat_ctx_t *hashcat_ctx);
void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx);
void status_benchmark (hashcat_ctx_t *hashcat_ctx);

View File

@ -56,12 +56,12 @@ void hc_signal (void (callback) (int));
#endif
*/
void mycracked (status_ctx_t *status_ctx);
void myabort (status_ctx_t *status_ctx);
void myquit (status_ctx_t *status_ctx);
void bypass (status_ctx_t *status_ctx);
void SuspendThreads (status_ctx_t *status_ctx);
void ResumeThreads (status_ctx_t *status_ctx);
int mycracked (hashcat_ctx_t *hashcat_ctx);
int myabort (hashcat_ctx_t *hashcat_ctx);
int myquit (hashcat_ctx_t *hashcat_ctx);
int bypass (hashcat_ctx_t *hashcat_ctx);
int SuspendThreads (hashcat_ctx_t *hashcat_ctx);
int ResumeThreads (hashcat_ctx_t *hashcat_ctx);
int stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx);
#endif // _THREAD_H

View File

@ -37,12 +37,6 @@ typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
#include "ext_OpenCL.h"
#include "ext_ADL.h"
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
// timer
#if defined (_WIN)
@ -81,6 +75,58 @@ typedef struct stat64 hc_stat;
// enums
typedef enum loglevel
{
LOGLEVEL_INFO = 0,
LOGLEVEL_WARNING = 1,
LOGLEVEL_ERROR = 2,
} loglevel_t;
typedef enum event_identifier
{
EVENT_LOG_INFO = 0x00000001,
EVENT_LOG_WARNING = 0x00000002,
EVENT_LOG_ERROR = 0x00000003,
EVENT_WELCOME_SCREEN = 0x00000011,
EVENT_GOODBYE_SCREEN = 0x00000012,
EVENT_OUTERLOOP_STARTING = 0x00000031,
EVENT_OUTERLOOP_MAINSCREEN = 0x00000032,
EVENT_OUTERLOOP_FINISHED = 0x00000033,
EVENT_INNERLOOP1_STARTING = 0x00000041,
EVENT_INNERLOOP1_FINISHED = 0x00000042,
EVENT_INNERLOOP2_STARTING = 0x00000051,
EVENT_INNERLOOP2_FINISHED = 0x00000052,
EVENT_CALCULATED_WORDS_BASE = 0x00000059,
EVENT_AUTOTUNE_STARTING = 0x00000053,
EVENT_AUTOTUNE_FINISHED = 0x00000054,
EVENT_CRACKER_STARTING = 0x00000055,
EVENT_CRACKER_FINISHED = 0x00000056,
EVENT_CRACKER_HASH_CRACKED = 0x00000058,
EVENT_POTFILE_REMOVE_PARSE_PRE = 0x00000061,
EVENT_POTFILE_REMOVE_PARSE_POST = 0x00000062,
EVENT_POTFILE_NUM_CRACKED = 0x00000063,
EVENT_POTFILE_ALL_CRACKED = 0x00000064,
EVENT_POTFILE_HASH_SHOW = 0x00000065,
EVENT_POTFILE_HASH_LEFT = 0x00000066,
EVENT_OPENCL_SESSION_PRE = 0x00000071,
EVENT_OPENCL_SESSION_POST = 0x00000072,
EVENT_BITMAP_INIT_PRE = 0x00000081,
EVENT_BITMAP_INIT_POST = 0x00000082,
EVENT_WEAK_HASH_PRE = 0x00000091,
EVENT_WEAK_HASH_POST = 0x00000092,
EVENT_SET_KERNEL_POWER_FINAL = 0x000000a1,
EVENT_MONITOR_THROTTLE1 = 0x000000b1,
EVENT_MONITOR_THROTTLE2 = 0x000000b2,
EVENT_MONITOR_THROTTLE3 = 0x000000b3,
EVENT_MONITOR_TEMP_ABORT = 0x000000c1,
EVENT_MONITOR_RUNTIME_LIMIT = 0x000000d1,
EVENT_MONITOR_STATUS_REFRESH = 0x000000e1,
// there will be much more event types soon
} event_identifier_t;
typedef enum amplifier_count
{
KERNEL_BFS = 1024,
@ -378,6 +424,7 @@ typedef enum parser_rc
PARSER_TC_FILE_SIZE = -15,
PARSER_VC_FILE_SIZE = -16,
PARSER_SIP_AUTH_DIRECTIVE = -17,
PARSER_HASH_FILE = -18,
PARSER_UNKNOWN_ERROR = -255
} parser_rc_t;
@ -430,6 +477,8 @@ typedef struct hash
void *esalt;
int cracked;
hashinfo_t *hash_info;
char *pw_buf;
int pw_len;
} hash_t;
@ -474,6 +523,7 @@ typedef struct hashes
void *esalts_buf;
u32 hashes_cnt_orig;
u32 hashes_cnt;
hash_t *hashes_buf;
@ -572,6 +622,8 @@ typedef struct wordr
} wordr_t;
#include "ext_OpenCL.h"
typedef struct hc_device_param
{
cl_device_id device;
@ -637,7 +689,7 @@ typedef struct hc_device_param
u32 innerloop_left;
u32 exec_pos;
double exec_ms[EXEC_CACHE];
double exec_msec[EXEC_CACHE];
// workaround cpu spinning
@ -649,7 +701,7 @@ typedef struct hc_device_param
u32 speed_pos;
u64 speed_cnt[SPEED_CACHE];
double speed_ms[SPEED_CACHE];
double speed_msec[SPEED_CACHE];
hc_timer_t timer_speed;
@ -776,17 +828,53 @@ typedef struct opencl_ctx
u32 devices_filter;
cl_device_type device_types_filter;
double target_ms;
double target_msec;
int need_adl;
int need_nvml;
int need_nvapi;
int need_xnvctrl;
bool need_adl;
bool need_nvml;
bool need_nvapi;
bool need_xnvctrl;
int force_jit_compilation;
} opencl_ctx_t;
#include "ext_ADL.h"
#include "ext_nvapi.h"
#include "ext_nvml.h"
#include "ext_xnvctrl.h"
typedef struct hm_attrs
{
HM_ADAPTER_ADL adl;
HM_ADAPTER_NVML nvml;
HM_ADAPTER_NVAPI nvapi;
HM_ADAPTER_XNVCTRL xnvctrl;
int od_version;
bool fan_get_supported;
bool fan_set_supported;
} hm_attrs_t;
typedef struct hwmon_ctx
{
bool enabled;
void *hm_adl;
void *hm_nvml;
void *hm_nvapi;
void *hm_xnvctrl;
hm_attrs_t *hm_device;
ADLOD6MemClockState *od_clock_mem_status;
int *od_power_control_status;
unsigned int *nvml_power_limit;
} hwmon_ctx_t;
#if defined (__APPLE__)
typedef struct cpu_set
{
@ -847,20 +935,6 @@ typedef struct dictstat_ctx
} dictstat_ctx_t;
typedef struct hm_attrs
{
HM_ADAPTER_ADL adl;
HM_ADAPTER_NVML nvml;
HM_ADAPTER_NVAPI nvapi;
HM_ADAPTER_XNVCTRL xnvctrl;
int od_version;
bool fan_get_supported;
bool fan_set_supported;
} hm_attrs_t;
typedef struct loopback_ctx
{
bool enabled;
@ -918,12 +992,6 @@ typedef struct potfile_ctx
FILE *fp;
char *filename;
pot_t *pot;
u32 pot_cnt;
u32 pot_avail;
u32 pot_hashes_avail;
} potfile_ctx_t;
typedef struct restore_data
@ -1026,87 +1094,10 @@ typedef struct wl_data
typedef struct user_options
{
bool usage;
bool version;
bool quiet;
bool benchmark;
bool stdout_flag;
bool show;
bool left;
bool username;
bool remove;
u32 remove_timer;
u64 skip;
u64 limit;
bool force;
bool keyspace;
bool potfile_disable;
char *potfile_path;
u32 debug_mode;
char *debug_file;
char *induction_dir;
char *outfile_check_dir;
u32 runtime;
u32 hash_mode;
u32 attack_mode;
char *outfile;
u32 outfile_format;
bool outfile_autohex;
u32 outfile_check_timer;
bool restore;
u32 restore_timer;
bool restore_disable;
bool status;
u32 status_timer;
bool machine_readable;
bool loopback;
u32 weak_hash_threshold;
char *session;
bool hex_charset;
bool hex_salt;
bool hex_wordlist;
u32 rp_gen;
u32 rp_gen_func_min;
u32 rp_gen_func_max;
u32 rp_gen_seed;
char *rule_buf_l;
char *rule_buf_r;
bool increment;
u32 increment_min;
u32 increment_max;
char *cpu_affinity;
bool opencl_info;
char *opencl_devices;
char *opencl_platforms;
char *opencl_device_types;
u32 opencl_vector_width;
char *truecrypt_keyfiles;
char *veracrypt_keyfiles;
u32 veracrypt_pim;
u32 workload_profile;
u32 kernel_accel;
u32 kernel_loops;
u32 nvidia_spin_damp;
bool gpu_temp_disable;
u32 gpu_temp_abort;
u32 gpu_temp_retain;
bool powertune_enable;
bool logfile_disable;
u32 segment_size;
u32 scrypt_tmto;
char separator;
u32 bitmap_min;
u32 bitmap_max;
bool markov_disable;
bool markov_classic;
u32 markov_threshold;
char *markov_hcstat;
char *custom_charset_1;
char *custom_charset_2;
char *custom_charset_3;
char *custom_charset_4;
u32 rp_files_cnt;
char **rp_files;
char *hc_bin;
int hc_argc;
char **hc_argv;
bool attack_mode_chgd;
bool hash_mode_chgd;
@ -1123,10 +1114,88 @@ typedef struct user_options
bool workload_profile_chgd;
bool segment_size_chgd;
char *hc_bin;
int hc_argc;
char **hc_argv;
bool benchmark;
bool force;
bool gpu_temp_disable;
bool hex_charset;
bool hex_salt;
bool hex_wordlist;
bool increment;
bool keyspace;
bool left;
bool logfile_disable;
bool loopback;
bool machine_readable;
bool markov_classic;
bool markov_disable;
bool opencl_info;
bool outfile_autohex;
bool potfile_disable;
bool powertune_enable;
bool quiet;
bool remove;
bool restore;
bool restore_disable;
bool show;
bool status;
bool stdout_flag;
bool speed_only;
bool usage;
bool username;
bool version;
char *cpu_affinity;
char *custom_charset_1;
char *custom_charset_2;
char *custom_charset_3;
char *custom_charset_4;
char *debug_file;
char *induction_dir;
char *markov_hcstat;
char *opencl_devices;
char *opencl_device_types;
char *opencl_platforms;
char *outfile;
char *outfile_check_dir;
char *potfile_path;
char **rp_files;
char *rule_buf_l;
char *rule_buf_r;
char separator;
char *session;
char *truecrypt_keyfiles;
char *veracrypt_keyfiles;
u32 attack_mode;
u32 bitmap_max;
u32 bitmap_min;
u32 debug_mode;
u32 gpu_temp_abort;
u32 gpu_temp_retain;
u32 hash_mode;
u32 increment_max;
u32 increment_min;
u32 kernel_accel;
u32 kernel_loops;
u32 markov_threshold;
u32 nvidia_spin_damp;
u32 opencl_vector_width;
u32 outfile_check_timer;
u32 outfile_format;
u32 remove_timer;
u32 restore_timer;
u32 rp_files_cnt;
u32 rp_gen;
u32 rp_gen_func_max;
u32 rp_gen_func_min;
u32 rp_gen_seed;
u32 runtime;
u32 scrypt_tmto;
u32 segment_size;
u32 status_timer;
u32 veracrypt_pim;
u32 weak_hash_threshold;
u32 workload_profile;
u64 limit;
u64 skip;
} user_options_t;
@ -1260,23 +1329,6 @@ typedef struct mask_ctx
} mask_ctx_t;
typedef struct hwmon_ctx
{
bool enabled;
void *hm_adl;
void *hm_nvml;
void *hm_nvapi;
void *hm_xnvctrl;
hm_attrs_t *hm_device;
ADLOD6MemClockState *od_clock_mem_status;
int *od_power_control_status;
unsigned int *nvml_power_limit;
} hwmon_ctx_t;
typedef struct cpt_ctx
{
bool enabled;
@ -1318,9 +1370,11 @@ typedef struct status_ctx
* workload
*/
u64 words_cnt;
u64 words_cur;
u64 words_base;
u64 words_off; // used by dispatcher; get_work () as offset; attention: needs to be redone on in restore case!
u64 words_cur; // used by dispatcher; the different to words_cur_next is that this counter guarantees that the work from zero to this counter has been actually computed
// has been finished actually, can be used for restore point therefore
u64 words_base; // the unamplified max keyspace
u64 words_cnt; // the amplified max keyspace
/**
* progress
@ -1346,10 +1400,31 @@ typedef struct status_ctx
hc_timer_t timer_running; // timer on current dict
hc_timer_t timer_paused; // timer on current dict
double ms_paused; // timer on current dict
double msec_paused; // timer on current dict
} status_ctx_t;
typedef struct hashcat_user
{
// use this for context specific data
int outer_threads_cnt;
hc_thread_t *outer_threads;
} hashcat_user_t;
typedef struct event_ctx
{
char msg_buf[HCBUFSIZ_TINY];
int msg_len;
bool msg_newline;
int prev_len;
hc_thread_mutex_t mux_event;
} event_ctx_t;
typedef struct hashcat_ctx
{
bitmap_ctx_t *bitmap_ctx;
@ -1357,7 +1432,9 @@ typedef struct hashcat_ctx
cpt_ctx_t *cpt_ctx;
debugfile_ctx_t *debugfile_ctx;
dictstat_ctx_t *dictstat_ctx;
event_ctx_t *event_ctx;
folder_config_t *folder_config;
hashcat_user_t *hashcat_user;
hashconfig_t *hashconfig;
hashes_t *hashes;
hwmon_ctx_t *hwmon_ctx;
@ -1377,8 +1454,107 @@ typedef struct hashcat_ctx
user_options_t *user_options;
wl_data_t *wl_data;
void (*event) (const u32, struct hashcat_ctx *, const void *, const size_t);
} hashcat_ctx_t;
typedef enum input_mode
{
INPUT_MODE_NONE = 0,
INPUT_MODE_STRAIGHT_FILE = 1,
INPUT_MODE_STRAIGHT_FILE_RULES_FILE = 2,
INPUT_MODE_STRAIGHT_FILE_RULES_GEN = 3,
INPUT_MODE_STRAIGHT_STDIN = 4,
INPUT_MODE_STRAIGHT_STDIN_RULES_FILE = 5,
INPUT_MODE_STRAIGHT_STDIN_RULES_GEN = 6,
INPUT_MODE_COMBINATOR_BASE_LEFT = 7,
INPUT_MODE_COMBINATOR_BASE_RIGHT = 8,
INPUT_MODE_MASK = 9,
INPUT_MODE_MASK_CS = 10,
INPUT_MODE_HYBRID1 = 11,
INPUT_MODE_HYBRID1_CS = 12,
INPUT_MODE_HYBRID2 = 13,
INPUT_MODE_HYBRID2_CS = 14,
} input_mode_t;
typedef enum progress_mode
{
PROGRESS_MODE_NONE = 0,
PROGRESS_MODE_KEYSPACE_KNOWN = 1,
PROGRESS_MODE_KEYSPACE_UNKNOWN = 2,
} progress_mode_t;
typedef struct
{
bool skipped_dev;
double hashes_msec_dev;
double hashes_msec_dev_benchmark;
double exec_msec_dev;
char *speed_sec_dev;
char *input_candidates_dev;
char *hwmon_dev;
} device_info_t;
typedef struct
{
char *hash_target;
char *hash_type;
char *input_base;
char *input_charset;
char *input_mod;
char *session;
char *status_string;
int status_number;
char *time_estimated_absolute;
char *time_estimated_relative;
char *time_started_absolute;
char *time_started_relative;
double msec_paused;
double msec_running;
double msec_real;
int digests_cnt;
int digests_done;
double digests_percent;
int input_mode;
int salts_cnt;
int salts_done;
double salts_percent;
int progress_mode;
double progress_finished_percent;
u64 progress_cur;
u64 progress_cur_relative_skip;
u64 progress_done;
u64 progress_end;
u64 progress_end_relative_skip;
u64 progress_ignore;
u64 progress_rejected;
double progress_rejected_percent;
u64 progress_restored;
u64 progress_skip;
u64 restore_point;
u64 restore_total;
double restore_percent;
int cpt_cur_min;
int cpt_cur_hour;
int cpt_cur_day;
double cpt_avg_min;
double cpt_avg_hour;
double cpt_avg_day;
char *cpt;
device_info_t device_info_buf[DEVICES_MAX];
int device_info_cnt;
int device_info_active;
double hashes_msec_all;
double exec_msec_all;
char *speed_sec_all;
} hashcat_status_t;
typedef struct thread_param
{
u32 tid;

View File

@ -6,6 +6,8 @@
#ifndef _USAGE_H
#define _USAGE_H
#include <stdio.h>
void usage_mini_print (const char *progname);
void usage_big_print (const char *progname);

View File

@ -10,45 +10,45 @@
typedef enum user_options_defaults
{
ATTACK_MODE = 0,
BENCHMARK = 0,
ATTACK_MODE = ATTACK_MODE_STRAIGHT,
BENCHMARK = false,
BITMAP_MAX = 24,
BITMAP_MIN = 16,
DEBUG_MODE = 0,
FORCE = 0,
FORCE = false,
GPU_TEMP_ABORT = 90,
GPU_TEMP_DISABLE = 0,
GPU_TEMP_DISABLE = false,
GPU_TEMP_RETAIN = 75,
HASH_MODE = 0,
HEX_CHARSET = 0,
HEX_SALT = 0,
HEX_WORDLIST = 0,
INCREMENT = 0,
HEX_CHARSET = false,
HEX_SALT = false,
HEX_WORDLIST = false,
INCREMENT = false,
INCREMENT_MAX = PW_MAX,
INCREMENT_MIN = 1,
KERNEL_ACCEL = 0,
KERNEL_LOOPS = 0,
KEYSPACE = 0,
LEFT = 0,
KEYSPACE = false,
LEFT = false,
LIMIT = 0,
LOGFILE_DISABLE = 0,
LOOPBACK = 0,
MACHINE_READABLE = 0,
MARKOV_CLASSIC = 0,
MARKOV_DISABLE = 0,
LOGFILE_DISABLE = false,
LOOPBACK = false,
MACHINE_READABLE = false,
MARKOV_CLASSIC = false,
MARKOV_DISABLE = false,
MARKOV_THRESHOLD = 0,
NVIDIA_SPIN_DAMP = 100,
OPENCL_VECTOR_WIDTH = 0,
OUTFILE_AUTOHEX = 1,
OUTFILE_AUTOHEX = true,
OUTFILE_CHECK_TIMER = 5,
OUTFILE_FORMAT = 3,
POTFILE_DISABLE = 0,
POWERTUNE_ENABLE = 0,
QUIET = 0,
REMOVE = 0,
POTFILE_DISABLE = false,
POWERTUNE_ENABLE = false,
QUIET = false,
REMOVE = false,
REMOVE_TIMER = 60,
RESTORE = 0,
RESTORE_DISABLE = 0,
RESTORE = false,
RESTORE_DISABLE = false,
RESTORE_TIMER = 60,
RP_GEN = 0,
RP_GEN_FUNC_MAX = 4,
@ -58,14 +58,15 @@ typedef enum user_options_defaults
SCRYPT_TMTO = 0,
SEGMENT_SIZE = 33554432,
SEPARATOR = ':',
SHOW = 0,
SHOW = false,
SKIP = 0,
STATUS = 0,
STATUS = false,
STATUS_TIMER = 10,
STDOUT_FLAG = 0,
USAGE = 0,
USERNAME = 0,
VERSION = 0,
STDOUT_FLAG = false,
SPEED_ONLY = false,
USAGE = false,
USERNAME = false,
VERSION = false,
WEAK_HASH_THRESHOLD = 100,
WORKLOAD_PROFILE = 2,
@ -145,18 +146,19 @@ typedef enum user_options_map
IDX_STATUS = 0xff2d,
IDX_STATUS_TIMER = 0xff2e,
IDX_STDOUT_FLAG = 0xff2f,
IDX_TRUECRYPT_KEYFILES = 0xff30,
IDX_USERNAME = 0xff31,
IDX_VERACRYPT_KEYFILES = 0xff32,
IDX_VERACRYPT_PIM = 0xff33,
IDX_SPEED_ONLY = 0xff30,
IDX_TRUECRYPT_KEYFILES = 0xff31,
IDX_USERNAME = 0xff32,
IDX_VERACRYPT_KEYFILES = 0xff33,
IDX_VERACRYPT_PIM = 0xff34,
IDX_VERSION_LOWER = 'v',
IDX_VERSION = 'V',
IDX_WEAK_HASH_THRESHOLD = 0xff34,
IDX_WEAK_HASH_THRESHOLD = 0xff35,
IDX_WORKLOAD_PROFILE = 'w'
} user_options_map_t;
void user_options_init (hashcat_ctx_t *hashcat_ctx);
int user_options_init (hashcat_ctx_t *hashcat_ctx);
void user_options_destroy (hashcat_ctx_t *hashcat_ctx);

View File

@ -6,6 +6,6 @@
#ifndef _WEAK_HASH_H
#define _WEAK_HASH_H
void weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 salt_pos);
int weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 salt_pos);
#endif // _WEAK_HASH_H

View File

@ -18,9 +18,9 @@ void get_next_word_uc (char *buf, u64 sz, u64 *len, u64 *off);
void get_next_word_std (char *buf, u64 sz, u64 *len, u64 *off);
void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *out_len);
void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd);
int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd);
u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile);
void wl_data_init (hashcat_ctx_t *hashcat_ctx);
int wl_data_init (hashcat_ctx_t *hashcat_ctx);
void wl_data_destroy (hashcat_ctx_t *hashcat_ctx);
#endif // _WORDLIST_H

View File

@ -12,9 +12,12 @@ PROG_NAME := hashcat
UNAME := $(shell uname -s)
# we need to strip the windows version number to be able to build hashcat on cygwin hosts
UNAME := $(patsubst CYGWIN_NT-%,CYGWIN_NT-,$(UNAME))
UNAME := $(patsubst CYGWIN_NT-%,CYGWIN,$(UNAME))
UNAME := $(patsubst MSYS_NT-%,MSYS2,$(UNAME))
UNAME := $(patsubst MINGW32_NT-%,MSYS2,$(UNAME))
UNAME := $(patsubst MINGW64_NT-%,MSYS2,$(UNAME))
ifeq (,$(filter $(UNAME),Linux Darwin CYGWIN_NT- FreeBSD))
ifeq (,$(filter $(UNAME),Linux Darwin CYGWIN MSYS2 FreeBSD))
$(error "! Your Operating System ($(UNAME)) is not supported by $(PROG_NAME) Makefile")
endif
@ -91,7 +94,9 @@ VERSION_TAG := $(shell test -d .git && git describe --tags --dirty=
## Compiler flags
##
CFLAGS += -pipe -W -Wall -std=c99 -Iinclude/ -IOpenCL/ -I$(OPENCL_HEADERS_KHRONOS)/
INCLUDE_PATHS := -Iinclude/ -IOpenCL/ -I$(OPENCL_HEADERS_KHRONOS)/
CFLAGS += -pipe -W -Wall -std=c99
ifndef DEBUG
CFLAGS += -O2
@ -102,6 +107,14 @@ CFLAGS += -fsanitize=address -fno-omit-frame-pointer
endif
endif
##
## Linker flags
##
ifndef DEBUG
LDFLAGS += -s
endif
##
## Native compilation target
##
@ -118,12 +131,9 @@ endif # darwin
ifeq ($(UNAME),Linux)
CFLAGS_NATIVE :=
ifndef DEBUG
CFLAGS_NATIVE += -s
endif
CFLAGS_NATIVE += $(CFLAGS)
LFLAGS_NATIVE := -lpthread -ldl
CFLAGS_NATIVE += -DWITH_HWMON
LFLAGS_NATIVE := -lpthread -ldl
LFLAGS_NATIVE += $(LDFLAGS)
endif # linux
@ -134,38 +144,45 @@ LFLAGS_NATIVE := -lpthread
LFLAGS_NATIVE += $(LDFLAGS)
endif # freebsd
CFLAGS_NATIVE_SHARED :=
CFLAGS_NATIVE_SHARED += $(CFLAGS)
CFLAGS_NATIVE_SHARED += -DWITH_HWMON -fpic
LFLAGS_NATIVE_SHARED := -L. -lhashcat
LFLAGS_NATIVE_SHARED += -Wl,-rpath=.
LFLAGS_NATIVE_SHARED += -lpthread -ldl
LFLAGS_NATIVE_SHARED += $(LDFLAGS)
##
## Cross compilation target
##
CFLAGS_CROSS_LINUX :=
ifndef DEBUG
CFLAGS_CROSS_LINUX += -s
endif
CFLAGS_CROSS_LINUX += $(CFLAGS)
CFLAGS_CROSS_LINUX += -DWITH_HWMON
#CFLAGS_CROSS_WIN := -D_WIN -DWIN -D__MSVCRT__ -D__USE_MINGW_ANSI_STDIO=1
CFLAGS_CROSS_WIN :=
ifndef DEBUG
CFLAGS_CROSS_WIN += -s
endif
CFLAGS_CROSS_WIN += $(filter-out -fsanitize=address,$(CFLAGS))
CFLAGS_CROSS_WIN += -DWITH_HWMON
CFLAGS_CROSS_32 := -m32
CFLAGS_CROSS_64 := -m64
LFLAGS_CROSS_LINUX := -lpthread -ldl
LFLAGS_CROSS_WIN := -lpsapi
LFLAGS_CROSS_LINUX :=
LFLAGS_CROSS_LINUX += $(LDFLAGS)
LFLAGS_CROSS_LINUX += -lpthread -ldl
LFLAGS_CROSS_WIN :=
LFLAGS_CROSS_WIN += $(LDFLAGS)
LFLAGS_CROSS_WIN += -lpsapi -Wl,--dynamicbase -Wl,--nxcompat
##
## Objects
##
OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 debugfile dictstat dispatch dynloader ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hashcat hashes hlfmt hwmon induct interface locking logfile logging loopback memory monitor mpsp opencl outfile_check outfile potfile restore rp rp_cpu rp_kernel_on_cpu shared status stdout straight terminal thread timer tuningdb usage user_options weak_hash wordlist
OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md5 cpu_sha1 cpu_sha256 debugfile dictstat dispatch dynloader event ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_xnvctrl filehandling folder hashcat hashes hlfmt hwmon induct interface locking logfile 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)
NATIVE_SHARED_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.SHARED.o)
LINUX_32_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).LINUX.32.o)
LINUX_64_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).LINUX.64.o)
@ -190,7 +207,7 @@ native: hashcat
binaries: linux32 linux64 win32 win64
clean:
$(RM) -f obj/*.o *.bin *.exe *.restore *.out *.pot *.log hashcat core
$(RM) -f obj/*.o *.bin *.exe *.restore *.out *.pot *.log hashcat hashcat_shared libhashcat.so core
$(RM) -rf *.induct
$(RM) -rf *.outfiles
$(RM) -rf *.dSYM
@ -254,36 +271,49 @@ uninstall:
## native compiled hashcat
##
obj/%.NATIVE.o: src/%.c
$(CC) $(CFLAGS_NATIVE) -c -o $@ $<
obj/%.NATIVE.o: src/%.c
$(CC) -c $(CFLAGS_NATIVE) $(INCLUDE_PATHS) -o $@ $^
$(BINARY_NATIVE): src/main.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)\"
$(BINARY_NATIVE): $(NATIVE_OBJS) src/main.c
$(CC) $(CFLAGS_NATIVE) $(INCLUDE_PATHS) -o $@ $^ -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" $(LFLAGS_NATIVE)
##
## native compiled hashcat (shared)
##
obj/%.NATIVE.SHARED.o: src/%.c
$(CC) -c $(CFLAGS_NATIVE_SHARED) $(INCLUDE_PATHS) -o $@ $^
lib$(BINARY_NATIVE).so: $(NATIVE_SHARED_OBJS)
$(CC) -o $@ $^ -shared
$(BINARY_NATIVE)_shared: lib$(BINARY_NATIVE).so src/main_shared.c
$(CC) $(CFLAGS_NATIVE_SHARED) $(INCLUDE_PATHS) -o $@ $^ -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\" $(LFLAGS_NATIVE_SHARED)
##
## cross compiled hashcat for binary release version
##
obj/%.LINUX.32.o: src/%.c
$(CC_LINUX_32) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) -c -o $@ $<
$(CC_LINUX_32) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) $(INCLUDE_PATHS) -c -o $@ $<
obj/%.LINUX.64.o: src/%.c
$(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) -c -o $@ $<
$(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) $(INCLUDE_PATHS) -c -o $@ $<
obj/%.WIN.32.o: src/%.c
$(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -c -o $@ $<
$(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) $(INCLUDE_PATHS) -c -o $@ $<
obj/%.WIN.64.o: src/%.c
$(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -c -o $@ $<
$(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) $(INCLUDE_PATHS) -c -o $@ $<
hashcat32.bin: src/main.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)\"
$(CC_LINUX_32) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_32) $(INCLUDE_PATHS) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
hashcat64.bin: src/main.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)\"
$(CC_LINUX_64) $(CFLAGS_CROSS_LINUX) $(CFLAGS_CROSS_64) $(INCLUDE_PATHS) -o $@ $^ $(LFLAGS_CROSS_LINUX) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\" -DINSTALL_FOLDER=\"$(INSTALL_FOLDER)\" -DSHARED_FOLDER=\"$(SHARED_FOLDER)\" -DDOCUMENT_FOLDER=\"$(DOCUMENT_FOLDER)\"
hashcat32.exe: src/main.c $(WIN_32_OBJS)
$(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\"
$(CC_WIN_32) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_32) $(INCLUDE_PATHS) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\"
hashcat64.exe: src/main.c $(WIN_64_OBJS)
$(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\"
$(CC_WIN_64) $(CFLAGS_CROSS_WIN) $(CFLAGS_CROSS_64) $(INCLUDE_PATHS) -o $@ $^ $(LFLAGS_CROSS_WIN) -DCOMPTIME=$(COMPTIME) -DVERSION_TAG=\"$(VERSION_TAG)\"

View File

@ -10,7 +10,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "affinity.h"
#if defined (__APPLE__)
@ -40,78 +40,86 @@ static int pthread_setaffinity_np (pthread_t thread, size_t cpu_size, cpu_set_t
thread_affinity_policy_data_t policy = { core };
const int rc = thread_policy_set (pthread_mach_thread_np (thread), THREAD_AFFINITY_POLICY, (thread_policy_t) &policy, 1);
if (rc != KERN_SUCCESS)
{
log_error ("ERROR: %s : %d", "thread_policy_set()", rc);
exit (-1);
}
return rc;
return thread_policy_set (pthread_mach_thread_np (thread), THREAD_AFFINITY_POLICY, (thread_policy_t) &policy, 1);
}
#endif
void set_cpu_affinity (char *cpu_affinity)
#if defined (__FreeBSD__)
typedef cpuset_t cpu_set_t;
#endif
int set_cpu_affinity (hashcat_ctx_t *hashcat_ctx)
{
#if defined(_WIN)
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->cpu_affinity == NULL) return 0;
#if defined (_WIN)
DWORD_PTR aff_mask = 0;
#elif defined(__FreeBSD__)
cpuset_t cpuset;
CPU_ZERO (&cpuset);
#elif defined(_POSIX)
#else
cpu_set_t cpuset;
CPU_ZERO (&cpuset);
#endif
if (cpu_affinity)
char *devices = hcstrdup (hashcat_ctx, user_options->cpu_affinity);
char *next = strtok (devices, ",");
do
{
char *devices = mystrdup (cpu_affinity);
int cpu_id = atoi (next);
char *next = strtok (devices, ",");
do
if (cpu_id == 0)
{
int cpu_id = atoi (next);
if (cpu_id == 0)
{
#if defined (_WIN)
aff_mask = 0;
#elif defined (_POSIX)
CPU_ZERO (&cpuset);
#endif
break;
}
if (cpu_id > 32)
{
log_error ("ERROR: Invalid cpu_id %u specified", cpu_id);
exit (-1);
}
#if defined (_WIN)
aff_mask |= 1u << (cpu_id - 1);
#elif defined (_POSIX)
CPU_SET ((cpu_id - 1), &cpuset);
aff_mask = 0;
#else
CPU_ZERO (&cpuset);
#endif
} while ((next = strtok (NULL, ",")) != NULL);
break;
}
myfree (devices);
if (cpu_id > 32)
{
event_log_error (hashcat_ctx, "Invalid cpu_id %u specified", cpu_id);
return (-1);
}
#if defined (_WIN)
aff_mask |= 1u << (cpu_id - 1);
#else
CPU_SET ((cpu_id - 1), &cpuset);
#endif
} while ((next = strtok (NULL, ",")) != NULL);
hcfree (devices);
#if defined (_WIN)
SetProcessAffinityMask (GetCurrentProcess (), aff_mask);
if (SetThreadAffinityMask (GetCurrentThread (), aff_mask) == 0)
{
event_log_error (hashcat_ctx, "%s", "SetThreadAffinityMask()");
return -1;
}
#if defined( _WIN)
SetProcessAffinityMask (GetCurrentProcess (), aff_mask);
SetThreadAffinityMask (GetCurrentThread (), aff_mask);
#elif defined(__FreeBSD__)
#else
pthread_t thread = pthread_self ();
pthread_setaffinity_np (thread, sizeof (cpuset_t), &cpuset);
#elif defined(_POSIX)
pthread_t thread = pthread_self ();
pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset);
if (pthread_setaffinity_np (thread, sizeof (cpu_set_t), &cpuset) == -1)
{
event_log_error (hashcat_ctx, "%s", "pthread_setaffinity_np()");
return -1;
}
#endif
return 0;
}

View File

@ -5,10 +5,9 @@
#include "common.h"
#include "types.h"
#include "logging.h"
#include "event.h"
#include "opencl.h"
#include "status.h"
#include "terminal.h"
#include "autotune.h"
static double try_run (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 kernel_accel, const u32 kernel_loops)
@ -30,9 +29,9 @@ static double try_run (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par
run_kernel (hashcat_ctx, device_param, KERN_RUN_2, kernel_power_try, true, 0);
}
const double exec_ms_prev = get_avg_exec_time (device_param, 1);
const double exec_msec_prev = get_avg_exec_time (device_param, 1);
return exec_ms_prev;
return exec_msec_prev;
}
static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
@ -42,7 +41,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
const double target_ms = opencl_ctx->target_ms;
const double target_msec = opencl_ctx->target_msec;
const u32 kernel_accel_min = device_param->kernel_accel_min;
const u32 kernel_accel_max = device_param->kernel_accel_max;
@ -82,9 +81,13 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
const u32 kernel_power_max = device_param->device_processors * device_param->kernel_threads * kernel_accel_max;
int CL_rc;
if (user_options_extra->attack_kern == ATTACK_KERN_BF)
{
run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 7, kernel_power_max * sizeof (pw_t));
CL_rc = run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 7, kernel_power_max * sizeof (pw_t));
if (CL_rc == -1) return -1;
}
else
{
@ -95,53 +98,45 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
device_param->pws_buf[i].pw_len = 7 + (i & 7);
}
cl_int CL_err = hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{
log_error ("ERROR: clEnqueueWriteBuffer(): %s\n", val2cstr_cl (CL_err));
return -1;
}
if (CL_rc == -1) return -1;
}
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
if (straight_ctx->kernel_rules_cnt > 1)
{
cl_int CL_err = hc_clEnqueueCopyBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL);
CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL);
if (CL_err != CL_SUCCESS)
{
log_error ("ERROR: clEnqueueCopyBuffer(): %s\n", val2cstr_cl (CL_err));
return -1;
}
if (CL_rc == -1) return -1;
}
}
else
{
run_kernel_amp (hashcat_ctx, device_param, kernel_power_max);
CL_rc = run_kernel_amp (hashcat_ctx, device_param, kernel_power_max);
if (CL_rc == -1) return -1;
}
#define VERIFIER_CNT 1
// first find out highest kernel-loops that stays below target_ms
// first find out highest kernel-loops that stays below target_msec
if (kernel_loops_min < kernel_loops_max)
{
for (kernel_loops = kernel_loops_max; kernel_loops > kernel_loops_min; kernel_loops >>= 1)
{
double exec_ms = try_run (hashcat_ctx, device_param, kernel_accel_min, kernel_loops);
double exec_msec = try_run (hashcat_ctx, device_param, kernel_accel_min, kernel_loops);
for (int i = 0; i < VERIFIER_CNT; i++)
{
double exec_ms_v = try_run (hashcat_ctx, device_param, kernel_accel_min, kernel_loops);
double exec_msec_v = try_run (hashcat_ctx, device_param, kernel_accel_min, kernel_loops);
exec_ms = MIN (exec_ms, exec_ms_v);
exec_msec = MIN (exec_msec, exec_msec_v);
}
if (exec_ms < target_ms) break;
if (exec_msec < target_msec) break;
}
}
@ -158,16 +153,16 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
if (kernel_accel_try < kernel_accel_min) continue;
if (kernel_accel_try > kernel_accel_max) break;
double exec_ms = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops);
double exec_msec = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops);
for (int i = 0; i < VERIFIER_CNT; i++)
{
double exec_ms_v = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops);
double exec_msec_v = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops);
exec_ms = MIN (exec_ms, exec_ms_v);
exec_msec = MIN (exec_msec, exec_msec_v);
}
if (exec_ms > target_ms) break;
if (exec_msec > target_msec) break;
kernel_accel = kernel_accel_try;
}
@ -177,17 +172,17 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
// we need a reference for the balancing loop following up, and this
// the balancing loop can have an effect that the creates a new opportunity, for example:
// if the target is 95 ms and the current runtime is 48ms the above loop
// stopped the execution because the previous exec_ms was > 95ms
// stopped the execution because the previous exec_msec was > 95ms
// due to the rebalance it's possible that the runtime reduces from 48ms to 47ms
// and this creates the possibility to double the workload -> 47 * 2 = 95ms, which is < 96ms
double exec_ms_pre_final = try_run (hashcat_ctx, device_param, kernel_accel, kernel_loops);
double exec_msec_pre_final = try_run (hashcat_ctx, device_param, kernel_accel, kernel_loops);
for (int i = 0; i < VERIFIER_CNT; i++)
{
double exec_ms_pre_final_v = try_run (hashcat_ctx, device_param, kernel_accel, kernel_loops);
double exec_msec_pre_final_v = try_run (hashcat_ctx, device_param, kernel_accel, kernel_loops);
exec_ms_pre_final = MIN (exec_ms_pre_final, exec_ms_pre_final_v);
exec_msec_pre_final = MIN (exec_msec_pre_final, exec_msec_pre_final_v);
}
u32 diff = kernel_loops - kernel_accel;
@ -211,18 +206,18 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
diff_new = diff;
double exec_ms = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops_try);
double exec_msec = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops_try);
for (int i = 0; i < VERIFIER_CNT; i++)
{
double exec_ms_v = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops_try);
double exec_msec_v = try_run (hashcat_ctx, device_param, kernel_accel_try, kernel_loops_try);
exec_ms = MIN (exec_ms, exec_ms_v);
exec_msec = MIN (exec_msec, exec_msec_v);
}
if (exec_ms < exec_ms_pre_final)
if (exec_msec < exec_msec_pre_final)
{
exec_ms_pre_final = exec_ms;
exec_msec_pre_final = exec_msec;
kernel_accel = kernel_accel_try;
kernel_loops = kernel_loops_try;
@ -230,7 +225,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
}
}
const double exec_left = target_ms / exec_ms_pre_final;
const double exec_left = target_msec / exec_msec_pre_final;
const double accel_left = kernel_accel_max / kernel_accel;
@ -248,22 +243,26 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
/*
memset (device_param->pws_buf, 0, kernel_power_max * sizeof (pw_t));
hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
hc_clEnqueueWriteBuffer (opencl_ctx->ocl, device_param->command_queue, device_param->d_pws_amp_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_amp_buf, CL_TRUE, 0, kernel_power_max * sizeof (pw_t), device_param->pws_buf, 0, NULL, NULL);
*/
run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 0, kernel_power_max * sizeof (pw_t));
CL_rc = run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_buf, 0, kernel_power_max * sizeof (pw_t));
if (CL_rc == -1) return -1;
if (hashconfig->attack_exec == ATTACK_EXEC_OUTSIDE_KERNEL)
{
run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_amp_buf, 0, kernel_power_max * sizeof (pw_t));
CL_rc = run_kernel_memset (hashcat_ctx, device_param, device_param->d_pws_amp_buf, 0, kernel_power_max * sizeof (pw_t));
if (CL_rc == -1) return -1;
}
// reset timer
device_param->exec_pos = 0;
memset (device_param->exec_ms, 0, EXEC_CACHE * sizeof (double));
memset (device_param->exec_msec, 0, EXEC_CACHE * sizeof (double));
memset (device_param->exec_us_prev1, 0, EXPECTED_ITERATIONS * sizeof (double));
memset (device_param->exec_us_prev2, 0, EXPECTED_ITERATIONS * sizeof (double));
@ -280,14 +279,19 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
#if defined (DEBUG)
user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == false)
{
clear_prompt ();
log_info ("- Device #%u: autotuned kernel-accel to %u\n"
"- Device #%u: autotuned kernel-loops to %u\n",
device_param->device_id + 1, kernel_accel,
device_param->device_id + 1, kernel_loops);
printf
(
"- Device #%u: autotuned kernel-accel to %u\n"
"- Device #%u: autotuned kernel-loops to %u\n",
device_param->device_id + 1, kernel_accel,
device_param->device_id + 1, kernel_loops
);
send_prompt ();
}
@ -309,9 +313,14 @@ void *thread_autotune (void *p)
hc_device_param_t *device_param = opencl_ctx->devices_param + thread_param->tid;
if (device_param->skipped) return NULL;
if (device_param->skipped == true) return NULL;
autotune (hashcat_ctx, device_param);
const int rc_autotune = autotune (hashcat_ctx, device_param);
if (rc_autotune == -1)
{
// we should do something here, tell hashcat main that autotune failed to abort
}
return NULL;
}

View File

@ -6,7 +6,6 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "bitmap.h"
static u32 generate_bitmaps (const u32 digests_cnt, const u32 dgst_size, const u32 dgst_shifts, char *digests_buf_ptr, const u32 dgst_pos0, const u32 dgst_pos1, const u32 dgst_pos2, const u32 dgst_pos3, const u32 bitmap_mask, const u32 bitmap_size, u32 *bitmap_a, u32 *bitmap_b, u32 *bitmap_c, u32 *bitmap_d, const u64 collisions_max)
@ -50,7 +49,7 @@ static u32 generate_bitmaps (const u32 digests_cnt, const u32 dgst_size, const u
return collisions;
}
void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx)
int bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx)
{
bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
@ -59,12 +58,12 @@ void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx)
bitmap_ctx->enabled = false;
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->usage == true) return;
if (user_options->version == true) return;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->opencl_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
bitmap_ctx->enabled = true;
@ -78,14 +77,14 @@ void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx)
const u32 bitmap_min = user_options->bitmap_min;
const u32 bitmap_max = user_options->bitmap_max;
u32 *bitmap_s1_a = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s1_b = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s1_c = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s1_d = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s2_a = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s2_b = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s2_c = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s2_d = (u32 *) mymalloc ((1u << bitmap_max) * sizeof (u32));
u32 *bitmap_s1_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s1_a);
u32 *bitmap_s1_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s1_b);
u32 *bitmap_s1_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s1_c);
u32 *bitmap_s1_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s1_d);
u32 *bitmap_s2_a = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s2_a);
u32 *bitmap_s2_b = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s2_b);
u32 *bitmap_s2_c = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s2_c);
u32 *bitmap_s2_d = (u32 *) hcmalloc (hashcat_ctx, (1u << bitmap_max) * sizeof (u32)); VERIFY_PTR (bitmap_s2_d);
u32 bitmap_bits;
u32 bitmap_nums;
@ -94,8 +93,6 @@ void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx)
for (bitmap_bits = bitmap_min; bitmap_bits < bitmap_max; bitmap_bits++)
{
if (user_options->quiet == false) log_info_nn ("Generating bitmap tables with %u bits...", bitmap_bits);
bitmap_nums = 1u << bitmap_bits;
bitmap_mask = bitmap_nums - 1;
@ -134,6 +131,8 @@ void bitmap_ctx_init (hashcat_ctx_t *hashcat_ctx)
bitmap_ctx->bitmap_s2_b = bitmap_s2_b;
bitmap_ctx->bitmap_s2_c = bitmap_s2_c;
bitmap_ctx->bitmap_s2_d = bitmap_s2_d;
return 0;
}
void bitmap_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
@ -142,14 +141,14 @@ void bitmap_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
if (bitmap_ctx->enabled == false) return;
myfree (bitmap_ctx->bitmap_s1_a);
myfree (bitmap_ctx->bitmap_s1_b);
myfree (bitmap_ctx->bitmap_s1_c);
myfree (bitmap_ctx->bitmap_s1_d);
myfree (bitmap_ctx->bitmap_s2_a);
myfree (bitmap_ctx->bitmap_s2_b);
myfree (bitmap_ctx->bitmap_s2_c);
myfree (bitmap_ctx->bitmap_s2_d);
hcfree (bitmap_ctx->bitmap_s1_a);
hcfree (bitmap_ctx->bitmap_s1_b);
hcfree (bitmap_ctx->bitmap_s1_c);
hcfree (bitmap_ctx->bitmap_s1_d);
hcfree (bitmap_ctx->bitmap_s2_a);
hcfree (bitmap_ctx->bitmap_s2_b);
hcfree (bitmap_ctx->bitmap_s2_c);
hcfree (bitmap_ctx->bitmap_s2_d);
memset (bitmap_ctx, 0, sizeof (bitmap_ctx_t));
}

View File

@ -5,8 +5,8 @@
#include "common.h"
#include "types.h"
#include "event.h"
#include "memory.h"
#include "logging.h"
#include "combinator.h"
#include "wordlist.h"
@ -30,7 +30,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
combinator_ctx->enabled = true;
combinator_ctx->scratch_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
combinator_ctx->scratch_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (combinator_ctx->scratch_buf);
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
@ -52,14 +52,14 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
if ((fp1 = fopen (dictfile1, "rb")) == NULL)
{
log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno));
return -1;
}
if (stat (dictfile1, &tmp_stat) == -1)
{
log_error ("ERROR: %s: %s", dictfile1, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno));
fclose (fp1);
@ -68,7 +68,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (S_ISDIR (tmp_stat.st_mode))
{
log_error ("ERROR: %s must be a regular file", dictfile1, strerror (errno));
event_log_error (hashcat_ctx, "%s must be a regular file", dictfile1, strerror (errno));
fclose (fp1);
@ -77,7 +77,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
if ((fp2 = fopen (dictfile2, "rb")) == NULL)
{
log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
fclose (fp1);
@ -86,7 +86,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (stat (dictfile2, &tmp_stat) == -1)
{
log_error ("ERROR: %s: %s", dictfile2, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno));
fclose (fp1);
fclose (fp2);
@ -96,7 +96,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (S_ISDIR (tmp_stat.st_mode))
{
log_error ("ERROR: %s must be a regular file", dictfile2, strerror (errno));
event_log_error (hashcat_ctx, "%s must be a regular file", dictfile2, strerror (errno));
fclose (fp1);
fclose (fp2);
@ -110,7 +110,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (words1_cnt == 0)
{
log_error ("ERROR: %s: empty file", dictfile1);
event_log_error (hashcat_ctx, "%s: empty file", dictfile1);
fclose (fp1);
fclose (fp2);
@ -124,7 +124,7 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (words2_cnt == 0)
{
log_error ("ERROR: %s: empty file", dictfile2);
event_log_error (hashcat_ctx, "%s: empty file", dictfile2);
fclose (fp1);
fclose (fp2);
@ -183,7 +183,7 @@ void combinator_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
if (combinator_ctx->enabled == false) return;
myfree (combinator_ctx->scratch_buf);
hcfree (combinator_ctx->scratch_buf);
memset (combinator_ctx, 0, sizeof (combinator_ctx_t));
}

View File

@ -4,4 +4,3 @@
*/
#include "common.h"

View File

@ -6,7 +6,6 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "cpt.h"
int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx)
@ -26,7 +25,7 @@ int cpt_ctx_init (hashcat_ctx_t *hashcat_ctx)
cpt_ctx->enabled = true;
cpt_ctx->cpt_buf = (cpt_t *) mycalloc (CPT_BUF, sizeof (cpt_t));
cpt_ctx->cpt_buf = (cpt_t *) hccalloc (hashcat_ctx, CPT_BUF, sizeof (cpt_t)); VERIFY_PTR (cpt_ctx->cpt_buf);
cpt_ctx->cpt_total = 0;
cpt_ctx->cpt_pos = 0;
@ -41,7 +40,7 @@ void cpt_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
if (cpt_ctx->enabled == false) return;
myfree (cpt_ctx->cpt_buf);
hcfree (cpt_ctx->cpt_buf);
memset (cpt_ctx, 0, sizeof (cpt_ctx_t));
}

View File

@ -6,7 +6,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "cpu_crc32.h"
static const u32 crc32tab[256] =
@ -77,7 +77,7 @@ static const u32 crc32tab[256] =
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
void cpu_crc32 (const char *filename, u8 keytab[64])
int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64])
{
u32 crc = ~0u;
@ -85,14 +85,14 @@ void cpu_crc32 (const char *filename, u8 keytab[64])
if (fd == NULL)
{
log_error ("%s: %s", filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno));
exit (-1);
return (-1);
}
#define MAX_KEY_SIZE (1024 * 1024)
u8 *buf = (u8 *) mymalloc (MAX_KEY_SIZE + 1);
u8 *buf = (u8 *) hcmalloc (hashcat_ctx, MAX_KEY_SIZE + 1); VERIFY_PTR (buf);
int nread = fread (buf, sizeof (u8), MAX_KEY_SIZE, fd);
@ -112,5 +112,7 @@ void cpu_crc32 (const char *filename, u8 keytab[64])
if (kpos >= 64) kpos = 0;
}
myfree (buf);
hcfree (buf);
return 0;
}

View File

@ -6,7 +6,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "debugfile.h"
static void debugfile_format_plain (hashcat_ctx_t *hashcat_ctx, const u8 *plain_ptr, const u32 plain_len)
@ -91,6 +91,7 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->opencl_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->debug_mode == 0) return 0;
@ -107,7 +108,7 @@ int debugfile_init (hashcat_ctx_t *hashcat_ctx)
if (debugfile_ctx->fp == NULL)
{
log_error ("ERROR: Could not open debug-file for writing");
event_log_error (hashcat_ctx, "Could not open debug-file for writing");
return -1;
}

View File

@ -6,7 +6,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "dictstat.h"
int sort_by_dictstat (const void *s1, const void *s2)
@ -42,17 +42,17 @@ int dictstat_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->attack_mode == ATTACK_MODE_BF) return 0;
dictstat_ctx->enabled = true;
dictstat_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY);
dictstat_ctx->base = (dictstat_t *) mycalloc (MAX_DICTSTAT, sizeof (dictstat_t));
dictstat_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (dictstat_ctx->filename);
dictstat_ctx->base = (dictstat_t *) hccalloc (hashcat_ctx, MAX_DICTSTAT, sizeof (dictstat_t)); VERIFY_PTR (dictstat_ctx->base);
dictstat_ctx->cnt = 0;
snprintf (dictstat_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.dictstat", folder_config->profile_dir);
FILE *fp = fopen (dictstat_ctx->filename, "wb");
FILE *fp = fopen (dictstat_ctx->filename, "ab");
if (fp == NULL)
{
log_error ("ERROR: %s: %s", dictstat_ctx->filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno));
return -1;
}
@ -68,8 +68,8 @@ void dictstat_destroy (hashcat_ctx_t *hashcat_ctx)
if (dictstat_ctx->enabled == false) return;
myfree (dictstat_ctx->filename);
myfree (dictstat_ctx->base);
hcfree (dictstat_ctx->filename);
hcfree (dictstat_ctx->base);
memset (dictstat_ctx, 0, sizeof (dictstat_ctx_t));
}
@ -101,7 +101,7 @@ void dictstat_read (hashcat_ctx_t *hashcat_ctx)
if (dictstat_ctx->cnt == MAX_DICTSTAT)
{
log_error ("ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat_ctx->filename);
event_log_error (hashcat_ctx, "There are too many entries in the %s database. You have to remove/rename it.", dictstat_ctx->filename);
break;
}
@ -120,7 +120,7 @@ int dictstat_write (hashcat_ctx_t *hashcat_ctx)
if (fp == NULL)
{
log_error ("ERROR: %s: %s", dictstat_ctx->filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", dictstat_ctx->filename, strerror (errno));
return -1;
}
@ -153,7 +153,7 @@ void dictstat_append (hashcat_ctx_t *hashcat_ctx, dictstat_t *d)
if (dictstat_ctx->cnt == MAX_DICTSTAT)
{
log_error ("ERROR: There are too many entries in the %s database. You have to remove/rename it.", dictstat_ctx->filename);
event_log_error (hashcat_ctx, "There are too many entries in the %s database. You have to remove/rename it.", dictstat_ctx->filename);
return;
}

View File

@ -9,7 +9,6 @@
#include "filehandling.h"
#include "interface.h"
#include "timer.h"
#include "logging.h"
#include "ext_OpenCL.h"
#include "ext_ADL.h"
#include "ext_nvapi.h"
@ -22,7 +21,6 @@
#include "restore.h"
#include "hashes.h"
#include "rp_cpu.h"
#include "terminal.h"
#include "mpsp.h"
#include "outfile.h"
#include "potfile.h"
@ -33,23 +31,45 @@
#include "wordlist.h"
#include "status.h"
#include "shared.h"
#include "event.h"
#include "dispatch.h"
static void set_kernel_power_final (opencl_ctx_t *opencl_ctx, const user_options_t *user_options, const u64 kernel_power_final)
static u64 get_lowest_words_done (const hashcat_ctx_t *hashcat_ctx)
{
if (user_options->quiet == false)
const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
u64 words_cur = 0xffffffffffffffff;
for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
{
clear_prompt ();
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
//log_info ("");
if (device_param->skipped) continue;
log_info ("INFO: approaching final keyspace, workload adjusted");
log_info ("");
const u64 words_done = device_param->words_done;
send_prompt ();
if (words_done < words_cur) words_cur = words_done;
}
// It's possible that a device's workload isn't finished right after a restore-case.
// In that case, this function would return 0 and overwrite the real restore point
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
if (words_cur < status_ctx->words_cur) words_cur = status_ctx->words_cur;
return words_cur;
}
static int set_kernel_power_final (hashcat_ctx_t *hashcat_ctx, const u32 kernel_power_final)
{
EVENT (EVENT_SET_KERNEL_POWER_FINAL);
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
opencl_ctx->kernel_power_final = kernel_power_final;
return 0;
}
static u32 get_power (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param)
@ -72,24 +92,28 @@ static u32 get_power (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param)
return device_param->kernel_power;
}
static u32 get_work (opencl_ctx_t *opencl_ctx, status_ctx_t *status_ctx, const user_options_t *user_options, hc_device_param_t *device_param, const u64 max)
static u32 get_work (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 max)
{
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
user_options_t *user_options = hashcat_ctx->user_options;
hc_thread_mutex_lock (status_ctx->mux_dispatcher);
const u64 words_cur = status_ctx->words_cur;
const u64 words_off = status_ctx->words_off;
const u64 words_base = (user_options->limit == 0) ? status_ctx->words_base : MIN (user_options->limit, status_ctx->words_base);
device_param->words_off = words_cur;
device_param->words_off = words_off;
const u64 kernel_power_all = opencl_ctx->kernel_power_all;
const u64 words_left = words_base - words_cur;
const u64 words_left = words_base - words_off;
if (words_left < kernel_power_all)
{
if (opencl_ctx->kernel_power_final == 0)
{
set_kernel_power_final (opencl_ctx, user_options, words_left);
set_kernel_power_final (hashcat_ctx, words_left);
}
}
@ -99,14 +123,14 @@ static u32 get_work (opencl_ctx_t *opencl_ctx, status_ctx_t *status_ctx, const u
work = MIN (work, max);
status_ctx->words_cur += work;
status_ctx->words_off += work;
hc_thread_mutex_unlock (status_ctx->mux_dispatcher);
return work;
}
static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
{
user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
@ -115,7 +139,7 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE);
char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (buf);
const u32 attack_kern = user_options_extra->attack_kern;
@ -130,9 +154,9 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa
break;
}
u32 words_cur = 0;
u32 words_buffered = 0;
while (words_cur < device_param->kernel_power)
while (words_buffered < device_param->kernel_power)
{
char *line_buf = fgets (buf, HCBUFSIZ_LARGE - 1, stdin);
@ -187,7 +211,7 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa
pw_add (device_param, (u8 *) line_buf, (int) line_len);
words_cur++;
words_buffered++;
while (status_ctx->run_thread_level1 == false) break;
}
@ -202,9 +226,15 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa
if (pws_cnt)
{
run_copy (hashcat_ctx, device_param, pws_cnt);
int CL_rc;
run_cracker (hashcat_ctx, device_param, pws_cnt);
CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt);
if (CL_rc == -1) return -1;
CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt);
if (CL_rc == -1) return -1;
device_param->pws_cnt = 0;
@ -212,20 +242,30 @@ static void calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_pa
still required?
if (attack_kern == ATTACK_KERN_STRAIGHT)
{
run_kernel_bzero (opencl_ctx, device_param, device_param->d_rules_c, device_param->size_rules_c);
CL_rc = run_kernel_bzero (opencl_ctx, device_param, device_param->d_rules_c, device_param->size_rules_c);
if (CL_rc == -1) return -1;
}
else if (attack_kern == ATTACK_KERN_COMBI)
{
run_kernel_bzero (opencl_ctx, device_param, device_param->d_combs_c, device_param->size_combs);
rCL_rc = un_kernel_bzero (opencl_ctx, device_param, device_param->d_combs_c, device_param->size_combs);
if (CL_rc == -1) return -1;
}
*/
}
if (status_ctx->run_thread_level1 == false) break;
if (user_options->speed_only == true) break;
}
device_param->kernel_accel = 0;
device_param->kernel_loops = 0;
myfree (buf);
hcfree (buf);
return 0;
}
void *thread_calc_stdin (void *p)
@ -242,12 +282,12 @@ void *thread_calc_stdin (void *p)
if (device_param->skipped) return NULL;
calc_stdin (hashcat_ctx, device_param);
calc_stdin (hashcat_ctx, device_param); // we should check the RC here
return NULL;
}
static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
{
user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
@ -255,7 +295,6 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
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 u32 attack_mode = user_options->attack_mode;
@ -265,7 +304,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
{
while (status_ctx->run_thread_level1 == true)
{
const u32 work = get_work (opencl_ctx, status_ctx, user_options, device_param, -1u);
const u32 work = get_work (hashcat_ctx, device_param, -1u);
if (work == 0) break;
@ -278,23 +317,29 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (pws_cnt)
{
run_copy (hashcat_ctx, device_param, pws_cnt);
int CL_rc;
run_cracker (hashcat_ctx, device_param, pws_cnt);
CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt);
if (CL_rc == -1) return -1;
CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt);
if (CL_rc == -1) return -1;
device_param->pws_cnt = 0;
}
/*
still required?
run_kernel_bzero (device_param, device_param->d_bfs_c, device_param->size_bfs);
*/
if (user_options->speed_only == true) break;
if (status_ctx->run_thread_level2 == true)
{
device_param->words_done = words_fin;
status_ctx->words_cur = get_lowest_words_done (hashcat_ctx);
}
if (status_ctx->run_thread_level1 == false) break;
if (user_options->benchmark == true) break;
device_param->words_done = words_fin;
}
}
else
@ -317,9 +362,9 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (fd == NULL)
{
log_error ("ERROR: %s: %s", dictfile, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno));
return;
return -1;
}
if (attack_mode == ATTACK_MODE_COMBI)
@ -334,11 +379,11 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (combs_fp == NULL)
{
log_error ("ERROR: %s: %s", combinator_ctx->dict2, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno));
fclose (fd);
return;
return -1;
}
device_param->combs_fp = combs_fp;
@ -351,18 +396,18 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (combs_fp == NULL)
{
log_error ("ERROR: %s: %s", dictfilec, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", dictfilec, strerror (errno));
fclose (fd);
return;
return -1;
}
device_param->combs_fp = combs_fp;
}
}
hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) mymalloc (sizeof (hashcat_ctx_t));
hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_ctx_t)); VERIFY_PTR (hashcat_ctx_tmp);
/*
hashcat_ctx_tmp->bitmap_ctx = hashcat_ctx->bitmap_ctx;
@ -392,9 +437,11 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
memcpy (hashcat_ctx_tmp, hashcat_ctx, sizeof (hashcat_ctx_t)); // yes we actually want to copy these pointers
hashcat_ctx_tmp->wl_data = (wl_data_t *) mymalloc (sizeof (wl_data_t));
hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (hashcat_ctx, sizeof (wl_data_t)); VERIFY_PTR (hashcat_ctx_tmp->wl_data);
wl_data_init (hashcat_ctx_tmp);
const int rc_wl_data_init = wl_data_init (hashcat_ctx_tmp);
if (rc_wl_data_init == -1) return -1;
u64 words_cur = 0;
@ -403,15 +450,15 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
u64 words_off = 0;
u64 words_fin = 0;
u64 max = -1llu;
u32 words_extra = -1u;
while (max)
while (words_extra)
{
const u32 work = get_work (opencl_ctx, status_ctx, user_options, device_param, max);
const u32 work = get_work (hashcat_ctx, device_param, words_extra);
if (work == 0) break;
max = 0;
words_extra = 0;
words_off = device_param->words_off;
words_fin = words_off + work;
@ -450,7 +497,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
{
if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max))
{
max++;
words_extra++;
hc_thread_mutex_lock (status_ctx->mux_counter);
@ -471,7 +518,7 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (line_len > hashconfig->pw_max)
{
max++;
words_extra++;
hc_thread_mutex_lock (status_ctx->mux_counter);
@ -504,9 +551,15 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
if (pws_cnt)
{
run_copy (hashcat_ctx, device_param, pws_cnt);
int CL_rc;
run_cracker (hashcat_ctx, device_param, pws_cnt);
CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt);
if (CL_rc == -1) return -1;
CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt);
if (CL_rc == -1) return -1;
device_param->pws_cnt = 0;
@ -514,20 +567,31 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
still required?
if (attack_kern == ATTACK_KERN_STRAIGHT)
{
run_kernel_bzero (device_param, device_param->d_rules_c, device_param->size_rules_c);
CL_rc = run_kernel_bzero (device_param, device_param->d_rules_c, device_param->size_rules_c);
if (CL_rc == -1) return -1;
}
else if (attack_kern == ATTACK_KERN_COMBI)
{
run_kernel_bzero (device_param, device_param->d_combs_c, device_param->size_combs);
CL_rc = run_kernel_bzero (device_param, device_param->d_combs_c, device_param->size_combs);
if (CL_rc == -1) return -1;
}
*/
}
if (user_options->speed_only == true) break;
if (status_ctx->run_thread_level2 == true)
{
device_param->words_done = words_fin;
status_ctx->words_cur = get_lowest_words_done (hashcat_ctx);
}
if (status_ctx->run_thread_level1 == false) break;
if (words_fin == 0) break;
device_param->words_done = words_fin;
}
if (attack_mode == ATTACK_MODE_COMBI)
@ -537,15 +601,17 @@ static void calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param)
wl_data_destroy (hashcat_ctx_tmp);
myfree (hashcat_ctx_tmp->wl_data);
hcfree (hashcat_ctx_tmp->wl_data);
myfree (hashcat_ctx_tmp);
hcfree (hashcat_ctx_tmp);
fclose (fd);
}
device_param->kernel_accel = 0;
device_param->kernel_loops = 0;
return 0;
}
void *thread_calc (void *p)
@ -562,7 +628,7 @@ void *thread_calc (void *p)
if (device_param->skipped) return NULL;
calc (hashcat_ctx, device_param);
calc (hashcat_ctx, device_param); // we should check the RC here
return NULL;
}

188
src/event.c Normal file
View File

@ -0,0 +1,188 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include "common.h"
#include "types.h"
#include "thread.h"
#include "event.h"
void event_call (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
{
bool need_mux = true;
switch (id)
{
case EVENT_LOG_INFO: need_mux = false;
case EVENT_LOG_WARNING: need_mux = false;
case EVENT_LOG_ERROR: need_mux = false;
}
if (need_mux == true)
{
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
hc_thread_mutex_lock (event_ctx->mux_event);
}
hashcat_ctx->event (id, hashcat_ctx, buf, len);
if (need_mux == true)
{
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
hc_thread_mutex_unlock (event_ctx->mux_event);
}
}
static int event_log (const char *fmt, va_list ap, char *s, const size_t sz)
{
return vsnprintf (s, sz, fmt, ap);
}
size_t event_log_info_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
event_ctx->msg_buf[event_ctx->msg_len] = 0;
va_end (ap);
event_ctx->msg_newline = false;
event_call (EVENT_LOG_INFO, hashcat_ctx, NULL, 0);
return event_ctx->msg_len;
}
size_t event_log_warning_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
event_ctx->msg_buf[event_ctx->msg_len] = 0;
va_end (ap);
event_ctx->msg_newline = false;
event_call (EVENT_LOG_WARNING, hashcat_ctx, NULL, 0);
return event_ctx->msg_len;
}
size_t event_log_error_nn (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
event_ctx->msg_buf[event_ctx->msg_len] = 0;
va_end (ap);
event_ctx->msg_newline = false;
event_call (EVENT_LOG_ERROR, hashcat_ctx, NULL, 0);
return event_ctx->msg_len;
}
size_t event_log_info (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
event_ctx->msg_buf[event_ctx->msg_len] = 0;
va_end (ap);
event_ctx->msg_newline = true;
event_call (EVENT_LOG_INFO, hashcat_ctx, NULL, 0);
return event_ctx->msg_len;
}
size_t event_log_warning (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
event_ctx->msg_buf[event_ctx->msg_len] = 0;
va_end (ap);
event_ctx->msg_newline = true;
event_call (EVENT_LOG_WARNING, hashcat_ctx, NULL, 0);
return event_ctx->msg_len;
}
size_t event_log_error (hashcat_ctx_t *hashcat_ctx, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
event_ctx->msg_len = event_log (fmt, ap, event_ctx->msg_buf, HCBUFSIZ_TINY - 1);
event_ctx->msg_buf[event_ctx->msg_len] = 0;
va_end (ap);
event_ctx->msg_newline = true;
event_call (EVENT_LOG_ERROR, hashcat_ctx, NULL, 0);
return event_ctx->msg_len;
}
int event_ctx_init (hashcat_ctx_t *hashcat_ctx)
{
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
hc_thread_mutex_init (event_ctx->mux_event);
event_ctx->msg_len = 0;
return 0;
}
void event_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
{
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
hc_thread_mutex_delete (event_ctx->mux_event);
event_ctx->msg_len = 0;
}

View File

@ -4,612 +4,9 @@
*/
#include "common.h"
#include "logging.h"
#include "memory.h"
#include "dynloader.h"
#include "ext_ADL.h"
int adl_init (ADL_PTR *adl)
{
if (!adl) return -1;
memset (adl, 0, sizeof (ADL_PTR));
#if defined (_WIN)
adl->lib = hc_dlopen ("atiadlxx.dll");
if (!adl->lib)
{
adl->lib = hc_dlopen ("atiadlxy.dll");
}
#elif defined (_POSIX)
adl->lib = hc_dlopen ("libatiadlxx.so", RTLD_NOW);
#endif
if (!adl->lib)
{
//if (user_options->quiet == false)
// log_info ("WARNING: load ADL library failed, proceed without ADL HWMon enabled.");
return -1;
}
HC_LOAD_FUNC(adl, ADL_Main_Control_Destroy, ADL_MAIN_CONTROL_DESTROY, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Main_Control_Create, ADL_MAIN_CONTROL_CREATE, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Adapter_NumberOfAdapters_Get, ADL_ADAPTER_NUMBEROFADAPTERS_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Adapter_AdapterInfo_Get, ADL_ADAPTER_ADAPTERINFO_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Display_DisplayInfo_Get, ADL_DISPLAY_DISPLAYINFO_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Adapter_ID_Get, ADL_ADAPTER_ID_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Adapter_VideoBiosInfo_Get, ADL_ADAPTER_VIDEOBIOSINFO_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive5_ThermalDevices_Enum, ADL_OVERDRIVE5_THERMALDEVICES_ENUM, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive5_Temperature_Get, ADL_OVERDRIVE5_TEMPERATURE_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_Temperature_Get, ADL_OVERDRIVE6_TEMPERATURE_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive5_CurrentActivity_Get, ADL_OVERDRIVE5_CURRENTACTIVITY_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeedInfo_Get, ADL_OVERDRIVE5_FANSPEEDINFO_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeed_Get, ADL_OVERDRIVE5_FANSPEED_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Get, ADL_OVERDRIVE6_FANSPEED_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeed_Set, ADL_OVERDRIVE5_FANSPEED_SET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Set, ADL_OVERDRIVE6_FANSPEED_SET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive5_FanSpeedToDefault_Set, ADL_OVERDRIVE5_FANSPEEDTODEFAULT_SET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive5_ODParameters_Get, ADL_OVERDRIVE5_ODPARAMETERS_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive5_ODPerformanceLevels_Get, ADL_OVERDRIVE5_ODPERFORMANCELEVELS_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive5_ODPerformanceLevels_Set, ADL_OVERDRIVE5_ODPERFORMANCELEVELS_SET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_PowerControlInfo_Get, ADL_OVERDRIVE6_POWERCONTROLINFO_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_PowerControl_Get, ADL_OVERDRIVE6_POWERCONTROL_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_PowerControl_Set, ADL_OVERDRIVE6_POWERCONTROL_SET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Adapter_Active_Get, ADL_ADAPTER_ACTIVE_GET, ADL, 0)
//HC_LOAD_FUNC(adl, ADL_DisplayEnable_Set, ADL_DISPLAYENABLE_SET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive_Caps, ADL_OVERDRIVE_CAPS, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_PowerControl_Caps, ADL_OVERDRIVE6_POWERCONTROL_CAPS, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_Capabilities_Get, ADL_OVERDRIVE6_CAPABILITIES_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_StateInfo_Get, ADL_OVERDRIVE6_STATEINFO_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_CurrentStatus_Get, ADL_OVERDRIVE6_CURRENTSTATUS_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_State_Set, ADL_OVERDRIVE6_STATE_SET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureData_Get, ADL_OVERDRIVE6_TARGETTEMPERATUREDATA_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_TargetTemperatureRangeInfo_Get, ADL_OVERDRIVE6_TARGETTEMPERATURERANGEINFO_GET, ADL, 0)
HC_LOAD_FUNC(adl, ADL_Overdrive6_FanSpeed_Reset, ADL_OVERDRIVE6_FANSPEED_RESET, ADL, 0)
return 0;
}
void adl_close (ADL_PTR *adl)
{
if (adl)
{
if (adl->lib)
hc_dlclose (adl->lib);
myfree (adl);
}
}
void *HC_API_CALL ADL_Main_Memory_Alloc (const int iSize)
{
return mymalloc ((size_t) iSize);
}
int hm_ADL_Main_Control_Destroy (ADL_PTR *adl)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Main_Control_Destroy ();
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Main_Control_Destroy()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Main_Control_Create (ADL_PTR *adl, ADL_MAIN_MALLOC_CALLBACK callback, int iEnumConnectedAdapters)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Main_Control_Create (callback, iEnumConnectedAdapters);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Main_Control_Create()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Adapter_NumberOfAdapters_Get (ADL_PTR *adl, int *lpNumAdapters)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Adapter_NumberOfAdapters_Get (lpNumAdapters);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Adapter_NumberOfAdapters_Get()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Adapter_AdapterInfo_Get (ADL_PTR *adl, LPAdapterInfo lpInfo, int iInputSize)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Adapter_AdapterInfo_Get (lpInfo, iInputSize);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Adapter_AdapterInfo_Get()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Display_DisplayInfo_Get (ADL_PTR *adl, int iAdapterIndex, int *iNumDisplays, ADLDisplayInfo **lppInfo, int iForceDetect)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Display_DisplayInfo_Get (iAdapterIndex, iNumDisplays, lppInfo, iForceDetect);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Display_DisplayInfo_Get()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Adapter_ID_Get (ADL_PTR *adl, int iAdapterIndex, int *lpAdapterID)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Adapter_ID_Get (iAdapterIndex, lpAdapterID);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Adapter_ID_Get()", ADL_rc);
}
return ADL_rc;
}
int hm_ADL_Adapter_VideoBiosInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLBiosInfo *lpBiosInfo)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Adapter_VideoBiosInfo_Get (iAdapterIndex, lpBiosInfo);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Adapter_VideoBiosInfo_Get()", ADL_rc);
}
return ADL_rc;
}
int hm_ADL_Overdrive_ThermalDevices_Enum (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLThermalControllerInfo *lpThermalControllerInfo)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive5_ThermalDevices_Enum (iAdapterIndex, iThermalControllerIndex, lpThermalControllerInfo);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive5_ThermalDevices_Enum()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Overdrive5_Temperature_Get (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLTemperature *lpTemperature)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive5_Temperature_Get (iAdapterIndex, iThermalControllerIndex, lpTemperature);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive5_Temperature_Get()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Overdrive6_Temperature_Get (ADL_PTR *adl, int iAdapterIndex, int *iTemperature)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive6_Temperature_Get (iAdapterIndex, iTemperature);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive6_Temperature_Get()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Overdrive_CurrentActivity_Get (ADL_PTR *adl, int iAdapterIndex, ADLPMActivity *lpActivity)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive5_CurrentActivity_Get (iAdapterIndex, lpActivity);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive5_CurrentActivity_Get()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Overdrive5_FanSpeedInfo_Get (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedInfo *lpFanSpeedInfo)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive5_FanSpeedInfo_Get (iAdapterIndex, iThermalControllerIndex, lpFanSpeedInfo);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive5_FanSpeedInfo_Get()", ADL_rc);
}
return ADL_rc;
}
int hm_ADL_Overdrive5_FanSpeed_Get (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive5_FanSpeed_Get (iAdapterIndex, iThermalControllerIndex, lpFanSpeedValue);
if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive5_FanSpeed_Get()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Overdrive6_FanSpeed_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6FanSpeedInfo *lpFanSpeedInfo)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive6_FanSpeed_Get (iAdapterIndex, lpFanSpeedInfo);
if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive6_FanSpeed_Get()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Overdrive5_FanSpeed_Set (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex, ADLFanSpeedValue *lpFanSpeedValue)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive5_FanSpeed_Set (iAdapterIndex, iThermalControllerIndex, lpFanSpeedValue);
if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive5_FanSpeed_Set()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Overdrive6_FanSpeed_Set (ADL_PTR *adl, int iAdapterIndex, ADLOD6FanSpeedValue *lpFanSpeedValue)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive6_FanSpeed_Set (iAdapterIndex, lpFanSpeedValue);
if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive6_FanSpeed_Set()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Overdrive5_FanSpeedToDefault_Set (ADL_PTR *adl, int iAdapterIndex, int iThermalControllerIndex)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive5_FanSpeedToDefault_Set (iAdapterIndex, iThermalControllerIndex);
if ((ADL_rc != ADL_OK) && (ADL_rc != ADL_ERR_NOT_SUPPORTED)) // exception allowed only here
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive5_FanSpeedToDefault_Set()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Overdrive_ODParameters_Get (ADL_PTR *adl, int iAdapterIndex, ADLODParameters *lpOdParameters)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive5_ODParameters_Get (iAdapterIndex, lpOdParameters);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive5_ODParameters_Get()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Overdrive_ODPerformanceLevels_Get (ADL_PTR *adl, int iAdapterIndex, int iDefault, ADLODPerformanceLevels *lpOdPerformanceLevels)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive5_ODPerformanceLevels_Get (iAdapterIndex, iDefault, lpOdPerformanceLevels);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive5_ODPerformanceLevels_Get()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Overdrive_ODPerformanceLevels_Set (ADL_PTR *adl, int iAdapterIndex, ADLODPerformanceLevels *lpOdPerformanceLevels)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive5_ODPerformanceLevels_Set (iAdapterIndex, lpOdPerformanceLevels);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Overdrive5_ODPerformanceLevels_Set()", ADL_rc);
}
return (ADL_rc);
}
int hm_ADL_Overdrive_PowerControlInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6PowerControlInfo *powertune)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive6_PowerControlInfo_Get (iAdapterIndex, powertune);
return (ADL_rc);
}
int hm_ADL_Overdrive_PowerControl_Get (ADL_PTR *adl, int iAdapterIndex, int *iCurrentValue)
{
if (!adl) return -1;
int default_value = 0;
int ADL_rc = adl->ADL_Overdrive6_PowerControl_Get (iAdapterIndex, iCurrentValue, &default_value);
return (ADL_rc);
}
int hm_ADL_Overdrive_PowerControl_Set (ADL_PTR *adl, int iAdapterIndex, int level)
{
if (!adl) return -1;
int ADL_rc = ADL_ERR;
ADLOD6PowerControlInfo powertune = {0, 0, 0, 0, 0};
if ((ADL_rc = hm_ADL_Overdrive_PowerControlInfo_Get (adl, iAdapterIndex, &powertune)) != ADL_OK)
{
log_info ("WARN: %s\n", "ADL_Overdrive6_PowerControl_Get", ADL_rc);
}
else
{
int min = powertune.iMinValue;
int max = powertune.iMaxValue;
int step = powertune.iStepValue;
if (level < min || level > max)
{
log_info ("WARN: ADL PowerControl level invalid");
return ADL_ERR;
}
if (level % step != 0)
{
log_info ("WARN: ADL PowerControl step invalid");
return ADL_ERR;
}
ADL_rc = adl->ADL_Overdrive6_PowerControl_Set (iAdapterIndex, level);
}
return (ADL_rc);
}
int hm_ADL_Adapter_Active_Get (ADL_PTR *adl, int iAdapterIndex, int *lpStatus)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Adapter_Active_Get (iAdapterIndex, lpStatus);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_Adapter_Active_Get()", ADL_rc);
}
return (ADL_rc);
}
/*
int hm_ADL_DisplayEnable_Set (ADL_PTR *adl, int iAdapterIndex, int *lpDisplayIndexList, int iDisplayListSize, int bPersistOnly)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_DisplayEnable_Set (iAdapterIndex, lpDisplayIndexList, iDisplayListSize, bPersistOnly);
if (ADL_rc != ADL_OK)
{
log_info ("WARN: %s: %d\n", "ADL_DisplayEnable_Set()", ADL_rc);
}
return (ADL_rc);
}
*/
int hm_ADL_Overdrive_Caps (ADL_PTR *adl, int iAdapterIndex, int *od_supported, int *od_enabled, int *od_version)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive_Caps (iAdapterIndex, od_supported, od_enabled, od_version);
return (ADL_rc);
}
int hm_ADL_Overdrive6_PowerControl_Caps (ADL_PTR *adl, int iAdapterIndex, int *lpSupported)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive6_PowerControl_Caps (iAdapterIndex, lpSupported);
return (ADL_rc);
}
int hm_ADL_Overdrive_Capabilities_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6Capabilities *caps)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive6_Capabilities_Get (iAdapterIndex, caps);
return (ADL_rc);
}
int hm_ADL_Overdrive_StateInfo_Get (ADL_PTR *adl, int iAdapterIndex, int type, ADLOD6MemClockState *state)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive6_StateInfo_Get (iAdapterIndex, type, state);
if (ADL_rc == ADL_OK)
{
// check if clocks are okay with step sizes
// if not run a little hack: adjust the clocks to nearest clock size (clock down just a little bit)
ADLOD6Capabilities caps;
if ((hm_ADL_Overdrive_Capabilities_Get (adl, iAdapterIndex, &caps)) != ADL_OK)
{
log_info ("ERROR: failed to get ADL device capabilities");
exit (1);
}
if (state->state.aLevels[0].iEngineClock % caps.sEngineClockRange.iStep != 0)
{
log_info ("WARN: ADL engine step size invalid for performance level 1");
state->state.aLevels[0].iEngineClock -= state->state.aLevels[0].iEngineClock % caps.sEngineClockRange.iStep;
}
if (state->state.aLevels[1].iEngineClock % caps.sEngineClockRange.iStep != 0)
{
log_info ("WARN: ADL engine step size invalid for performance level 2");
state->state.aLevels[1].iEngineClock -= state->state.aLevels[1].iEngineClock % caps.sEngineClockRange.iStep;
}
if (state->state.aLevels[0].iMemoryClock % caps.sMemoryClockRange.iStep != 0)
{
log_info ("WARN: ADL memory step size invalid for performance level 1");
state->state.aLevels[0].iMemoryClock -= state->state.aLevels[0].iMemoryClock % caps.sMemoryClockRange.iStep;
}
if (state->state.aLevels[1].iMemoryClock % caps.sMemoryClockRange.iStep != 0)
{
log_info ("WARN: ADL memory step size invalid for performance level 2");
state->state.aLevels[1].iMemoryClock -= state->state.aLevels[1].iMemoryClock % caps.sMemoryClockRange.iStep;
}
}
return (ADL_rc);
}
int hm_ADL_Overdrive_CurrentStatus_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6CurrentStatus *status)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive6_CurrentStatus_Get (iAdapterIndex, status);
return (ADL_rc);
}
int hm_ADL_Overdrive_State_Set (ADL_PTR *adl, int iAdapterIndex, int type, ADLOD6StateInfo *state)
{
if (!adl) return -1;
// sanity checks
ADLOD6Capabilities caps;
if ((hm_ADL_Overdrive_Capabilities_Get (adl, iAdapterIndex, &caps)) != ADL_OK)
{
log_info ("ERROR: failed to get ADL device capabilities");
exit (1);
}
if (state->aLevels[0].iEngineClock < caps.sEngineClockRange.iMin || state->aLevels[1].iEngineClock > caps.sEngineClockRange.iMax)
{
log_info ("WARN: ADL engine clock outside valid range");
return ADL_ERR;
}
if (state->aLevels[1].iEngineClock % caps.sEngineClockRange.iStep != 0)
{
log_info ("WARN: ADL engine step size invalid");
return ADL_ERR;
}
if (state->aLevels[0].iMemoryClock < caps.sMemoryClockRange.iMin || state->aLevels[1].iMemoryClock > caps.sMemoryClockRange.iMax)
{
log_info ("WARN: ADL memory clock outside valid range");
return ADL_ERR;
}
if (state->aLevels[1].iMemoryClock % caps.sMemoryClockRange.iStep != 0)
{
log_info ("WARN: ADL memory step size invalid");
return ADL_ERR;
}
int ADL_rc = adl->ADL_Overdrive6_State_Set (iAdapterIndex, type, state);
return (ADL_rc);
}
int hm_ADL_Overdrive6_TargetTemperatureData_Get (ADL_PTR *adl, int iAdapterIndex, int *cur_temp, int *default_temp)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive6_TargetTemperatureData_Get (iAdapterIndex, cur_temp, default_temp);
return (ADL_rc);
}
int hm_ADL_Overdrive6_TargetTemperatureRangeInfo_Get (ADL_PTR *adl, int iAdapterIndex, ADLOD6ParameterRange *lpTargetTemperatureInfo)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive6_TargetTemperatureRangeInfo_Get (iAdapterIndex, lpTargetTemperatureInfo);
return (ADL_rc);
}
int hm_ADL_Overdrive6_FanSpeed_Reset (ADL_PTR *adl, int iAdapterIndex)
{
if (!adl) return -1;
int ADL_rc = adl->ADL_Overdrive6_FanSpeed_Reset (iAdapterIndex);
return (ADL_rc);
return malloc ((size_t) iSize);
}

View File

@ -6,8 +6,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "dynloader.h"
#include "event.h"
#include "ext_OpenCL.h"
const char *val2cstr_cl (cl_int CL_err)
@ -58,279 +57,3 @@ const char *val2cstr_cl (cl_int CL_err)
return "CL_UNKNOWN_ERROR";
}
int ocl_init (OCL_PTR *ocl)
{
if (!ocl)
{
log_error ("ERROR: OpenCL library pointer is null");
exit (-1);
}
memset (ocl, 0, sizeof (hc_opencl_lib_t));
#if defined(_WIN)
ocl->lib = hc_dlopen ("OpenCL");
#elif defined(__APPLE__)
ocl->lib = hc_dlopen ("/System/Library/Frameworks/OpenCL.framework/OpenCL", RTLD_NOW);
#else
ocl->lib = hc_dlopen ("libOpenCL.so", RTLD_NOW);
if (ocl->lib == NULL) ocl->lib = hc_dlopen ("libOpenCL.so.1", RTLD_NOW);
#endif
if (ocl->lib == NULL)
{
log_info ("");
log_info ("ATTENTION! Can't find OpenCL ICD loader library");
log_info ("");
#if defined (__linux__)
log_info ("You're probably missing the \"ocl-icd-libopencl1\" package (Debian/Ubuntu)");
log_info (" sudo apt-get install ocl-icd-libopencl1");
log_info ("");
#elif defined (_WIN)
log_info ("You're probably missing the OpenCL runtime installation");
log_info (" AMD users require AMD drivers 14.9 or later (recommended 15.12 or later)");
log_info (" Intel users require Intel OpenCL Runtime 14.2 or later (recommended 15.1 or later)");
log_info (" NVidia users require NVidia drivers 346.59 or later (recommended 361.x or later)");
log_info ("");
#endif
exit (-1);
}
HC_LOAD_FUNC(ocl, clBuildProgram, OCL_CLBUILDPROGRAM, OpenCL, 1)
HC_LOAD_FUNC(ocl, clCreateBuffer, OCL_CLCREATEBUFFER, OpenCL, 1)
HC_LOAD_FUNC(ocl, clCreateCommandQueue, OCL_CLCREATECOMMANDQUEUE, OpenCL, 1)
HC_LOAD_FUNC(ocl, clCreateContext, OCL_CLCREATECONTEXT, OpenCL, 1)
HC_LOAD_FUNC(ocl, clCreateKernel, OCL_CLCREATEKERNEL, OpenCL, 1)
HC_LOAD_FUNC(ocl, clCreateProgramWithBinary, OCL_CLCREATEPROGRAMWITHBINARY, OpenCL, 1)
HC_LOAD_FUNC(ocl, clCreateProgramWithSource, OCL_CLCREATEPROGRAMWITHSOURCE, OpenCL, 1)
HC_LOAD_FUNC(ocl, clEnqueueCopyBuffer, OCL_CLENQUEUECOPYBUFFER, OpenCL, 1)
HC_LOAD_FUNC(ocl, clEnqueueMapBuffer, OCL_CLENQUEUEMAPBUFFER, OpenCL, 1)
HC_LOAD_FUNC(ocl, clEnqueueNDRangeKernel, OCL_CLENQUEUENDRANGEKERNEL, OpenCL, 1)
HC_LOAD_FUNC(ocl, clEnqueueReadBuffer, OCL_CLENQUEUEREADBUFFER, OpenCL, 1)
HC_LOAD_FUNC(ocl, clEnqueueUnmapMemObject, OCL_CLENQUEUEUNMAPMEMOBJECT, OpenCL, 1)
HC_LOAD_FUNC(ocl, clEnqueueWriteBuffer, OCL_CLENQUEUEWRITEBUFFER, OpenCL, 1)
HC_LOAD_FUNC(ocl, clFinish, OCL_CLFINISH, OpenCL, 1)
HC_LOAD_FUNC(ocl, clFlush, OCL_CLFLUSH, OpenCL, 1)
HC_LOAD_FUNC(ocl, clGetDeviceIDs, OCL_CLGETDEVICEIDS, OpenCL, 1)
HC_LOAD_FUNC(ocl, clGetDeviceInfo, OCL_CLGETDEVICEINFO, OpenCL, 1)
HC_LOAD_FUNC(ocl, clGetEventInfo, OCL_CLGETEVENTINFO, OpenCL, 1)
HC_LOAD_FUNC(ocl, clGetKernelWorkGroupInfo, OCL_CLGETKERNELWORKGROUPINFO, OpenCL, 1)
HC_LOAD_FUNC(ocl, clGetPlatformIDs, OCL_CLGETPLATFORMIDS, OpenCL, 1)
HC_LOAD_FUNC(ocl, clGetPlatformInfo, OCL_CLGETPLATFORMINFO, OpenCL, 1)
HC_LOAD_FUNC(ocl, clGetProgramBuildInfo, OCL_CLGETPROGRAMBUILDINFO, OpenCL, 1)
HC_LOAD_FUNC(ocl, clGetProgramInfo, OCL_CLGETPROGRAMINFO, OpenCL, 1)
HC_LOAD_FUNC(ocl, clReleaseCommandQueue, OCL_CLRELEASECOMMANDQUEUE, OpenCL, 1)
HC_LOAD_FUNC(ocl, clReleaseContext, OCL_CLRELEASECONTEXT, OpenCL, 1)
HC_LOAD_FUNC(ocl, clReleaseKernel, OCL_CLRELEASEKERNEL, OpenCL, 1)
HC_LOAD_FUNC(ocl, clReleaseMemObject, OCL_CLRELEASEMEMOBJECT, OpenCL, 1)
HC_LOAD_FUNC(ocl, clReleaseProgram, OCL_CLRELEASEPROGRAM, OpenCL, 1)
HC_LOAD_FUNC(ocl, clSetKernelArg, OCL_CLSETKERNELARG, OpenCL, 1)
HC_LOAD_FUNC(ocl, clWaitForEvents, OCL_CLWAITFOREVENTS, OpenCL, 1)
HC_LOAD_FUNC(ocl, clGetEventProfilingInfo, OCL_CLGETEVENTPROFILINGINFO, OpenCL, 1)
HC_LOAD_FUNC(ocl, clReleaseEvent, OCL_CLRELEASEEVENT, OpenCL, 1)
return 0;
}
void ocl_close (OCL_PTR *ocl)
{
if (ocl)
{
if (ocl->lib)
{
hc_dlclose (ocl->lib);
}
}
}
cl_int hc_clEnqueueNDRangeKernel (OCL_PTR *ocl, cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t *global_work_offset, const size_t *global_work_size, const size_t *local_work_size, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
{
return ocl->clEnqueueNDRangeKernel (command_queue, kernel, work_dim, global_work_offset, global_work_size, local_work_size, num_events_in_wait_list, event_wait_list, event);
}
cl_int hc_clGetEventInfo (OCL_PTR *ocl, cl_event event, cl_event_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
{
return ocl->clGetEventInfo (event, param_name, param_value_size, param_value, param_value_size_ret);
}
cl_int hc_clFlush (OCL_PTR *ocl, cl_command_queue command_queue)
{
return ocl->clFlush (command_queue);
}
cl_int hc_clFinish (OCL_PTR *ocl, cl_command_queue command_queue)
{
return ocl->clFinish (command_queue);
}
cl_int hc_clSetKernelArg (OCL_PTR *ocl, cl_kernel kernel, cl_uint arg_index, size_t arg_size, const void *arg_value)
{
return ocl->clSetKernelArg (kernel, arg_index, arg_size, arg_value);
}
cl_int hc_clEnqueueWriteBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_write, size_t offset, size_t cb, const void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
{
return ocl->clEnqueueWriteBuffer (command_queue, buffer, blocking_write, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event);
}
cl_int hc_clEnqueueCopyBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_buffer, size_t src_offset, size_t dst_offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
{
return ocl->clEnqueueCopyBuffer (command_queue, src_buffer, dst_buffer, src_offset, dst_offset, cb, num_events_in_wait_list, event_wait_list, event);
}
cl_int hc_clEnqueueReadBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void *ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
{
return ocl->clEnqueueReadBuffer (command_queue, buffer, blocking_read, offset, cb, ptr, num_events_in_wait_list, event_wait_list, event);
}
cl_int hc_clGetPlatformIDs (OCL_PTR *ocl, cl_uint num_entries, cl_platform_id *platforms, cl_uint *num_platforms)
{
return ocl->clGetPlatformIDs (num_entries, platforms, num_platforms);
}
cl_int hc_clGetPlatformInfo (OCL_PTR *ocl, cl_platform_id platform, cl_platform_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
{
return ocl->clGetPlatformInfo (platform, param_name, param_value_size, param_value, param_value_size_ret);
}
cl_int hc_clGetDeviceIDs (OCL_PTR *ocl, cl_platform_id platform, cl_device_type device_type, cl_uint num_entries, cl_device_id *devices, cl_uint *num_devices)
{
return ocl->clGetDeviceIDs (platform, device_type, num_entries, devices, num_devices);
}
cl_int hc_clGetDeviceInfo (OCL_PTR *ocl, cl_device_id device, cl_device_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
{
return ocl->clGetDeviceInfo (device, param_name, param_value_size, param_value, param_value_size_ret);
}
cl_int hc_clCreateContext (OCL_PTR *ocl, cl_context_properties *properties, cl_uint num_devices, const cl_device_id *devices, void (CL_CALLBACK *pfn_notify) (const char *, const void *, size_t, void *), void *user_data, cl_context *context)
{
cl_int CL_err;
*context = ocl->clCreateContext (properties, num_devices, devices, pfn_notify, user_data, &CL_err);
return CL_err;
}
cl_int hc_clCreateCommandQueue (OCL_PTR *ocl, cl_context context, cl_device_id device, cl_command_queue_properties properties, cl_command_queue *command_queue)
{
cl_int CL_err;
*command_queue = ocl->clCreateCommandQueue (context, device, properties, &CL_err);
return CL_err;
}
cl_int hc_clCreateBuffer (OCL_PTR *ocl, cl_context context, cl_mem_flags flags, size_t size, void *host_ptr, cl_mem *mem)
{
cl_int CL_err;
*mem = ocl->clCreateBuffer (context, flags, size, host_ptr, &CL_err);
return CL_err;
}
cl_int hc_clCreateProgramWithSource (OCL_PTR *ocl, cl_context context, cl_uint count, const char **strings, const size_t *lengths, cl_program *program)
{
cl_int CL_err;
*program = ocl->clCreateProgramWithSource (context, count, strings, lengths, &CL_err);
return CL_err;
}
cl_int hc_clCreateProgramWithBinary (OCL_PTR *ocl, cl_context context, cl_uint num_devices, const cl_device_id *device_list, const size_t *lengths, const unsigned char **binaries, cl_int *binary_status, cl_program *program)
{
cl_int CL_err;
*program = ocl->clCreateProgramWithBinary (context, num_devices, device_list, lengths, binaries, binary_status, &CL_err);
return CL_err;
}
cl_int hc_clBuildProgram (OCL_PTR *ocl, cl_program program, cl_uint num_devices, const cl_device_id *device_list, const char *options, void (CL_CALLBACK *pfn_notify) (cl_program program, void *user_data), void *user_data)
{
return ocl->clBuildProgram (program, num_devices, device_list, options, pfn_notify, user_data);
}
cl_int hc_clCreateKernel (OCL_PTR *ocl, cl_program program, const char *kernel_name, cl_kernel *kernel)
{
cl_int CL_err;
*kernel = ocl->clCreateKernel (program, kernel_name, &CL_err);
return CL_err;
}
cl_int hc_clReleaseMemObject (OCL_PTR *ocl, cl_mem mem)
{
return ocl->clReleaseMemObject (mem);
}
cl_int hc_clReleaseKernel (OCL_PTR *ocl, cl_kernel kernel)
{
return ocl->clReleaseKernel (kernel);
}
cl_int hc_clReleaseProgram (OCL_PTR *ocl, cl_program program)
{
return ocl->clReleaseProgram (program);
}
cl_int hc_clReleaseCommandQueue (OCL_PTR *ocl, cl_command_queue command_queue)
{
return ocl->clReleaseCommandQueue (command_queue);
}
cl_int hc_clReleaseContext (OCL_PTR *ocl, cl_context context)
{
return ocl->clReleaseContext (context);
}
cl_int hc_clEnqueueMapBuffer (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event, void **buf)
{
cl_int CL_err;
*buf = ocl->clEnqueueMapBuffer (command_queue, buffer, blocking_read, map_flags, offset, cb, num_events_in_wait_list, event_wait_list, event, &CL_err);
return CL_err;
}
cl_int hc_clEnqueueUnmapMemObject (OCL_PTR *ocl, cl_command_queue command_queue, cl_mem memobj, void *mapped_ptr, cl_uint num_events_in_wait_list, const cl_event *event_wait_list, cl_event *event)
{
return ocl->clEnqueueUnmapMemObject (command_queue, memobj, mapped_ptr, num_events_in_wait_list, event_wait_list, event);
}
cl_int hc_clGetKernelWorkGroupInfo (OCL_PTR *ocl, cl_kernel kernel, cl_device_id device, cl_kernel_work_group_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
{
return ocl->clGetKernelWorkGroupInfo (kernel, device, param_name, param_value_size, param_value, param_value_size_ret);
}
cl_int hc_clGetProgramBuildInfo (OCL_PTR *ocl, cl_program program, cl_device_id device, cl_program_build_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
{
return ocl->clGetProgramBuildInfo (program, device, param_name, param_value_size, param_value, param_value_size_ret);
}
cl_int hc_clGetProgramInfo (OCL_PTR *ocl, cl_program program, cl_program_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
{
return ocl->clGetProgramInfo (program, param_name, param_value_size, param_value, param_value_size_ret);
}
cl_int hc_clWaitForEvents (OCL_PTR *ocl, cl_uint num_events, const cl_event *event_list)
{
return ocl->clWaitForEvents (num_events, event_list);
}
cl_int hc_clGetEventProfilingInfo (OCL_PTR *ocl, cl_event event, cl_profiling_info param_name, size_t param_value_size, void *param_value, size_t *param_value_size_ret)
{
return ocl->clGetEventProfilingInfo (event, param_name, param_value_size, param_value, param_value_size_ret);
}
cl_int hc_clReleaseEvent (OCL_PTR *ocl, cl_event event)
{
return ocl->clReleaseEvent (event);
}

View File

@ -4,203 +4,7 @@
*/
#include "common.h"
#include "logging.h"
#include "types.h"
#include "event.h"
#include "memory.h"
#include "dynloader.h"
#include "ext_nvapi.h"
int nvapi_init (NVAPI_PTR *nvapi)
{
if (!nvapi) return -1;
memset (nvapi, 0, sizeof (NVAPI_PTR));
#if defined (_WIN)
#if defined (WIN64)
nvapi->lib = hc_dlopen ("nvapi64.dll");
#elif defined (WIN32)
nvapi->lib = hc_dlopen ("nvapi.dll");
#endif
#else
nvapi->lib = hc_dlopen ("nvapi.so", RTLD_NOW); // uhm yes, but .. yeah
#endif
if (!nvapi->lib)
{
//if (user_options->quiet == false)
// log_info ("WARNING: load NVAPI library failed, proceed without NVAPI HWMon enabled.");
return -1;
}
HC_LOAD_FUNC(nvapi, nvapi_QueryInterface, NVAPI_QUERYINTERFACE, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_Initialize, NVAPI_INITIALIZE, nvapi_QueryInterface, 0x0150E828, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_Unload, NVAPI_UNLOAD, nvapi_QueryInterface, 0xD22BDD7E, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GetErrorMessage, NVAPI_GETERRORMESSAGE, nvapi_QueryInterface, 0x6C2D048C, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_EnumPhysicalGPUs, NVAPI_ENUMPHYSICALGPUS, nvapi_QueryInterface, 0xE5AC921F, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesInfo, NVAPI_GPU_GETPERFPOLICIESINFO, nvapi_QueryInterface, 0x409D9841, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_GetPerfPoliciesStatus, NVAPI_GPU_GETPERFPOLICIESSTATUS, nvapi_QueryInterface, 0x3D358A0C, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_SetCoolerLevels, NVAPI_GPU_SETCOOLERLEVELS, nvapi_QueryInterface, 0x891FA0AE, NVAPI, 0)
HC_LOAD_ADDR(nvapi, NvAPI_GPU_RestoreCoolerSettings, NVAPI_GPU_RESTORECOOLERSETTINGS, nvapi_QueryInterface, 0x8F6ED0FB, NVAPI, 0)
return 0;
}
void nvapi_close (NVAPI_PTR *nvapi)
{
if (nvapi)
{
if (nvapi->lib)
hc_dlclose (nvapi->lib);
myfree (nvapi);
}
}
int hm_NvAPI_GetErrorMessage (NVAPI_PTR *nvapi, NvAPI_Status NvAPI_rc, NvAPI_ShortString string)
{
if (!nvapi) return -1;
return nvapi->NvAPI_GetErrorMessage (NvAPI_rc, string);
}
NvAPI_Status hm_NvAPI_Initialize (NVAPI_PTR *nvapi)
{
if (!nvapi) return (NvAPI_Status) -1;
NvAPI_Status NvAPI_rc = nvapi->NvAPI_Initialize ();
if (NvAPI_rc == NVAPI_LIBRARY_NOT_FOUND) NvAPI_rc = NVAPI_OK; // not a bug
if (NvAPI_rc != NVAPI_OK)
{
NvAPI_ShortString string = { 0 };
hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string);
log_info ("WARN: %s %d %s\n", "NvAPI_Initialize()", NvAPI_rc, string);
}
return NvAPI_rc;
}
NvAPI_Status hm_NvAPI_Unload (NVAPI_PTR *nvapi)
{
if (!nvapi) return (NvAPI_Status) -1;
NvAPI_Status NvAPI_rc = nvapi->NvAPI_Unload ();
if (NvAPI_rc != NVAPI_OK)
{
NvAPI_ShortString string = { 0 };
hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string);
log_info ("WARN: %s %d %s\n", "NvAPI_Unload()", NvAPI_rc, string);
}
return NvAPI_rc;
}
NvAPI_Status hm_NvAPI_EnumPhysicalGPUs (NVAPI_PTR *nvapi, NvPhysicalGpuHandle nvGPUHandle[NVAPI_MAX_PHYSICAL_GPUS], NvU32 *pGpuCount)
{
if (!nvapi) return (NvAPI_Status) -1;
NvAPI_Status NvAPI_rc = nvapi->NvAPI_EnumPhysicalGPUs (nvGPUHandle, pGpuCount);
if (NvAPI_rc != NVAPI_OK)
{
NvAPI_ShortString string = { 0 };
hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string);
log_info ("WARN: %s %d %s\n", "NvAPI_EnumPhysicalGPUs()", NvAPI_rc, string);
}
return NvAPI_rc;
}
NvAPI_Status hm_NvAPI_GPU_GetPerfPoliciesInfo (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 *perfPolicies_info)
{
if (!nvapi) return (NvAPI_Status) -1;
NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetPerfPoliciesInfo (hPhysicalGpu, perfPolicies_info);
if (NvAPI_rc != NVAPI_OK)
{
NvAPI_ShortString string = { 0 };
hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string);
log_info ("WARN: %s %d %s\n", "NvAPI_GPU_GetPerfPoliciesInfo()", NvAPI_rc, string);
}
return NvAPI_rc;
}
NvAPI_Status hm_NvAPI_GPU_GetPerfPoliciesStatus (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 *perfPolicies_status)
{
if (!nvapi) return (NvAPI_Status) -1;
NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_GetPerfPoliciesStatus (hPhysicalGpu, perfPolicies_status);
if (NvAPI_rc != NVAPI_OK)
{
NvAPI_ShortString string = { 0 };
hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string);
log_info ("WARN: %s %d %s\n", "NvAPI_GPU_GetPerfPoliciesStatus()", NvAPI_rc, string);
}
return NvAPI_rc;
}
NvAPI_Status hm_NvAPI_GPU_SetCoolerLevels (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex, NV_GPU_COOLER_LEVELS *pCoolerLevels)
{
if (!nvapi) return (NvAPI_Status) -1;
NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_SetCoolerLevels (hPhysicalGpu, coolerIndex, pCoolerLevels);
if (NvAPI_rc != NVAPI_OK)
{
NvAPI_ShortString string = { 0 };
hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string);
log_info ("WARN: %s %d %s\n", "NvAPI_GPU_SetCoolerLevels()", NvAPI_rc, string);
}
return NvAPI_rc;
}
NvAPI_Status hm_NvAPI_GPU_RestoreCoolerSettings (NVAPI_PTR *nvapi, NvPhysicalGpuHandle hPhysicalGpu, NvU32 coolerIndex)
{
if (!nvapi) return (NvAPI_Status) -1;
NvAPI_Status NvAPI_rc = nvapi->NvAPI_GPU_RestoreCoolerSettings (hPhysicalGpu, coolerIndex);
if (NvAPI_rc != NVAPI_OK)
{
NvAPI_ShortString string = { 0 };
hm_NvAPI_GetErrorMessage (nvapi, NvAPI_rc, string);
log_info ("WARN: %s %d %s\n", "NvAPI_GPU_RestoreCoolerSettings()", NvAPI_rc, string);
}
return NvAPI_rc;
}
#if defined (__MINGW64__)
void __security_check_cookie (uintptr_t _StackCookie)
{
(void) _StackCookie;
}
void __GSHandlerCheck ()
{
}
#endif

View File

@ -4,466 +4,8 @@
*/
#include "common.h"
#include "logging.h"
#include "types.h"
#include "event.h"
#include "memory.h"
#include "dynloader.h"
#include "ext_nvml.h"
int nvml_init (NVML_PTR *nvml)
{
if (!nvml) return -1;
memset (nvml, 0, sizeof (NVML_PTR));
#if defined (_WIN)
nvml->lib = hc_dlopen ("nvml.dll");
if (!nvml->lib)
{
DWORD BufferSize = 1024;
DWORD Type = REG_SZ;
char *Buffer = (char *) mymalloc (BufferSize + 1);
HKEY hKey = 0;
if (RegOpenKeyExA (HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\NVSMI", 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
{
if (RegQueryValueExA (hKey, "NVSMIPATH", NULL, &Type, (LPBYTE)Buffer, &BufferSize) == ERROR_SUCCESS)
{
Buffer[BufferSize] = 0;
}
else
{
//if (user_options->quiet == false)
// log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled.");
return -1;
}
RegCloseKey (hKey);
}
else
{
//if (user_options->quiet == false)
// log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled.");
return -1;
}
strcat (Buffer, "\\nvml.dll");
nvml->lib = hc_dlopen (Buffer);
myfree (Buffer);
}
#elif defined (_POSIX)
nvml->lib = hc_dlopen ("libnvidia-ml.so", RTLD_NOW);
#endif
if (!nvml->lib)
{
//if (user_options->quiet == false)
// log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled.");
return -1;
}
HC_LOAD_FUNC(nvml, nvmlErrorString, NVML_ERROR_STRING, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlInit, NVML_INIT, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlShutdown, NVML_SHUTDOWN, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetName, NVML_DEVICE_GET_NAME, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetHandleByIndex, NVML_DEVICE_GET_HANDLE_BY_INDEX, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperature, NVML_DEVICE_GET_TEMPERATURE, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetFanSpeed, NVML_DEVICE_GET_FAN_SPEED, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerUsage, NVML_DEVICE_GET_POWER_USAGE, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetUtilizationRates, NVML_DEVICE_GET_UTILIZATION_RATES, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetClockInfo, NVML_DEVICE_GET_CLOCKINFO, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetTemperatureThreshold, NVML_DEVICE_GET_THRESHOLD, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkGeneration, NVML_DEVICE_GET_CURRPCIELINKGENERATION, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrPcieLinkWidth, NVML_DEVICE_GET_CURRPCIELINKWIDTH, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetCurrentClocksThrottleReasons, NVML_DEVICE_GET_CURRENTCLOCKSTHROTTLEREASONS, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetSupportedClocksThrottleReasons, NVML_DEVICE_GET_SUPPORTEDCLOCKSTHROTTLEREASONS, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceSetComputeMode, NVML_DEVICE_SET_COMPUTEMODE, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceSetGpuOperationMode, NVML_DEVICE_SET_OPERATIONMODE, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerManagementLimitConstraints, NVML_DEVICE_GET_POWERMANAGEMENTLIMITCONSTRAINTS, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceSetPowerManagementLimit, NVML_DEVICE_SET_POWERMANAGEMENTLIMIT, NVML, 0)
HC_LOAD_FUNC(nvml, nvmlDeviceGetPowerManagementLimit, NVML_DEVICE_GET_POWERMANAGEMENTLIMIT, NVML, 0)
return 0;
}
void nvml_close (NVML_PTR *nvml)
{
if (nvml)
{
if (nvml->lib)
hc_dlclose (nvml->lib);
myfree (nvml);
}
}
const char *hm_NVML_nvmlErrorString (NVML_PTR *nvml, nvmlReturn_t nvml_rc)
{
if (!nvml) return NULL;
return nvml->nvmlErrorString (nvml_rc);
}
nvmlReturn_t hm_NVML_nvmlInit (NVML_PTR *nvml)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = (nvmlReturn_t)nvml->nvmlInit ();
if (nvml_rc != NVML_SUCCESS)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlInit()", nvml_rc, string);
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlShutdown (NVML_PTR *nvml)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = (nvmlReturn_t)nvml->nvmlShutdown ();
if (nvml_rc != NVML_SUCCESS)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlShutdown()", nvml_rc, string);
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetName (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, char *name, unsigned int length)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetName (device, name, length);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetName()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetHandleByIndex (NVML_PTR *nvml, int skip_warnings, unsigned int index, nvmlDevice_t *device)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetHandleByIndex (index, device);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetHandleByIndex()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetTemperature (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlTemperatureSensors_t sensorType, unsigned int *temp)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperature (device, sensorType, temp);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetTemperature()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetFanSpeed (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *speed)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetFanSpeed (device, speed);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetFanSpeed()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetPowerUsage (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *power)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerUsage (device, power);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetPowerUsage()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetUtilizationRates (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlUtilization_t *utilization)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetUtilizationRates (device, utilization);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetUtilizationRates()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetClockInfo (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlClockType_t type, unsigned int *clock)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetClockInfo (device, type, clock);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetClockInfo()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetTemperatureThreshold (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlTemperatureThresholds_t thresholdType, unsigned int *temp)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetTemperatureThreshold (device, thresholdType, temp);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetTemperatureThreshold()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkGeneration (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *currLinkGen)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkGeneration (device, currLinkGen);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetCurrPcieLinkGeneration()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetCurrPcieLinkWidth (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *currLinkWidth)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrPcieLinkWidth (device, currLinkWidth);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetCurrPcieLinkWidth()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetCurrentClocksThrottleReasons (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned long long *clocksThrottleReasons)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetCurrentClocksThrottleReasons (device, clocksThrottleReasons);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetCurrentClocksThrottleReasons()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetSupportedClocksThrottleReasons (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned long long *supportedClocksThrottleReasons)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetSupportedClocksThrottleReasons (device, supportedClocksThrottleReasons);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetSupportedClocksThrottleReasons()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceSetComputeMode (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlComputeMode_t mode)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetComputeMode (device, mode);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceSetComputeMode()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceSetGpuOperationMode (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, nvmlGpuOperationMode_t mode)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetGpuOperationMode (device, mode);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceSetGpuOperationMode()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimitConstraints (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *minLimit, unsigned int *maxLimit)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerManagementLimitConstraints (device, minLimit, maxLimit);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetPowerManagementLimitConstraints()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceSetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int limit)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceSetPowerManagementLimit (device, limit);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceSetPowerManagementLimit()", nvml_rc, string);
}
}
return nvml_rc;
}
nvmlReturn_t hm_NVML_nvmlDeviceGetPowerManagementLimit (NVML_PTR *nvml, int skip_warnings, nvmlDevice_t device, unsigned int *limit)
{
if (!nvml) return (nvmlReturn_t) -1;
nvmlReturn_t nvml_rc = nvml->nvmlDeviceGetPowerManagementLimit (device, limit);
if (nvml_rc != NVML_SUCCESS)
{
if (skip_warnings == 0)
{
const char *string = hm_NVML_nvmlErrorString (nvml, nvml_rc);
log_info ("WARN: %s %d %s\n", "nvmlDeviceGetPowerManagementLimit()", nvml_rc, string);
}
}
return nvml_rc;
}

View File

@ -4,216 +4,7 @@
*/
#include "common.h"
#include "logging.h"
#include "types.h"
#include "event.h"
#include "memory.h"
#include "dynloader.h"
#include "ext_xnvctrl.h"
int xnvctrl_init (XNVCTRL_PTR *xnvctrl)
{
if (!xnvctrl) return -1;
memset (xnvctrl, 0, sizeof (XNVCTRL_PTR));
#if defined (_WIN)
// unsupport platform?
return -1;
#elif defined (_POSIX)
xnvctrl->lib_x11 = dlopen ("libX11.so", RTLD_LAZY);
if (xnvctrl->lib_x11 == NULL)
{
//if (user_options->quiet == false) log_info ("WARNING: Failed loading the X11 library: %s", dlerror());
//if (user_options->quiet == false) log_info (" Please install libx11-dev package.");
//if (user_options->quiet == false) log_info ("");
return -1;
}
xnvctrl->lib_xnvctrl = dlopen ("libXNVCtrl.so", RTLD_LAZY);
if (xnvctrl->lib_xnvctrl == NULL)
{
//if (user_options->quiet == false) log_info ("WARNING: Failed loading the XNVCTRL library: %s", dlerror());
//if (user_options->quiet == false) log_info (" Please install libxnvctrl-dev package.");
//if (user_options->quiet == false) log_info ("");
return -1;
}
HC_LOAD_FUNC2 (xnvctrl, XOpenDisplay, XOPENDISPLAY, lib_x11, X11, 0);
HC_LOAD_FUNC2 (xnvctrl, XCloseDisplay, XCLOSEDISPLAY, lib_x11, X11, 0);
HC_LOAD_FUNC2 (xnvctrl, XNVCTRLQueryTargetAttribute, XNVCTRLQUERYTARGETATTRIBUTE, lib_xnvctrl, XNVCTRL, 0);
HC_LOAD_FUNC2 (xnvctrl, XNVCTRLSetTargetAttribute, XNVCTRLSETTARGETATTRIBUTE, lib_xnvctrl, XNVCTRL, 0);
#endif
return 0;
}
void xnvctrl_close (XNVCTRL_PTR *xnvctrl)
{
if (xnvctrl)
{
#if defined (_POSIX)
if (xnvctrl->lib_x11)
{
dlclose (xnvctrl->lib_x11);
}
if (xnvctrl->lib_xnvctrl)
{
dlclose (xnvctrl->lib_xnvctrl);
}
#endif
myfree (xnvctrl);
}
}
int hm_XNVCTRL_XOpenDisplay (XNVCTRL_PTR *xnvctrl)
{
if (xnvctrl == NULL) return -1;
if (xnvctrl->XOpenDisplay == NULL) return -1;
void *dpy = xnvctrl->XOpenDisplay (NULL);
if (dpy == NULL)
{
xnvctrl->dpy = NULL;
return -1;
}
xnvctrl->dpy = dpy;
return 0;
}
void hm_XNVCTRL_XCloseDisplay (XNVCTRL_PTR *xnvctrl)
{
if (xnvctrl == NULL) return;
if (xnvctrl->XCloseDisplay == NULL) return;
if (xnvctrl->dpy == NULL) return;
xnvctrl->XCloseDisplay (xnvctrl->dpy);
}
int get_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int *val)
{
if (xnvctrl == NULL) return -1;
if (xnvctrl->XNVCTRLQueryTargetAttribute == NULL) return -1;
if (xnvctrl->dpy == NULL) return -1;
int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val);
if (!rc) return -1;
return 0;
}
int set_fan_control (XNVCTRL_PTR *xnvctrl, int gpu, int val)
{
if (xnvctrl == NULL) return -1;
if (xnvctrl->XNVCTRLSetTargetAttribute == NULL) return -1;
if (xnvctrl->dpy == NULL) return -1;
int cur;
int rc = get_fan_control (xnvctrl, gpu, &cur);
if (rc == -1) return -1;
xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_COOLER_MANUAL_CONTROL, val);
rc = get_fan_control (xnvctrl, gpu, &cur);
if (rc == -1) return -1;
if (cur != val) return -1;
return 0;
}
int get_core_threshold (XNVCTRL_PTR *xnvctrl, int gpu, int *val)
{
if (xnvctrl == NULL) return -1;
if (xnvctrl->XNVCTRLQueryTargetAttribute == NULL) return -1;
if (xnvctrl->dpy == NULL) return -1;
int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_GPU, gpu, 0, NV_CTRL_GPU_CORE_THRESHOLD, val);
if (!rc) return -1;
return 0;
}
int get_fan_speed_current (XNVCTRL_PTR *xnvctrl, int gpu, int *val)
{
if (xnvctrl == NULL) return -1;
if (xnvctrl->XNVCTRLQueryTargetAttribute == NULL) return -1;
if (xnvctrl->dpy == NULL) return -1;
int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_CURRENT_LEVEL, val);
if (!rc) return -1;
return 0;
}
int get_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int *val)
{
if (xnvctrl == NULL) return -1;
if (xnvctrl->XNVCTRLQueryTargetAttribute == NULL) return -1;
if (xnvctrl->dpy == NULL) return -1;
int rc = xnvctrl->XNVCTRLQueryTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val);
if (!rc) return -1;
return 0;
}
int set_fan_speed_target (XNVCTRL_PTR *xnvctrl, int gpu, int val)
{
if (xnvctrl == NULL) return -1;
if (xnvctrl->XNVCTRLSetTargetAttribute == NULL) return -1;
if (xnvctrl->dpy == NULL) return -1;
int cur;
int rc = get_fan_speed_target (xnvctrl, gpu, &cur);
if (rc == -1) return -1;
xnvctrl->XNVCTRLSetTargetAttribute (xnvctrl->dpy, NV_CTRL_TARGET_TYPE_COOLER, gpu, 0, NV_CTRL_THERMAL_COOLER_LEVEL, val);
rc = get_fan_speed_target (xnvctrl, gpu, &cur);
if (rc == -1) return -1;
if (cur != val) return -1;
return 0;
}

View File

@ -8,11 +8,11 @@
#include "memory.h"
#include "filehandling.h"
u64 count_lines (FILE *fd)
u64 count_lines (hashcat_ctx_t *hashcat_ctx, FILE *fd)
{
u64 cnt = 0;
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE + 1);
char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE + 1); VERIFY_PTR (buf);
char prev = '\n';
@ -32,7 +32,7 @@ u64 count_lines (FILE *fd)
}
}
myfree (buf);
hcfree (buf);
return cnt;
}

View File

@ -10,12 +10,12 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "shared.h"
#include "folder.h"
#if defined (__APPLE__)
#include "logging.h"
#include "event.h"
#endif
int sort_by_stringptr (const void *p1, const void *p2)
@ -26,34 +26,25 @@ int sort_by_stringptr (const void *p1, const void *p2)
return strcmp (*s1, *s2);
}
char *get_exec_path ()
static int get_exec_path (char *exec_path, const size_t exec_path_sz)
{
size_t exec_path_len = 1024;
char *exec_path = (char *) mymalloc (exec_path_len);
#if defined (__linux__)
char tmp[32] = { 0 };
snprintf (tmp, sizeof (tmp) - 1, "/proc/%d/exe", getpid ());
const int len = readlink (tmp, exec_path, exec_path_len - 1);
const int len = readlink (tmp, exec_path, exec_path_sz - 1);
#elif defined (_WIN)
const int len = GetModuleFileName (NULL, exec_path, exec_path_len - 1);
const int len = GetModuleFileName (NULL, exec_path, exec_path_sz - 1);
#elif defined (__APPLE__)
u32 size = (u32) exec_path_len;
u32 size = (u32) exec_path_sz;
if (_NSGetExecutablePath (exec_path, &size) != 0)
{
log_error("! executable path buffer too small\n");
exit (-1);
}
if (_NSGetExecutablePath (exec_path, &size) != 0) return -1;
const size_t len = strlen (exec_path);
@ -68,11 +59,11 @@ char *get_exec_path ()
char tmp[32] = { 0 };
size_t size = exec_path_len;
size_t size = exec_path_sz;
sysctl (mib, 4, exec_path, &size, NULL, 0);
const int len = readlink (tmp, exec_path, exec_path_len - 1);
const int len = readlink (tmp, exec_path, exec_path_sz - 1);
#else
#error Your Operating System is not supported or detected
@ -80,13 +71,14 @@ char *get_exec_path ()
exec_path[len] = 0;
return exec_path;
return 0;
}
char *get_install_dir (const char *progname)
void get_install_dir (char *install_dir, const char *exec_path)
{
char *install_dir = mystrdup (progname);
char *last_slash = NULL;
strncpy (install_dir, exec_path, HCBUFSIZ_TINY - 1);
char *last_slash = NULL;
if ((last_slash = strrchr (install_dir, '/')) != NULL)
{
@ -101,26 +93,16 @@ char *get_install_dir (const char *progname)
install_dir[0] = '.';
install_dir[1] = 0;
}
return (install_dir);
}
char *get_profile_dir (const char *homedir)
void get_profile_dir (char *profile_dir, const char *home_dir)
{
char *profile_dir = (char *) mymalloc (HCBUFSIZ_TINY + 1);
snprintf (profile_dir, HCBUFSIZ_TINY - 1, "%s/%s", homedir, DOT_HASHCAT);
return profile_dir;
snprintf (profile_dir, HCBUFSIZ_TINY - 1, "%s/%s", home_dir, DOT_HASHCAT);
}
char *get_session_dir (const char *profile_dir)
void get_session_dir (char *session_dir, const char *profile_dir)
{
char *session_dir = (char *) mymalloc (HCBUFSIZ_TINY);
snprintf (session_dir, HCBUFSIZ_TINY - 1, "%s/%s", profile_dir, SESSIONS_FOLDER);
return session_dir;
}
int count_dictionaries (char **dictionary_files)
@ -137,9 +119,9 @@ int count_dictionaries (char **dictionary_files)
return (cnt);
}
char **scan_directory (const char *path)
char **scan_directory (hashcat_ctx_t *hashcat_ctx, const char *path)
{
char *tmp_path = mystrdup (path);
char *tmp_path = hcstrdup (hashcat_ctx, path);
size_t tmp_path_len = strlen (tmp_path);
@ -152,7 +134,7 @@ char **scan_directory (const char *path)
char **files = NULL;
int num_files = 0;
size_t num_files = 0;
DIR *d = NULL;
@ -168,12 +150,7 @@ char **scan_directory (const char *path)
struct dirent *de = NULL;
if (readdir_r (d, &e, &de) != 0)
{
log_error ("ERROR: readdir_r() failed");
break;
}
if (readdir_r (d, &e, &de) != 0) break;
if (de == NULL) break;
@ -188,13 +165,9 @@ char **scan_directory (const char *path)
if ((strcmp (de->d_name, ".") == 0) || (strcmp (de->d_name, "..") == 0)) continue;
size_t path_size = strlen (tmp_path) + 1 + strlen (de->d_name);
char *path_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY);
char *path_file = (char *) mymalloc (path_size + 1);
snprintf (path_file, path_size + 1, "%s/%s", tmp_path, de->d_name);
path_file[path_size] = 0;
snprintf (path_file, HCBUFSIZ_TINY - 1, "%s/%s", tmp_path, de->d_name);
DIR *d_test;
@ -202,15 +175,15 @@ char **scan_directory (const char *path)
{
closedir (d_test);
myfree (path_file);
hcfree (path_file);
}
else
{
files = (char **) myrealloc (files, (size_t) num_files * sizeof (char *), sizeof (char *));
files = (char **) hcrealloc (hashcat_ctx, files, (num_files + 1) * sizeof (char *), sizeof (char *));
files[num_files] = path_file;
num_files++;
files[num_files - 1] = path_file;
}
}
@ -218,25 +191,25 @@ char **scan_directory (const char *path)
}
else if (errno == ENOTDIR)
{
files = (char **) myrealloc (files, (size_t) num_files * sizeof (char *), sizeof (char *));
files = (char **) hcrealloc (hashcat_ctx, files, (num_files + 1) * sizeof (char *), sizeof (char *));
files[num_files] = hcstrdup (hashcat_ctx, path);
num_files++;
files[num_files - 1] = mystrdup (path);
}
files = (char **) myrealloc (files, (size_t) num_files * sizeof (char *), sizeof (char *));
files = (char **) hcrealloc (hashcat_ctx, files, (num_files + 1) * sizeof (char *), sizeof (char *));
files[num_files] = NULL;
num_files++;
files[num_files - 1] = NULL;
myfree (tmp_path);
hcfree (tmp_path);
return (files);
}
int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder, const char *shared_folder)
int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *install_folder, MAYBE_UNUSED const char *shared_folder)
{
folder_config_t *folder_config = hashcat_ctx->folder_config;
@ -247,11 +220,11 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder,
* then chdir() back to where we came from so we need to save it first
*/
char *cwd = (char *) mymalloc (HCBUFSIZ_TINY);
char *cwd = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (cwd);
if (getcwd (cwd, HCBUFSIZ_TINY - 1) == NULL)
{
log_error ("ERROR: getcwd(): %s", strerror (errno));
event_log_error (hashcat_ctx, "getcwd(): %s", strerror (errno));
return -1;
}
@ -260,7 +233,18 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder,
* folders, as discussed on https://github.com/hashcat/hashcat/issues/20
*/
char *exec_path = get_exec_path ();
const size_t exec_path_sz = 1024;
char *exec_path = (char *) hcmalloc (hashcat_ctx, exec_path_sz); VERIFY_PTR (exec_path);
const int rc = get_exec_path (exec_path, exec_path_sz);
if (rc == -1)
{
event_log_error (hashcat_ctx, "get_exec_path() failed");
return -1;
}
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
@ -271,19 +255,22 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder,
if (resolved_install_folder == NULL)
{
log_error ("ERROR: %s: %s", resolved_install_folder, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", resolved_install_folder, strerror (errno));
return -1;
}
if (resolved_exec_path == NULL)
{
log_error ("ERROR: %s: %s", resolved_exec_path, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", resolved_exec_path, strerror (errno));
return -1;
}
char *install_dir = get_install_dir (resolved_exec_path);
char *install_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (install_dir);
get_install_dir (install_dir, resolved_exec_path);
char *profile_dir = NULL;
char *session_dir = NULL;
char *shared_dir = NULL;
@ -292,11 +279,15 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder,
{
struct passwd *pw = getpwuid (getuid ());
const char *homedir = pw->pw_dir;
const char *home_dir = pw->pw_dir;
profile_dir = get_profile_dir (homedir);
session_dir = get_session_dir (profile_dir);
shared_dir = mystrdup (shared_folder);
profile_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (profile_dir);
session_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (session_dir);
get_profile_dir (profile_dir, home_dir);
get_session_dir (session_dir, profile_dir);
shared_dir = hcstrdup (hashcat_ctx, shared_folder);
hc_mkdir (profile_dir, 0700);
hc_mkdir (session_dir, 0700);
@ -308,22 +299,22 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder,
shared_dir = install_dir;
}
myfree (resolved_install_folder);
myfree (resolved_exec_path);
hcfree (resolved_install_folder);
hcfree (resolved_exec_path);
#else
if (install_folder == NULL) install_folder = NULL; // make compiler happy
if (shared_folder == NULL) shared_folder = NULL; // make compiler happy
char *install_dir = hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (install_dir);
get_install_dir (install_dir, exec_path);
char *install_dir = get_install_dir (exec_path);
char *profile_dir = install_dir;
char *session_dir = install_dir;
char *shared_dir = install_dir;
#endif
myfree (exec_path);
hcfree (exec_path);
/**
* There's alot of problem related to bad support -I parameters when building the kernel.
@ -332,17 +323,17 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder,
* The best workaround found so far is to modify the TMP variable (only inside hashcat process) before the runtime is load
*/
char *cpath = (char *) mymalloc (HCBUFSIZ_TINY);
char *cpath = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (cpath);
#if defined (_WIN)
snprintf (cpath, HCBUFSIZ_TINY - 1, "%s\\OpenCL\\", shared_dir);
char *cpath_real = (char *) mymalloc (HCBUFSIZ_TINY);
char *cpath_real = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (cpath_real);
if (GetFullPathName (cpath, HCBUFSIZ_TINY - 1, cpath_real, NULL) == 0)
{
log_error ("ERROR: %s: %s", cpath, "GetFullPathName()");
event_log_error (hashcat_ctx, "%s: %s", cpath, "GetFullPathName()");
return -1;
}
@ -351,18 +342,18 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder,
snprintf (cpath, HCBUFSIZ_TINY - 1, "%s/OpenCL/", shared_dir);
char *cpath_real = (char *) mymalloc (PATH_MAX);
char *cpath_real = (char *) hcmalloc (hashcat_ctx, PATH_MAX); VERIFY_PTR (cpath_real);
if (realpath (cpath, cpath_real) == NULL)
{
log_error ("ERROR: %s: %s", cpath, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", cpath, strerror (errno));
return -1;
}
#endif
myfree (cpath);
hcfree (cpath);
//if (getenv ("TMP") == NULL)
if (1)
@ -391,13 +382,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder,
* kernel cache, we need to make sure folder exist
*/
char *kernels_folder = (char *) mymalloc (HCBUFSIZ_TINY);
char *kernels_folder = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (kernels_folder);
snprintf (kernels_folder, HCBUFSIZ_TINY - 1, "%s/kernels", profile_dir);
hc_mkdir (kernels_folder, 0700);
myfree (kernels_folder);
hcfree (kernels_folder);
/**
* store for later use
@ -417,17 +408,16 @@ void folder_config_destroy (hashcat_ctx_t *hashcat_ctx)
{
folder_config_t *folder_config = hashcat_ctx->folder_config;
myfree (folder_config->cpath_real);
myfree (folder_config->cwd);
myfree (folder_config->install_dir);
hcfree (folder_config->cpath_real);
hcfree (folder_config->cwd);
hcfree (folder_config->install_dir);
memset (folder_config, 0, sizeof (folder_config_t));
}
int hc_mkdir (const char *name, int mode)
int hc_mkdir (const char *name, MAYBE_UNUSED const int mode)
{
#if defined (_WIN)
if (mode == 0) mode = 0; // makes compiler happy
return _mkdir (name);
#else
return mkdir (name, mode);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -22,7 +22,7 @@ static const char HLFMT_TEXT_NSLDAPS[] = "nsldaps";
// hlfmt hashcat
static void hlfmt_hash_hashcat (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
static void hlfmt_hash_hashcat (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
@ -54,7 +54,7 @@ static void hlfmt_hash_hashcat (hashcat_ctx_t *hashcat_ctx, char *line_buf, int
}
}
static void hlfmt_user_hashcat (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
static void hlfmt_user_hashcat (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
{
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
@ -86,10 +86,8 @@ static void hlfmt_user_hashcat (hashcat_ctx_t *hashcat_ctx, char *line_buf, int
// hlfmt pwdump
static int hlfmt_detect_pwdump (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len)
static int hlfmt_detect_pwdump (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len)
{
if (hashcat_ctx == NULL) hashcat_ctx = NULL; // makes GCC happy
int sep_cnt = 0;
int sep2_len = 0;
@ -113,7 +111,7 @@ static int hlfmt_detect_pwdump (hashcat_ctx_t *hashcat_ctx, char *line_buf, int
return 0;
}
static void hlfmt_hash_pwdump (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
static void hlfmt_hash_pwdump (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
{
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
@ -155,10 +153,8 @@ static void hlfmt_hash_pwdump (hashcat_ctx_t *hashcat_ctx, char *line_buf, int l
*hashbuf_len = len;
}
static void hlfmt_user_pwdump (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
static void hlfmt_user_pwdump (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
{
if (hashcat_ctx == NULL) hashcat_ctx = NULL; // makes GCC happy
char *pos = NULL;
int len = 0;
@ -187,10 +183,8 @@ static void hlfmt_user_pwdump (hashcat_ctx_t *hashcat_ctx, char *line_buf, int l
// hlfmt passwd
static int hlfmt_detect_passwd (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len)
static int hlfmt_detect_passwd (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len)
{
if (hashcat_ctx == NULL) hashcat_ctx = NULL; // makes GCC happy
int sep_cnt = 0;
char sep5_first = 0;
@ -214,10 +208,8 @@ static int hlfmt_detect_passwd (hashcat_ctx_t *hashcat_ctx, char *line_buf, int
return 0;
}
static void hlfmt_hash_passwd (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
static void hlfmt_hash_passwd (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
{
if (hashcat_ctx == NULL) hashcat_ctx = NULL; // makes GCC happy
char *pos = NULL;
int len = 0;
@ -244,10 +236,8 @@ static void hlfmt_hash_passwd (hashcat_ctx_t *hashcat_ctx, char *line_buf, int l
*hashbuf_len = len;
}
static void hlfmt_user_passwd (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
static void hlfmt_user_passwd (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
{
if (hashcat_ctx == NULL) hashcat_ctx = NULL; // makes GCC happy
char *pos = NULL;
int len = 0;
@ -276,10 +266,8 @@ static void hlfmt_user_passwd (hashcat_ctx_t *hashcat_ctx, char *line_buf, int l
// hlfmt shadow
static int hlfmt_detect_shadow (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len)
static int hlfmt_detect_shadow (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len)
{
if (hashcat_ctx == NULL) hashcat_ctx = NULL; // makes GCC happy
int sep_cnt = 0;
for (int i = 0; i < line_len; i++)
@ -292,12 +280,12 @@ static int hlfmt_detect_shadow (hashcat_ctx_t *hashcat_ctx, char *line_buf, int
return 0;
}
static void hlfmt_hash_shadow (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
static void hlfmt_hash_shadow (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **hashbuf_pos, int *hashbuf_len)
{
hlfmt_hash_passwd (hashcat_ctx, line_buf, line_len, hashbuf_pos, hashbuf_len);
}
static void hlfmt_user_shadow (hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
static void hlfmt_user_shadow (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, char *line_buf, int line_len, char **userbuf_pos, int *userbuf_len)
{
hlfmt_user_passwd (hashcat_ctx, line_buf, line_len, userbuf_pos, userbuf_len);
}
@ -354,11 +342,11 @@ u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check)
if (hashconfig->hash_mode == 5300) return HLFMT_HASHCAT;
if (hashconfig->hash_mode == 5400) return HLFMT_HASHCAT;
u32 *formats_cnt = (u32 *) mycalloc (HLFMTS_CNT, sizeof (u32));
u32 *formats_cnt = (u32 *) hccalloc (hashcat_ctx, HLFMTS_CNT, sizeof (u32)); VERIFY_PTR (formats_cnt);
u32 num_check = 0;
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf);
while (!feof (fp))
{
@ -375,7 +363,7 @@ u32 hlfmt_detect (hashcat_ctx_t *hashcat_ctx, FILE *fp, u32 max_check)
num_check++;
}
myfree (line_buf);
hcfree (line_buf);
u32 hashlist_format = HLFMT_HASHCAT;

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "folder.h"
#include "induct.h"
@ -36,6 +36,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->opencl_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
@ -46,7 +47,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->induction_dir == NULL)
{
char *root_directory = (char *) mymalloc (HCBUFSIZ_TINY);
char *root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (root_directory);
snprintf (root_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, INDUCT_DIR);
@ -58,20 +59,20 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx)
}
else if (errno == ENOTEMPTY)
{
char *root_directory_mv = (char *) mymalloc (HCBUFSIZ_TINY);
char *root_directory_mv = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (root_directory_mv);
snprintf (root_directory_mv, HCBUFSIZ_TINY - 1, "%s/%s.induct.%d", folder_config->session_dir, user_options->session, (int) status_ctx->proc_start);
if (rename (root_directory, root_directory_mv) != 0)
{
log_error ("ERROR: Rename directory %s to %s: %s", root_directory, root_directory_mv, strerror (errno));
event_log_error (hashcat_ctx, "Rename directory %s to %s: %s", root_directory, root_directory_mv, strerror (errno));
return -1;
}
}
else
{
log_error ("ERROR: %s: %s", root_directory, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", root_directory, strerror (errno));
return -1;
}
@ -79,7 +80,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (hc_mkdir (root_directory, 0700) == -1)
{
log_error ("ERROR: %s: %s", root_directory, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", root_directory, strerror (errno));
return -1;
}
@ -88,7 +89,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx)
}
else
{
induct_ctx->root_directory = mystrdup (user_options->induction_dir);
induct_ctx->root_directory = hcstrdup (hashcat_ctx, user_options->induction_dir);
}
return 0;
@ -100,7 +101,7 @@ void induct_ctx_scan (hashcat_ctx_t *hashcat_ctx)
if (induct_ctx->enabled == false) return;
induct_ctx->induction_dictionaries = scan_directory (induct_ctx->root_directory);
induct_ctx->induction_dictionaries = scan_directory (hashcat_ctx, induct_ctx->root_directory);
induct_ctx->induction_dictionaries_cnt = count_dictionaries (induct_ctx->induction_dictionaries);
@ -142,13 +143,13 @@ void induct_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
}
else
{
log_error ("ERROR: %s: %s", induct_ctx->root_directory, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", induct_ctx->root_directory, strerror (errno));
//return -1;
}
}
myfree (induct_ctx->root_directory);
hcfree (induct_ctx->root_directory);
memset (induct_ctx, 0, sizeof (induct_ctx_t));
}

File diff suppressed because it is too large Load Diff

View File

@ -4,12 +4,13 @@
*/
#include "common.h"
#include "logging.h"
#include "types.h"
#include "event.h"
#include "locking.h"
#if defined (F_SETLKW)
void lock_file (FILE *fp)
int lock_file (FILE *fp)
{
struct flock lock;
@ -17,15 +18,9 @@ void lock_file (FILE *fp)
lock.l_type = F_WRLCK;
while (fcntl (fileno (fp), F_SETLKW, &lock))
{
if (errno != EINTR)
{
log_error ("ERROR: Failed acquiring write lock: %s", strerror (errno));
if (fcntl (fileno (fp), F_SETLKW, &lock)) return -1;
exit (-1);
}
}
return 0;
}
void unlock_file (FILE *fp)

View File

@ -10,7 +10,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "logfile.h"
static int logfile_generate_id ()
@ -77,20 +77,20 @@ int logfile_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->logfile_disable == true) return 0;
logfile_ctx->logfile = (char *) mymalloc (HCBUFSIZ_TINY);
logfile_ctx->logfile = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (logfile_ctx->logfile);
snprintf (logfile_ctx->logfile, HCBUFSIZ_TINY - 1, "%s/%s.log", folder_config->session_dir, user_options->session);
logfile_ctx->subid = (char *) mymalloc (HCBUFSIZ_TINY);
logfile_ctx->topid = (char *) mymalloc (HCBUFSIZ_TINY);
logfile_ctx->subid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (logfile_ctx->subid);
logfile_ctx->topid = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (logfile_ctx->topid);
logfile_ctx->enabled = true;
FILE *fp = fopen (logfile_ctx->logfile, "wb");
FILE *fp = fopen (logfile_ctx->logfile, "ab");
if (fp == NULL)
{
log_error ("ERROR: %s: %s", logfile_ctx->logfile, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", logfile_ctx->logfile, strerror (errno));
return -1;
}
@ -106,9 +106,9 @@ void logfile_destroy (hashcat_ctx_t *hashcat_ctx)
if (logfile_ctx->enabled == false) return;
myfree (logfile_ctx->logfile);
myfree (logfile_ctx->topid);
myfree (logfile_ctx->subid);
hcfree (logfile_ctx->logfile);
hcfree (logfile_ctx->topid);
hcfree (logfile_ctx->subid);
memset (logfile_ctx, 0, sizeof (logfile_ctx_t));
}

View File

@ -1,138 +0,0 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#if defined (__APPLE__)
#include <stdio.h>
#endif
#include "common.h"
#include "logging.h"
static int last_len = 0;
static int log_final (FILE *fp, const char *fmt, va_list ap)
{
if (last_len)
{
fputc ('\r', fp);
for (int i = 0; i < last_len; i++)
{
fputc (' ', fp);
}
fputc ('\r', fp);
}
char s[4096] = { 0 };
const size_t max_len = sizeof (s);
const int len = vsnprintf (s, max_len, fmt, ap);
//if (len > max_len) len = max_len;
fwrite (s, (size_t) len, 1, fp);
fflush (fp);
last_len = len;
return last_len;
}
int log_out_nn (FILE *fp, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
const int len = log_final (fp, fmt, ap);
va_end (ap);
return len;
}
int log_info_nn (const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
const int len = log_final (stdout, fmt, ap);
va_end (ap);
return len;
}
int log_error_nn (const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
const int len = log_final (stderr, fmt, ap);
va_end (ap);
return len;
}
int log_out (FILE *fp, const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
const int len = log_final (fp, fmt, ap);
va_end (ap);
fputc ('\n', fp);
last_len = 0;
return len;
}
int log_info (const char *fmt, ...)
{
va_list ap;
va_start (ap, fmt);
const int len = log_final (stdout, fmt, ap);
va_end (ap);
fputc ('\n', stdout);
last_len = 0;
return len;
}
int log_error (const char *fmt, ...)
{
fputc ('\n', stderr);
fputc ('\n', stderr);
va_list ap;
va_start (ap, fmt);
const int len = log_final (stderr, fmt, ap);
va_end (ap);
fputc ('\n', stderr);
fputc ('\n', stderr);
last_len = 0;
return len;
}

View File

@ -6,7 +6,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "shared.h"
#include "loopback.h"
@ -65,12 +65,13 @@ int loopback_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->opencl_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
loopback_ctx->enabled = true;
loopback_ctx->fp = NULL;
loopback_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY);
loopback_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (loopback_ctx->filename);
return 0;
}
@ -105,7 +106,7 @@ int loopback_write_open (hashcat_ctx_t *hashcat_ctx)
if (loopback_ctx->fp == NULL)
{
log_error ("ERROR: %s: %s", loopback_ctx->filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", loopback_ctx->filename, strerror (errno));
return -1;
}

View File

@ -10,135 +10,781 @@
#include "common.h"
#include "types.h"
#include "user_options.h"
#include "usage.h"
#include "memory.h"
#include "hashcat.h"
#include "terminal.h" // commandline only
#include "usage.h" // commandline only
#include "terminal.h"
#include "thread.h"
#include "status.h"
#include "interface.h"
#include "event.h"
#define RUN_AS_COMMANDLINE true
static void main_log_clear_line (MAYBE_UNUSED const int prev_len, MAYBE_UNUSED FILE *fp)
{
#if defined (_WIN)
fputc ('\r', fp);
for (int i = 0; i < prev_len; i++)
{
fputc (' ', fp);
}
fputc ('\r', fp);
#else
printf ("\033[2K\r");
#endif
}
static void main_log (hashcat_ctx_t *hashcat_ctx, FILE *fp, const int loglevel)
{
event_ctx_t *event_ctx = hashcat_ctx->event_ctx;
const char *msg_buf = event_ctx->msg_buf;
const int msg_len = event_ctx->msg_len;
const bool msg_newline = event_ctx->msg_newline;
// handle last_len
const int prev_len = event_ctx->prev_len;
if (prev_len)
{
main_log_clear_line (prev_len, fp);
}
if (msg_newline == true)
{
event_ctx->prev_len = 0;
}
else
{
event_ctx->prev_len = msg_len;
}
// color stuff pre
#if defined (_WIN)
HANDLE hConsole = GetStdHandle (STD_OUTPUT_HANDLE);
CONSOLE_SCREEN_BUFFER_INFO con_info;
GetConsoleScreenBufferInfo (hConsole, &con_info);
const int orig = con_info.wAttributes;
switch (loglevel)
{
case LOGLEVEL_INFO: break;
case LOGLEVEL_WARNING: SetConsoleTextAttribute (hConsole, 6); break;
case LOGLEVEL_ERROR: SetConsoleTextAttribute (hConsole, FOREGROUND_RED); break;
}
#else
switch (loglevel)
{
case LOGLEVEL_INFO: break;
case LOGLEVEL_WARNING: fwrite ("\033[33m", 5, 1, fp); break;
case LOGLEVEL_ERROR: fwrite ("\033[31m", 5, 1, fp); break;
}
#endif
// finally, print
fwrite (msg_buf, msg_len, 1, fp);
// color stuff post
#if defined (_WIN)
switch (loglevel)
{
case LOGLEVEL_INFO: break;
case LOGLEVEL_WARNING: SetConsoleTextAttribute (hConsole, orig); break;
case LOGLEVEL_ERROR: SetConsoleTextAttribute (hConsole, orig); break;
}
#else
switch (loglevel)
{
case LOGLEVEL_INFO: break;
case LOGLEVEL_WARNING: fwrite ("\033[0m", 4, 1, fp); break;
case LOGLEVEL_ERROR: fwrite ("\033[0m", 4, 1, fp); break;
}
#endif
// eventual newline
if (msg_newline == true)
{
fwrite (EOL, strlen (EOL), 1, fp);
// on error, add another newline
if (loglevel == LOGLEVEL_ERROR)
{
fwrite (EOL, strlen (EOL), 1, fp);
}
}
fflush (fp);
}
static void main_log_info (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
main_log (hashcat_ctx, stdout, LOGLEVEL_INFO);
}
static void main_log_warning (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
main_log (hashcat_ctx, stdout, LOGLEVEL_WARNING);
}
static void main_log_error (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
main_log (hashcat_ctx, stderr, LOGLEVEL_ERROR);
}
static void main_welcome_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
// sets dos window size (windows only)
setup_console (hashcat_ctx);
// Inform user things getting started
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
//const user_options_t *user_options = hashcat_ctx->user_options;
//if (user_options->machine_readable == true) return;
welcome_screen (hashcat_ctx, status_ctx->proc_start, VERSION_TAG);
}
static void main_goodbye_screen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
// Inform user we're done
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->machine_readable == true) return;
goodbye_screen (hashcat_ctx, status_ctx->proc_start, status_ctx->proc_stop);
}
static void main_outerloop_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
/**
* keypress thread
*/
hashcat_user->outer_threads_cnt = 0;
hashcat_user->outer_threads = (hc_thread_t *) hccalloc (hashcat_ctx, 2, sizeof (hc_thread_t)); if (hashcat_user->outer_threads == NULL) return;
status_ctx->shutdown_outer = false;
if (user_options->keyspace == false && user_options->benchmark == false && user_options->stdout_flag == false && user_options->opencl_info == false && user_options->speed_only == false)
{
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
// see thread_keypress() how to access status information
hc_thread_create (hashcat_user->outer_threads[hashcat_user->outer_threads_cnt], thread_keypress, hashcat_ctx);
hashcat_user->outer_threads_cnt++;
}
}
}
static void main_outerloop_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
hashcat_user_t *hashcat_user = hashcat_ctx->hashcat_user;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
// wait for outer threads
status_ctx->shutdown_outer = true;
for (int thread_idx = 0; thread_idx < hashcat_user->outer_threads_cnt; thread_idx++)
{
hc_thread_wait (1, &hashcat_user->outer_threads[thread_idx]);
}
hcfree (hashcat_user->outer_threads);
hashcat_user->outer_threads_cnt = 0;
}
static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
if (user_options->quiet == true) return;
// Tell the user we're about to start
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
if ((user_options->quiet == false) && (user_options->benchmark == false) && (user_options->speed_only == false))
{
event_log_info_nn (hashcat_ctx, "");
send_prompt ();
}
}
else if (user_options_extra->wordlist_mode == WL_MODE_STDIN)
{
event_log_info (hashcat_ctx, "Starting attack in stdin mode...");
event_log_info (hashcat_ctx, "");
}
}
static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const hashes_t *hashes = hashcat_ctx->hashes;
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
if (user_options->keyspace == true) return;
if (user_options->opencl_info == true) return;
if (user_options->stdout_flag == true) return;
// if we had a prompt, clear it
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
if ((user_options->benchmark == false) && (user_options->speed_only == false))
{
clear_prompt ();
}
}
// print final status
if ((user_options->benchmark == true) || (user_options->speed_only == true))
{
status_benchmark (hashcat_ctx);
if (user_options->machine_readable == false)
{
event_log_info (hashcat_ctx, "");
}
}
else
{
if (user_options->quiet == false)
{
if (hashes->digests_saved != hashes->digests_done) event_log_info (hashcat_ctx, "");
status_display (hashcat_ctx);
event_log_info (hashcat_ctx, "");
}
}
}
static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
user_options_t *user_options = hashcat_ctx->user_options;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt ();
}
fwrite (buf, len, 1, stdout);
fwrite (EOL, strlen (EOL), 1, stdout);
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
if (status_ctx->devices_status != STATUS_CRACKED)
{
if (outfile_ctx->filename == NULL) if (user_options->quiet == false) send_prompt ();
}
}
}
static void main_calculated_words_base (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->keyspace == false) return;
event_log_info (hashcat_ctx, "%" PRIu64 "", status_ctx->words_base);
}
static void main_potfile_remove_parse_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Comparing hashes with potfile entries...");
}
static void main_potfile_remove_parse_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Compared hashes with potfile entries...");
}
static void main_potfile_hash_show (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile
fwrite (buf, len, 1, stdout);
fwrite (EOL, strlen (EOL), 1, stdout);
}
static void main_potfile_hash_left (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile
fwrite (buf, len, 1, stdout);
fwrite (EOL, strlen (EOL), 1, stdout);
}
static void main_potfile_num_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const hashes_t *hashes = hashcat_ctx->hashes;
if (user_options->quiet == true) return;
const int potfile_remove_cracks = hashes->digests_done;
if (potfile_remove_cracks > 0)
{
if (potfile_remove_cracks == 1)
{
event_log_info (hashcat_ctx, "INFO: Removed 1 hash found in potfile");
event_log_info (hashcat_ctx, "");
}
else
{
event_log_info (hashcat_ctx, "INFO: Removed %d hashes found in potfile", potfile_remove_cracks);
event_log_info (hashcat_ctx, "");
}
}
}
static void main_potfile_all_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return;
event_log_info (hashcat_ctx, "INFO: All hashes found in potfile! You can use --show to display them.");
event_log_info (hashcat_ctx, "");
}
static void main_outerloop_mainscreen (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const bitmap_ctx_t *bitmap_ctx = hashcat_ctx->bitmap_ctx;
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
const hashes_t *hashes = hashcat_ctx->hashes;
const hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx;
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
const user_options_t *user_options = hashcat_ctx->user_options;
/**
* In benchmark-mode, inform user which algorithm is checked
*/
if (user_options->benchmark == true)
{
if (user_options->machine_readable == false)
{
char *hash_type = strhashtype (hashconfig->hash_mode); // not a bug
event_log_info (hashcat_ctx, "Hashtype: %s", hash_type);
event_log_info (hashcat_ctx, "");
}
}
if (user_options->quiet == true) return;
event_log_info (hashcat_ctx, "Hashes: %u digests; %u unique digests, %u unique salts", hashes->hashes_cnt_orig, hashes->digests_cnt, hashes->salts_cnt);
event_log_info (hashcat_ctx, "Bitmaps: %u bits, %u entries, 0x%08x mask, %u bytes, %u/%u rotates", bitmap_ctx->bitmap_bits, bitmap_ctx->bitmap_nums, bitmap_ctx->bitmap_mask, bitmap_ctx->bitmap_size, bitmap_ctx->bitmap_shift1, bitmap_ctx->bitmap_shift2);
if (user_options->attack_mode == ATTACK_MODE_STRAIGHT)
{
event_log_info (hashcat_ctx, "Rules: %u", straight_ctx->kernel_rules_cnt);
}
if (user_options->quiet == false) event_log_info (hashcat_ctx, "");
if (hashconfig->opti_type)
{
event_log_info (hashcat_ctx, "Applicable Optimizers:");
for (u32 i = 0; i < 32; i++)
{
const u32 opti_bit = 1u << i;
if (hashconfig->opti_type & opti_bit) event_log_info (hashcat_ctx, "* %s", stroptitype (opti_bit));
}
}
event_log_info (hashcat_ctx, "");
/**
* Watchdog and Temperature balance
*/
if (hwmon_ctx->enabled == false && user_options->gpu_temp_disable == false)
{
event_log_info (hashcat_ctx, "Watchdog: Hardware Monitoring Interface not found on your system");
}
if (hwmon_ctx->enabled == true && user_options->gpu_temp_abort > 0)
{
event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger set to %uc", user_options->gpu_temp_abort);
}
else
{
event_log_info (hashcat_ctx, "Watchdog: Temperature abort trigger disabled");
}
if (hwmon_ctx->enabled == true && user_options->gpu_temp_retain > 0)
{
event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger set to %uc", user_options->gpu_temp_retain);
}
else
{
event_log_info (hashcat_ctx, "Watchdog: Temperature retain trigger disabled");
}
event_log_info (hashcat_ctx, "");
#if defined (DEBUG)
if (user_options->benchmark == true) event_log_info (hashcat_ctx, "Hashmode: %d", hashconfig->hash_mode);
#endif
}
static void main_opencl_session_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Initializing device kernels and memory...");
}
static void main_opencl_session_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Initialized device kernels and memory...");
}
static void main_weak_hash_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Checking for weak hashes...");
}
static void main_weak_hash_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Checked for weak hashes...");
}
static void main_bitmap_init_pre (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Generating bitmap tables...");
}
static void main_bitmap_init_post (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return;
event_log_info_nn (hashcat_ctx, "Generated bitmap tables...");
}
static void main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->quiet == true) return;
clear_prompt ();
event_log_info (hashcat_ctx, "INFO: approaching final keyspace, workload adjusted");
event_log_info (hashcat_ctx, "");
send_prompt ();
}
static void main_monitor_throttle1 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
if (user_options->quiet == true) return;
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
clear_prompt ();
}
u32 *device_id = (u32 *) buf;
event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", *device_id + 1);
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
send_prompt ();
}
}
static void main_monitor_throttle2 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
if (user_options->quiet == true) return;
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
clear_prompt ();
}
u32 *device_id = (u32 *) buf;
event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", *device_id + 1);
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
send_prompt ();
}
}
static void main_monitor_throttle3 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
if (user_options->quiet == true) return;
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
clear_prompt ();
}
u32 *device_id = (u32 *) buf;
event_log_warning (hashcat_ctx, "Drivers temperature threshold hit on GPU #%d, expect performance to drop...", *device_id + 1);
event_log_warning (hashcat_ctx, "");
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
send_prompt ();
}
}
static void main_monitor_temp_abort (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
if (user_options->quiet == true) return;
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
clear_prompt ();
}
u32 *device_id = (u32 *) buf;
event_log_error (hashcat_ctx, "Temperature limit on GPU #%u reached, aborting...", *device_id + 1);
}
static void main_monitor_runtime_limit (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
if (user_options->quiet == true) return;
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
clear_prompt ();
}
event_log_warning (hashcat_ctx, "Runtime limit reached, aborting...");
}
static void main_monitor_status_refresh (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
const user_options_t *user_options = hashcat_ctx->user_options;
const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
if (user_options->quiet == false)
{
//clear_prompt ();
event_log_info (hashcat_ctx, "");
event_log_info (hashcat_ctx, "");
}
}
status_display (hashcat_ctx);
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
if (user_options->quiet == false)
{
event_log_info (hashcat_ctx, "");
send_prompt ();
}
}
}
void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
{
switch (id)
{
case EVENT_LOG_INFO: main_log_info (hashcat_ctx, buf, len); break;
case EVENT_LOG_WARNING: main_log_warning (hashcat_ctx, buf, len); break;
case EVENT_LOG_ERROR: main_log_error (hashcat_ctx, buf, len); break;
case EVENT_WELCOME_SCREEN: main_welcome_screen (hashcat_ctx, buf, len); break;
case EVENT_GOODBYE_SCREEN: main_goodbye_screen (hashcat_ctx, buf, len); break;
case EVENT_OUTERLOOP_STARTING: main_outerloop_starting (hashcat_ctx, buf, len); break;
case EVENT_OUTERLOOP_FINISHED: main_outerloop_finished (hashcat_ctx, buf, len); break;
case EVENT_OUTERLOOP_MAINSCREEN: main_outerloop_mainscreen (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_STARTING: main_cracker_starting (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_FINISHED: main_cracker_finished (hashcat_ctx, buf, len); break;
case EVENT_CRACKER_HASH_CRACKED: main_cracker_hash_cracked (hashcat_ctx, buf, len); break;
case EVENT_CALCULATED_WORDS_BASE: main_calculated_words_base (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_REMOVE_PARSE_PRE: main_potfile_remove_parse_pre (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_REMOVE_PARSE_POST: main_potfile_remove_parse_post (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_HASH_SHOW: main_potfile_hash_show (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_HASH_LEFT: main_potfile_hash_left (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_NUM_CRACKED: main_potfile_num_cracked (hashcat_ctx, buf, len); break;
case EVENT_POTFILE_ALL_CRACKED: main_potfile_all_cracked (hashcat_ctx, buf, len); break;
case EVENT_OPENCL_SESSION_PRE: main_opencl_session_pre (hashcat_ctx, buf, len); break;
case EVENT_OPENCL_SESSION_POST: main_opencl_session_post (hashcat_ctx, buf, len); break;
case EVENT_BITMAP_INIT_PRE: main_bitmap_init_pre (hashcat_ctx, buf, len); break;
case EVENT_BITMAP_INIT_POST: main_bitmap_init_post (hashcat_ctx, buf, len); break;
case EVENT_WEAK_HASH_PRE: main_weak_hash_pre (hashcat_ctx, buf, len); break;
case EVENT_WEAK_HASH_POST: main_weak_hash_post (hashcat_ctx, buf, len); break;
case EVENT_SET_KERNEL_POWER_FINAL: main_set_kernel_power_final (hashcat_ctx, buf, len); break;
case EVENT_MONITOR_THROTTLE1: main_monitor_throttle1 (hashcat_ctx, buf, len); break;
case EVENT_MONITOR_THROTTLE2: main_monitor_throttle2 (hashcat_ctx, buf, len); break;
case EVENT_MONITOR_THROTTLE3: main_monitor_throttle3 (hashcat_ctx, buf, len); break;
case EVENT_MONITOR_TEMP_ABORT: main_monitor_temp_abort (hashcat_ctx, buf, len); break;
case EVENT_MONITOR_RUNTIME_LIMIT: main_monitor_runtime_limit (hashcat_ctx, buf, len); break;
case EVENT_MONITOR_STATUS_REFRESH: main_monitor_status_refresh (hashcat_ctx, buf, len); break;
}
}
int main (int argc, char **argv)
{
// hashcat main context
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t));
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t)); VERIFY_PTR (hashcat_ctx);
hashcat_ctx_init (hashcat_ctx);
const int rc_hashcat_init = hashcat_init (hashcat_ctx, event);
// initialize the session via getops for commandline use or
// alternatively you can set the user_options directly
if (rc_hashcat_init == -1) return -1;
int rc_hashcat = 0;
// install and shared folder need to be set to recognize "make install" use
bool run_as_commandline = RUN_AS_COMMANDLINE;
char *install_folder = NULL;
char *shared_folder = NULL;
if (run_as_commandline == true)
#if defined (INSTALL_FOLDER)
install_folder = INSTALL_FOLDER;
#endif
#if defined (SHARED_FOLDER)
shared_folder = SHARED_FOLDER;
#endif
// initialize the user options with some defaults (you can override them later)
const int rc_options_init = user_options_init (hashcat_ctx);
if (rc_options_init == -1) return -1;
// parse commandline parameters and check them
const int rc_options_getopt = user_options_getopt (hashcat_ctx, argc, argv);
if (rc_options_getopt == -1) return -1;
const int rc_options_sanity = user_options_sanity (hashcat_ctx);
if (rc_options_sanity == -1) return -1;
// some early exits
user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->version == true)
{
// install and shared folder need to be set to recognize "make install" use
printf ("%s\n", VERSION_TAG);
char *install_folder = NULL;
char *shared_folder = NULL;
#if defined (INSTALL_FOLDER)
install_folder = INSTALL_FOLDER;
#endif
#if defined (SHARED_FOLDER)
shared_folder = SHARED_FOLDER;
#endif
// sets dos window size (windows only)
const int rc_console = setup_console ();
if (rc_console == -1) return -1;
// initialize the user options with some defaults (you can override them later)
user_options_init (hashcat_ctx);
// parse commandline parameters and check them
const int rc_options_getopt = user_options_getopt (hashcat_ctx, argc, argv);
if (rc_options_getopt == -1) return -1;
const int rc_options_sanity = user_options_sanity (hashcat_ctx);
if (rc_options_sanity == -1) return -1;
// some early exits
user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->version == true)
{
printf ("%s\n", VERSION_TAG);
return 0;
}
if (user_options->usage == true)
{
usage_big_print (PROGNAME);
return 0;
}
// Inform user things getting started
time_t proc_start;
time (&proc_start);
welcome_screen (hashcat_ctx, proc_start, VERSION_TAG);
// now run hashcat
rc_hashcat = hashcat (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME);
// Inform user we're done
time_t proc_stop;
time (&proc_stop);
goodbye_screen (hashcat_ctx, proc_start, proc_stop);
return 0;
}
else
if (user_options->usage == true)
{
// this is a bit ugly, but it's the example you're looking for
usage_big_print (PROGNAME);
char *hash = "8743b52063cd84097a65d1633f5c74f5";
char *mask = "?l?l?l?l?l?l?l";
char *hc_argv[] = { hash, mask, NULL };
// initialize the user options with some defaults (you can override them later)
user_options_init (hashcat_ctx);
// your own stuff
user_options_t *user_options = hashcat_ctx->user_options;
user_options->hc_argv = hc_argv;
user_options->hc_argc = 2;
user_options->quiet = true;
user_options->potfile_disable = true;
user_options->attack_mode = ATTACK_MODE_BF; // this is -a 3
user_options->hash_mode = 0; // MD5
user_options->workload_profile = 3;
// now run hashcat
rc_hashcat = hashcat (hashcat_ctx, NULL, NULL, 0, NULL, 0);
return 0;
}
// now run hashcat
const int rc_hashcat = hashcat_session_run (hashcat_ctx, install_folder, shared_folder, argc, argv, COMPTIME);
// finished with hashcat, clean up
hashcat_ctx_destroy (hashcat_ctx);
hashcat_destroy (hashcat_ctx);
free (hashcat_ctx);
return rc_hashcat;
}
}

102
src/main_shared.c Normal file
View File

@ -0,0 +1,102 @@
/**
* Author......: See docs/credits.txt
* License.....: MIT
*/
#include <stdio.h>
#include <assert.h>
#include "common.h"
#include "types.h"
#include "memory.h"
#include "user_options.h"
#include "hashcat.h"
static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
{
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
if (outfile_ctx->fp != NULL) return; // cracked hash was not written to an outfile
fwrite (buf, len, 1, stdout);
fwrite (EOL, strlen (EOL), 1, stdout);
}
void event (const u32 id, hashcat_ctx_t *hashcat_ctx, const void *buf, const size_t len)
{
switch (id)
{
case EVENT_CRACKER_HASH_CRACKED: main_cracker_hash_cracked (hashcat_ctx, buf, len); break;
}
}
int main ()
{
// hashcat main context
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) malloc (sizeof (hashcat_ctx_t));
assert (hashcat_ctx);
const int rc_hashcat_init = hashcat_init (hashcat_ctx, event);
if (rc_hashcat_init == -1) return -1;
// this is a bit ugly, but it's the example you're looking for
char *hash = "8743b52063cd84097a65d1633f5c74f5";
char *mask = "?l?l?l?l?l?l?l";
char *hc_argv[] = { hash, mask, NULL };
// initialize the user options with some defaults (you can override them later)
const int rc_options_init = user_options_init (hashcat_ctx);
if (rc_options_init == -1) return -1;
// your own stuff
user_options_t *user_options = hashcat_ctx->user_options;
user_options->hc_argv = hc_argv;
user_options->hc_argc = 2;
user_options->quiet = true;
user_options->potfile_disable = true;
user_options->attack_mode = ATTACK_MODE_BF; // this is -a 3
user_options->hash_mode = 0; // MD5
user_options->workload_profile = 3;
// now run hashcat
const int rc_hashcat = hashcat_session_run (hashcat_ctx, NULL, NULL, 0, NULL, 0);
if (rc_hashcat == 0)
{
hashcat_status_t hashcat_status;
const int rc = hashcat_get_status (hashcat_ctx, &hashcat_status);
printf ("Session: %s\n", hashcat_status.session);
printf ("Status: %s\n", hashcat_status.status_string);
if (rc == 0)
{
printf ("%d\n", hashcat_status.device_info_cnt);
}
}
else if (rc_hashcat == -1)
{
char *msg = hashcat_get_log (hashcat_ctx);
fprintf (stderr, "%s\n", msg);
}
hashcat_destroy (hashcat_ctx);
free (hashcat_ctx);
return 0;
}

View File

@ -4,69 +4,74 @@
*/
#include "common.h"
#include "logging.h"
#include "types.h"
#include "event.h"
#include "memory.h"
void *mycalloc (size_t nmemb, size_t size)
void *hccalloc (hashcat_ctx_t *hashcat_ctx, const size_t nmemb, const size_t sz)
{
void *p = calloc (nmemb, size);
void *p = calloc (nmemb, sz);
if (p == NULL)
{
log_error ("ERROR: %s", MSG_ENOMEM);
event_log_error (hashcat_ctx, "%s", MSG_ENOMEM);
exit (-1);
return (NULL);
}
return (p);
}
void *mymalloc (size_t size)
void *hcmalloc (hashcat_ctx_t *hashcat_ctx, const size_t sz)
{
void *p = malloc (size);
void *p = malloc (sz);
if (p == NULL)
{
log_error ("ERROR: %s", MSG_ENOMEM);
event_log_error (hashcat_ctx, "%s", MSG_ENOMEM);
exit (-1);
return (NULL);
}
memset (p, 0, size);
memset (p, 0, sz);
return (p);
}
void myfree (void *ptr)
void *hcrealloc (hashcat_ctx_t *hashcat_ctx, void *ptr, const size_t oldsz, const size_t addsz)
{
void *p = realloc (ptr, oldsz + addsz);
if (p == NULL)
{
event_log_error (hashcat_ctx, "%s", MSG_ENOMEM);
return (NULL);
}
memset ((char *) p + oldsz, 0, addsz);
return (p);
}
char *hcstrdup (hashcat_ctx_t *hashcat_ctx, const char *s)
{
const size_t len = strlen (s);
char *b = (char *) hcmalloc (hashcat_ctx, len + 1);
if (b == NULL) return (NULL);
memcpy (b, s, len);
b[len] = 0;
return (b);
}
void hcfree (void *ptr)
{
if (ptr == NULL) return;
free (ptr);
}
void *myrealloc (void *ptr, size_t oldsz, size_t add)
{
void *p = realloc (ptr, oldsz + add);
if (p == NULL)
{
log_error ("ERROR: %s", MSG_ENOMEM);
exit (-1);
}
memset ((char *) p + oldsz, 0, add);
return (p);
}
char *mystrdup (const char *s)
{
const size_t len = strlen (s);
char *b = (char *) mymalloc (len + 1);
memcpy (b, s, len);
return (b);
}

View File

@ -5,26 +5,47 @@
#include "common.h"
#include "types.h"
#include "logging.h"
#include "event.h"
#include "memory.h"
#include "hwmon.h"
#include "timer.h"
#include "hashes.h"
#include "thread.h"
#include "restore.h"
#include "terminal.h"
#include "status.h"
#include "shared.h"
#include "monitor.h"
static void monitor (hashcat_ctx_t *hashcat_ctx)
int get_runtime_left (const hashcat_ctx_t *hashcat_ctx)
{
hashes_t *hashes = hashcat_ctx->hashes;
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_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;
user_options_t *user_options = hashcat_ctx->user_options;
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
const user_options_t *user_options = hashcat_ctx->user_options;
double msec_paused = status_ctx->msec_paused;
if (status_ctx->devices_status == STATUS_PAUSED)
{
double msec_paused_tmp = hc_timer_get (status_ctx->timer_paused);
msec_paused += msec_paused_tmp;
}
time_t runtime_cur;
time (&runtime_cur);
const int runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (msec_paused / 1000) - runtime_cur;
return runtime_left;
}
static int monitor (hashcat_ctx_t *hashcat_ctx)
{
hashes_t *hashes = hashcat_ctx->hashes;
hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_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;
user_options_t *user_options = hashcat_ctx->user_options;
bool runtime_check = false;
bool remove_check = false;
@ -64,17 +85,17 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
if ((runtime_check == false) && (remove_check == false) && (status_check == false) && (restore_check == false) && (hwmon_check == false))
{
return;
return 0;
}
// these variables are mainly used for fan control
int *fan_speed_chgd = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int));
int *fan_speed_chgd = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); VERIFY_PTR (fan_speed_chgd);
// temperature controller "loopback" values
int *temp_diff_old = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int));
int *temp_diff_sum = (int *) mycalloc (opencl_ctx->devices_cnt, sizeof (int));
int *temp_diff_old = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); VERIFY_PTR (temp_diff_old);
int *temp_diff_sum = (int *) hccalloc (hashcat_ctx, opencl_ctx->devices_cnt, sizeof (int)); VERIFY_PTR (temp_diff_sum);
time_t last_temp_check_time;
@ -102,48 +123,21 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
if (device_param->skipped) continue;
if (device_param->device_vendor_id == VENDOR_ID_NV)
const int rc_throttle = hm_get_throttle_with_device_id (hashcat_ctx, device_id);
if (rc_throttle == -1) continue;
if (rc_throttle > 0)
{
if (hwmon_ctx->hm_nvapi)
{
NV_GPU_PERF_POLICIES_INFO_PARAMS_V1 perfPolicies_info;
NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1 perfPolicies_status;
slowdown_warnings++;
memset (&perfPolicies_info, 0, sizeof (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1));
memset (&perfPolicies_status, 0, sizeof (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1));
perfPolicies_info.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_INFO_PARAMS_V1, 1);
perfPolicies_status.version = MAKE_NVAPI_VERSION (NV_GPU_PERF_POLICIES_STATUS_PARAMS_V1, 1);
hm_NvAPI_GPU_GetPerfPoliciesInfo (hwmon_ctx->hm_nvapi, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_info);
perfPolicies_status.info_value = perfPolicies_info.info_value;
hm_NvAPI_GPU_GetPerfPoliciesStatus (hwmon_ctx->hm_nvapi, hwmon_ctx->hm_device[device_id].nvapi, &perfPolicies_status);
if (perfPolicies_status.throttle & 2)
{
if (slowdown_warnings < 3)
{
if (user_options->quiet == false) clear_prompt ();
log_info ("WARNING: Drivers temperature threshold hit on GPU #%d, expect performance to drop...", device_id + 1);
if (slowdown_warnings == 2)
{
log_info ("");
}
if (user_options->quiet == false) send_prompt ();
slowdown_warnings++;
}
}
else
{
slowdown_warnings = 0;
}
}
if (slowdown_warnings == 1) EVENT_DATA (EVENT_MONITOR_THROTTLE1, &device_id, sizeof (u32));
if (slowdown_warnings == 2) EVENT_DATA (EVENT_MONITOR_THROTTLE2, &device_id, sizeof (u32));
if (slowdown_warnings == 3) EVENT_DATA (EVENT_MONITOR_THROTTLE3, &device_id, sizeof (u32));
}
else
{
slowdown_warnings = 0;
}
}
@ -174,11 +168,9 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
if (temperature > (int) user_options->gpu_temp_abort)
{
log_error ("ERROR: Temperature limit on GPU %d reached, aborting...", device_id + 1);
EVENT_DATA (EVENT_MONITOR_TEMP_ABORT, &device_id, sizeof (u32));
myabort (status_ctx);
break;
myabort (hashcat_ctx);
}
const u32 gpu_temp_retain = user_options->gpu_temp_retain;
@ -259,7 +251,9 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
if (restore_left == 0)
{
cycle_restore (hashcat_ctx);
const int rc = cycle_restore (hashcat_ctx);
if (rc == -1) return -1;
restore_left = user_options->restore_timer;
}
@ -267,29 +261,13 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
if ((runtime_check == true) && (status_ctx->runtime_start > 0))
{
double ms_paused = status_ctx->ms_paused;
if (status_ctx->devices_status == STATUS_PAUSED)
{
double ms_paused_tmp = hc_timer_get (status_ctx->timer_paused);
ms_paused += ms_paused_tmp;
}
time_t runtime_cur;
time (&runtime_cur);
int runtime_left = status_ctx->proc_start + user_options->runtime + status_ctx->prepare_time + (ms_paused / 1000) - runtime_cur;
const int runtime_left = get_runtime_left (hashcat_ctx);
if (runtime_left <= 0)
{
if (user_options->benchmark == false)
{
if (user_options->quiet == false) log_info ("\nNOTE: Runtime limit reached, aborting...\n");
}
EVENT_DATA (EVENT_MONITOR_RUNTIME_LIMIT, NULL, 0);
myabort (status_ctx);
myabort (hashcat_ctx);
}
}
@ -303,7 +281,9 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
{
hashes->digests_saved = hashes->digests_done;
save_hash (hashcat_ctx);
const int rc = save_hash (hashcat_ctx);
if (rc == -1) return -1;
}
remove_left = user_options->remove_timer;
@ -318,13 +298,7 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
{
hc_thread_mutex_lock (status_ctx->mux_display);
if (user_options->quiet == false) clear_prompt ();
if (user_options->quiet == false) log_info ("");
status_display (hashcat_ctx);
if (user_options->quiet == false) log_info ("");
EVENT_DATA (EVENT_MONITOR_STATUS_REFRESH, NULL, 0);
hc_thread_mutex_unlock (status_ctx->mux_display);
@ -339,7 +313,9 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
{
if (hashes->digests_saved != hashes->digests_done)
{
save_hash (hashcat_ctx);
const int rc = save_hash (hashcat_ctx);
if (rc == -1) return -1;
}
}
@ -347,20 +323,24 @@ static void monitor (hashcat_ctx_t *hashcat_ctx)
if (restore_check == true)
{
cycle_restore (hashcat_ctx);
const int rc = cycle_restore (hashcat_ctx);
if (rc == -1) return -1;
}
myfree (fan_speed_chgd);
hcfree (fan_speed_chgd);
myfree (temp_diff_old);
myfree (temp_diff_sum);
hcfree (temp_diff_old);
hcfree (temp_diff_sum);
return 0;
}
void *thread_monitor (void *p)
{
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p;
monitor (hashcat_ctx);
monitor (hashcat_ctx); // we should give back some useful returncode
return NULL;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,8 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "convert.h"
#include "interface.h"
#include "hashes.h"
#include "mpsp.h"
@ -15,7 +16,7 @@
#include "opencl.h"
#include "outfile.h"
void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u32 *plain_buf, int *out_len)
int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u32 *plain_buf, int *out_len)
{
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
@ -35,7 +36,9 @@ void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, p
{
pw_t pw;
gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
if (rc == -1) return -1;
for (int i = 0; i < 16; i++)
{
@ -54,7 +57,9 @@ void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, p
{
pw_t pw;
gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
if (rc == -1) return -1;
for (int i = 0; i < 16; i++)
{
@ -104,7 +109,9 @@ void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, p
{
pw_t pw;
gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
if (rc == -1) return -1;
for (int i = 0; i < 16; i++)
{
@ -131,7 +138,9 @@ void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, p
{
pw_t pw;
gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
if (rc == -1) return -1;
for (int i = 0; i < 16; i++)
{
@ -182,9 +191,11 @@ void build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, p
}
*out_len = plain_len;
return 0;
}
void build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u64 *out_pos)
int build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u64 *out_pos)
{
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
@ -216,9 +227,11 @@ void build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
}
*out_pos = crackpos;
return 0;
}
void build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u8 *debug_rule_buf, int *debug_rule_len, u8 *debug_plain_ptr, int *debug_plain_len)
int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, plain_t *plain, u8 *debug_rule_buf, int *debug_rule_len, u8 *debug_plain_ptr, int *debug_plain_len)
{
debugfile_ctx_t *debugfile_ctx = hashcat_ctx->debugfile_ctx;
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
@ -227,15 +240,17 @@ void build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para
const u32 gidvid = plain->gidvid;
const u32 il_pos = plain->il_pos;
if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) return;
if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) return 0;
const u32 debug_mode = debugfile_ctx->mode;
if (debug_mode == 0) return;
if (debug_mode == 0) return 0;
pw_t pw;
gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
if (rc == -1) return -1;
int plain_len = (int) pw.pw_len;
@ -254,49 +269,8 @@ void build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para
*debug_plain_len = plain_len;
}
}
static void outfile_format_plain (hashcat_ctx_t *hashcat_ctx, const unsigned char *plain_ptr, const u32 plain_len)
{
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
bool needs_hexify = false;
if (outfile_ctx->outfile_autohex == true)
{
for (u32 i = 0; i < plain_len; i++)
{
if (plain_ptr[i] < 0x20)
{
needs_hexify = true;
break;
}
if (plain_ptr[i] > 0x7f)
{
needs_hexify = true;
break;
}
}
}
if (needs_hexify == true)
{
fprintf (outfile_ctx->fp, "$HEX[");
for (u32 i = 0; i < plain_len; i++)
{
fprintf (outfile_ctx->fp, "%02x", plain_ptr[i]);
}
fprintf (outfile_ctx->fp, "]");
}
else
{
fwrite (plain_ptr, plain_len, 1, outfile_ctx->fp);
}
return 0;
}
int outfile_init (hashcat_ctx_t *hashcat_ctx)
@ -304,17 +278,8 @@ int outfile_init (hashcat_ctx_t *hashcat_ctx)
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->outfile == NULL)
{
outfile_ctx->fp = stdout;
outfile_ctx->filename = NULL;
}
else
{
outfile_ctx->fp = NULL;
outfile_ctx->filename = user_options->outfile;
}
outfile_ctx->fp = NULL;
outfile_ctx->filename = user_options->outfile;
outfile_ctx->outfile_format = user_options->outfile_format;
outfile_ctx->outfile_autohex = user_options->outfile_autohex;
@ -342,7 +307,7 @@ int outfile_write_open (hashcat_ctx_t *hashcat_ctx)
if (outfile_ctx->fp == NULL)
{
log_error ("ERROR: %s: %s", outfile_ctx->filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", outfile_ctx->filename, strerror (errno));
return -1;
}
@ -354,48 +319,79 @@ void outfile_write_close (hashcat_ctx_t *hashcat_ctx)
{
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
if (outfile_ctx->fp == stdout) return;
if (outfile_ctx->fp == NULL) return;
fclose (outfile_ctx->fp);
}
void outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len)
int outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsigned char *plain_ptr, const u32 plain_len, const u64 crackpos, const unsigned char *username, const u32 user_len, char tmp_buf[HCBUFSIZ_LARGE])
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
const outfile_ctx_t *outfile_ctx = hashcat_ctx->outfile_ctx;
if (outfile_ctx->outfile_format & OUTFILE_FMT_HASH)
{
fprintf (outfile_ctx->fp, "%s", out_buf);
int tmp_len = 0;
if (outfile_ctx->outfile_format & (OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS))
{
fputc (hashconfig->separator, outfile_ctx->fp);
}
}
else if (user_len)
if (user_len > 0)
{
if (username != NULL)
{
for (u32 i = 0; i < user_len; i++)
{
fprintf (outfile_ctx->fp, "%c", username[i]);
}
memcpy (tmp_buf + tmp_len, username, user_len);
if (outfile_ctx->outfile_format & (OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS))
tmp_len += user_len;
if (outfile_ctx->outfile_format & (OUTFILE_FMT_HASH | OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS))
{
fputc (hashconfig->separator, outfile_ctx->fp);
tmp_buf[tmp_len] = hashconfig->separator;
tmp_len += 1;
}
}
}
if (outfile_ctx->outfile_format & OUTFILE_FMT_HASH)
{
const size_t out_len = strlen (out_buf);
memcpy (tmp_buf + tmp_len, out_buf, out_len);
tmp_len += out_len;
if (outfile_ctx->outfile_format & (OUTFILE_FMT_PLAIN | OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS))
{
tmp_buf[tmp_len] = hashconfig->separator;
tmp_len += 1;
}
}
if (outfile_ctx->outfile_format & OUTFILE_FMT_PLAIN)
{
outfile_format_plain (hashcat_ctx, plain_ptr, plain_len);
if (need_hexify (plain_ptr, plain_len) == true)
{
tmp_buf[tmp_len++] = '$';
tmp_buf[tmp_len++] = 'H';
tmp_buf[tmp_len++] = 'E';
tmp_buf[tmp_len++] = 'X';
tmp_buf[tmp_len++] = '[';
exec_hexify ((const u8 *) plain_ptr, plain_len, (u8 *) tmp_buf + tmp_len);
tmp_len += plain_len * 2;
tmp_buf[tmp_len++] = ']';
}
else
{
memcpy (tmp_buf + tmp_len, plain_ptr, plain_len);
tmp_len += plain_len;
}
if (outfile_ctx->outfile_format & (OUTFILE_FMT_HEXPLAIN | OUTFILE_FMT_CRACKPOS))
{
fputc (hashconfig->separator, outfile_ctx->fp);
tmp_buf[tmp_len] = hashconfig->separator;
tmp_len += 1;
}
}
@ -403,21 +399,32 @@ void outfile_write (hashcat_ctx_t *hashcat_ctx, const char *out_buf, const unsig
{
for (u32 i = 0; i < plain_len; i++)
{
fprintf (outfile_ctx->fp, "%02x", plain_ptr[i]);
exec_hexify ((const u8 *) plain_ptr, plain_len, (u8 *) tmp_buf + tmp_len);
tmp_len += 2;
}
if (outfile_ctx->outfile_format & (OUTFILE_FMT_CRACKPOS))
{
fputc (hashconfig->separator, outfile_ctx->fp);
tmp_buf[tmp_len] = hashconfig->separator;
tmp_len += 1;
}
}
if (outfile_ctx->outfile_format & OUTFILE_FMT_CRACKPOS)
{
fprintf (outfile_ctx->fp, "%" PRIu64, crackpos);
sprintf (tmp_buf + tmp_len, "%" PRIu64, crackpos);
}
fputs (EOL, outfile_ctx->fp);
tmp_buf[tmp_len] = 0;
if (outfile_ctx->fp)
{
fprintf (outfile_ctx->fp, "%s" EOL, tmp_buf);
}
return tmp_len;
}
int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx)
@ -492,7 +499,7 @@ int outfile_and_hashfile (hashcat_ctx_t *hashcat_ctx)
if (memcmp (&tmpstat_outfile, &tmpstat_hashfile, sizeof (hc_stat)) == 0)
{
log_error ("ERROR: Hashfile and Outfile are not allowed to point to the same file");
event_log_error (hashcat_ctx, "Hashfile and Outfile are not allowed to point to the same file");
return -1;
}

View File

@ -6,7 +6,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "outfile_check.h"
#include "convert.h"
@ -16,7 +16,7 @@
#include "shared.h"
#include "thread.h"
static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
{
// some hash-dependent constants
@ -36,12 +36,12 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
u32 outfile_check_timer = user_options->outfile_check_timer;
// buffers
hash_t hash_buf = { 0, 0, 0, 0, 0 };
hash_t hash_buf = { 0, 0, 0, 0, 0, NULL, 0 };
hash_buf.digest = mymalloc (dgst_size);
hash_buf.digest = hcmalloc (hashcat_ctx, dgst_size); VERIFY_PTR (hash_buf.digest);
if (is_salted) hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t));
if (esalt_size) hash_buf.esalt = (void *) mymalloc (esalt_size);
if (is_salted) hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); VERIFY_PTR (hash_buf.salt);
if (esalt_size) hash_buf.esalt = (void *) hcmalloc (hashcat_ctx, esalt_size); VERIFY_PTR (hash_buf.esalt);
u32 digest_buf[64] = { 0 };
@ -75,7 +75,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
{
if (outfile_check_stat.st_mtime > folder_mtime)
{
char **out_files_new = scan_directory (root_directory);
char **out_files_new = scan_directory (hashcat_ctx, root_directory);
int out_cnt_new = count_dictionaries (out_files_new);
@ -83,7 +83,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
if (out_cnt_new > 0)
{
out_info_new = (outfile_data_t *) mycalloc (out_cnt_new, sizeof (outfile_data_t));
out_info_new = (outfile_data_t *) hccalloc (hashcat_ctx, out_cnt_new, sizeof (outfile_data_t)); VERIFY_PTR (out_info_new);
for (int i = 0; i < out_cnt_new; i++)
{
@ -110,8 +110,8 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
}
}
myfree (out_info);
myfree (out_files);
hcfree (out_info);
hcfree (out_files);
out_files = out_files_new;
out_cnt = out_cnt_new;
@ -146,7 +146,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
fseek (fp, out_info[j].seek, SEEK_SET);
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf);
while (!feof (fp))
{
@ -263,7 +263,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
hashes->salts_done++;
if (hashes->salts_done == hashes->salts_cnt) mycracked (status_ctx);
if (hashes->salts_done == hashes->salts_cnt) mycracked (hashcat_ctx);
}
}
}
@ -282,7 +282,7 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
if (status_ctx->devices_status == STATUS_CRACKED) break;
}
myfree (line_buf);
hcfree (line_buf);
out_info[j].seek = ftell (fp);
@ -298,22 +298,26 @@ static void outfile_remove (hashcat_ctx_t *hashcat_ctx)
}
}
myfree (hash_buf.esalt);
hcfree (hash_buf.esalt);
myfree (hash_buf.salt);
hcfree (hash_buf.salt);
myfree (hash_buf.digest);
hcfree (hash_buf.digest);
myfree (out_info);
hcfree (out_info);
myfree (out_files);
hcfree (out_files);
return 0;
}
void *thread_outfile_remove (void *p)
{
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p;
outfile_remove (hashcat_ctx);
const int rc = outfile_remove (hashcat_ctx);
if (rc == -1) return NULL;
return NULL;
}
@ -328,6 +332,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->keyspace == true) return 0;
if (user_options->benchmark == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->opencl_info == true) return 0;
if (user_options->outfile_check_timer == 0) return 0;
@ -339,7 +344,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->outfile_check_dir == NULL)
{
outcheck_ctx->root_directory = (char *) mymalloc (HCBUFSIZ_TINY);
outcheck_ctx->root_directory = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (outcheck_ctx->root_directory);
snprintf (outcheck_ctx->root_directory, HCBUFSIZ_TINY - 1, "%s/%s.%s", folder_config->session_dir, user_options->session, OUTFILES_DIR);
}
@ -356,7 +361,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (is_dir == 0)
{
log_error ("ERROR: Directory specified in outfile-check '%s' is not a valid directory", outcheck_ctx->root_directory);
event_log_error (hashcat_ctx, "Directory specified in outfile-check '%s' is not a valid directory", outcheck_ctx->root_directory);
return -1;
}
@ -365,7 +370,7 @@ int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx)
{
if (hc_mkdir (outcheck_ctx->root_directory, 0700) == -1)
{
log_error ("ERROR: %s: %s", outcheck_ctx->root_directory, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", outcheck_ctx->root_directory, strerror (errno));
return -1;
}
@ -394,13 +399,13 @@ void outcheck_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
}
else
{
log_error ("ERROR: %s: %s", outcheck_ctx->root_directory, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", outcheck_ctx->root_directory, strerror (errno));
//return -1;
}
}
myfree (outcheck_ctx->root_directory);
hcfree (outcheck_ctx->root_directory);
memset (outcheck_ctx, 0, sizeof (outcheck_ctx_t));
}

View File

@ -7,7 +7,7 @@
#include "types.h"
#include "convert.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "interface.h"
#include "filehandling.h"
#include "outfile.h"
@ -26,7 +26,7 @@ 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, void *v3)
int sort_by_pot (const void *v1, const void *v2, MAYBE_UNUSED void *v3)
{
const pot_t *p1 = (const pot_t *) v1;
const pot_t *p2 = (const pot_t *) v2;
@ -37,10 +37,8 @@ int sort_by_pot (const void *v1, const void *v2, void *v3)
return sort_by_hash (h1, h2, v3);
}
int sort_by_salt_buf (const void *v1, const void *v2, void *v3)
int sort_by_salt_buf (const void *v1, const void *v2, MAYBE_UNUSED 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;
@ -54,7 +52,7 @@ int sort_by_salt_buf (const void *v1, const void *v2, void *v3)
while (n--)
{
if (s1->salt_buf[n] > s2->salt_buf[n]) return ( 1);
if (s1->salt_buf[n] > s2->salt_buf[n]) return 1;
if (s1->salt_buf[n] < s2->salt_buf[n]) return -1;
}
@ -146,48 +144,6 @@ void *hc_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size
return (NULL);
}
static void potfile_format_plain (hashcat_ctx_t *hashcat_ctx, const unsigned char *plain_ptr, const u32 plain_len)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return;
bool needs_hexify = false;
for (u32 i = 0; i < plain_len; i++)
{
if (plain_ptr[i] < 0x20)
{
needs_hexify = true;
break;
}
if (plain_ptr[i] > 0x7f)
{
needs_hexify = true;
break;
}
}
if (needs_hexify == true)
{
fprintf (potfile_ctx->fp, "$HEX[");
for (u32 i = 0; i < plain_len; i++)
{
fprintf (potfile_ctx->fp, "%02x", plain_ptr[i]);
}
fprintf (potfile_ctx->fp, "]");
}
else
{
fwrite (plain_ptr, plain_len, 1, potfile_ctx->fp);
}
}
int potfile_init (hashcat_ctx_t *hashcat_ctx)
{
folder_config_t *folder_config = hashcat_ctx->folder_config;
@ -200,6 +156,7 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->keyspace == true) return 0;
if (user_options->opencl_info == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->potfile_disable == true) return 0;
@ -208,14 +165,14 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx)
if (user_options->potfile_path == NULL)
{
potfile_ctx->filename = (char *) mymalloc (HCBUFSIZ_TINY);
potfile_ctx->filename = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (potfile_ctx->filename);
potfile_ctx->fp = NULL;
snprintf (potfile_ctx->filename, HCBUFSIZ_TINY - 1, "%s/hashcat.potfile", folder_config->profile_dir);
}
else
{
potfile_ctx->filename = mystrdup (user_options->potfile_path);
potfile_ctx->filename = hcstrdup (hashcat_ctx, user_options->potfile_path); VERIFY_PTR (potfile_ctx->filename);
potfile_ctx->fp = NULL;
}
@ -225,11 +182,6 @@ int potfile_init (hashcat_ctx_t *hashcat_ctx)
potfile_write_close (hashcat_ctx);
potfile_ctx->pot = NULL;
potfile_ctx->pot_cnt = 0;
potfile_ctx->pot_avail = 0;
potfile_ctx->pot_hashes_avail = 0;
return 0;
}
@ -252,7 +204,7 @@ int potfile_read_open (hashcat_ctx_t *hashcat_ctx)
if (potfile_ctx->fp == NULL)
{
//log_error ("ERROR: %s: %s", potfile_ctx->filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", potfile_ctx->filename, strerror (errno));
return -1;
}
@ -260,116 +212,6 @@ int potfile_read_open (hashcat_ctx_t *hashcat_ctx)
return 0;
}
void potfile_read_parse (hashcat_ctx_t *hashcat_ctx)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
if (potfile_ctx->enabled == false) return;
if (potfile_ctx->fp == NULL) return;
potfile_ctx->pot_avail = count_lines (potfile_ctx->fp);
potfile_ctx->pot = (pot_t *) mycalloc (potfile_ctx->pot_avail, sizeof (pot_t));
rewind (potfile_ctx->fp);
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
for (u32 line_num = 0; line_num < potfile_ctx->pot_avail; line_num++)
{
int line_len = fgetl (potfile_ctx->fp, line_buf);
if (line_len == 0) continue;
pot_t *pot_ptr = &potfile_ctx->pot[potfile_ctx->pot_cnt];
// we do not initialize all hashes_buf->digest etc at the beginning, since many lines may not be
// valid lines of this specific hash type (otherwise it would be more waste of memory than gain)
if (potfile_ctx->pot_cnt == potfile_ctx->pot_hashes_avail)
{
potfile_hash_alloc (hashcat_ctx, INCR_POT);
}
int parser_status;
int iter = MAX_CUT_TRIES;
hash_t *hashes_buf = &pot_ptr->hash;
char *plain_buf = line_buf + line_len;
int plain_len = 0;
do
{
for (int i = line_len - 1; i; i--, plain_len++, plain_buf--, line_len--)
{
if (line_buf[i] == ':')
{
line_len--;
break;
}
}
if (hashconfig->hash_mode != 2500)
{
parser_status = hashconfig->parse_func (line_buf, line_len, hashes_buf, hashconfig);
}
else
{
int max_salt_size = sizeof (hashes_buf->salt->salt_buf);
if (line_len > max_salt_size)
{
parser_status = PARSER_GLOBAL_LENGTH;
}
else
{
memset (&hashes_buf->salt->salt_buf, 0, max_salt_size);
memcpy (&hashes_buf->salt->salt_buf, line_buf, line_len);
hashes_buf->salt->salt_len = line_len;
parser_status = PARSER_OK;
}
}
// if NOT parsed without error, we add the ":" to the plain
if (parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH)
{
plain_len++;
plain_buf--;
}
} while ((parser_status == PARSER_GLOBAL_LENGTH || parser_status == PARSER_HASH_LENGTH || parser_status == PARSER_SALT_LENGTH) && --iter);
if (parser_status < PARSER_GLOBAL_ZERO)
{
// log_info ("WARNING: Potfile '%s' in line %u (%s): %s", potfile, line_num, line_buf, strparser (parser_status));
continue;
}
if (plain_len >= HCBUFSIZ_TINY) continue;
memcpy (pot_ptr->plain_buf, plain_buf, plain_len);
pot_ptr->plain_len = plain_len;
potfile_ctx->pot_cnt++;
}
myfree (line_buf);
hc_qsort_r (potfile_ctx->pot, potfile_ctx->pot_cnt, sizeof (pot_t), sort_by_pot, (void *) hashconfig);
}
void potfile_read_close (hashcat_ctx_t *hashcat_ctx)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
@ -391,7 +233,7 @@ int potfile_write_open (hashcat_ctx_t *hashcat_ctx)
if (potfile_ctx->fp == NULL)
{
log_error ("ERROR: %s: %s", potfile_ctx->filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", potfile_ctx->filename, strerror (errno));
return -1;
}
@ -414,352 +256,52 @@ void potfile_write_append (hashcat_ctx_t *hashcat_ctx, const char *out_buf, u8 *
if (potfile_ctx->enabled == false) return;
FILE *fp = potfile_ctx->fp;
char tmp_buf[HCBUFSIZ_LARGE];
fprintf (fp, "%s:", out_buf);
int tmp_len = 0;
potfile_format_plain (hashcat_ctx, plain_ptr, plain_len);
fputc ('\n', fp);
fflush (fp);
}
void potfile_hash_alloc (hashcat_ctx_t *hashcat_ctx, const u32 num)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
if (potfile_ctx->enabled == false) return;
u32 pos = 0;
for (pos = 0; pos < num; pos++)
if (1)
{
if ((potfile_ctx->pot_cnt + pos) >= potfile_ctx->pot_avail) break;
const size_t out_len = strlen (out_buf);
pot_t *tmp_pot = &potfile_ctx->pot[potfile_ctx->pot_cnt + pos];
memcpy (tmp_buf + tmp_len, out_buf, out_len);
hash_t *tmp_hash = &tmp_pot->hash;
tmp_len += out_len;
tmp_hash->digest = mymalloc (hashconfig->dgst_size);
tmp_buf[tmp_len] = ':';
if (hashconfig->is_salted)
{
tmp_hash->salt = (salt_t *) mymalloc (sizeof (salt_t));
}
if (hashconfig->esalt_size)
{
tmp_hash->esalt = mymalloc (hashconfig->esalt_size);
}
potfile_ctx->pot_hashes_avail++;
tmp_len += 1;
}
}
void potfile_hash_free (hashcat_ctx_t *hashcat_ctx)
{
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
if (potfile_ctx->enabled == false) return;
for (u32 i = 0; i < potfile_ctx->pot_cnt; i++)
if (1)
{
pot_t *pot_ptr = &potfile_ctx->pot[i];
hash_t *hashes_buf = &pot_ptr->hash;
myfree (hashes_buf->digest);
if (hashconfig->is_salted)
if (need_hexify (plain_ptr, plain_len) == true)
{
myfree (hashes_buf->salt);
tmp_buf[tmp_len++] = '$';
tmp_buf[tmp_len++] = 'H';
tmp_buf[tmp_len++] = 'E';
tmp_buf[tmp_len++] = 'X';
tmp_buf[tmp_len++] = '[';
exec_hexify ((const u8 *) plain_ptr, plain_len, (u8 *) tmp_buf + tmp_len);
tmp_len += plain_len * 2;
tmp_buf[tmp_len++] = ']';
}
if (hashconfig->esalt_size)
else
{
myfree (hashes_buf->esalt);
memcpy (tmp_buf + tmp_len, plain_ptr, plain_len);
tmp_len += plain_len;
}
}
myfree (potfile_ctx->pot);
}
tmp_buf[tmp_len] = 0;
void potfile_show_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *))
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
fprintf (potfile_ctx->fp, "%s\n", tmp_buf);
if (potfile_ctx->enabled == false) return;
pot_t pot_key;
pot_key.hash.salt = hashes_buf->salt;
pot_key.hash.digest = hashes_buf->digest;
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)
{
log_info_nn ("");
input_buf[input_len] = 0;
// user
unsigned char *username = NULL;
u32 user_len = 0;
if (hashes_buf->hash_info)
{
user_t *user = hashes_buf->hash_info->user;
if (user)
{
username = (unsigned char *) (user->user_name);
user_len = user->user_len;
}
}
// do output the line
outfile_write (hashcat_ctx, input_buf, (const unsigned char *) pot_ptr->plain_buf, pot_ptr->plain_len, 0, username, user_len);
}
}
void potfile_left_request (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *, void *))
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return;
pot_t pot_key;
memcpy (&pot_key.hash, hashes_buf, sizeof (hash_t));
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)
{
log_info_nn ("");
input_buf[input_len] = 0;
outfile_write (hashcat_ctx, input_buf, NULL, 0, 0, NULL, 0);
}
}
void potfile_show_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *))
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return;
// left
pot_t pot_left_key;
pot_left_key.hash.salt = hash_left->salt;
pot_left_key.hash.digest = hash_left->digest;
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
u32 weak_hash_found = 0;
pot_t pot_right_key;
pot_right_key.hash.salt = hash_right->salt;
pot_right_key.hash.digest = hash_right->digest;
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)
{
// special case, if "weak hash"
if (memcmp (hash_right->digest, LM_WEAK_HASH, 8) == 0)
{
weak_hash_found = 1;
pot_right_ptr = (pot_t *) mycalloc (1, sizeof (pot_t));
// in theory this is not needed, but we are paranoia:
memset (pot_right_ptr->plain_buf, 0, sizeof (pot_right_ptr->plain_buf));
pot_right_ptr->plain_len = 0;
}
}
if ((pot_left_ptr == NULL) && (pot_right_ptr == NULL))
{
if (weak_hash_found == 1) myfree (pot_right_ptr); // this shouldn't happen at all: if weak_hash_found == 1, than pot_right_ptr is not NULL for sure
return;
}
// at least one half was found:
log_info_nn ("");
input_buf[input_len] = 0;
// user
unsigned char *username = NULL;
u32 user_len = 0;
if (hash_left->hash_info)
{
user_t *user = hash_left->hash_info->user;
if (user)
{
username = (unsigned char *) (user->user_name);
user_len = user->user_len;
}
}
// mask the part which was not found
u32 left_part_masked = 0;
u32 right_part_masked = 0;
u32 mask_plain_len = strlen (LM_MASKED_PLAIN);
if (pot_left_ptr == NULL)
{
left_part_masked = 1;
pot_left_ptr = (pot_t *) mycalloc (1, sizeof (pot_t));
memset (pot_left_ptr->plain_buf, 0, sizeof (pot_left_ptr->plain_buf));
memcpy (pot_left_ptr->plain_buf, LM_MASKED_PLAIN, mask_plain_len);
pot_left_ptr->plain_len = mask_plain_len;
}
if (pot_right_ptr == NULL)
{
right_part_masked = 1;
pot_right_ptr = (pot_t *) mycalloc (1, sizeof (pot_t));
memset (pot_right_ptr->plain_buf, 0, sizeof (pot_right_ptr->plain_buf));
memcpy (pot_right_ptr->plain_buf, LM_MASKED_PLAIN, mask_plain_len);
pot_right_ptr->plain_len = mask_plain_len;
}
// create the pot_ptr out of pot_left_ptr and pot_right_ptr
pot_t pot_ptr;
pot_ptr.plain_len = pot_left_ptr->plain_len + pot_right_ptr->plain_len;
memcpy (pot_ptr.plain_buf, pot_left_ptr->plain_buf, pot_left_ptr->plain_len);
memcpy (pot_ptr.plain_buf + pot_left_ptr->plain_len, pot_right_ptr->plain_buf, pot_right_ptr->plain_len);
// do output the line
outfile_write (hashcat_ctx, input_buf, (unsigned char *) pot_ptr.plain_buf, pot_ptr.plain_len, 0, username, user_len);
if (weak_hash_found == 1) myfree (pot_right_ptr);
if (left_part_masked == 1) myfree (pot_left_ptr);
if (right_part_masked == 1) myfree (pot_right_ptr);
}
void potfile_left_request_lm (hashcat_ctx_t *hashcat_ctx, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *, void *))
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
potfile_ctx_t *potfile_ctx = hashcat_ctx->potfile_ctx;
if (potfile_ctx->enabled == false) return;
// left
pot_t pot_left_key;
memcpy (&pot_left_key.hash, hash_left, sizeof (hash_t));
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
pot_t pot_right_key;
memcpy (&pot_right_key.hash, hash_right, sizeof (hash_t));
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);
u32 weak_hash_found = 0;
if (pot_right_ptr == NULL)
{
// special case, if "weak hash"
if (memcmp (hash_right->digest, LM_WEAK_HASH, 8) == 0)
{
weak_hash_found = 1;
// we just need that pot_right_ptr is not a NULL pointer
pot_right_ptr = (pot_t *) mycalloc (1, sizeof (pot_t));
}
}
if ((pot_left_ptr != NULL) && (pot_right_ptr != NULL))
{
if (weak_hash_found == 1) myfree (pot_right_ptr);
return;
}
// ... at least one part was not cracked
log_info_nn ("");
input_buf[input_len] = 0;
// only show the hash part which is still not cracked
u32 user_len = (u32)input_len - 32u;
char *hash_output = (char *) mymalloc (33);
memcpy (hash_output, input_buf, input_len);
if (pot_left_ptr != NULL)
{
// only show right part (because left part was already found)
memcpy (hash_output + user_len, input_buf + user_len + 16, 16);
hash_output[user_len + 16] = 0;
}
if (pot_right_ptr != NULL)
{
// only show left part (because right part was already found)
memcpy (hash_output + user_len, input_buf + user_len, 16);
hash_output[user_len + 16] = 0;
}
outfile_write (hashcat_ctx, hash_output, NULL, 0, 0, NULL, 0);
myfree (hash_output);
if (weak_hash_found == 1) myfree (pot_right_ptr);
fflush (potfile_ctx->fp);
}
int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
@ -771,25 +313,20 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
if (potfile_ctx->enabled == false) return 0;
hash_t *hashes_buf = hashes->hashes_buf;
u32 hashes_cnt = hashes->hashes_cnt;
u32 hashes_cnt = hashes->hashes_cnt;
// no solution for these special hash types (for instane because they use hashfile in output etc)
if (hashconfig->hash_mode == 5200)
return 0;
if ((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299))
return 0;
if (hashconfig->hash_mode == 9000)
return 0;
if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799))
return 0;
if (hashconfig->hash_mode == 5200) return 0;
if ((hashconfig->hash_mode >= 6200)
&& (hashconfig->hash_mode <= 6299)) return 0;
if (hashconfig->hash_mode == 9000) return 0;
if ((hashconfig->hash_mode >= 13700)
&& (hashconfig->hash_mode <= 13799)) return 0;
hash_t hash_buf;
hash_buf.digest = mymalloc (hashconfig->dgst_size);
hash_buf.digest = hcmalloc (hashcat_ctx, hashconfig->dgst_size); VERIFY_PTR (hash_buf.digest);
hash_buf.salt = NULL;
hash_buf.esalt = NULL;
hash_buf.hash_info = NULL;
@ -797,38 +334,34 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
if (hashconfig->is_salted)
{
hash_buf.salt = (salt_t *) mymalloc (sizeof (salt_t));
hash_buf.salt = (salt_t *) hcmalloc (hashcat_ctx, sizeof (salt_t)); VERIFY_PTR (hash_buf.salt);
}
if (hashconfig->esalt_size)
{
hash_buf.esalt = mymalloc (hashconfig->esalt_size);
hash_buf.esalt = hcmalloc (hashcat_ctx, hashconfig->esalt_size); VERIFY_PTR (hash_buf.esalt);
}
const int rc = potfile_read_open (hashcat_ctx);
if (rc == -1) return 0;
if (rc == -1) return -1;
int potfile_remove_cracks = 0;
char *line_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
char *line_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf);
// to be safe work with a copy (because of line_len loop, i etc)
// moved up here because it's easier to handle continue case
// it's just 64kb
char *line_buf_cpy = (char *) mymalloc (HCBUFSIZ_LARGE);
char *line_buf_cpy = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (line_buf_cpy);
while (!feof (potfile_ctx->fp))
{
char *ptr = fgets (line_buf, HCBUFSIZ_LARGE - 1, potfile_ctx->fp);
if (ptr == NULL) break;
int line_len = strlen (line_buf);
int line_len = fgetl (potfile_ctx->fp, line_buf);
if (line_len == 0) continue;
const int line_len_orig = line_len;
int iter = MAX_CUT_TRIES;
for (int i = line_len - 1; i && iter; i--, line_len--)
@ -946,7 +479,15 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
if (found == NULL) continue;
if (!found->cracked) potfile_remove_cracks++;
char *pw_buf = line_buf + line_len;
int pw_len = line_len_orig - line_len;
found->pw_buf = (char *) hcmalloc (hashcat_ctx, pw_len + 1); VERIFY_PTR (found->pw_buf);
found->pw_len = pw_len;
memcpy (found->pw_buf, pw_buf, pw_len);
found->pw_buf[found->pw_len] = 0;
found->cracked = 1;
@ -956,23 +497,145 @@ int potfile_remove_parse (hashcat_ctx_t *hashcat_ctx)
}
}
myfree (line_buf_cpy);
hcfree (line_buf_cpy);
myfree (line_buf);
hcfree (line_buf);
potfile_read_close (hashcat_ctx);
if (hashconfig->esalt_size)
{
myfree (hash_buf.esalt);
hcfree (hash_buf.esalt);
}
if (hashconfig->is_salted)
{
myfree (hash_buf.salt);
hcfree (hash_buf.salt);
}
myfree (hash_buf.digest);
hcfree (hash_buf.digest);
return potfile_remove_cracks;
return 0;
}
int potfile_handle_show (hashcat_ctx_t *hashcat_ctx)
{
hashes_t *hashes = hashcat_ctx->hashes;
hash_t *hashes_buf = hashes->hashes_buf;
u32 salts_cnt = hashes->salts_cnt;
salt_t *salts_buf = hashes->salts_buf;
for (u32 salt_idx = 0; salt_idx < salts_cnt; salt_idx++)
{
salt_t *salt_buf = salts_buf + salt_idx;
u32 digests_cnt = salt_buf->digests_cnt;
for (u32 digest_idx = 0; digest_idx < digests_cnt; digest_idx++)
{
const u32 hashes_idx = salt_buf->digests_offset + digest_idx;
u32 *digests_shown = hashes->digests_shown;
if (digests_shown[hashes_idx] == 0) continue;
char out_buf[HCBUFSIZ_LARGE]; // scratch buffer
out_buf[0] = 0;
ascii_digest (hashcat_ctx, out_buf, salt_idx, digest_idx);
char tmp_buf[HCBUFSIZ_LARGE]; // scratch buffer
hash_t *hash = &hashes_buf[hashes_idx];
// user
unsigned char *username = NULL;
u32 user_len = 0;
if (hash->hash_info != NULL)
{
user_t *user = hash->hash_info->user;
if (user)
{
username = (unsigned char *) (user->user_name);
user_len = user->user_len;
username[user_len] = 0;
}
}
const int tmp_len = outfile_write (hashcat_ctx, out_buf, (unsigned char *) hash->pw_buf, hash->pw_len, 0, username, user_len, tmp_buf);
EVENT_DATA (EVENT_POTFILE_HASH_SHOW, tmp_buf, tmp_len);
}
}
return 0;
}
int potfile_handle_left (hashcat_ctx_t *hashcat_ctx)
{
hashes_t *hashes = hashcat_ctx->hashes;
hash_t *hashes_buf = hashes->hashes_buf;
u32 salts_cnt = hashes->salts_cnt;
salt_t *salts_buf = hashes->salts_buf;
for (u32 salt_idx = 0; salt_idx < salts_cnt; salt_idx++)
{
salt_t *salt_buf = salts_buf + salt_idx;
u32 digests_cnt = salt_buf->digests_cnt;
for (u32 digest_idx = 0; digest_idx < digests_cnt; digest_idx++)
{
const u32 hashes_idx = salt_buf->digests_offset + digest_idx;
u32 *digests_shown = hashes->digests_shown;
if (digests_shown[hashes_idx] == 1) continue;
char out_buf[HCBUFSIZ_LARGE]; // scratch buffer
out_buf[0] = 0;
ascii_digest (hashcat_ctx, out_buf, salt_idx, digest_idx);
hash_t *hash = &hashes_buf[hashes_idx];
// user
unsigned char *username = NULL;
u32 user_len = 0;
if (hash->hash_info != NULL)
{
user_t *user = hash->hash_info->user;
if (user)
{
username = (unsigned char *) (user->user_name);
user_len = user->user_len;
username[user_len] = 0;
}
}
char tmp_buf[HCBUFSIZ_LARGE]; // scratch buffer
const int tmp_len = outfile_write (hashcat_ctx, out_buf, NULL, 0, 0, username, user_len, tmp_buf);
EVENT_DATA (EVENT_POTFILE_HASH_LEFT, tmp_buf, tmp_len);
}
}
return 0;
}

View File

@ -6,7 +6,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "user_options.h"
#include "restore.h"
@ -19,40 +19,7 @@ static void fsync (int fd)
}
#endif
u64 get_lowest_words_done (hashcat_ctx_t *hashcat_ctx)
{
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
if (restore_ctx->enabled == false) return 0;
restore_data_t *rd = restore_ctx->rd;
u64 words_cur = -1llu;
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];
if (device_param->skipped) continue;
const u64 words_done = device_param->words_done;
if (words_done < words_cur) words_cur = words_done;
}
// It's possible that a device's workload isn't finished right after a restore-case.
// In that case, this function would return 0 and overwrite the real restore point
// There's also status_ctx->words_cur which is set to rd->words_cur but it changes while
// the attack is running therefore we should stick to rd->words_cur.
// Note that -s influences rd->words_cur we should keep a close look on that.
if (words_cur < rd->words_cur) words_cur = rd->words_cur;
return words_cur;
}
static void check_running_process (hashcat_ctx_t *hashcat_ctx)
static int check_running_process (hashcat_ctx_t *hashcat_ctx)
{
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
@ -60,24 +27,24 @@ static void check_running_process (hashcat_ctx_t *hashcat_ctx)
FILE *fp = fopen (eff_restore_file, "rb");
if (fp == NULL) return;
if (fp == NULL) return 0;
restore_data_t *rd = (restore_data_t *) mymalloc (sizeof (restore_data_t));
restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); VERIFY_PTR (rd);
const size_t nread = fread (rd, sizeof (restore_data_t), 1, fp);
if (nread != 1)
{
log_error ("ERROR: Cannot read %s", eff_restore_file);
event_log_error (hashcat_ctx, "Cannot read %s", eff_restore_file);
exit (-1);
return -1;
}
fclose (fp);
if (rd->pid)
{
char *pidbin = (char *) mymalloc (HCBUFSIZ_LARGE);
char *pidbin = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin);
int pidbin_len = -1;
@ -104,16 +71,16 @@ static void check_running_process (hashcat_ctx_t *hashcat_ctx)
if (strcmp (argv0_r, pidbin_r) == 0)
{
log_error ("ERROR: Already an instance %s running on pid %d", pidbin, rd->pid);
event_log_error (hashcat_ctx, "Already an instance %s running on pid %d", pidbin, rd->pid);
exit (-1);
return -1;
}
}
#elif defined (_WIN)
HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, rd->pid);
char *pidbin2 = (char *) mymalloc (HCBUFSIZ_LARGE);
char *pidbin2 = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (pidbin2);
int pidbin2_len = -1;
@ -127,38 +94,42 @@ static void check_running_process (hashcat_ctx_t *hashcat_ctx)
{
if (strcmp (pidbin, pidbin2) == 0)
{
log_error ("ERROR: Already an instance %s running on pid %d", pidbin2, rd->pid);
event_log_error (hashcat_ctx, "Already an instance %s running on pid %d", pidbin2, rd->pid);
exit (-1);
return -1;
}
}
myfree (pidbin2);
hcfree (pidbin2);
#endif
myfree (pidbin);
hcfree (pidbin);
}
if (rd->version < RESTORE_VERSION_MIN)
{
log_error ("ERROR: Cannot use outdated %s. Please remove it.", eff_restore_file);
event_log_error (hashcat_ctx, "Cannot use outdated %s. Please remove it.", eff_restore_file);
exit (-1);
return -1;
}
myfree (rd);
hcfree (rd);
return 0;
}
void init_restore (hashcat_ctx_t *hashcat_ctx)
static int init_restore (hashcat_ctx_t *hashcat_ctx)
{
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
restore_data_t *rd = (restore_data_t *) mymalloc (sizeof (restore_data_t));
restore_data_t *rd = (restore_data_t *) hcmalloc (hashcat_ctx, sizeof (restore_data_t)); VERIFY_PTR (rd);
restore_ctx->rd = rd;
check_running_process (hashcat_ctx);
const int rc = check_running_process (hashcat_ctx);
if (rc == -1) return -1;
rd->version = RESTORE_VERSION_CUR;
@ -173,17 +144,19 @@ void init_restore (hashcat_ctx_t *hashcat_ctx)
if (getcwd (rd->cwd, 255) == NULL)
{
log_error ("ERROR: getcwd(): %s", strerror (errno));
event_log_error (hashcat_ctx, "getcwd(): %s", strerror (errno));
exit (-1);
return -1;
}
return 0;
}
void read_restore (hashcat_ctx_t *hashcat_ctx)
static int read_restore (hashcat_ctx_t *hashcat_ctx)
{
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
if (restore_ctx->enabled == false) return;
if (restore_ctx->enabled == false) return 0;
char *eff_restore_file = restore_ctx->eff_restore_file;
@ -191,68 +164,75 @@ void read_restore (hashcat_ctx_t *hashcat_ctx)
if (fp == NULL)
{
log_error ("ERROR: Restore file '%s': %s", eff_restore_file, strerror (errno));
event_log_error (hashcat_ctx, "Restore file '%s': %s", eff_restore_file, strerror (errno));
exit (-1);
return -1;
}
restore_data_t *rd = restore_ctx->rd;
if (fread (rd, sizeof (restore_data_t), 1, fp) != 1)
{
log_error ("ERROR: Can't read %s", eff_restore_file);
event_log_error (hashcat_ctx, "Can't read %s", eff_restore_file);
exit (-1);
return -1;
}
rd->argv = (char **) mycalloc (rd->argc, sizeof (char *));
rd->argv = (char **) hccalloc (hashcat_ctx, rd->argc, sizeof (char *)); VERIFY_PTR (rd->argv);
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE);
char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (buf);
for (u32 i = 0; i < rd->argc; i++)
{
if (fgets (buf, HCBUFSIZ_LARGE - 1, fp) == NULL)
{
log_error ("ERROR: Can't read %s", eff_restore_file);
event_log_error (hashcat_ctx, "Can't read %s", eff_restore_file);
exit (-1);
return -1;
}
size_t len = strlen (buf);
if (len) buf[len - 1] = 0;
rd->argv[i] = mystrdup (buf);
rd->argv[i] = hcstrdup (hashcat_ctx, buf);
}
myfree (buf);
hcfree (buf);
fclose (fp);
log_info ("INFO: Changing current working directory to the path found within the .restore file: '%s'", rd->cwd);
event_log_info (hashcat_ctx, "INFO: Changing current working directory to '%s'", rd->cwd);
event_log_info (hashcat_ctx, "");
if (chdir (rd->cwd))
{
log_error ("ERROR: The directory '%s' does not exist. It is needed to restore (--restore) the session.\n"
" You could either create this directory (or link it) or update the .restore file using e.g. the analyze_hc_restore.pl tool:\n"
" https://github.com/philsmd/analyze_hc_restore\n"
" The directory must be relative to (or contain) all files/folders mentioned within the command line.", rd->cwd);
event_log_error (hashcat_ctx,
"The directory '%s' does not exist. It is needed to restore (--restore) the session." EOL
"You could either create this directory or update the .restore file using e.g. the analyze_hc_restore.pl tool:" EOL
"https://github.com/philsmd/analyze_hc_restore" EOL
"The directory must contain all files and folders mentioned within the command line.", rd->cwd);
exit (-1);
return -1;
}
return 0;
}
void write_restore (hashcat_ctx_t *hashcat_ctx)
static int write_restore (hashcat_ctx_t *hashcat_ctx)
{
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
const restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
if (restore_ctx->enabled == false) return;
const u64 words_cur = get_lowest_words_done (hashcat_ctx);
if (restore_ctx->enabled == false) return 0;
restore_data_t *rd = restore_ctx->rd;
rd->words_cur = words_cur;
rd->masks_pos = mask_ctx->masks_pos;
rd->dicts_pos = straight_ctx->dicts_pos;
rd->words_cur = status_ctx->words_cur;
char *new_restore_file = restore_ctx->new_restore_file;
@ -260,16 +240,16 @@ void write_restore (hashcat_ctx_t *hashcat_ctx)
if (fp == NULL)
{
log_error ("ERROR: %s: %s", new_restore_file, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", new_restore_file, strerror (errno));
exit (-1);
return -1;
}
if (setvbuf (fp, NULL, _IONBF, 0))
{
log_error ("ERROR: setvbuf file '%s': %s", new_restore_file, strerror (errno));
event_log_error (hashcat_ctx, "setvbuf file '%s': %s", new_restore_file, strerror (errno));
exit (-1);
return -1;
}
fwrite (rd, sizeof (restore_data_t), 1, fp);
@ -286,18 +266,22 @@ void write_restore (hashcat_ctx_t *hashcat_ctx)
fsync (fileno (fp));
fclose (fp);
return 0;
}
void cycle_restore (hashcat_ctx_t *hashcat_ctx)
int cycle_restore (hashcat_ctx_t *hashcat_ctx)
{
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
if (restore_ctx->enabled == false) return;
if (restore_ctx->enabled == false) return 0;
const char *eff_restore_file = restore_ctx->eff_restore_file;
const char *new_restore_file = restore_ctx->new_restore_file;
write_restore (hashcat_ctx);
const int rc_write_restore = write_restore (hashcat_ctx);
if (rc_write_restore == -1) return -1;
struct stat st;
@ -305,14 +289,16 @@ void cycle_restore (hashcat_ctx_t *hashcat_ctx)
{
if (unlink (eff_restore_file))
{
log_info ("WARN: Unlink file '%s': %s", eff_restore_file, strerror (errno));
event_log_warning (hashcat_ctx, "Unlink file '%s': %s", eff_restore_file, strerror (errno));
}
}
if (rename (new_restore_file, eff_restore_file))
{
log_info ("WARN: Rename file '%s' to '%s': %s", new_restore_file, eff_restore_file, strerror (errno));
event_log_warning (hashcat_ctx, "Rename file '%s' to '%s': %s", new_restore_file, eff_restore_file, strerror (errno));
}
return 0;
}
void unlink_restore (hashcat_ctx_t *hashcat_ctx)
@ -320,6 +306,8 @@ void unlink_restore (hashcat_ctx_t *hashcat_ctx)
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
if (restore_ctx->enabled == false) return;
if ((status_ctx->devices_status == STATUS_EXHAUSTED) && (status_ctx->run_thread_level1 == true)) // this is to check for [c]heckpoint
{
unlink (restore_ctx->eff_restore_file);
@ -333,44 +321,6 @@ void unlink_restore (hashcat_ctx_t *hashcat_ctx)
}
}
void stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx)
{
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
// this feature only makes sense if --restore-disable was not specified
if (restore_ctx->enabled == false)
{
log_info ("WARNING: This feature is disabled when --restore-disable is specified");
return;
}
if (status_ctx->devices_status != STATUS_RUNNING) return;
if ((status_ctx->run_thread_level1 == true) && (status_ctx->run_thread_level2 == true))
{
status_ctx->run_main_level1 = false;
status_ctx->run_main_level2 = false;
status_ctx->run_main_level3 = false;
status_ctx->run_thread_level1 = false;
status_ctx->run_thread_level2 = true;
log_info ("Checkpoint enabled: Will quit at next Restore Point update");
}
else
{
status_ctx->run_main_level1 = true;
status_ctx->run_main_level2 = true;
status_ctx->run_main_level3 = true;
status_ctx->run_thread_level1 = true;
status_ctx->run_thread_level2 = true;
log_info ("Checkpoint disabled: Restore Point updates will no longer be monitored");
}
}
int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
{
folder_config_t *folder_config = hashcat_ctx->folder_config;
@ -379,8 +329,22 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
restore_ctx->enabled = false;
char *eff_restore_file = (char *) mymalloc (HCBUFSIZ_TINY);
char *new_restore_file = (char *) mymalloc (HCBUFSIZ_TINY);
if (user_options->benchmark == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->opencl_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->speed_only == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->restore_disable == true) return 0;
if (argc == 0) return 0;
if (argv == NULL) return 0;
char *eff_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (eff_restore_file);
char *new_restore_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (new_restore_file);
snprintf (eff_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore", folder_config->session_dir, user_options->session);
snprintf (new_restore_file, HCBUFSIZ_TINY - 1, "%s/%s.restore.new", folder_config->session_dir, user_options->session);
@ -391,32 +355,23 @@ int restore_ctx_init (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
restore_ctx->eff_restore_file = eff_restore_file;
restore_ctx->new_restore_file = new_restore_file;
init_restore (hashcat_ctx);
const int rc_init_restore = init_restore (hashcat_ctx);
if (argc == 0) return 0;
if (argv == NULL) return 0;
if (user_options->benchmark == true) return 0;
if (user_options->keyspace == true) return 0;
if (user_options->left == true) return 0;
if (user_options->opencl_info == true) return 0;
if (user_options->show == true) return 0;
if (user_options->stdout_flag == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
if (user_options->restore_disable == true) return 0;
if (rc_init_restore == -1) return -1;
restore_ctx->enabled = true;
if (user_options->restore == true)
{
read_restore (hashcat_ctx);
const int rc_read_restore = read_restore (hashcat_ctx);
if (rc_read_restore == -1) return -1;
restore_data_t *rd = restore_ctx->rd;
if (rd->version < RESTORE_VERSION_MIN)
{
log_error ("ERROR: Incompatible restore-file version");
event_log_error (hashcat_ctx, "Incompatible restore-file version");
return -1;
}
@ -441,12 +396,12 @@ void restore_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
{
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
myfree (restore_ctx->eff_restore_file);
myfree (restore_ctx->new_restore_file);
myfree (restore_ctx->rd);
if (restore_ctx->enabled == false) return;
hcfree (restore_ctx->eff_restore_file);
hcfree (restore_ctx->new_restore_file);
hcfree (restore_ctx->rd);
memset (restore_ctx, 0, sizeof (restore_ctx_t));
}

View File

@ -10,7 +10,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "shared.h"
#include "filehandling.h"
#include "rp.h"
@ -728,12 +728,12 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
if (user_options->rp_files_cnt)
{
all_kernel_rules_cnt = (u32 *) mycalloc (user_options->rp_files_cnt, sizeof (u32));
all_kernel_rules_cnt = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (u32)); VERIFY_PTR (all_kernel_rules_cnt);
all_kernel_rules_buf = (kernel_rule_t **) mycalloc (user_options->rp_files_cnt, sizeof (kernel_rule_t *));
all_kernel_rules_buf = (kernel_rule_t **) hccalloc (hashcat_ctx, user_options->rp_files_cnt, sizeof (kernel_rule_t *)); VERIFY_PTR (all_kernel_rules_buf);
}
char *rule_buf = (char *) mymalloc (HCBUFSIZ_LARGE);
char *rule_buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (rule_buf);
int rule_len = 0;
@ -756,7 +756,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
if ((fp = fopen (rp_file, "rb")) == NULL)
{
log_error ("ERROR: %s: %s", rp_file, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", rp_file, strerror (errno));
return -1;
}
@ -773,7 +773,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
if (kernel_rules_avail == kernel_rules_cnt)
{
kernel_rules_buf = (kernel_rule_t *) myrealloc (kernel_rules_buf, kernel_rules_avail * sizeof (kernel_rule_t), INCR_RULES * sizeof (kernel_rule_t));
kernel_rules_buf = (kernel_rule_t *) hcrealloc (hashcat_ctx, kernel_rules_buf, kernel_rules_avail * sizeof (kernel_rule_t), INCR_RULES * sizeof (kernel_rule_t)); VERIFY_PTR (kernel_rules_buf);
kernel_rules_avail += INCR_RULES;
}
@ -785,14 +785,14 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
if (result == -1)
{
log_info ("WARNING: Skipping invalid or unsupported rule in file %s on line %u: %s", rp_file, rule_line, rule_buf);
event_log_warning (hashcat_ctx, "Skipping invalid or unsupported rule in file %s on line %u: %s", rp_file, rule_line, rule_buf);
continue;
}
if (cpu_rule_to_kernel_rule (rule_buf, rule_len, &kernel_rules_buf[kernel_rules_cnt]) == -1)
{
log_info ("WARNING: Cannot convert rule for use on OpenCL device in file %s on line %u: %s", rp_file, rule_line, rule_buf);
event_log_warning (hashcat_ctx, "Cannot convert rule for use on OpenCL device in file %s on line %u: %s", rp_file, rule_line, rule_buf);
memset (&kernel_rules_buf[kernel_rules_cnt], 0, sizeof (kernel_rule_t)); // needs to be cleared otherwise we could have some remaining data
@ -808,7 +808,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
all_kernel_rules_buf[i] = kernel_rules_buf;
}
myfree (rule_buf);
hcfree (rule_buf);
/**
* merge rules
@ -816,7 +816,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
u32 kernel_rules_cnt = 1;
u32 *repeats = (u32 *) mycalloc (user_options->rp_files_cnt + 1, sizeof (u32));
u32 *repeats = (u32 *) hccalloc (hashcat_ctx, user_options->rp_files_cnt + 1, sizeof (u32)); VERIFY_PTR (repeats);
repeats[0] = kernel_rules_cnt;
@ -827,7 +827,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
repeats[i + 1] = kernel_rules_cnt;
}
kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) mycalloc (kernel_rules_cnt, sizeof (kernel_rule_t));
kernel_rule_t *kernel_rules_buf = (kernel_rule_t *) hccalloc (hashcat_ctx, kernel_rules_cnt, sizeof (kernel_rule_t)); VERIFY_PTR (kernel_rules_buf);
for (u32 i = 0; i < kernel_rules_cnt; i++)
{
@ -846,7 +846,7 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
{
if (out_pos == RULES_MAX - 1)
{
// log_info ("WARNING: Truncating chaining of rule %d and rule %d as maximum number of function calls per rule exceeded", i, in_off);
// event_log_warning (hashcat_ctx, "Truncating chaining of rule %d and rule %d as maximum number of function calls per rule exceeded", i, in_off);
break;
}
@ -856,17 +856,17 @@ int kernel_rules_load (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf, u32
}
}
myfree (repeats);
hcfree (repeats);
if (kernel_rules_cnt == 0)
{
log_error ("ERROR: No valid rules left");
event_log_error (hashcat_ctx, "No valid rules left");
return -1;
}
myfree (all_kernel_rules_cnt);
myfree (all_kernel_rules_buf);
hcfree (all_kernel_rules_cnt);
hcfree (all_kernel_rules_buf);
*out_cnt = kernel_rules_cnt;
*out_buf = kernel_rules_buf;
@ -879,9 +879,9 @@ int kernel_rules_generate (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf,
const user_options_t *user_options = hashcat_ctx->user_options;
u32 kernel_rules_cnt = 0;
kernel_rule_t *kernel_rules_buf = mycalloc (user_options->rp_gen, sizeof (kernel_rule_t));
kernel_rule_t *kernel_rules_buf = hccalloc (hashcat_ctx, user_options->rp_gen, sizeof (kernel_rule_t)); VERIFY_PTR (kernel_rules_buf);
char *rule_buf = (char *) mymalloc (RP_RULE_BUFSIZ);
char *rule_buf = (char *) hcmalloc (hashcat_ctx, RP_RULE_BUFSIZ); VERIFY_PTR (rule_buf);
for (kernel_rules_cnt = 0; kernel_rules_cnt < user_options->rp_gen; kernel_rules_cnt++)
{
@ -892,7 +892,7 @@ int kernel_rules_generate (hashcat_ctx_t *hashcat_ctx, kernel_rule_t **out_buf,
if (cpu_rule_to_kernel_rule (rule_buf, rule_len, &kernel_rules_buf[kernel_rules_cnt]) == -1) continue;
}
myfree (rule_buf);
hcfree (rule_buf);
*out_cnt = kernel_rules_cnt;
*out_buf = kernel_rules_buf;

View File

@ -3,9 +3,6 @@
* License.....: MIT
*/
#pragma GCC diagnostic ignored "-Wunused-parameter"
#pragma GCC diagnostic ignored "-Wunused-function"
#include "common.h"
#include "types.h"
#include "bitops.h"
@ -1069,7 +1066,7 @@ static void reverse_block (u32 in0[4], u32 in1[4], u32 out0[4], u32 out1[4], con
out1[3] = swap_workaround (tib41[3]);
}
static u32 rule_op_mangle_lrest (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_lrest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
buf0[0] |= (generate_cmask (buf0[0]));
buf0[1] |= (generate_cmask (buf0[1]));
@ -1083,7 +1080,7 @@ static u32 rule_op_mangle_lrest (const u32 p0, const u32 p1, u32 buf0[4], u32 bu
return in_len;
}
static u32 rule_op_mangle_urest (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_urest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
buf0[0] &= ~(generate_cmask (buf0[0]));
buf0[1] &= ~(generate_cmask (buf0[1]));
@ -1097,7 +1094,7 @@ static u32 rule_op_mangle_urest (const u32 p0, const u32 p1, u32 buf0[4], u32 bu
return in_len;
}
static u32 rule_op_mangle_lrest_ufirst (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_lrest_ufirst (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
rule_op_mangle_lrest (p0, p1, buf0, buf1, in_len);
@ -1106,7 +1103,7 @@ static u32 rule_op_mangle_lrest_ufirst (const u32 p0, const u32 p1, u32 buf0[4],
return in_len;
}
static u32 rule_op_mangle_urest_lfirst (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_urest_lfirst (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
rule_op_mangle_urest (p0, p1, buf0, buf1, in_len);
@ -1115,7 +1112,7 @@ static u32 rule_op_mangle_urest_lfirst (const u32 p0, const u32 p1, u32 buf0[4],
return in_len;
}
static u32 rule_op_mangle_trest (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_trest (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
buf0[0] ^= (generate_cmask (buf0[0]));
buf0[1] ^= (generate_cmask (buf0[1]));
@ -1129,7 +1126,7 @@ static u32 rule_op_mangle_trest (const u32 p0, const u32 p1, u32 buf0[4], u32 bu
return in_len;
}
static u32 rule_op_mangle_toggle_at (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_toggle_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 >= in_len) return (in_len);
@ -1150,14 +1147,14 @@ static u32 rule_op_mangle_toggle_at (const u32 p0, const u32 p1, u32 buf0[4], u3
return in_len;
}
static u32 rule_op_mangle_reverse (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_reverse (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
reverse_block (buf0, buf1, buf0, buf1, in_len);
return in_len;
}
static u32 rule_op_mangle_dupeword (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_dupeword (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if ((in_len + in_len) >= 32) return (in_len);
@ -1182,7 +1179,7 @@ static u32 rule_op_mangle_dupeword (const u32 p0, const u32 p1, u32 buf0[4], u32
return out_len;
}
static u32 rule_op_mangle_dupeword_times (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_dupeword_times (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (((in_len * p0) + in_len) >= 32) return (in_len);
@ -1210,7 +1207,7 @@ static u32 rule_op_mangle_dupeword_times (const u32 p0, const u32 p1, u32 buf0[4
return out_len;
}
static u32 rule_op_mangle_reflect (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_reflect (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if ((in_len + in_len) >= 32) return (in_len);
@ -1228,7 +1225,7 @@ static u32 rule_op_mangle_reflect (const u32 p0, const u32 p1, u32 buf0[4], u32
return out_len;
}
static u32 rule_op_mangle_append (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_append (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if ((in_len + 1) >= 32) return (in_len);
@ -1241,7 +1238,7 @@ static u32 rule_op_mangle_append (const u32 p0, const u32 p1, u32 buf0[4], u32 b
return out_len;
}
static u32 rule_op_mangle_prepend (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_prepend (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if ((in_len + 1) >= 32) return (in_len);
@ -1256,7 +1253,7 @@ static u32 rule_op_mangle_prepend (const u32 p0, const u32 p1, u32 buf0[4], u32
return out_len;
}
static u32 rule_op_mangle_rotate_left (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_rotate_left (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (in_len == 0) return (in_len);
@ -1283,7 +1280,7 @@ static u32 rule_op_mangle_rotate_left (const u32 p0, const u32 p1, u32 buf0[4],
return in_len;
}
static u32 rule_op_mangle_rotate_right (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_rotate_right (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (in_len == 0) return (in_len);
@ -1314,7 +1311,7 @@ static u32 rule_op_mangle_rotate_right (const u32 p0, const u32 p1, u32 buf0[4],
return in_len;
}
static u32 rule_op_mangle_delete_first (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_delete_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (in_len == 0) return (in_len);
@ -1325,7 +1322,7 @@ static u32 rule_op_mangle_delete_first (const u32 p0, const u32 p1, u32 buf0[4],
return in_len1;
}
static u32 rule_op_mangle_delete_last (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_delete_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (in_len == 0) return (in_len);
@ -1348,7 +1345,7 @@ static u32 rule_op_mangle_delete_last (const u32 p0, const u32 p1, u32 buf0[4],
return in_len1;
}
static u32 rule_op_mangle_delete_at (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_delete_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 >= in_len) return (in_len);
@ -1423,7 +1420,7 @@ static u32 rule_op_mangle_delete_at (const u32 p0, const u32 p1, u32 buf0[4], u3
return out_len;
}
static u32 rule_op_mangle_extract (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_extract (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 >= in_len) return (in_len);
@ -1438,7 +1435,7 @@ static u32 rule_op_mangle_extract (const u32 p0, const u32 p1, u32 buf0[4], u32
return out_len;
}
static u32 rule_op_mangle_omit (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_omit (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 >= in_len) return (in_len);
@ -1524,7 +1521,7 @@ static u32 rule_op_mangle_omit (const u32 p0, const u32 p1, u32 buf0[4], u32 buf
return out_len;
}
static u32 rule_op_mangle_insert (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_insert (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 > in_len) return (in_len);
@ -1596,7 +1593,7 @@ static u32 rule_op_mangle_insert (const u32 p0, const u32 p1, u32 buf0[4], u32 b
return out_len;
}
static u32 rule_op_mangle_overstrike (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_overstrike (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 >= in_len) return (in_len);
@ -1619,7 +1616,7 @@ static u32 rule_op_mangle_overstrike (const u32 p0, const u32 p1, u32 buf0[4], u
return in_len;
}
static u32 rule_op_mangle_truncate_at (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_truncate_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 >= in_len) return (in_len);
@ -1628,7 +1625,7 @@ static u32 rule_op_mangle_truncate_at (const u32 p0, const u32 p1, u32 buf0[4],
return p0;
}
static u32 rule_op_mangle_replace (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_replace (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
for (u32 i = 0; i < in_len; i++)
{
@ -1672,7 +1669,7 @@ static u32 rule_op_mangle_replace (const u32 p0, const u32 p1, u32 buf0[4], u32
return in_len;
}
static u32 rule_op_mangle_purgechar (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_purgechar (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
u32 out_len = 0;
@ -1714,14 +1711,14 @@ static u32 rule_op_mangle_purgechar (const u32 p0, const u32 p1, u32 buf0[4], u3
}
/*
static u32 rule_op_mangle_togglecase_rec (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_togglecase_rec (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
// TODO
return in_len;
}
*/
static u32 rule_op_mangle_dupechar_first (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_dupechar_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if ( in_len == 0) return (in_len);
if ((in_len + p0) >= 32) return (in_len);
@ -1908,7 +1905,7 @@ static u32 rule_op_mangle_dupechar_first (const u32 p0, const u32 p1, u32 buf0[4
return out_len;
}
static u32 rule_op_mangle_dupechar_last (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_dupechar_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if ( in_len == 0) return (in_len);
if ((in_len + p0) >= 32) return (in_len);
@ -1943,7 +1940,7 @@ static u32 rule_op_mangle_dupechar_last (const u32 p0, const u32 p1, u32 buf0[4]
return out_len;
}
static u32 rule_op_mangle_dupechar_all (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_dupechar_all (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if ( in_len == 0) return (in_len);
if ((in_len + in_len) >= 32) return (in_len);
@ -1976,7 +1973,7 @@ static u32 rule_op_mangle_dupechar_all (const u32 p0, const u32 p1, u32 buf0[4],
return out_len;
}
static u32 rule_op_mangle_switch_first (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_switch_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (in_len < 2) return (in_len);
@ -1985,7 +1982,7 @@ static u32 rule_op_mangle_switch_first (const u32 p0, const u32 p1, u32 buf0[4],
return in_len;
}
static u32 rule_op_mangle_switch_last (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_switch_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (in_len < 2) return (in_len);
@ -2070,7 +2067,7 @@ static u32 rule_op_mangle_switch_last (const u32 p0, const u32 p1, u32 buf0[4],
return in_len;
}
static u32 rule_op_mangle_switch_at (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_switch_at (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 >= in_len) return (in_len);
if (p1 >= in_len) return (in_len);
@ -2317,7 +2314,7 @@ static u32 rule_op_mangle_switch_at (const u32 p0, const u32 p1, u32 buf0[4], u3
return in_len;
}
static u32 rule_op_mangle_chr_shiftl (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_chr_shiftl (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 >= in_len) return (in_len);
@ -2339,7 +2336,7 @@ static u32 rule_op_mangle_chr_shiftl (const u32 p0, const u32 p1, u32 buf0[4], u
return in_len;
}
static u32 rule_op_mangle_chr_shiftr (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_chr_shiftr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 >= in_len) return (in_len);
@ -2361,7 +2358,7 @@ static u32 rule_op_mangle_chr_shiftr (const u32 p0, const u32 p1, u32 buf0[4], u
return in_len;
}
static u32 rule_op_mangle_chr_incr (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_chr_incr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 >= in_len) return (in_len);
@ -2385,7 +2382,7 @@ static u32 rule_op_mangle_chr_incr (const u32 p0, const u32 p1, u32 buf0[4], u32
return in_len;
}
static u32 rule_op_mangle_chr_decr (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_chr_decr (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 >= in_len) return (in_len);
@ -2409,7 +2406,7 @@ static u32 rule_op_mangle_chr_decr (const u32 p0, const u32 p1, u32 buf0[4], u32
return in_len;
}
static u32 rule_op_mangle_replace_np1 (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_replace_np1 (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if ((p0 + 1) >= in_len) return (in_len);
@ -2436,7 +2433,7 @@ static u32 rule_op_mangle_replace_np1 (const u32 p0, const u32 p1, u32 buf0[4],
return in_len;
}
static u32 rule_op_mangle_replace_nm1 (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_replace_nm1 (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 == 0) return (in_len);
@ -2465,7 +2462,7 @@ static u32 rule_op_mangle_replace_nm1 (const u32 p0, const u32 p1, u32 buf0[4],
return in_len;
}
static u32 rule_op_mangle_dupeblock_first (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_dupeblock_first (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 > in_len) return (in_len);
@ -2503,7 +2500,7 @@ static u32 rule_op_mangle_dupeblock_first (const u32 p0, const u32 p1, u32 buf0[
return out_len;
}
static u32 rule_op_mangle_dupeblock_last (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_dupeblock_last (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
if (p0 > in_len) return (in_len);
@ -2532,7 +2529,7 @@ static u32 rule_op_mangle_dupeblock_last (const u32 p0, const u32 p1, u32 buf0[4
return out_len;
}
static u32 rule_op_mangle_title (const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
static u32 rule_op_mangle_title (MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
buf0[0] |= (generate_cmask (buf0[0]));
buf0[1] |= (generate_cmask (buf0[1]));
@ -2653,7 +2650,7 @@ static u32 rule_op_mangle_title (const u32 p0, const u32 p1, u32 buf0[4], u32 bu
return in_len;
}
u32 apply_rule (const u32 name, const u32 p0, const u32 p1, u32 buf0[4], u32 buf1[4], const u32 in_len)
u32 apply_rule (const u32 name, MAYBE_UNUSED const u32 p0, MAYBE_UNUSED const u32 p1, MAYBE_UNUSED u32 buf0[4], MAYBE_UNUSED u32 buf1[4], const u32 in_len)
{
u32 out_len = in_len;
@ -2704,7 +2701,7 @@ u32 apply_rule (const u32 name, const u32 p0, const u32 p1, u32 buf0[4], u32 buf
return out_len;
}
u32 apply_rules (u32 *cmds, u32 buf0[4], u32 buf1[4], const u32 len)
u32 apply_rules (u32 *cmds, u32 buf0[4] MAYBE_UNUSED, u32 buf1[4] MAYBE_UNUSED, const u32 len)
{
u32 out_len = len;

View File

@ -99,7 +99,7 @@ void naive_escape (char *s, size_t s_max, const char key_char, const char escape
strncpy (s, s_escaped, s_max - 1);
}
void hc_sleep_ms (const u32 msec)
void hc_sleep_msec (const u32 msec)
{
#if defined (_WIN)
Sleep (msec);

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
#include "common.h"
#include "types.h"
#include "logging.h"
#include "event.h"
#include "locking.h"
#include "rp_kernel_on_cpu.h"
#include "mpsp.h"
@ -35,7 +35,7 @@ static void out_push (out_t *out, const u8 *pw_buf, const int pw_len)
}
}
void process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt)
int process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 pws_cnt)
{
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
@ -56,11 +56,13 @@ void process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
{
if ((out.fp = fopen (filename, "ab")) != NULL)
{
lock_file (out.fp);
const int rc = lock_file (out.fp);
if (rc == -1) return -1;
}
else
{
log_error ("ERROR: %s: %s", filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno));
out.fp = stdout;
}
@ -82,7 +84,9 @@ void process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
for (u32 gidvid = 0; gidvid < pws_cnt; gidvid++)
{
gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
if (rc == -1) return -1;
const u32 pos = device_param->innerloop_pos;
@ -109,7 +113,9 @@ void process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
for (u32 gidvid = 0; gidvid < pws_cnt; gidvid++)
{
gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
if (rc == -1) return -1;
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
{
@ -175,7 +181,9 @@ void process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
for (u32 gidvid = 0; gidvid < pws_cnt; gidvid++)
{
gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
if (rc == -1) return -1;
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
{
@ -205,7 +213,9 @@ void process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
for (u32 gidvid = 0; gidvid < pws_cnt; gidvid++)
{
gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw);
if (rc == -1) return -1;
for (u32 il_pos = 0; il_pos < il_cnt; il_pos++)
{
@ -240,4 +250,6 @@ void process_stdout (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
fclose (out.fp);
}
return 0;
}

View File

@ -10,7 +10,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "logfile.h"
#include "shared.h"
#include "filehandling.h"
@ -20,18 +20,22 @@
#include "straight.h"
#include "wordlist.h"
static void straight_ctx_add_wl (straight_ctx_t *straight_ctx, const char *dict)
static int straight_ctx_add_wl (hashcat_ctx_t *hashcat_ctx, const char *dict)
{
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
if (straight_ctx->dicts_avail == straight_ctx->dicts_cnt)
{
straight_ctx->dicts = (char **) myrealloc (straight_ctx->dicts, straight_ctx->dicts_avail * sizeof (char *), INCR_DICTS * sizeof (char *));
straight_ctx->dicts = (char **) hcrealloc (hashcat_ctx, straight_ctx->dicts, straight_ctx->dicts_avail * sizeof (char *), INCR_DICTS * sizeof (char *)); VERIFY_PTR (straight_ctx->dicts);
straight_ctx->dicts_avail += INCR_DICTS;
}
straight_ctx->dicts[straight_ctx->dicts_cnt] = mystrdup (dict);
straight_ctx->dicts[straight_ctx->dicts_cnt] = hcstrdup (hashcat_ctx, dict); VERIFY_PTR (straight_ctx->dicts[straight_ctx->dicts_cnt]);
straight_ctx->dicts_cnt++;
return 0;
}
int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
@ -69,7 +73,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
if (fd2 == NULL)
{
log_error ("ERROR: %s: %s", straight_ctx->dict, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", straight_ctx->dict, strerror (errno));
return -1;
}
@ -97,7 +101,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
if (fd2 == NULL)
{
log_error ("ERROR: %s: %s", combinator_ctx->dict1, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict1, strerror (errno));
return -1;
}
@ -112,7 +116,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
if (fd2 == NULL)
{
log_error ("ERROR: %s: %s", combinator_ctx->dict2, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno));
return -1;
}
@ -151,7 +155,7 @@ int straight_ctx_update_loop (hashcat_ctx_t *hashcat_ctx)
if (fd2 == NULL)
{
log_error ("ERROR: %s: %s", straight_ctx->dict, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", straight_ctx->dict, strerror (errno));
return -1;
}
@ -196,7 +200,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0))
{
straight_ctx->kernel_rules_buf = (kernel_rule_t *) mymalloc (sizeof (kernel_rule_t));
straight_ctx->kernel_rules_buf = (kernel_rule_t *) hcmalloc (hashcat_ctx, sizeof (kernel_rule_t)); VERIFY_PTR (straight_ctx->kernel_rules_buf);
straight_ctx->kernel_rules_buf[0].cmds[0] = RULE_OP_MANGLE_NOOP;
@ -272,7 +276,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (stat (l0_filename, &l0_stat) == -1)
{
log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", l0_filename, strerror (errno));
return -1;
}
@ -281,7 +285,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
{
char **dictionary_files = NULL;
dictionary_files = scan_directory (l0_filename);
dictionary_files = scan_directory (hashcat_ctx, l0_filename);
if (dictionary_files != NULL)
{
@ -295,29 +299,33 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (stat (l1_filename, &l1_stat) == -1)
{
log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", l1_filename, strerror (errno));
return -1;
}
if (S_ISREG (l1_stat.st_mode))
{
straight_ctx_add_wl (straight_ctx, l1_filename);
const int rc = straight_ctx_add_wl (hashcat_ctx, l1_filename);
if (rc == -1) return -1;
}
}
}
myfree (dictionary_files);
hcfree (dictionary_files);
}
else
{
straight_ctx_add_wl (straight_ctx, l0_filename);
const int rc = straight_ctx_add_wl (hashcat_ctx, l0_filename);
if (rc == -1) return -1;
}
}
if (straight_ctx->dicts_cnt == 0)
{
log_error ("ERROR: No usable dictionary file found.");
event_log_error (hashcat_ctx, "No usable dictionary file found.");
return -1;
}
@ -341,7 +349,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (stat (l0_filename, &l0_stat) == -1)
{
log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", l0_filename, strerror (errno));
return -1;
}
@ -350,7 +358,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
{
char **dictionary_files = NULL;
dictionary_files = scan_directory (l0_filename);
dictionary_files = scan_directory (hashcat_ctx, l0_filename);
if (dictionary_files != NULL)
{
@ -364,29 +372,33 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (stat (l1_filename, &l1_stat) == -1)
{
log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", l1_filename, strerror (errno));
return -1;
}
if (S_ISREG (l1_stat.st_mode))
{
straight_ctx_add_wl (straight_ctx, l1_filename);
const int rc = straight_ctx_add_wl (hashcat_ctx, l1_filename);
if (rc == -1) return -1;
}
}
}
myfree (dictionary_files);
hcfree (dictionary_files);
}
else
{
straight_ctx_add_wl (straight_ctx, l0_filename);
const int rc = straight_ctx_add_wl (hashcat_ctx, l0_filename);
if (rc == -1) return -1;
}
}
if (straight_ctx->dicts_cnt == 0)
{
log_error ("ERROR: No usable dictionary file found.");
event_log_error (hashcat_ctx, "No usable dictionary file found.");
return -1;
}
@ -401,7 +413,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (stat (l0_filename, &l0_stat) == -1)
{
log_error ("ERROR: %s: %s", l0_filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", l0_filename, strerror (errno));
return -1;
}
@ -410,7 +422,7 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
{
char **dictionary_files = NULL;
dictionary_files = scan_directory (l0_filename);
dictionary_files = scan_directory (hashcat_ctx, l0_filename);
if (dictionary_files != NULL)
{
@ -424,29 +436,33 @@ int straight_ctx_init (hashcat_ctx_t *hashcat_ctx)
if (stat (l1_filename, &l1_stat) == -1)
{
log_error ("ERROR: %s: %s", l1_filename, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", l1_filename, strerror (errno));
return -1;
}
if (S_ISREG (l1_stat.st_mode))
{
straight_ctx_add_wl (straight_ctx, l1_filename);
const int rc = straight_ctx_add_wl (hashcat_ctx, l1_filename);
if (rc == -1) return -1;
}
}
}
myfree (dictionary_files);
hcfree (dictionary_files);
}
else
{
straight_ctx_add_wl (straight_ctx, l0_filename);
const int rc = straight_ctx_add_wl (hashcat_ctx, l0_filename);
if (rc == -1) return -1;
}
}
if (straight_ctx->dicts_cnt == 0)
{
log_error ("ERROR: No usable dictionary file found.");
event_log_error (hashcat_ctx, "No usable dictionary file found.");
return -1;
}
@ -463,12 +479,12 @@ void straight_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
for (u32 dict_pos = 0; dict_pos < straight_ctx->dicts_cnt; dict_pos++)
{
myfree (straight_ctx->dicts[dict_pos]);
hcfree (straight_ctx->dicts[dict_pos]);
}
myfree (straight_ctx->dicts);
hcfree (straight_ctx->dicts);
myfree (straight_ctx->kernel_rules_buf);
hcfree (straight_ctx->kernel_rules_buf);
memset (straight_ctx, 0, sizeof (straight_ctx_t));
}

View File

@ -5,13 +5,19 @@
#include "common.h"
#include "types.h"
#include "logging.h"
#include "memory.h"
#include "event.h"
#include "convert.h"
#include "thread.h"
#include "timer.h"
#include "status.h"
#include "restore.h"
#include "shared.h"
#include "hwmon.h"
#include "interface.h"
#include "outfile.h"
#include "terminal.h"
#include "hashcat.h"
const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint [q]uit => ";
@ -29,23 +35,28 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const
{
if (user_options->machine_readable == false)
{
log_info ("%s (%s) starting in benchmark-mode...", PROGNAME, version_tag);
log_info ("");
event_log_info (hashcat_ctx, "%s (%s) starting in benchmark mode...", PROGNAME, version_tag);
event_log_info (hashcat_ctx, "");
}
else
{
log_info ("# %s (%s) %s", PROGNAME, version_tag, ctime (&proc_start));
event_log_info (hashcat_ctx, "# %s (%s) %s", PROGNAME, version_tag, ctime (&proc_start));
}
}
else if (user_options->restore == true)
{
log_info ("%s (%s) starting in restore-mode...", PROGNAME, version_tag);
log_info ("");
event_log_info (hashcat_ctx, "%s (%s) starting in restore mode...", PROGNAME, version_tag);
event_log_info (hashcat_ctx, "");
}
else if (user_options->speed_only == true)
{
event_log_info (hashcat_ctx, "%s (%s) starting in speed-only mode...", PROGNAME, version_tag);
event_log_info (hashcat_ctx, "");
}
else
{
log_info ("%s (%s) starting...", PROGNAME, version_tag);
log_info ("");
event_log_info (hashcat_ctx, "%s (%s) starting...", PROGNAME, version_tag);
event_log_info (hashcat_ctx, "");
}
}
@ -59,32 +70,32 @@ void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const
if (user_options->show == true) return;
if (user_options->left == true) return;
log_info_nn ("Started: %s", ctime (&proc_start));
log_info_nn ("Stopped: %s", ctime (&proc_stop));
event_log_info_nn (hashcat_ctx, "Started: %s", ctime (&proc_start));
event_log_info_nn (hashcat_ctx, "Stopped: %s", ctime (&proc_stop));
}
int setup_console ()
int setup_console (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx)
{
#if defined (_WIN)
SetConsoleWindowSize (132);
if (_setmode (_fileno (stdin), _O_BINARY) == -1)
{
log_error ("ERROR: %s: %s", "stdin", strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", "stdin", strerror (errno));
return -1;
}
if (_setmode (_fileno (stdout), _O_BINARY) == -1)
{
log_error ("ERROR: %s: %s", "stdout", strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", "stdout", strerror (errno));
return -1;
}
if (_setmode (_fileno (stderr), _O_BINARY) == -1)
{
log_error ("ERROR: %s: %s", "stderr", strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", "stderr", strerror (errno));
return -1;
}
@ -120,7 +131,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx)
user_options_t *user_options = hashcat_ctx->user_options;
// 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);
while (status_ctx->devices_status == STATUS_INIT) hc_sleep_msec (100);
const bool quiet = user_options->quiet;
@ -141,7 +152,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx)
hc_thread_mutex_lock (status_ctx->mux_display);
log_info ("");
event_log_info (hashcat_ctx, "");
switch (ch)
{
@ -149,11 +160,11 @@ static void keypress (hashcat_ctx_t *hashcat_ctx)
case '\r':
case '\n':
log_info ("");
event_log_info (hashcat_ctx, "");
status_display (hashcat_ctx);
log_info ("");
event_log_info (hashcat_ctx, "");
if (quiet == false) send_prompt ();
@ -161,11 +172,13 @@ static void keypress (hashcat_ctx_t *hashcat_ctx)
case 'b':
log_info ("");
event_log_info (hashcat_ctx, "");
bypass (status_ctx);
bypass (hashcat_ctx);
log_info ("");
event_log_info (hashcat_ctx, "Next dictionary / mask in queue selected, bypassing current one");
event_log_info (hashcat_ctx, "");
if (quiet == false) send_prompt ();
@ -173,11 +186,16 @@ static void keypress (hashcat_ctx_t *hashcat_ctx)
case 'p':
log_info ("");
event_log_info (hashcat_ctx, "");
SuspendThreads (status_ctx);
SuspendThreads (hashcat_ctx);
log_info ("");
if (status_ctx->devices_status == STATUS_PAUSED)
{
event_log_info (hashcat_ctx, "Paused");
}
event_log_info (hashcat_ctx, "");
if (quiet == false) send_prompt ();
@ -185,11 +203,16 @@ static void keypress (hashcat_ctx_t *hashcat_ctx)
case 'r':
log_info ("");
event_log_info (hashcat_ctx, "");
ResumeThreads (status_ctx);
ResumeThreads (hashcat_ctx);
log_info ("");
if (status_ctx->devices_status == STATUS_RUNNING)
{
event_log_info (hashcat_ctx, "Resumed");
}
event_log_info (hashcat_ctx, "");
if (quiet == false) send_prompt ();
@ -197,11 +220,11 @@ static void keypress (hashcat_ctx_t *hashcat_ctx)
case 'c':
log_info ("");
event_log_info (hashcat_ctx, "");
stop_at_checkpoint (hashcat_ctx);
log_info ("");
event_log_info (hashcat_ctx, "");
if (quiet == false) send_prompt ();
@ -209,9 +232,9 @@ static void keypress (hashcat_ctx_t *hashcat_ctx)
case 'q':
log_info ("");
event_log_info (hashcat_ctx, "");
myabort (status_ctx);
myquit (hashcat_ctx);
break;
}
@ -422,3 +445,466 @@ int tty_fix()
return 0;
}
#endif
void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t));
const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status);
if (rc_status == -1)
{
hcfree (hashcat_status);
return;
}
printf ("STATUS\t%u\t", hashcat_status->status_number);
printf ("SPEED\t");
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (device_info->skipped_dev == true) continue;
printf ("%" PRIu64 "\t", (u64) device_info->hashes_msec_dev);
// that 1\t is for backward compatibility
printf ("1\t");
}
printf ("EXEC_RUNTIME\t");
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (device_info->skipped_dev == true) continue;
printf ("%f\t", device_info->exec_msec_dev);
}
printf ("CURKU\t%" PRIu64 "\t", hashcat_status->restore_point);
printf ("PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip);
printf ("RECHASH\t%u\t%u\t", hashcat_status->digests_done, hashcat_status->digests_cnt);
printf ("RECSALT\t%u\t%u\t", hashcat_status->salts_done, hashcat_status->salts_cnt);
if (user_options->gpu_temp_disable == false)
{
printf ("TEMP\t");
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (device_info->skipped_dev == true) continue;
// ok, little cheat here...
const int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id);
printf ("%d\t", temp);
}
}
printf (EOL);
fflush (stdout);
hcfree (hashcat_status);
}
void status_display (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->machine_readable == true)
{
status_display_machine_readable (hashcat_ctx);
return;
}
hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t));
const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status);
if (rc_status == -1)
{
hcfree (hashcat_status);
return;
}
/**
* show something
*/
event_log_info (hashcat_ctx,
"Session........: %s",
hashcat_status->session);
event_log_info (hashcat_ctx,
"Status.........: %s",
hashcat_status->status_string);
event_log_info (hashcat_ctx,
"Hash.Type......: %s",
hashcat_status->hash_type);
event_log_info (hashcat_ctx,
"Hash.Target....: %s",
hashcat_status->hash_target);
event_log_info (hashcat_ctx,
"Time.Started...: %s (%s)",
hashcat_status->time_started_absolute,
hashcat_status->time_started_relative);
event_log_info (hashcat_ctx,
"Time.Estimated.: %s (%s)",
hashcat_status->time_estimated_absolute,
hashcat_status->time_estimated_relative);
switch (hashcat_status->input_mode)
{
case INPUT_MODE_STRAIGHT_FILE:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s)",
hashcat_status->input_base);
break;
case INPUT_MODE_STRAIGHT_FILE_RULES_FILE:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s)",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: Rules (%s)",
hashcat_status->input_mod);
break;
case INPUT_MODE_STRAIGHT_FILE_RULES_GEN:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s)",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: Rules (Generated)");
break;
case INPUT_MODE_STRAIGHT_STDIN:
event_log_info (hashcat_ctx,
"Input.Base.....: Pipe");
break;
case INPUT_MODE_STRAIGHT_STDIN_RULES_FILE:
event_log_info (hashcat_ctx,
"Input.Base.....: Pipe");
event_log_info (hashcat_ctx,
"Input.Mod......: Rules (%s)",
hashcat_status->input_mod);
break;
case INPUT_MODE_STRAIGHT_STDIN_RULES_GEN:
event_log_info (hashcat_ctx,
"Input.Base.....: Pipe");
event_log_info (hashcat_ctx,
"Input.Mod......: Rules (Generated)");
break;
case INPUT_MODE_COMBINATOR_BASE_LEFT:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s), Left Side",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: File (%s), Right Side",
hashcat_status->input_mod);
break;
case INPUT_MODE_COMBINATOR_BASE_RIGHT:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s), Right Side",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: File (%s), Left Side",
hashcat_status->input_mod);
break;
case INPUT_MODE_MASK:
event_log_info (hashcat_ctx,
"Input.Mask.....: %s",
hashcat_status->input_base);
break;
case INPUT_MODE_MASK_CS:
event_log_info (hashcat_ctx,
"Input.Mask.....: %s",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Charset..: %s",
hashcat_status->input_charset);
break;
case INPUT_MODE_HYBRID1:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s), Left Side",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: Mask (%s), Right Side",
hashcat_status->input_mod);
break;
case INPUT_MODE_HYBRID1_CS:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s), Left Side",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: Mask (%s), Right Side",
hashcat_status->input_mod);
event_log_info (hashcat_ctx,
"Input.Charset..: %s",
hashcat_status->input_charset);
break;
case INPUT_MODE_HYBRID2:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s), Right Side",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: Mask (%s), Left Side",
hashcat_status->input_mod);
break;
case INPUT_MODE_HYBRID2_CS:
event_log_info (hashcat_ctx,
"Input.Base.....: File (%s), Right Side",
hashcat_status->input_base);
event_log_info (hashcat_ctx,
"Input.Mod......: Mask (%s), Left Side",
hashcat_status->input_mod);
event_log_info (hashcat_ctx,
"Input.Charset..: %s",
hashcat_status->input_charset);
break;
}
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (device_info->skipped_dev == true) continue;
event_log_info (hashcat_ctx,
"Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1,
device_info->speed_sec_dev,
device_info->exec_msec_dev);
}
if (hashcat_status->device_info_active > 1)
{
event_log_info (hashcat_ctx,
"Speed.Dev.#*...: %9sH/s",
hashcat_status->speed_sec_all);
}
event_log_info (hashcat_ctx,
"Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts",
hashcat_status->digests_done,
hashcat_status->digests_cnt,
hashcat_status->digests_percent,
hashcat_status->salts_done,
hashcat_status->salts_cnt,
hashcat_status->salts_percent);
event_log_info (hashcat_ctx,
"Recovered/Time.: %s",
hashcat_status->cpt);
switch (hashcat_status->progress_mode)
{
case PROGRESS_MODE_KEYSPACE_KNOWN:
event_log_info (hashcat_ctx,
"Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)",
hashcat_status->progress_cur_relative_skip,
hashcat_status->progress_end_relative_skip,
hashcat_status->progress_finished_percent);
event_log_info (hashcat_ctx,
"Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)",
hashcat_status->progress_rejected,
hashcat_status->progress_cur_relative_skip,
hashcat_status->progress_rejected_percent);
event_log_info (hashcat_ctx,
"Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)",
hashcat_status->restore_point,
hashcat_status->restore_total,
hashcat_status->restore_percent);
break;
case PROGRESS_MODE_KEYSPACE_UNKNOWN:
event_log_info (hashcat_ctx,
"Progress.......: %" PRIu64,
hashcat_status->progress_cur_relative_skip);
event_log_info (hashcat_ctx,
"Rejected.......: %" PRIu64,
hashcat_status->progress_rejected);
event_log_info (hashcat_ctx,
"Restore.Point..: %" PRIu64,
hashcat_status->restore_point);
break;
}
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (device_info->skipped_dev == true) continue;
event_log_info (hashcat_ctx,
"Candidates.#%d..: %s", device_id + 1,
device_info->input_candidates_dev);
}
if (user_options->gpu_temp_disable == false)
{
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (device_info->skipped_dev == true) continue;
event_log_info (hashcat_ctx,
"HWMon.Dev.#%d...: %s", device_id + 1,
device_info->hwmon_dev);
}
}
hcfree (hashcat_status);
}
void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx)
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
const u32 hash_mode = hashconfig->hash_mode;
hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t));
const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status);
if (rc_status == -1)
{
hcfree (hashcat_status);
return;
}
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (device_info->skipped_dev == true) continue;
event_log_info (hashcat_ctx, "%u:%u:%" PRIu64, device_id + 1, hash_mode, (u64) (device_info->hashes_msec_dev_benchmark * 1000));
}
hcfree (hashcat_status);
}
void status_benchmark (hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
if (user_options->machine_readable == true)
{
status_benchmark_automate (hashcat_ctx);
return;
}
hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t));
const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status);
if (rc_status == -1)
{
hcfree (hashcat_status);
return;
}
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (device_info->skipped_dev == true) continue;
event_log_info (hashcat_ctx,
"Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1,
device_info->speed_sec_dev,
device_info->exec_msec_dev);
}
if (hashcat_status->device_info_active > 1)
{
event_log_info (hashcat_ctx,
"Speed.Dev.#*...: %9sH/s",
hashcat_status->speed_sec_all);
}
hcfree (hashcat_status);
}

View File

@ -6,7 +6,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "timer.h"
#include "shared.h"
#include "thread.h"
@ -116,8 +116,10 @@ void hc_signal (void (callback) (int))
#endif
*/
void mycracked (status_ctx_t *status_ctx)
int mycracked (hashcat_ctx_t *hashcat_ctx)
{
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
//if (status_ctx->devices_status != STATUS_RUNNING) return;
status_ctx->devices_status = STATUS_CRACKED;
@ -127,11 +129,16 @@ void mycracked (status_ctx_t *status_ctx)
status_ctx->run_main_level3 = false;
status_ctx->run_thread_level1 = false;
status_ctx->run_thread_level2 = false;
return 0;
}
void myabort (status_ctx_t *status_ctx)
int myabort (hashcat_ctx_t *hashcat_ctx)
{
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
//those checks create problems in benchmark mode, it's simply too short of a timeframe where it's running as STATUS_RUNNING
// not sure if this is still valid, but abort is also called by gpu temp monitor
//if (status_ctx->devices_status != STATUS_RUNNING) return;
status_ctx->devices_status = STATUS_ABORTED;
@ -141,11 +148,15 @@ void myabort (status_ctx_t *status_ctx)
status_ctx->run_main_level3 = false;
status_ctx->run_thread_level1 = false;
status_ctx->run_thread_level2 = false;
return 0;
}
void myquit (status_ctx_t *status_ctx)
int myquit (hashcat_ctx_t *hashcat_ctx)
{
//if (status_ctx->devices_status != STATUS_RUNNING) return;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
if (status_ctx->devices_status != STATUS_RUNNING) return -1;
status_ctx->devices_status = STATUS_QUIT;
@ -154,11 +165,15 @@ void myquit (status_ctx_t *status_ctx)
status_ctx->run_main_level3 = false;
status_ctx->run_thread_level1 = false;
status_ctx->run_thread_level2 = false;
return 0;
}
void bypass (status_ctx_t *status_ctx)
int bypass (hashcat_ctx_t *hashcat_ctx)
{
//if (status_ctx->devices_status != STATUS_RUNNING) return;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
if (status_ctx->devices_status != STATUS_RUNNING) return -1;
status_ctx->devices_status = STATUS_BYPASS;
@ -168,29 +183,76 @@ void bypass (status_ctx_t *status_ctx)
status_ctx->run_thread_level1 = false;
status_ctx->run_thread_level2 = false;
log_info ("Next dictionary / mask in queue selected, bypassing current one");
return 0;
}
void SuspendThreads (status_ctx_t *status_ctx)
int SuspendThreads (hashcat_ctx_t *hashcat_ctx)
{
if (status_ctx->devices_status != STATUS_RUNNING) return;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
if (status_ctx->devices_status != STATUS_RUNNING) return -1;
hc_timer_set (&status_ctx->timer_paused);
status_ctx->devices_status = STATUS_PAUSED;
log_info ("Paused");
return 0;
}
void ResumeThreads (status_ctx_t *status_ctx)
int ResumeThreads (hashcat_ctx_t *hashcat_ctx)
{
if (status_ctx->devices_status != STATUS_PAUSED) return;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
double ms_paused = hc_timer_get (status_ctx->timer_paused);
if (status_ctx->devices_status != STATUS_PAUSED) return -1;
status_ctx->ms_paused += ms_paused;
const double msec_paused = hc_timer_get (status_ctx->timer_paused);
status_ctx->msec_paused += msec_paused;
status_ctx->devices_status = STATUS_RUNNING;
log_info ("Resumed");
return 0;
}
int stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx)
{
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
if (status_ctx->devices_status != STATUS_RUNNING) return -1;
// this feature only makes sense if --restore-disable was not specified
restore_ctx_t *restore_ctx = hashcat_ctx->restore_ctx;
if (restore_ctx->enabled == false)
{
event_log_warning (hashcat_ctx, "This feature is disabled when --restore-disable is specified");
return -1;
}
// Enable or Disable
if ((status_ctx->run_thread_level1 == true) && (status_ctx->run_thread_level2 == true))
{
status_ctx->run_main_level1 = false;
status_ctx->run_main_level2 = false;
status_ctx->run_main_level3 = false;
status_ctx->run_thread_level1 = false;
status_ctx->run_thread_level2 = true;
event_log_info (hashcat_ctx, "Checkpoint enabled: Will quit at next Restore Point update");
}
else
{
status_ctx->run_main_level1 = true;
status_ctx->run_main_level2 = true;
status_ctx->run_main_level3 = true;
status_ctx->run_thread_level1 = true;
status_ctx->run_thread_level2 = true;
event_log_info (hashcat_ctx, "Checkpoint disabled: Restore Point updates will no longer be monitored");
}
return 0;
}

View File

@ -7,7 +7,7 @@
#include "types.h"
#include "interface.h"
#include "timer.h"
#include "logging.h"
#include "event.h"
#include "memory.h"
#include "filehandling.h"
#include "ext_OpenCL.h"
@ -67,7 +67,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
tuning_db->enabled = true;
char *tuning_db_file = (char *) mymalloc (HCBUFSIZ_TINY);
char *tuning_db_file = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_TINY); VERIFY_PTR (tuning_db_file);
snprintf (tuning_db_file, HCBUFSIZ_TINY - 1, "%s/%s", folder_config->shared_dir, TUNING_DB_FILE);
@ -75,28 +75,28 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
if (fp == NULL)
{
log_error ("%s: %s", tuning_db_file, strerror (errno));
event_log_error (hashcat_ctx, "%s: %s", tuning_db_file, strerror (errno));
return -1;
}
myfree (tuning_db_file);
hcfree (tuning_db_file);
int num_lines = count_lines (fp);
int num_lines = count_lines (hashcat_ctx, fp);
// a bit over-allocated
tuning_db->alias_buf = (tuning_db_alias_t *) mycalloc (num_lines + 1, sizeof (tuning_db_alias_t));
tuning_db->alias_buf = (tuning_db_alias_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_alias_t)); VERIFY_PTR (tuning_db->alias_buf);
tuning_db->alias_cnt = 0;
tuning_db->entry_buf = (tuning_db_entry_t *) mycalloc (num_lines + 1, sizeof (tuning_db_entry_t));
tuning_db->entry_buf = (tuning_db_entry_t *) hccalloc (hashcat_ctx, num_lines + 1, sizeof (tuning_db_entry_t)); VERIFY_PTR (tuning_db->entry_buf);
tuning_db->entry_cnt = 0;
rewind (fp);
int line_num = 0;
char *buf = (char *) mymalloc (HCBUFSIZ_LARGE);
char *buf = (char *) hcmalloc (hashcat_ctx, HCBUFSIZ_LARGE); VERIFY_PTR (buf);
while (!feof (fp))
{
@ -138,8 +138,8 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
tuning_db_alias_t *alias = &tuning_db->alias_buf[tuning_db->alias_cnt];
alias->device_name = mystrdup (device_name);
alias->alias_name = mystrdup (alias_name);
alias->device_name = hcstrdup (hashcat_ctx, device_name);
alias->alias_name = hcstrdup (hashcat_ctx, alias_name);
tuning_db->alias_cnt++;
}
@ -150,7 +150,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
(token_ptr[1][0] != '3') &&
(token_ptr[1][0] != '*'))
{
log_info ("WARNING: Tuning-db: Invalid attack_mode '%c' in Line '%u'", token_ptr[1][0], line_num);
event_log_warning (hashcat_ctx, "Tuning-db: Invalid attack_mode '%c' in Line '%u'", token_ptr[1][0], line_num);
continue;
}
@ -161,7 +161,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
(token_ptr[3][0] != '8') &&
(token_ptr[3][0] != 'N'))
{
log_info ("WARNING: Tuning-db: Invalid vector_width '%c' in Line '%u'", token_ptr[3][0], line_num);
event_log_warning (hashcat_ctx, "Tuning-db: Invalid vector_width '%c' in Line '%u'", token_ptr[3][0], line_num);
continue;
}
@ -184,7 +184,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
if ((kernel_accel < 1) || (kernel_accel > 1024))
{
log_info ("WARNING: Tuning-db: Invalid kernel_accel '%d' in Line '%u'", kernel_accel, line_num);
event_log_warning (hashcat_ctx, "Tuning-db: Invalid kernel_accel '%d' in Line '%u'", kernel_accel, line_num);
continue;
}
@ -200,7 +200,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
if ((kernel_loops < 1) || (kernel_loops > 1024))
{
log_info ("WARNING: Tuning-db: Invalid kernel_loops '%d' in Line '%u'", kernel_loops, line_num);
event_log_warning (hashcat_ctx, "Tuning-db: Invalid kernel_loops '%d' in Line '%u'", kernel_loops, line_num);
continue;
}
@ -212,7 +212,7 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
tuning_db_entry_t *entry = &tuning_db->entry_buf[tuning_db->entry_cnt];
entry->device_name = mystrdup (device_name);
entry->device_name = hcstrdup (hashcat_ctx, device_name);
entry->attack_mode = attack_mode;
entry->hash_type = hash_type;
entry->vector_width = vector_width;
@ -223,13 +223,13 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
}
else
{
log_info ("WARNING: Tuning-db: Invalid number of token in Line '%u'", line_num);
event_log_warning (hashcat_ctx, "Tuning-db: Invalid number of token in Line '%u'", line_num);
continue;
}
}
myfree (buf);
hcfree (buf);
fclose (fp);
@ -255,19 +255,19 @@ void tuning_db_destroy (hashcat_ctx_t *hashcat_ctx)
{
tuning_db_alias_t *alias = &tuning_db->alias_buf[i];
myfree (alias->device_name);
myfree (alias->alias_name);
hcfree (alias->device_name);
hcfree (alias->alias_name);
}
for (i = 0; i < tuning_db->entry_cnt; i++)
{
tuning_db_entry_t *entry = &tuning_db->entry_buf[i];
myfree (entry->device_name);
hcfree (entry->device_name);
}
myfree (tuning_db->alias_buf);
myfree (tuning_db->entry_buf);
hcfree (tuning_db->alias_buf);
hcfree (tuning_db->entry_buf);
memset (tuning_db, 0, sizeof (tuning_db_t));
}
@ -280,7 +280,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev
// first we need to convert all spaces in the device_name to underscore
char *device_name_nospace = mystrdup (device_name);
char *device_name_nospace = hcstrdup (hashcat_ctx, device_name);
int device_name_length = strlen (device_name_nospace);
@ -364,7 +364,7 @@ tuning_db_entry_t *tuning_db_search (hashcat_ctx_t *hashcat_ctx, const char *dev
// free converted device_name
myfree (device_name_nospace);
hcfree (device_name_nospace);
return entry;
}

View File

@ -4,7 +4,6 @@
*/
#include "common.h"
#include "logging.h"
#include "usage.h"
static const char *USAGE_MINI[] =
@ -69,6 +68,7 @@ static const char *USAGE_BIG[] =
" --veracrypt-keyfiles | File | Keyfiles used, separate with comma | --veracrypt-key=x.txt",
" --veracrypt-pim | Num | VeraCrypt personal iterations multiplier | --veracrypt-pim=1000",
" -b, --benchmark | | Run benchmark |",
" --speed-only | | Just return expected speed of the attack and quit |",
" -c, --segment-size | Num | Sets size in MB to cache from the wordfile to X | -c 32",
" --bitmap-min | Num | Sets minimum bits allowed for bitmaps to X | --bitmap-min=24",
" --bitmap-max | Num | Sets maximum bits allowed for bitmaps to X | --bitmap-max=24",
@ -411,10 +411,18 @@ static const char *USAGE_BIG[] =
void usage_mini_print (const char *progname)
{
for (int i = 0; USAGE_MINI[i] != NULL; i++) log_info (USAGE_MINI[i], progname);
for (int i = 0; USAGE_MINI[i] != NULL; i++)
{
printf (USAGE_MINI[i], progname);
printf (EOL);
}
}
void usage_big_print (const char *progname)
{
for (int i = 0; USAGE_BIG[i] != NULL; i++) log_info (USAGE_BIG[i], progname);
for (int i = 0; USAGE_BIG[i] != NULL; i++)
{
printf (USAGE_BIG[i], progname);
printf (EOL);
}
}

View File

@ -6,7 +6,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "logfile.h"
#include "interface.h"
#include "shared.h"
@ -18,86 +18,87 @@ static const char short_options[] = "hVvm:a:r:j:k:g:o:t:d:D:n:u:c:p:s:l:1:2:3:4:
static const struct option long_options[] =
{
{"help", no_argument, 0, IDX_HELP},
{"version", no_argument, 0, IDX_VERSION},
{"quiet", no_argument, 0, IDX_QUIET},
{"show", no_argument, 0, IDX_SHOW},
{"left", no_argument, 0, IDX_LEFT},
{"username", no_argument, 0, IDX_USERNAME},
{"remove", no_argument, 0, IDX_REMOVE},
{"remove-timer", required_argument, 0, IDX_REMOVE_TIMER},
{"skip", required_argument, 0, IDX_SKIP},
{"limit", required_argument, 0, IDX_LIMIT},
{"keyspace", no_argument, 0, IDX_KEYSPACE},
{"potfile-disable", no_argument, 0, IDX_POTFILE_DISABLE},
{"potfile-path", required_argument, 0, IDX_POTFILE_PATH},
{"debug-mode", required_argument, 0, IDX_DEBUG_MODE},
{"debug-file", required_argument, 0, IDX_DEBUG_FILE},
{"induction-dir", required_argument, 0, IDX_INDUCTION_DIR},
{"outfile-check-dir", required_argument, 0, IDX_OUTFILE_CHECK_DIR},
{"force", no_argument, 0, IDX_FORCE},
{"benchmark", no_argument, 0, IDX_BENCHMARK},
{"stdout", no_argument, 0, IDX_STDOUT_FLAG},
{"restore", no_argument, 0, IDX_RESTORE},
{"restore-disable", no_argument, 0, IDX_RESTORE_DISABLE},
{"status", no_argument, 0, IDX_STATUS},
{"status-timer", required_argument, 0, IDX_STATUS_TIMER},
{"machine-readable", no_argument, 0, IDX_MACHINE_READABLE},
{"loopback", no_argument, 0, IDX_LOOPBACK},
{"weak-hash-threshold", required_argument, 0, IDX_WEAK_HASH_THRESHOLD},
{"session", required_argument, 0, IDX_SESSION},
{"runtime", required_argument, 0, IDX_RUNTIME},
{"generate-rules", required_argument, 0, IDX_RP_GEN},
{"generate-rules-func-min", required_argument, 0, IDX_RP_GEN_FUNC_MIN},
{"generate-rules-func-max", required_argument, 0, IDX_RP_GEN_FUNC_MAX},
{"generate-rules-seed", required_argument, 0, IDX_RP_GEN_SEED},
{"rule-left", required_argument, 0, IDX_RULE_BUF_L},
{"rule-right", required_argument, 0, IDX_RULE_BUF_R},
{"hash-type", required_argument, 0, IDX_HASH_MODE},
{"attack-mode", required_argument, 0, IDX_ATTACK_MODE},
{"rules-file", required_argument, 0, IDX_RP_FILE},
{"outfile", required_argument, 0, IDX_OUTFILE},
{"outfile-format", required_argument, 0, IDX_OUTFILE_FORMAT},
{"outfile-autohex-disable", no_argument, 0, IDX_OUTFILE_AUTOHEX_DISABLE},
{"outfile-check-timer", required_argument, 0, IDX_OUTFILE_CHECK_TIMER},
{"hex-charset", no_argument, 0, IDX_HEX_CHARSET},
{"hex-salt", no_argument, 0, IDX_HEX_SALT},
{"hex-wordlist", no_argument, 0, IDX_HEX_WORDLIST},
{"markov-disable", no_argument, 0, IDX_MARKOV_DISABLE},
{"markov-classic", no_argument, 0, IDX_MARKOV_CLASSIC},
{"markov-threshold", required_argument, 0, IDX_MARKOV_THRESHOLD},
{"markov-hcstat", required_argument, 0, IDX_MARKOV_HCSTAT},
{"cpu-affinity", required_argument, 0, IDX_CPU_AFFINITY},
{"opencl-info", no_argument, 0, IDX_OPENCL_INFO},
{"opencl-devices", required_argument, 0, IDX_OPENCL_DEVICES},
{"opencl-platforms", required_argument, 0, IDX_OPENCL_PLATFORMS},
{"opencl-device-types", required_argument, 0, IDX_OPENCL_DEVICE_TYPES},
{"opencl-vector-width", required_argument, 0, IDX_OPENCL_VECTOR_WIDTH},
{"workload-profile", required_argument, 0, IDX_WORKLOAD_PROFILE},
{"kernel-accel", required_argument, 0, IDX_KERNEL_ACCEL},
{"kernel-loops", required_argument, 0, IDX_KERNEL_LOOPS},
{"nvidia-spin-damp", required_argument, 0, IDX_NVIDIA_SPIN_DAMP},
{"gpu-temp-disable", no_argument, 0, IDX_GPU_TEMP_DISABLE},
{"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT},
{"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN},
{"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE},
{"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE},
{"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES},
{"veracrypt-keyfiles", required_argument, 0, IDX_VERACRYPT_KEYFILES},
{"veracrypt-pim", required_argument, 0, IDX_VERACRYPT_PIM},
{"segment-size", required_argument, 0, IDX_SEGMENT_SIZE},
{"scrypt-tmto", required_argument, 0, IDX_SCRYPT_TMTO},
{"seperator", required_argument, 0, IDX_SEPARATOR},
{"separator", required_argument, 0, IDX_SEPARATOR},
{"bitmap-min", required_argument, 0, IDX_BITMAP_MIN},
{"benchmark", no_argument, 0, IDX_BENCHMARK},
{"bitmap-max", required_argument, 0, IDX_BITMAP_MAX},
{"increment", no_argument, 0, IDX_INCREMENT},
{"increment-min", required_argument, 0, IDX_INCREMENT_MIN},
{"increment-max", required_argument, 0, IDX_INCREMENT_MAX},
{"bitmap-min", required_argument, 0, IDX_BITMAP_MIN},
{"cpu-affinity", required_argument, 0, IDX_CPU_AFFINITY},
{"custom-charset1", required_argument, 0, IDX_CUSTOM_CHARSET_1},
{"custom-charset2", required_argument, 0, IDX_CUSTOM_CHARSET_2},
{"custom-charset3", required_argument, 0, IDX_CUSTOM_CHARSET_3},
{"custom-charset4", required_argument, 0, IDX_CUSTOM_CHARSET_4},
{"debug-file", required_argument, 0, IDX_DEBUG_FILE},
{"debug-mode", required_argument, 0, IDX_DEBUG_MODE},
{"force", no_argument, 0, IDX_FORCE},
{"generate-rules-func-max", required_argument, 0, IDX_RP_GEN_FUNC_MAX},
{"generate-rules-func-min", required_argument, 0, IDX_RP_GEN_FUNC_MIN},
{"generate-rules", required_argument, 0, IDX_RP_GEN},
{"generate-rules-seed", required_argument, 0, IDX_RP_GEN_SEED},
{"gpu-temp-abort", required_argument, 0, IDX_GPU_TEMP_ABORT},
{"gpu-temp-disable", no_argument, 0, IDX_GPU_TEMP_DISABLE},
{"gpu-temp-retain", required_argument, 0, IDX_GPU_TEMP_RETAIN},
{"hash-type", required_argument, 0, IDX_HASH_MODE},
{"help", no_argument, 0, IDX_HELP},
{"hex-charset", no_argument, 0, IDX_HEX_CHARSET},
{"hex-salt", no_argument, 0, IDX_HEX_SALT},
{"hex-wordlist", no_argument, 0, IDX_HEX_WORDLIST},
{"increment-max", required_argument, 0, IDX_INCREMENT_MAX},
{"increment-min", required_argument, 0, IDX_INCREMENT_MIN},
{"increment", no_argument, 0, IDX_INCREMENT},
{"induction-dir", required_argument, 0, IDX_INDUCTION_DIR},
{"kernel-accel", required_argument, 0, IDX_KERNEL_ACCEL},
{"kernel-loops", required_argument, 0, IDX_KERNEL_LOOPS},
{"keyspace", no_argument, 0, IDX_KEYSPACE},
{"left", no_argument, 0, IDX_LEFT},
{"limit", required_argument, 0, IDX_LIMIT},
{"logfile-disable", no_argument, 0, IDX_LOGFILE_DISABLE},
{"loopback", no_argument, 0, IDX_LOOPBACK},
{"machine-readable", no_argument, 0, IDX_MACHINE_READABLE},
{"markov-classic", no_argument, 0, IDX_MARKOV_CLASSIC},
{"markov-disable", no_argument, 0, IDX_MARKOV_DISABLE},
{"markov-hcstat", required_argument, 0, IDX_MARKOV_HCSTAT},
{"markov-threshold", required_argument, 0, IDX_MARKOV_THRESHOLD},
{"nvidia-spin-damp", required_argument, 0, IDX_NVIDIA_SPIN_DAMP},
{"opencl-devices", required_argument, 0, IDX_OPENCL_DEVICES},
{"opencl-device-types", required_argument, 0, IDX_OPENCL_DEVICE_TYPES},
{"opencl-info", no_argument, 0, IDX_OPENCL_INFO},
{"opencl-platforms", required_argument, 0, IDX_OPENCL_PLATFORMS},
{"opencl-vector-width", required_argument, 0, IDX_OPENCL_VECTOR_WIDTH},
{"outfile-autohex-disable", no_argument, 0, IDX_OUTFILE_AUTOHEX_DISABLE},
{"outfile-check-dir", required_argument, 0, IDX_OUTFILE_CHECK_DIR},
{"outfile-check-timer", required_argument, 0, IDX_OUTFILE_CHECK_TIMER},
{"outfile-format", required_argument, 0, IDX_OUTFILE_FORMAT},
{"outfile", required_argument, 0, IDX_OUTFILE},
{"potfile-disable", no_argument, 0, IDX_POTFILE_DISABLE},
{"potfile-path", required_argument, 0, IDX_POTFILE_PATH},
{"powertune-enable", no_argument, 0, IDX_POWERTUNE_ENABLE},
{"quiet", no_argument, 0, IDX_QUIET},
{"remove", no_argument, 0, IDX_REMOVE},
{"remove-timer", required_argument, 0, IDX_REMOVE_TIMER},
{"restore-disable", no_argument, 0, IDX_RESTORE_DISABLE},
{"restore", no_argument, 0, IDX_RESTORE},
{"rule-left", required_argument, 0, IDX_RULE_BUF_L},
{"rule-right", required_argument, 0, IDX_RULE_BUF_R},
{"rules-file", required_argument, 0, IDX_RP_FILE},
{"runtime", required_argument, 0, IDX_RUNTIME},
{"scrypt-tmto", required_argument, 0, IDX_SCRYPT_TMTO},
{"segment-size", required_argument, 0, IDX_SEGMENT_SIZE},
{"separator", required_argument, 0, IDX_SEPARATOR},
{"seperator", required_argument, 0, IDX_SEPARATOR},
{"session", required_argument, 0, IDX_SESSION},
{"show", no_argument, 0, IDX_SHOW},
{"skip", required_argument, 0, IDX_SKIP},
{"status", no_argument, 0, IDX_STATUS},
{"status-timer", required_argument, 0, IDX_STATUS_TIMER},
{"stdout", no_argument, 0, IDX_STDOUT_FLAG},
{"speed-only", no_argument, 0, IDX_SPEED_ONLY},
{"truecrypt-keyfiles", required_argument, 0, IDX_TRUECRYPT_KEYFILES},
{"username", no_argument, 0, IDX_USERNAME},
{"veracrypt-keyfiles", required_argument, 0, IDX_VERACRYPT_KEYFILES},
{"veracrypt-pim", required_argument, 0, IDX_VERACRYPT_PIM},
{"version", no_argument, 0, IDX_VERSION},
{"weak-hash-threshold", required_argument, 0, IDX_WEAK_HASH_THRESHOLD},
{"workload-profile", required_argument, 0, IDX_WORKLOAD_PROFILE},
{0, 0, 0, 0}
};
@ -108,7 +109,7 @@ static char DEF_MASK_CS_1[] = "?l?d?u";
static char DEF_MASK_CS_2[] = "?l?d";
static char DEF_MASK_CS_3[] = "?l?d*!$@_";
void user_options_init (hashcat_ctx_t *hashcat_ctx)
int user_options_init (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
@ -183,6 +184,7 @@ void user_options_init (hashcat_ctx_t *hashcat_ctx)
user_options->status = STATUS;
user_options->status_timer = STATUS_TIMER;
user_options->stdout_flag = STDOUT_FLAG;
user_options->speed_only = SPEED_ONLY;
user_options->truecrypt_keyfiles = NULL;
user_options->usage = USAGE;
user_options->username = USERNAME;
@ -192,17 +194,19 @@ void user_options_init (hashcat_ctx_t *hashcat_ctx)
user_options->weak_hash_threshold = WEAK_HASH_THRESHOLD;
user_options->workload_profile = WORKLOAD_PROFILE;
user_options->rp_files_cnt = 0;
user_options->rp_files = (char **) mycalloc (256, sizeof (char *));
user_options->rp_files = (char **) hccalloc (hashcat_ctx, 256, sizeof (char *)); VERIFY_PTR (user_options->rp_files);
user_options->hc_bin = PROGNAME;
user_options->hc_argc = 0;
user_options->hc_argv = NULL;
return 0;
}
void user_options_destroy (hashcat_ctx_t *hashcat_ctx)
{
user_options_t *user_options = hashcat_ctx->user_options;
myfree (user_options->rp_files);
hcfree (user_options->rp_files);
//do not reset this, it might be used from main.c
//memset (user_options, 0, sizeof (user_options_t));
@ -245,6 +249,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
case IDX_KEYSPACE: user_options->keyspace = true; break;
case IDX_BENCHMARK: user_options->benchmark = true; break;
case IDX_STDOUT_FLAG: user_options->stdout_flag = true; break;
case IDX_SPEED_ONLY: user_options->speed_only = true; break;
case IDX_RESTORE_DISABLE: user_options->restore_disable = true; break;
case IDX_STATUS: user_options->status = true; break;
case IDX_STATUS_TIMER: user_options->status_timer = atoi (optarg); break;
@ -320,7 +325,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
default:
{
log_error ("ERROR: Invalid argument specified");
event_log_error (hashcat_ctx, "Invalid argument specified");
return -1;
}
@ -329,7 +334,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
if (optopt != 0)
{
log_error ("ERROR: Invalid argument specified");
event_log_error (hashcat_ctx, "Invalid argument specified");
return -1;
}
@ -348,14 +353,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
if (user_options->hc_argc < 0)
{
log_error ("ERROR: hc_argc %d is invalid", user_options->hc_argc);
event_log_error (hashcat_ctx, "hc_argc %d is invalid", user_options->hc_argc);
return -1;
}
if (user_options->hc_argv == NULL)
{
log_error ("ERROR: hc_argv is NULL");
event_log_error (hashcat_ctx, "hc_argv is NULL");
return -1;
}
@ -367,21 +372,21 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
&& (user_options->attack_mode != ATTACK_MODE_HYBRID2)
&& (user_options->attack_mode != ATTACK_MODE_NONE))
{
log_error ("ERROR: Invalid attack-mode specified");
event_log_error (hashcat_ctx, "Invalid attack-mode specified");
return -1;
}
if (user_options->runtime_chgd == true && user_options->runtime == 0)
{
log_error ("ERROR: Invalid runtime specified");
event_log_error (hashcat_ctx, "Invalid runtime specified");
return -1;
}
if (user_options->hash_mode > 14100)
{
log_error ("ERROR: Invalid hash-type specified");
event_log_error (hashcat_ctx, "Invalid hash-type specified");
return -1;
}
@ -393,7 +398,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
|| ((user_options->hash_mode >= 6200) && (user_options->hash_mode <= 6299))
|| ((user_options->hash_mode >= 13700) && (user_options->hash_mode <= 13799)))
{
log_error ("ERROR: Mixing support for user names and hashes of type %s is not supported", strhashtype (user_options->hash_mode));
event_log_error (hashcat_ctx, "Mixing support for user names and hashes of type %s is not supported", strhashtype (user_options->hash_mode));
return -1;
}
@ -401,7 +406,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
if (user_options->outfile_format > 16)
{
log_error ("ERROR: Invalid outfile-format specified");
event_log_error (hashcat_ctx, "Invalid outfile-format specified");
return -1;
}
@ -410,7 +415,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->outfile_format_chgd == true)
{
log_error ("ERROR: Mixing outfile-format > 1 with left parameter is not allowed");
event_log_error (hashcat_ctx, "Mixing outfile-format > 1 with left parameter is not allowed");
return -1;
}
@ -420,7 +425,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->outfile_format_chgd == true)
{
log_error ("ERROR: Mixing outfile-format > 7 with show parameter is not allowed");
event_log_error (hashcat_ctx, "Mixing outfile-format > 7 with show parameter is not allowed");
return -1;
}
@ -428,49 +433,49 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
if (user_options->increment_min < INCREMENT_MIN)
{
log_error ("ERROR: Invalid increment-min specified");
event_log_error (hashcat_ctx, "Invalid increment-min specified");
return -1;
}
if (user_options->increment_max > INCREMENT_MAX)
{
log_error ("ERROR: Invalid increment-max specified");
event_log_error (hashcat_ctx, "Invalid increment-max specified");
return -1;
}
if (user_options->increment_min > user_options->increment_max)
{
log_error ("ERROR: Invalid increment-min specified");
event_log_error (hashcat_ctx, "Invalid increment-min specified");
return -1;
}
if ((user_options->increment == true) && (user_options->attack_mode == ATTACK_MODE_STRAIGHT))
{
log_error ("ERROR: Increment is not allowed in attack-mode 0");
event_log_error (hashcat_ctx, "Increment is not allowed in attack-mode 0");
return -1;
}
if ((user_options->increment == false) && (user_options->increment_min_chgd == true))
{
log_error ("ERROR: Increment-min is only supported combined with increment switch");
event_log_error (hashcat_ctx, "Increment-min is only supported combined with increment switch");
return -1;
}
if ((user_options->increment == false) && (user_options->increment_max_chgd == true))
{
log_error ("ERROR: Increment-max is only supported combined with increment switch");
event_log_error (hashcat_ctx, "Increment-max is only supported combined with increment switch");
return -1;
}
if (user_options->rp_files_cnt > 0 && user_options->rp_gen == true)
{
log_error ("ERROR: Use of both rules-file and rules-generate is not supported");
event_log_error (hashcat_ctx, "Use of both rules-file and rules-generate is not supported");
return -1;
}
@ -479,7 +484,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->attack_mode != ATTACK_MODE_STRAIGHT)
{
log_error ("ERROR: Use of rules-file or rules-generate only allowed in attack-mode 0");
event_log_error (hashcat_ctx, "Use of rules-file or rules-generate only allowed in attack-mode 0");
return -1;
}
@ -487,14 +492,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
if (user_options->bitmap_min > user_options->bitmap_max)
{
log_error ("ERROR: Invalid bitmap-min specified");
event_log_error (hashcat_ctx, "Invalid bitmap-min specified");
return -1;
}
if (user_options->rp_gen_func_min > user_options->rp_gen_func_max)
{
log_error ("ERROR: Invalid rp-gen-func-min specified");
event_log_error (hashcat_ctx, "Invalid rp-gen-func-min specified");
return -1;
}
@ -503,24 +508,24 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->force == false)
{
log_info ("The manual use of the -n option (or --kernel-accel) is outdated");
log_info ("Please consider using the -w option instead");
log_info ("You can use --force to override this but do not post error reports if you do so");
log_info ("");
event_log_info (hashcat_ctx, "The manual use of the -n option (or --kernel-accel) is outdated");
event_log_info (hashcat_ctx, "Please consider using the -w option instead");
event_log_info (hashcat_ctx, "You can use --force to override this but do not post error reports if you do so");
event_log_info (hashcat_ctx, "");
return -1;
}
if (user_options->kernel_accel < 1)
{
log_error ("ERROR: Invalid kernel-accel specified");
event_log_error (hashcat_ctx, "Invalid kernel-accel specified");
return -1;
}
if (user_options->kernel_accel > 1024)
{
log_error ("ERROR: Invalid kernel-accel specified");
event_log_error (hashcat_ctx, "Invalid kernel-accel specified");
return -1;
}
@ -530,24 +535,24 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->force == false)
{
log_info ("The manual use of the -u option (or --kernel-loops) is outdated");
log_info ("Please consider using the -w option instead");
log_info ("You can use --force to override this but do not post error reports if you do so");
log_info ("");
event_log_info (hashcat_ctx, "The manual use of the -u option (or --kernel-loops) is outdated");
event_log_info (hashcat_ctx, "Please consider using the -w option instead");
event_log_info (hashcat_ctx, "You can use --force to override this but do not post error reports if you do so");
event_log_info (hashcat_ctx, "");
return -1;
}
if (user_options->kernel_loops < 1)
{
log_error ("ERROR: Invalid kernel-loops specified");
event_log_error (hashcat_ctx, "Invalid kernel-loops specified");
return -1;
}
if (user_options->kernel_loops > 1024)
{
log_error ("ERROR: Invalid kernel-loops specified");
event_log_error (hashcat_ctx, "Invalid kernel-loops specified");
return -1;
}
@ -555,7 +560,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
if ((user_options->workload_profile < 1) || (user_options->workload_profile > 4))
{
log_error ("ERROR: workload-profile %i not available", user_options->workload_profile);
event_log_error (hashcat_ctx, "workload-profile %i not available", user_options->workload_profile);
return -1;
}
@ -564,7 +569,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (is_power_of_2 (user_options->opencl_vector_width) == false || user_options->opencl_vector_width > 16)
{
log_error ("ERROR: opencl-vector-width %i not allowed", user_options->opencl_vector_width);
event_log_error (hashcat_ctx, "opencl-vector-width %i not allowed", user_options->opencl_vector_width);
return -1;
}
@ -574,14 +579,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->remove == true)
{
log_error ("ERROR: Mixing remove parameter not allowed with show parameter or left parameter");
event_log_error (hashcat_ctx, "Mixing remove parameter not allowed with show parameter or left parameter");
return -1;
}
if (user_options->potfile_disable == true)
{
log_error ("ERROR: Mixing potfile-disable parameter not allowed with show parameter or left parameter");
event_log_error (hashcat_ctx, "Mixing potfile-disable parameter not allowed with show parameter or left parameter");
return -1;
}
@ -591,7 +596,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->outfile_autohex == false)
{
log_error ("ERROR: Mixing outfile-autohex-disable parameter not allowed with show parameter");
event_log_error (hashcat_ctx, "Mixing outfile-autohex-disable parameter not allowed with show parameter");
return -1;
}
@ -601,13 +606,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->show == true)
{
log_error ("ERROR: Combining show parameter with keyspace parameter is not allowed");
event_log_error (hashcat_ctx, "Combining show parameter with keyspace parameter is not allowed");
return -1;
}
else if (user_options->left == true)
{
log_error ("ERROR: Combining left parameter with keyspace parameter is not allowed");
event_log_error (hashcat_ctx, "Combining left parameter with keyspace parameter is not allowed");
return -1;
}
@ -617,14 +622,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->remove == false)
{
log_error ("ERROR: Parameter remove-timer require parameter remove enabled");
event_log_error (hashcat_ctx, "Parameter remove-timer require parameter remove enabled");
return -1;
}
if (user_options->remove_timer < 1)
{
log_error ("ERROR: Parameter remove-timer must have a value greater than or equal to 1");
event_log_error (hashcat_ctx, "Parameter remove-timer must have a value greater than or equal to 1");
return -1;
}
@ -636,14 +641,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0))
{
log_error ("ERROR: Parameter loopback not allowed without rules-file or rules-generate");
event_log_error (hashcat_ctx, "Parameter loopback not allowed without rules-file or rules-generate");
return -1;
}
}
else
{
log_error ("ERROR: Parameter loopback allowed in attack-mode 0 only");
event_log_error (hashcat_ctx, "Parameter loopback allowed in attack-mode 0 only");
return -1;
}
@ -654,14 +659,14 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->attack_mode != ATTACK_MODE_STRAIGHT)
{
log_error ("ERROR: Parameter debug-mode option is only available with attack-mode 0");
event_log_error (hashcat_ctx, "Parameter debug-mode option is only available with attack-mode 0");
return -1;
}
if ((user_options->rp_files_cnt == 0) && (user_options->rp_gen == 0))
{
log_error ("ERROR: Parameter debug-mode not allowed without rules-file or rules-generate");
event_log_error (hashcat_ctx, "Parameter debug-mode not allowed without rules-file or rules-generate");
return -1;
}
@ -669,7 +674,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
if (user_options->debug_mode > 4)
{
log_error ("ERROR: Invalid debug-mode specified");
event_log_error (hashcat_ctx, "Invalid debug-mode specified");
return -1;
}
@ -678,7 +683,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->debug_mode < 1)
{
log_error ("ERROR: Parameter debug-file requires parameter debug-mode to be set");
event_log_error (hashcat_ctx, "Parameter debug-file requires parameter debug-mode to be set");
return -1;
}
@ -688,7 +693,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->attack_mode == ATTACK_MODE_BF)
{
log_error ("ERROR: Parameter induction-dir not allowed with brute-force attacks");
event_log_error (hashcat_ctx, "Parameter induction-dir not allowed with brute-force attacks");
return -1;
}
@ -698,7 +703,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if ((user_options->weak_hash_threshold != WEAK_HASH_THRESHOLD) && (user_options->weak_hash_threshold != 0))
{
log_error ("ERROR: setting --weak-hash-threshold allowed only in straight-attack mode");
event_log_error (hashcat_ctx, "setting --weak-hash-threshold allowed only in straight-attack mode");
return -1;
}
@ -706,7 +711,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
if (user_options->nvidia_spin_damp > 100)
{
log_error ("ERROR: setting --nvidia-spin-damp must be between 0 and 100 (inclusive)");
event_log_error (hashcat_ctx, "setting --nvidia-spin-damp must be between 0 and 100 (inclusive)");
return -1;
}
@ -715,7 +720,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->gpu_temp_abort < user_options->gpu_temp_retain)
{
log_error ("ERROR: Invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain.");
event_log_error (hashcat_ctx, "Invalid values for gpu-temp-abort. Parameter gpu-temp-abort is less than gpu-temp-retain.");
return -1;
}
@ -727,7 +732,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
{
if (user_options->attack_mode != ATTACK_MODE_BF)
{
log_error ("ERROR: Only attack-mode 3 allowed in benchmark mode");
event_log_error (hashcat_ctx, "Only attack-mode 3 allowed in benchmark mode");
return -1;
}
@ -907,7 +912,8 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
if (user_options->opencl_info == true
|| user_options->keyspace == true
|| user_options->benchmark == true
|| user_options->stdout_flag == true)
|| user_options->stdout_flag == true
|| user_options->speed_only == true)
{
user_options->show = false;
user_options->left = false;
@ -930,6 +936,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
user_options->session = "benchmark";
user_options->attack_mode = ATTACK_MODE_BF;
user_options->increment = false;
user_options->speed_only = true;
if (user_options->workload_profile_chgd == false)
{
@ -966,7 +973,7 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx)
user_options->quiet = true;
user_options->opencl_platforms = NULL;
user_options->opencl_devices = NULL;
user_options->opencl_device_types = mystrdup ("1,2,3");
user_options->opencl_device_types = hcstrdup (hashcat_ctx, "1,2,3");
}
if (user_options->left == true)
@ -1103,23 +1110,6 @@ void user_options_extra_init (hashcat_ctx_t *hashcat_ctx)
user_options_extra->rule_len_l = (int) strlen (user_options->rule_buf_l);
user_options_extra->rule_len_r = (int) strlen (user_options->rule_buf_r);
// wordlist_mode
user_options_extra->wordlist_mode = WL_MODE_NONE;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
{
user_options_extra->wordlist_mode = (user_options->hc_argc >= 2) ? WL_MODE_FILE : WL_MODE_STDIN;
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
user_options_extra->wordlist_mode = WL_MODE_FILE;
}
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
{
user_options_extra->wordlist_mode = WL_MODE_MASK;
}
// hc_hash and hc_work*
user_options_extra->hc_hash = NULL;
@ -1150,6 +1140,23 @@ void user_options_extra_init (hashcat_ctx_t *hashcat_ctx)
user_options_extra->hc_workc = user_options->hc_argc - 1;
user_options_extra->hc_workv = user_options->hc_argv + 1;
}
// wordlist_mode
user_options_extra->wordlist_mode = WL_MODE_NONE;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT)
{
user_options_extra->wordlist_mode = (user_options_extra->hc_workc >= 1) ? WL_MODE_FILE : WL_MODE_STDIN;
}
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI)
{
user_options_extra->wordlist_mode = WL_MODE_FILE;
}
else if (user_options_extra->attack_kern == ATTACK_KERN_BF)
{
user_options_extra->wordlist_mode = WL_MODE_MASK;
}
}
void user_options_extra_destroy (hashcat_ctx_t *hashcat_ctx)
@ -1196,66 +1203,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx)
user_options_t *user_options = hashcat_ctx->user_options;
logfile_ctx_t *logfile_ctx = hashcat_ctx->logfile_ctx;
logfile_top_uint (user_options->benchmark);
logfile_top_uint (user_options->force);
logfile_top_uint (user_options->gpu_temp_disable);
logfile_top_uint (user_options->hex_charset);
logfile_top_uint (user_options->hex_salt);
logfile_top_uint (user_options->hex_wordlist);
logfile_top_uint (user_options->increment);
logfile_top_uint (user_options->keyspace);
logfile_top_uint (user_options->left);
logfile_top_uint (user_options->logfile_disable);
logfile_top_uint (user_options->loopback);
logfile_top_uint (user_options->machine_readable);
logfile_top_uint (user_options->markov_classic);
logfile_top_uint (user_options->markov_disable);
logfile_top_uint (user_options->opencl_info);
logfile_top_uint (user_options->outfile_autohex);
logfile_top_uint (user_options->potfile_disable);
logfile_top_uint (user_options->powertune_enable);
logfile_top_uint (user_options->quiet);
logfile_top_uint (user_options->remove);
logfile_top_uint (user_options->restore);
logfile_top_uint (user_options->restore_disable);
logfile_top_uint (user_options->show);
logfile_top_uint (user_options->status);
logfile_top_uint (user_options->stdout_flag);
logfile_top_uint (user_options->usage);
logfile_top_uint (user_options->username);
logfile_top_uint (user_options->version);
logfile_top_uint (user_options->attack_mode);
logfile_top_uint (user_options->bitmap_max);
logfile_top_uint (user_options->bitmap_min);
logfile_top_uint (user_options->debug_mode);
logfile_top_uint (user_options->gpu_temp_abort);
logfile_top_uint (user_options->gpu_temp_retain);
logfile_top_uint (user_options->hash_mode);
logfile_top_uint (user_options->increment_max);
logfile_top_uint (user_options->increment_min);
logfile_top_uint (user_options->kernel_accel);
logfile_top_uint (user_options->kernel_loops);
logfile_top_uint (user_options->markov_threshold);
logfile_top_uint (user_options->nvidia_spin_damp);
logfile_top_uint (user_options->opencl_vector_width);
logfile_top_uint (user_options->outfile_check_timer);
logfile_top_uint (user_options->outfile_format);
logfile_top_uint (user_options->remove_timer);
logfile_top_uint (user_options->restore_timer);
logfile_top_uint (user_options->rp_files_cnt);
logfile_top_uint (user_options->rp_gen);
logfile_top_uint (user_options->rp_gen_func_max);
logfile_top_uint (user_options->rp_gen_func_min);
logfile_top_uint (user_options->rp_gen_seed);
logfile_top_uint (user_options->runtime);
logfile_top_uint (user_options->scrypt_tmto);
logfile_top_uint (user_options->segment_size);
logfile_top_uint (user_options->status_timer);
logfile_top_uint (user_options->veracrypt_pim);
logfile_top_uint (user_options->weak_hash_threshold);
logfile_top_uint (user_options->workload_profile);
logfile_top_uint64 (user_options->limit);
logfile_top_uint64 (user_options->skip);
logfile_top_char (user_options->separator);
logfile_top_string (user_options->cpu_affinity);
logfile_top_string (user_options->custom_charset_1);
logfile_top_string (user_options->custom_charset_2);
@ -1273,8 +1221,68 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx)
logfile_top_string (user_options->rp_files[0]);
logfile_top_string (user_options->rule_buf_l);
logfile_top_string (user_options->rule_buf_r);
logfile_top_char (user_options->separator);
logfile_top_string (user_options->session);
logfile_top_string (user_options->truecrypt_keyfiles);
logfile_top_string (user_options->veracrypt_keyfiles);
logfile_top_uint64 (user_options->limit);
logfile_top_uint64 (user_options->skip);
logfile_top_uint (user_options->attack_mode);
logfile_top_uint (user_options->benchmark);
logfile_top_uint (user_options->bitmap_max);
logfile_top_uint (user_options->bitmap_min);
logfile_top_uint (user_options->debug_mode);
logfile_top_uint (user_options->force);
logfile_top_uint (user_options->gpu_temp_abort);
logfile_top_uint (user_options->gpu_temp_disable);
logfile_top_uint (user_options->gpu_temp_retain);
logfile_top_uint (user_options->hash_mode);
logfile_top_uint (user_options->hex_charset);
logfile_top_uint (user_options->hex_salt);
logfile_top_uint (user_options->hex_wordlist);
logfile_top_uint (user_options->increment);
logfile_top_uint (user_options->increment_max);
logfile_top_uint (user_options->increment_min);
logfile_top_uint (user_options->kernel_accel);
logfile_top_uint (user_options->kernel_loops);
logfile_top_uint (user_options->keyspace);
logfile_top_uint (user_options->left);
logfile_top_uint (user_options->logfile_disable);
logfile_top_uint (user_options->loopback);
logfile_top_uint (user_options->machine_readable);
logfile_top_uint (user_options->markov_classic);
logfile_top_uint (user_options->markov_disable);
logfile_top_uint (user_options->markov_threshold);
logfile_top_uint (user_options->nvidia_spin_damp);
logfile_top_uint (user_options->opencl_info);
logfile_top_uint (user_options->opencl_vector_width);
logfile_top_uint (user_options->outfile_autohex);
logfile_top_uint (user_options->outfile_check_timer);
logfile_top_uint (user_options->outfile_format);
logfile_top_uint (user_options->potfile_disable);
logfile_top_uint (user_options->powertune_enable);
logfile_top_uint (user_options->quiet);
logfile_top_uint (user_options->remove);
logfile_top_uint (user_options->remove_timer);
logfile_top_uint (user_options->restore);
logfile_top_uint (user_options->restore_disable);
logfile_top_uint (user_options->restore_timer);
logfile_top_uint (user_options->rp_files_cnt);
logfile_top_uint (user_options->rp_gen);
logfile_top_uint (user_options->rp_gen_func_max);
logfile_top_uint (user_options->rp_gen_func_min);
logfile_top_uint (user_options->rp_gen_seed);
logfile_top_uint (user_options->runtime);
logfile_top_uint (user_options->scrypt_tmto);
logfile_top_uint (user_options->segment_size);
logfile_top_uint (user_options->show);
logfile_top_uint (user_options->status);
logfile_top_uint (user_options->status_timer);
logfile_top_uint (user_options->stdout_flag);
logfile_top_uint (user_options->speed_only);
logfile_top_uint (user_options->usage);
logfile_top_uint (user_options->username);
logfile_top_uint (user_options->veracrypt_pim);
logfile_top_uint (user_options->version);
logfile_top_uint (user_options->weak_hash_threshold);
logfile_top_uint (user_options->workload_profile);
}

View File

@ -5,12 +5,12 @@
#include "common.h"
#include "types.h"
#include "logging.h"
#include "event.h"
#include "opencl.h"
#include "hashes.h"
#include "weak_hash.h"
void weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 salt_pos)
int weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u32 salt_pos)
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
hashes_t *hashes = hashcat_ctx->hashes;
@ -33,13 +33,19 @@ void weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para
* run the kernel
*/
int CL_rc;
if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL)
{
run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 1, false, 0);
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 1, false, 0);
if (CL_rc == -1) return -1;
}
else
{
run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 1, false, 0);
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_1, 1, false, 0);
if (CL_rc == -1) return -1;
u32 loop_step = 16;
@ -54,10 +60,14 @@ void weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para
device_param->kernel_params_buf32[28] = loop_pos;
device_param->kernel_params_buf32[29] = loop_left;
run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 1, false, 0);
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_2, 1, false, 0);
if (CL_rc == -1) return -1;
}
run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 1, false, 0);
CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_3, 1, false, 0);
if (CL_rc == -1) return -1;
}
/**
@ -80,4 +90,6 @@ void weak_hash_check (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_para
device_param->kernel_params_buf32[34] = 0;
straight_ctx->kernel_rules_buf[0].cmds[0] = cmd0_rule_old;
return 0;
}

View File

@ -18,8 +18,13 @@ ifneq (,$(IS_WIN_BUILD))
# entering this code path means: we need to check for CRT_glob.o since we try to build binaries for windows operating systems
ifeq ($(UNAME),MSYS2)
CRT_GLOB_LIB_PATH_32 ?= /mingw32/i686-w64-mingw32/lib/
CRT_GLOB_LIB_PATH_64 ?= /mingw64/x86_64-w64-mingw32/lib/
else
CRT_GLOB_LIB_PATH_32 ?= /usr/i686-w64-mingw32/lib/
CRT_GLOB_LIB_PATH_64 ?= /usr/x86_64-w64-mingw32/lib/
endif
CRT_GLOB_LIB_SYSROOT_32 := $(shell $(CC_WIN_32) --verbose 2>&1 | $(EGREP) -m 1 -o '(with-sysroot="[^"]"|with-sysroot=[^ ]*)' | $(SED) 's/^with-sysroot="\?\([^"]*\)"\?$$/\1/')
CRT_GLOB_LIB_SYSROOT_64 := $(shell $(CC_WIN_64) --verbose 2>&1 | $(EGREP) -m 1 -o '(with-sysroot="[^"]"|with-sysroot=[^ ]*)' | $(SED) 's/^with-sysroot="\?\([^"]*\)"\?$$/\1/')

View File

@ -6,7 +6,7 @@
#include "common.h"
#include "types.h"
#include "memory.h"
#include "logging.h"
#include "event.h"
#include "convert.h"
#include "dictstat.h"
#include "thread.h"
@ -58,7 +58,7 @@ u32 convert_from_hex (hashcat_ctx_t *hashcat_ctx, char *line_buf, const u32 line
return (line_len);
}
void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd)
int load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd)
{
wl_data_t *wl_data = hashcat_ctx->wl_data;
@ -70,15 +70,15 @@ void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd)
wl_data->buf[wl_data->cnt] = 0;
if (wl_data->cnt == 0) return;
if (wl_data->cnt == 0) return 0;
if (wl_data->buf[wl_data->cnt - 1] == '\n') return;
if (wl_data->buf[wl_data->cnt - 1] == '\n') return 0;
while (!feof (fd))
{
if (wl_data->cnt == wl_data->avail)
{
wl_data->buf = (char *) myrealloc (wl_data->buf, wl_data->avail, wl_data->incr);
wl_data->buf = (char *) hcrealloc (hashcat_ctx, wl_data->buf, wl_data->avail, wl_data->incr); VERIFY_PTR (wl_data->buf);
wl_data->avail += wl_data->incr;
}
@ -103,7 +103,7 @@ void load_segment (hashcat_ctx_t *hashcat_ctx, FILE *fd)
wl_data->buf[wl_data->cnt - 1] = '\n';
}
return;
return 0;
}
void get_next_word_lm (char *buf, u64 sz, u64 *len, u64 *off)
@ -322,8 +322,8 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile)
keyspace *= combinator_ctx->combs_cnt;
}
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 ("");
if (user_options->quiet == false) event_log_info (hashcat_ctx, "Cache-hit dictionary stats %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, d.stat.st_size, cached_cnt, keyspace);
if (user_options->quiet == false) event_log_info (hashcat_ctx, "");
//hc_signal (sigHandler_default);
@ -399,13 +399,13 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile)
double percent = (double) comp / (double) d.stat.st_size;
if (user_options->quiet == false) log_info_nn ("Generating dictionary stats for %s: %" PRIu64 " bytes (%.2f%%), %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, percent * 100, cnt2, cnt);
if (user_options->quiet == false) event_log_info_nn (hashcat_ctx, "Generating dictionary stats for %s: %" PRIu64 " bytes (%.2f%%), %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, percent * 100, cnt2, cnt);
time (&prev);
}
if (user_options->quiet == false) log_info ("Generated dictionary stats for %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, cnt2, cnt);
if (user_options->quiet == false) log_info ("");
if (user_options->quiet == false) event_log_info (hashcat_ctx, "Generated dictionary stats for %s: %" PRIu64 " bytes, %" PRIu64 " words, %" PRIu64 " keyspace", dictfile, comp, cnt2, cnt);
if (user_options->quiet == false) event_log_info (hashcat_ctx, "");
dictstat_append (hashcat_ctx, &d);
@ -414,7 +414,7 @@ u64 count_words (hashcat_ctx_t *hashcat_ctx, FILE *fd, const char *dictfile)
return (cnt);
}
void wl_data_init (hashcat_ctx_t *hashcat_ctx)
int wl_data_init (hashcat_ctx_t *hashcat_ctx)
{
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
user_options_t *user_options = hashcat_ctx->user_options;
@ -422,16 +422,15 @@ void wl_data_init (hashcat_ctx_t *hashcat_ctx)
wl_data->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->usage == true) return;
if (user_options->version == true) return;
if (user_options->benchmark == true) return 0;
if (user_options->left == true) return 0;
if (user_options->opencl_info == true) return 0;
if (user_options->usage == true) return 0;
if (user_options->version == true) return 0;
wl_data->enabled = true;
wl_data->buf = (char *) mymalloc (user_options->segment_size);
wl_data->buf = (char *) hcmalloc (hashcat_ctx, user_options->segment_size); VERIFY_PTR (wl_data->buf);
wl_data->avail = user_options->segment_size;
wl_data->incr = user_options->segment_size;
wl_data->cnt = 0;
@ -452,6 +451,8 @@ void wl_data_init (hashcat_ctx_t *hashcat_ctx)
{
wl_data->func = get_next_word_lm;
}
return 0;
}
void wl_data_destroy (hashcat_ctx_t *hashcat_ctx)
@ -460,7 +461,7 @@ void wl_data_destroy (hashcat_ctx_t *hashcat_ctx)
if (wl_data->enabled == false) return;
myfree (wl_data->buf);
hcfree (wl_data->buf);
memset (wl_data, 0, sizeof (wl_data_t));
}