Make status_display_machine_readable() use of hashcat_status_t

pull/544/head
jsteube 8 years ago
parent 89e3168280
commit c3266e363a

@ -21,6 +21,7 @@ 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);

@ -1500,7 +1500,8 @@ typedef struct
char *input_charset;
char *input_mod;
char *session;
char *status;
char *status_string;
int status_number;
char *time_estimated_absolute;
char *time_estimated_relative;
char *time_started_absolute;

@ -1189,7 +1189,8 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st
hashcat_status->salts_done = status_get_salts_done (hashcat_ctx);
hashcat_status->salts_percent = status_get_salts_percent (hashcat_ctx);
hashcat_status->session = status_get_session (hashcat_ctx);
hashcat_status->status = status_get_status_string (hashcat_ctx);
hashcat_status->status_string = status_get_status_string (hashcat_ctx);
hashcat_status->status_number = status_get_status_number (hashcat_ctx);
hashcat_status->time_estimated_absolute = status_get_time_estimated_absolute (hashcat_ctx);
hashcat_status->time_estimated_relative = status_get_time_estimated_relative (hashcat_ctx);
hashcat_status->time_started_absolute = status_get_time_started_absolute (hashcat_ctx);

@ -207,6 +207,13 @@ char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx)
return ((char *) ST_9999);
}
int status_get_status_number (const hashcat_ctx_t *hashcat_ctx)
{
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
return status_ctx->devices_status;
}
char *status_get_hash_type (const hashcat_ctx_t *hashcat_ctx)
{
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;

@ -448,167 +448,75 @@ int tty_fix()
void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx)
{
combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx;
hashes_t *hashes = hashcat_ctx->hashes;
mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx;
opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx;
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx;
user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra;
user_options_t *user_options = hashcat_ctx->user_options;
if (status_ctx->devices_status == STATUS_INIT)
{
event_log_error (hashcat_ctx, "status view is not available during initialization phase");
return;
}
if (status_ctx->devices_status == STATUS_AUTOTUNE)
{
event_log_error (hashcat_ctx, "status view is not available during autotune phase");
return;
}
FILE *out = stdout;
fprintf (out, "STATUS\t%u\t", status_ctx->devices_status);
const user_options_t *user_options = hashcat_ctx->user_options;
/**
* speed new
*/
hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (hashcat_ctx, sizeof (hashcat_status_t));
fprintf (out, "SPEED\t");
const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status);
for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
if (rc_status == -1)
{
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
u64 speed_cnt = 0;
double speed_msec = 0;
for (int i = 0; i < SPEED_CACHE; i++)
{
speed_cnt += device_param->speed_cnt[i];
speed_msec += device_param->speed_msec[i];
}
speed_cnt /= SPEED_CACHE;
speed_msec /= SPEED_CACHE;
hcfree (hashcat_status);
fprintf (out, "%" PRIu64 "\t%f\t", speed_cnt, speed_msec);
return;
}
/**
* exec time
*/
printf ("STATUS\t%u\t", hashcat_status->status_number);
fprintf (out, "EXEC_RUNTIME\t");
printf ("SPEED\t");
for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
if (device_param->skipped) continue;
const double exec_msec_avg = get_avg_exec_time (device_param, EXEC_CACHE);
fprintf (out, "%f\t", exec_msec_avg);
}
/**
* words_cur
*/
u64 words_cur = get_lowest_words_done (hashcat_ctx);
fprintf (out, "CURKU\t%" PRIu64 "\t", words_cur);
/**
* counter
*/
u64 progress_total = status_ctx->words_cnt * hashes->salts_cnt;
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
u64 all_done = 0;
u64 all_rejected = 0;
u64 all_restored = 0;
if (device_info->skipped_dev == true) continue;
for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++)
{
all_done += status_ctx->words_progress_done[salt_pos];
all_rejected += status_ctx->words_progress_rejected[salt_pos];
all_restored += status_ctx->words_progress_restored[salt_pos];
// the 1\t is for backward compatibility
printf ("%" PRIu64 "\t1\t", (u64) device_info->hashes_msec_dev);
}
u64 progress_cur = all_restored + all_done + all_rejected;
u64 progress_end = progress_total;
u64 progress_skip = 0;
printf ("EXEC_RUNTIME\t");
if (user_options->skip)
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
progress_skip = MIN (user_options->skip, status_ctx->words_base) * hashes->salts_cnt;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_skip *= straight_ctx->kernel_rules_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_skip *= combinator_ctx->combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_skip *= mask_ctx->bfs_cnt;
}
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (user_options->limit)
{
progress_end = MIN (user_options->limit, status_ctx->words_base) * hashes->salts_cnt;
if (device_info->skipped_dev == true) continue;
if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) progress_end *= straight_ctx->kernel_rules_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) progress_end *= combinator_ctx->combs_cnt;
else if (user_options_extra->attack_kern == ATTACK_KERN_BF) progress_end *= mask_ctx->bfs_cnt;
printf ("%f\t", device_info->exec_msec_dev);
}
u64 progress_cur_relative_skip = progress_cur - progress_skip;
u64 progress_end_relative_skip = progress_end - progress_skip;
printf ("CURKU\t%" PRIu64 "\t", hashcat_status->restore_point);
fprintf (out, "PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", progress_cur_relative_skip, progress_end_relative_skip);
printf ("PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip);
/**
* cracks
*/
printf ("RECHASH\t%u\t%u\t", hashcat_status->digests_done, hashcat_status->digests_cnt);
fprintf (out, "RECHASH\t%u\t%u\t", hashes->digests_done, hashes->digests_cnt);
fprintf (out, "RECSALT\t%u\t%u\t", hashes->salts_done, hashes->salts_cnt);
/**
* temperature
*/
printf ("RECSALT\t%u\t%u\t", hashcat_status->salts_done, hashcat_status->salts_cnt);
if (user_options->gpu_temp_disable == false)
{
fprintf (out, "TEMP\t");
hc_thread_mutex_lock (status_ctx->mux_hwmon);
printf ("TEMP\t");
for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++)
for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++)
{
hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id];
const device_info_t *device_info = hashcat_status->device_info_buf + device_id;
if (device_param->skipped) continue;
if (device_info->skipped_dev == true) continue;
int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id);
// ok, little cheat here...
fprintf (out, "%d\t", temp);
}
const int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id);
hc_thread_mutex_unlock (status_ctx->mux_hwmon);
printf ("%d\t", temp);
}
}
/**
* flush
*/
printf (EOL);
fflush (stdout);
fputs (EOL, out);
fflush (out);
hcfree (hashcat_status);
}
void status_display (hashcat_ctx_t *hashcat_ctx)
@ -642,8 +550,9 @@ void status_display (hashcat_ctx_t *hashcat_ctx)
hashcat_status->session);
event_log_info (hashcat_ctx,
"Status.........: %s",
hashcat_status->status);
"Status.........: %s (%u)",
hashcat_status->status_string,
hashcat_status->status_number);
event_log_info (hashcat_ctx,
"Time.Started...: %s (%s)",

Loading…
Cancel
Save