2016-09-15 02:29:22 +00:00
|
|
|
/**
|
|
|
|
* Author......: See docs/credits.txt
|
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "types.h"
|
2016-10-09 20:41:55 +00:00
|
|
|
#include "event.h"
|
2016-09-15 02:29:22 +00:00
|
|
|
#include "memory.h"
|
2016-10-04 09:13:33 +00:00
|
|
|
#include "hwmon.h"
|
2016-09-15 02:29:22 +00:00
|
|
|
#include "timer.h"
|
2016-10-04 09:13:33 +00:00
|
|
|
#include "hashes.h"
|
2016-09-20 11:18:47 +00:00
|
|
|
#include "thread.h"
|
2016-09-15 14:02:52 +00:00
|
|
|
#include "restore.h"
|
2016-09-15 02:29:22 +00:00
|
|
|
#include "shared.h"
|
2016-11-21 17:30:36 +00:00
|
|
|
#include "status.h"
|
2016-09-15 02:29:22 +00:00
|
|
|
#include "monitor.h"
|
|
|
|
|
2016-10-17 11:44:07 +00:00
|
|
|
int get_runtime_left (const hashcat_ctx_t *hashcat_ctx)
|
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2017-08-16 17:43:41 +00:00
|
|
|
hc_time_t runtime_cur;
|
2016-10-17 11:44:07 +00:00
|
|
|
|
2017-08-16 17:43:41 +00:00
|
|
|
hc_time (&runtime_cur);
|
2016-10-17 11:44:07 +00:00
|
|
|
|
2016-10-30 17:55:27 +00:00
|
|
|
const int runtime_left = (int) (status_ctx->runtime_start
|
|
|
|
+ user_options->runtime
|
|
|
|
+ (msec_paused / 1000)
|
|
|
|
- runtime_cur);
|
2016-10-17 11:44:07 +00:00
|
|
|
|
|
|
|
return runtime_left;
|
|
|
|
}
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
static int monitor (hashcat_ctx_t *hashcat_ctx)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-10-17 11:44:07 +00:00
|
|
|
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;
|
2016-09-22 09:56:06 +00:00
|
|
|
|
2016-11-21 17:30:36 +00:00
|
|
|
bool runtime_check = false;
|
|
|
|
bool remove_check = false;
|
|
|
|
bool status_check = false;
|
|
|
|
bool restore_check = false;
|
|
|
|
bool hwmon_check = false;
|
|
|
|
bool performance_check = false;
|
2016-09-22 09:56:06 +00:00
|
|
|
|
2016-11-21 17:30:36 +00:00
|
|
|
const int sleep_time = 1;
|
|
|
|
const int temp_threshold = 1; // degrees celcius
|
2016-11-22 15:51:06 +00:00
|
|
|
const int fan_speed_min = 33; // in percentage
|
2016-11-21 17:30:36 +00:00
|
|
|
const int fan_speed_max = 100;
|
|
|
|
const float exec_low = 50.0f; // in ms
|
|
|
|
const float util_low = 90.0f; // in percent
|
2016-09-22 09:56:06 +00:00
|
|
|
|
|
|
|
if (user_options->runtime)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-09-22 09:56:06 +00:00
|
|
|
runtime_check = true;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
|
2016-09-30 10:11:46 +00:00
|
|
|
if (restore_ctx->enabled == true)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-09-22 09:56:06 +00:00
|
|
|
restore_check = true;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
if ((user_options->remove == true) && (hashes->hashlist_mode == HL_MODE_FILE))
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-09-22 09:56:06 +00:00
|
|
|
remove_check = true;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
if (user_options->status == true)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-09-22 09:56:06 +00:00
|
|
|
status_check = true;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
|
2016-09-30 10:11:46 +00:00
|
|
|
if (hwmon_ctx->enabled == true)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-09-22 09:56:06 +00:00
|
|
|
hwmon_check = true;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
|
2016-11-21 17:30:36 +00:00
|
|
|
if (hwmon_ctx->enabled == true)
|
|
|
|
{
|
|
|
|
performance_check = true; // this check simply requires hwmon to work
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((runtime_check == false) && (remove_check == false) && (status_check == false) && (restore_check == false) && (hwmon_check == false) && (performance_check == false))
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
return 0;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
// these variables are mainly used for fan control
|
|
|
|
|
2017-02-14 15:00:10 +00:00
|
|
|
int fan_speed_chgd[DEVICES_MAX];
|
|
|
|
|
|
|
|
memset (fan_speed_chgd, 0, sizeof (fan_speed_chgd));
|
2016-09-22 09:56:06 +00:00
|
|
|
|
|
|
|
// temperature controller "loopback" values
|
|
|
|
|
2017-02-14 15:00:10 +00:00
|
|
|
int temp_diff_old[DEVICES_MAX];
|
|
|
|
int temp_diff_sum[DEVICES_MAX];
|
|
|
|
|
|
|
|
memset (temp_diff_old, 0, sizeof (temp_diff_old));
|
|
|
|
memset (temp_diff_sum, 0, sizeof (temp_diff_sum));
|
|
|
|
|
|
|
|
// timer
|
2016-09-22 09:56:06 +00:00
|
|
|
|
2017-08-16 17:43:41 +00:00
|
|
|
hc_time_t last_temp_check_time;
|
2016-09-22 09:56:06 +00:00
|
|
|
|
2017-08-16 17:43:41 +00:00
|
|
|
hc_time (&last_temp_check_time);
|
2016-09-22 09:56:06 +00:00
|
|
|
|
2016-11-21 17:30:36 +00:00
|
|
|
u32 slowdown_warnings = 0;
|
|
|
|
u32 performance_warnings = 0;
|
2016-09-22 09:56:06 +00:00
|
|
|
|
2016-11-21 17:30:36 +00:00
|
|
|
u32 restore_left = user_options->restore_timer;
|
|
|
|
u32 remove_left = user_options->remove_timer;
|
|
|
|
u32 status_left = user_options->status_timer;
|
2016-09-22 09:56:06 +00:00
|
|
|
|
2016-09-29 21:49:33 +00:00
|
|
|
while (status_ctx->shutdown_inner == false)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
|
|
|
hc_sleep (sleep_time);
|
|
|
|
|
2016-09-29 21:25:29 +00:00
|
|
|
if (status_ctx->devices_status == STATUS_INIT) continue;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
if (hwmon_check == true)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-09-29 22:04:12 +00:00
|
|
|
hc_thread_mutex_lock (status_ctx->mux_hwmon);
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-10-04 09:22:08 +00:00
|
|
|
for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-09-15 14:02:52 +00:00
|
|
|
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-18 09:09:03 +00:00
|
|
|
if (device_param->skipped == true) continue;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
const int rc_throttle = hm_get_throttle_with_device_id (hashcat_ctx, device_id);
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
if (rc_throttle == -1) continue;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
if (rc_throttle > 0)
|
|
|
|
{
|
2016-10-17 23:24:03 +00:00
|
|
|
slowdown_warnings++;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-10-17 23:24:03 +00:00
|
|
|
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));
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
2016-10-10 09:03:11 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
slowdown_warnings = 0;
|
|
|
|
}
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
|
2016-09-29 22:04:12 +00:00
|
|
|
hc_thread_mutex_unlock (status_ctx->mux_hwmon);
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
if (hwmon_check == true)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-09-29 22:04:12 +00:00
|
|
|
hc_thread_mutex_lock (status_ctx->mux_hwmon);
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2017-08-16 17:43:41 +00:00
|
|
|
hc_time_t temp_check_time;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2017-08-16 17:43:41 +00:00
|
|
|
hc_time (&temp_check_time);
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-10-04 09:22:08 +00:00
|
|
|
u32 Ta = temp_check_time - last_temp_check_time; // set Ta = sleep_time; is not good enough (see --remove etc)
|
2016-09-15 02:29:22 +00:00
|
|
|
|
|
|
|
if (Ta == 0) Ta = 1;
|
|
|
|
|
2016-10-04 09:22:08 +00:00
|
|
|
for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-09-15 14:02:52 +00:00
|
|
|
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-18 09:09:03 +00:00
|
|
|
if (device_param->skipped == true) continue;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-09-15 14:02:52 +00:00
|
|
|
if ((opencl_ctx->devices_param[device_id].device_type & CL_DEVICE_TYPE_GPU) == 0) continue;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-10-06 09:10:00 +00:00
|
|
|
const int temperature = hm_get_temperature_with_device_id (hashcat_ctx, device_id);
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
if (temperature > (int) user_options->gpu_temp_abort)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-10-17 23:24:03 +00:00
|
|
|
EVENT_DATA (EVENT_MONITOR_TEMP_ABORT, &device_id, sizeof (u32));
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
myabort (hashcat_ctx);
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
|
2016-11-21 14:58:44 +00:00
|
|
|
if (hwmon_ctx->hm_device[device_id].fanspeed_get_supported == false) continue;
|
|
|
|
if (hwmon_ctx->hm_device[device_id].fanspeed_set_supported == false) continue;
|
2016-11-20 15:08:10 +00:00
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
const u32 gpu_temp_retain = user_options->gpu_temp_retain;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
if (gpu_temp_retain > 0)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-11-20 15:08:10 +00:00
|
|
|
int temp_cur = temperature;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
int temp_diff_new = (int) gpu_temp_retain - temp_cur;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
temp_diff_sum[device_id] = temp_diff_sum[device_id] + temp_diff_new;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
// calculate Ta value (time difference in seconds between the last check and this check)
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
last_temp_check_time = temp_check_time;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2017-01-04 14:01:35 +00:00
|
|
|
float Kp = 1.6f;
|
|
|
|
float Ki = 0.001f;
|
|
|
|
float Kd = 10.0f;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
// PID controller (3-term controller: proportional - Kp, integral - Ki, derivative - Kd)
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
int fan_diff_required = (int) (Kp * (float)temp_diff_new + Ki * Ta * (float)temp_diff_sum[device_id] + Kd * ((float)(temp_diff_new - temp_diff_old[device_id])) / Ta);
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
if (abs (fan_diff_required) >= temp_threshold)
|
|
|
|
{
|
|
|
|
const int fan_speed_cur = hm_get_fanspeed_with_device_id (hashcat_ctx, device_id);
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
int fan_speed_level = fan_speed_cur;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
if (fan_speed_chgd[device_id] == 0) fan_speed_level = temp_cur;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
int fan_speed_new = fan_speed_level - fan_diff_required;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
if (fan_speed_new > fan_speed_max) fan_speed_new = fan_speed_max;
|
|
|
|
if (fan_speed_new < fan_speed_min) fan_speed_new = fan_speed_min;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
if (fan_speed_new != fan_speed_cur)
|
|
|
|
{
|
|
|
|
int freely_change_fan_speed = (fan_speed_chgd[device_id] == 1);
|
|
|
|
int fan_speed_must_change = (fan_speed_new > fan_speed_cur);
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
if ((freely_change_fan_speed == 1) || (fan_speed_must_change == 1))
|
|
|
|
{
|
|
|
|
if (device_param->device_vendor_id == VENDOR_ID_AMD)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-11-20 15:08:10 +00:00
|
|
|
if (hwmon_ctx->hm_adl)
|
|
|
|
{
|
|
|
|
hm_set_fanspeed_with_device_id_adl (hashcat_ctx, device_id, fan_speed_new, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hwmon_ctx->hm_sysfs)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-11-20 15:08:10 +00:00
|
|
|
hm_set_fanspeed_with_device_id_sysfs (hashcat_ctx, device_id, fan_speed_new);
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
2016-11-20 15:08:10 +00:00
|
|
|
}
|
|
|
|
else if (device_param->device_vendor_id == VENDOR_ID_NV)
|
|
|
|
{
|
|
|
|
if (hwmon_ctx->hm_nvapi)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-10-06 09:10:00 +00:00
|
|
|
hm_set_fanspeed_with_device_id_nvapi (hashcat_ctx, device_id, fan_speed_new, 1);
|
2016-11-20 15:08:10 +00:00
|
|
|
}
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
if (hwmon_ctx->hm_xnvctrl)
|
|
|
|
{
|
2016-10-06 09:10:00 +00:00
|
|
|
hm_set_fanspeed_with_device_id_xnvctrl (hashcat_ctx, device_id, fan_speed_new);
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-20 15:08:10 +00:00
|
|
|
fan_speed_chgd[device_id] = 1;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
2016-11-20 15:08:10 +00:00
|
|
|
|
|
|
|
temp_diff_old[device_id] = temp_diff_new;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-29 22:04:12 +00:00
|
|
|
hc_thread_mutex_unlock (status_ctx->mux_hwmon);
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
if (restore_check == true)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
|
|
|
restore_left--;
|
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
if (restore_left == 0)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
const int rc = cycle_restore (hashcat_ctx);
|
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
restore_left = user_options->restore_timer;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-29 21:49:33 +00:00
|
|
|
if ((runtime_check == true) && (status_ctx->runtime_start > 0))
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-10-17 11:44:07 +00:00
|
|
|
const int runtime_left = get_runtime_left (hashcat_ctx);
|
2016-09-15 02:29:22 +00:00
|
|
|
|
|
|
|
if (runtime_left <= 0)
|
|
|
|
{
|
2016-10-17 23:24:03 +00:00
|
|
|
EVENT_DATA (EVENT_MONITOR_RUNTIME_LIMIT, NULL, 0);
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2017-01-06 07:45:40 +00:00
|
|
|
myabort_runtime (hashcat_ctx);
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
if (remove_check == true)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
|
|
|
remove_left--;
|
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
if (remove_left == 0)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-09-16 15:01:18 +00:00
|
|
|
if (hashes->digests_saved != hashes->digests_done)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-09-16 15:01:18 +00:00
|
|
|
hashes->digests_saved = hashes->digests_done;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
const int rc = save_hash (hashcat_ctx);
|
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
remove_left = user_options->remove_timer;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
if (status_check == true)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
|
|
|
status_left--;
|
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
if (status_left == 0)
|
2016-09-15 02:29:22 +00:00
|
|
|
{
|
2016-09-29 22:04:12 +00:00
|
|
|
hc_thread_mutex_lock (status_ctx->mux_display);
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-10-17 23:24:03 +00:00
|
|
|
EVENT_DATA (EVENT_MONITOR_STATUS_REFRESH, NULL, 0);
|
2016-10-14 19:38:52 +00:00
|
|
|
|
2016-09-29 22:04:12 +00:00
|
|
|
hc_thread_mutex_unlock (status_ctx->mux_display);
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-09-22 09:56:06 +00:00
|
|
|
status_left = user_options->status_timer;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
}
|
2016-11-21 17:30:36 +00:00
|
|
|
|
|
|
|
if (performance_check == true)
|
|
|
|
{
|
|
|
|
int exec_cnt = 0;
|
|
|
|
int util_cnt = 0;
|
|
|
|
|
|
|
|
double exec_total = 0;
|
|
|
|
double util_total = 0;
|
|
|
|
|
|
|
|
hc_thread_mutex_lock (status_ctx->mux_hwmon);
|
|
|
|
|
|
|
|
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 == true) continue;
|
|
|
|
|
|
|
|
exec_cnt++;
|
|
|
|
|
|
|
|
const double exec = status_get_exec_msec_dev (hashcat_ctx, device_id);
|
|
|
|
|
|
|
|
exec_total += exec;
|
|
|
|
|
|
|
|
const int util = hm_get_utilization_with_device_id (hashcat_ctx, device_id);
|
|
|
|
|
|
|
|
if (util == -1) continue;
|
|
|
|
|
|
|
|
util_total += (double) util;
|
|
|
|
|
|
|
|
util_cnt++;
|
|
|
|
}
|
|
|
|
|
|
|
|
hc_thread_mutex_unlock (status_ctx->mux_hwmon);
|
|
|
|
|
|
|
|
double exec_avg = 0;
|
|
|
|
double util_avg = 0;
|
|
|
|
|
|
|
|
if (exec_cnt > 0) exec_avg = exec_total / exec_cnt;
|
|
|
|
if (util_cnt > 0) util_avg = util_total / util_cnt;
|
|
|
|
|
|
|
|
if ((exec_avg > 0) && (exec_avg < exec_low))
|
|
|
|
{
|
|
|
|
performance_warnings++;
|
|
|
|
|
|
|
|
if (performance_warnings == 10) EVENT_DATA (EVENT_MONITOR_PERFORMANCE_HINT, NULL, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((util_avg > 0) && (util_avg < util_low))
|
|
|
|
{
|
|
|
|
performance_warnings++;
|
|
|
|
|
|
|
|
if (performance_warnings == 10) EVENT_DATA (EVENT_MONITOR_PERFORMANCE_HINT, NULL, 0);
|
|
|
|
}
|
|
|
|
}
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|
|
|
|
|
2016-10-04 09:03:20 +00:00
|
|
|
// final round of save_hash
|
|
|
|
|
|
|
|
if (remove_check == true)
|
|
|
|
{
|
|
|
|
if (hashes->digests_saved != hashes->digests_done)
|
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
const int rc = save_hash (hashcat_ctx);
|
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-10-04 09:03:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// final round of cycle_restore
|
|
|
|
|
|
|
|
if (restore_check == true)
|
|
|
|
{
|
2016-10-09 20:41:55 +00:00
|
|
|
const int rc = cycle_restore (hashcat_ctx);
|
|
|
|
|
|
|
|
if (rc == -1) return -1;
|
2016-10-04 09:03:20 +00:00
|
|
|
}
|
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
return 0;
|
2016-09-30 20:52:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void *thread_monitor (void *p)
|
|
|
|
{
|
|
|
|
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p;
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-10-09 20:41:55 +00:00
|
|
|
monitor (hashcat_ctx); // we should give back some useful returncode
|
2016-09-15 02:29:22 +00:00
|
|
|
|
2016-09-30 20:52:44 +00:00
|
|
|
return NULL;
|
2016-09-15 02:29:22 +00:00
|
|
|
}
|