Added CPT functions for later use in status.c

pull/544/head
jsteube 8 years ago
parent df521d664b
commit 86c1c7ef10

@ -16,6 +16,9 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_en
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_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_input_mode (const hashcat_ctx_t *hashcat_ctx);
@ -32,6 +35,7 @@ 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);
@ -49,11 +53,18 @@ 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 u32 device_id);
double status_get_hashes_msec_dev (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 u32 device_id);
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 u32 device_id);
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);
int status_progress_init (hashcat_ctx_t *hashcat_ctx);
void status_progress_destroy (hashcat_ctx_t *hashcat_ctx);

@ -1452,13 +1452,6 @@ typedef struct hashcat_ctx
} hashcat_ctx_t;
typedef struct
{
bool skipped;
} device_info_t;
typedef enum input_mode
{
INPUT_MODE_NONE = 0,
@ -1479,6 +1472,15 @@ typedef enum input_mode
} input_mode_t;
typedef struct
{
bool skipped_dev;
double hashes_msec_dev;
double exec_msec_dev;
char *speed_sec_dev;
} device_info_t;
typedef struct
{
char *hash_target;
@ -1494,6 +1496,7 @@ typedef struct
char *time_started_relative;
double msec_paused;
double msec_running;
double msec_real;
int digests_cnt;
int digests_done;
double digests_percent;
@ -1513,9 +1516,21 @@ typedef struct
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;

@ -1144,6 +1144,7 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st
hashcat_status->input_mod = status_get_input_mod (hashcat_ctx);
hashcat_status->msec_paused = status_get_msec_paused (hashcat_ctx);
hashcat_status->msec_running = status_get_msec_running (hashcat_ctx);
hashcat_status->msec_real = status_get_msec_real (hashcat_ctx);
hashcat_status->progress_cur_relative_skip = status_get_progress_cur_relative_skip (hashcat_ctx);
hashcat_status->progress_cur = status_get_progress_cur (hashcat_ctx);
hashcat_status->progress_done = status_get_progress_done (hashcat_ctx);
@ -1165,6 +1166,32 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st
hashcat_status->time_estimated_relative = status_get_time_estimated_relative (hashcat_ctx);
hashcat_status->time_started_absolute = status_get_time_started_absolute (hashcat_ctx);
hashcat_status->time_started_relative = status_get_time_started_relative (hashcat_ctx);
hashcat_status->cpt_cur_min = status_get_cpt_cur_min (hashcat_ctx);
hashcat_status->cpt_cur_hour = status_get_cpt_cur_hour (hashcat_ctx);
hashcat_status->cpt_cur_day = status_get_cpt_cur_day (hashcat_ctx);
hashcat_status->cpt_avg_min = status_get_cpt_avg_min (hashcat_ctx);
hashcat_status->cpt_avg_hour = status_get_cpt_avg_hour (hashcat_ctx);
hashcat_status->cpt_avg_day = status_get_cpt_avg_day (hashcat_ctx);
hashcat_status->cpt = status_get_cpt (hashcat_ctx);
// multiple devices
hashcat_status->device_info_cnt = status_get_device_info_cnt (hashcat_ctx);
hashcat_status->device_info_active = status_get_device_info_active (hashcat_ctx);
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
device_info_t *device_info = hashcat_status->device_info_buf + device_id;
device_info->skipped_dev = status_get_skipped_dev (hashcat_ctx, device_id);
device_info->hashes_msec_dev = status_get_hashes_msec_dev (hashcat_ctx, device_id);
device_info->exec_msec_dev = status_get_exec_msec_dev (hashcat_ctx, device_id);
device_info->speed_sec_dev = status_get_speed_sec_dev (hashcat_ctx, device_id);
}
hashcat_status->hashes_msec_all = status_get_hashes_msec_all (hashcat_ctx);
hashcat_status->exec_msec_all = status_get_exec_msec_all (hashcat_ctx);
hashcat_status->speed_sec_all = status_get_speed_sec_all (hashcat_ctx);
return 0;
}

@ -155,6 +155,29 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_en
return exec_msec_sum / exec_msec_cnt;
}
int status_get_device_info_cnt (const hashcat_ctx_t *hashcat_ctx)
{
const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
return opencl_ctx->devices_cnt;
}
int status_get_device_info_active (const hashcat_ctx_t *hashcat_ctx)
{
const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
return opencl_ctx->devices_active;
}
bool status_get_skipped_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id)
{
const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
return device_param->skipped;
}
char *status_get_session (const hashcat_ctx_t *hashcat_ctx)
{
const user_options_t *user_options = hashcat_ctx->user_options;
@ -555,6 +578,16 @@ double status_get_msec_paused (const hashcat_ctx_t *hashcat_ctx)
return msec_paused;
}
double status_get_msec_real (const hashcat_ctx_t *hashcat_ctx)
{
const double msec_running = status_get_msec_running (hashcat_ctx);
const double msec_paused = status_get_msec_paused (hashcat_ctx);
const double msec_real = msec_running - msec_paused;
return msec_real;
}
char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx)
{
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
@ -943,7 +976,7 @@ double status_get_hashes_msec_all (const hashcat_ctx_t *hashcat_ctx)
return hashes_all_msec;
}
double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id)
double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id)
{
const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
@ -988,7 +1021,7 @@ double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx)
return exec_all_msec;
}
double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id)
double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id)
{
const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
@ -1015,7 +1048,7 @@ char *status_get_speed_sec_all (const hashcat_ctx_t *hashcat_ctx)
return display;
}
char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 device_id)
char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id)
{
const double hashes_msec_dev = status_get_hashes_msec_dev (hashcat_ctx, device_id);
@ -1026,6 +1059,159 @@ char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const u32 devi
return display;
}
int status_get_cpt_cur_min (const hashcat_ctx_t *hashcat_ctx)
{
const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
const time_t now = time (NULL);
int cpt_cur_min = 0;
for (int i = 0; i < CPT_BUF; i++)
{
const u32 cracked = cpt_ctx->cpt_buf[i].cracked;
const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp;
if ((timestamp + 60) > now)
{
cpt_cur_min += cracked;
}
}
return cpt_cur_min;
}
int status_get_cpt_cur_hour (const hashcat_ctx_t *hashcat_ctx)
{
const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
const time_t now = time (NULL);
int cpt_cur_hour = 0;
for (int i = 0; i < CPT_BUF; i++)
{
const u32 cracked = cpt_ctx->cpt_buf[i].cracked;
const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp;
if ((timestamp + 3600) > now)
{
cpt_cur_hour += cracked;
}
}
return cpt_cur_hour;
}
int status_get_cpt_cur_day (const hashcat_ctx_t *hashcat_ctx)
{
const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
const time_t now = time (NULL);
int cpt_cur_day = 0;
for (int i = 0; i < CPT_BUF; i++)
{
const u32 cracked = cpt_ctx->cpt_buf[i].cracked;
const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp;
if ((timestamp + 86400) > now)
{
cpt_cur_day += cracked;
}
}
return cpt_cur_day;
}
double status_get_cpt_avg_min (const hashcat_ctx_t *hashcat_ctx)
{
const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
const double msec_real = status_get_msec_real (hashcat_ctx);
const double cpt_avg_min = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 60);
return cpt_avg_min;
}
double status_get_cpt_avg_hour (const hashcat_ctx_t *hashcat_ctx)
{
const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
const double msec_real = status_get_msec_real (hashcat_ctx);
const double cpt_avg_hour = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 3600);
return cpt_avg_hour;
}
double status_get_cpt_avg_day (const hashcat_ctx_t *hashcat_ctx)
{
const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
const double msec_real = status_get_msec_real (hashcat_ctx);
const double cpt_avg_day = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 86400);
return cpt_avg_day;
}
char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx)
{
const cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
const time_t now = time (NULL);
char *cpt = (char *) malloc (HCBUFSIZ_TINY);
const int cpt_cur_min = status_get_cpt_cur_min (hashcat_ctx);
const int cpt_cur_hour = status_get_cpt_cur_hour (hashcat_ctx);
const int cpt_cur_day = status_get_cpt_cur_day (hashcat_ctx);
const double cpt_avg_min = status_get_cpt_avg_min (hashcat_ctx);
const double cpt_avg_hour = status_get_cpt_avg_hour (hashcat_ctx);
const double cpt_avg_day = status_get_cpt_avg_day (hashcat_ctx);
if ((cpt_ctx->cpt_start + 86400) < now)
{
snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
cpt_cur_min,
cpt_cur_hour,
cpt_cur_day,
cpt_avg_min,
cpt_avg_hour,
cpt_avg_day);
}
else if ((cpt_ctx->cpt_start + 3600) < now)
{
snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
cpt_cur_min,
cpt_cur_hour,
cpt_avg_min,
cpt_avg_hour,
cpt_avg_day);
}
else if ((cpt_ctx->cpt_start + 60) < now)
{
snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
cpt_cur_min,
cpt_avg_min,
cpt_avg_hour,
cpt_avg_day);
}
else
{
snprintf (cpt, HCBUFSIZ_TINY - 1, "CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
cpt_avg_min,
cpt_avg_hour,
cpt_avg_day);
}
return cpt;
}
int status_progress_init (hashcat_ctx_t *hashcat_ctx)
{
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;

@ -611,8 +611,6 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx)
void status_display (hashcat_ctx_t *hashcat_ctx)
{
cpt_ctx_t *cpt_ctx = hashcat_ctx->cpt_ctx;
hashes_t *hashes = hashcat_ctx->hashes;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
@ -669,6 +667,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx)
status_get_salts_done (hashcat_ctx),
status_get_salts_cnt (hashcat_ctx),
status_get_salts_percent (hashcat_ctx));
event_log_info (hashcat_ctx, "Recovered/Time.: %s", status_get_cpt (hashcat_ctx));
const int input_mode = status_get_input_mode (hashcat_ctx);
@ -731,27 +730,19 @@ void status_display (hashcat_ctx_t *hashcat_ctx)
break;
}
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];
const int device_info_cnt = status_get_device_info_cnt (hashcat_ctx);
const int device_info_active = status_get_device_info_active (hashcat_ctx);
if (device_param->skipped) continue;
for (int device_id = 0; device_id < device_info_cnt; device_id++)
{
if (status_get_skipped_dev (hashcat_ctx, device_id) == true) continue;
event_log_info (hashcat_ctx, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1,
status_get_speed_sec_dev (hashcat_ctx, device_id),
status_get_exec_msec_dev (hashcat_ctx, device_id));
}
if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", status_get_speed_sec_all (hashcat_ctx));
/**
* timers
*/
const double msec_running = status_get_msec_running (hashcat_ctx);
const double msec_paused = status_get_msec_paused (hashcat_ctx);
if (device_info_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", status_get_speed_sec_all (hashcat_ctx));
/**
@ -763,80 +754,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx)
const u64 progress_cur_relative_skip = status_get_progress_cur_relative_skip (hashcat_ctx);
const u64 progress_end_relative_skip = status_get_progress_end_relative_skip (hashcat_ctx);
// crack-per-time
if (hashes->digests_cnt > 100)
{
time_t now = time (NULL);
int cpt_cur_min = 0;
int cpt_cur_hour = 0;
int cpt_cur_day = 0;
for (int i = 0; i < CPT_BUF; i++)
{
const u32 cracked = cpt_ctx->cpt_buf[i].cracked;
const time_t timestamp = cpt_ctx->cpt_buf[i].timestamp;
if ((timestamp + 60) > now)
{
cpt_cur_min += cracked;
}
if ((timestamp + 3600) > now)
{
cpt_cur_hour += cracked;
}
if ((timestamp + 86400) > now)
{
cpt_cur_day += cracked;
}
}
const double msec_real = msec_running - msec_paused;
double cpt_avg_min = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 60);
double cpt_avg_hour = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 3600);
double cpt_avg_day = (double) cpt_ctx->cpt_total / ((msec_real / 1000) / 86400);
if ((cpt_ctx->cpt_start + 86400) < now)
{
event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
cpt_cur_min,
cpt_cur_hour,
cpt_cur_day,
cpt_avg_min,
cpt_avg_hour,
cpt_avg_day);
}
else if ((cpt_ctx->cpt_start + 3600) < now)
{
event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
cpt_cur_min,
cpt_cur_hour,
cpt_avg_min,
cpt_avg_hour,
cpt_avg_day);
}
else if ((cpt_ctx->cpt_start + 60) < now)
{
event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
cpt_cur_min,
cpt_avg_min,
cpt_avg_hour,
cpt_avg_day);
}
else
{
event_log_info (hashcat_ctx, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)",
cpt_avg_min,
cpt_avg_hour,
cpt_avg_day);
}
}
// Restore point
const u64 restore_point = status_get_restore_point (hashcat_ctx);

Loading…
Cancel
Save