diff --git a/src/status.c b/src/status.c index a3b05fb58..5dc6217a7 100644 --- a/src/status.c +++ b/src/status.c @@ -6,6 +6,7 @@ #include "common.h" #include "types.h" #include "memory.h" +#include "event.h" #include "convert.h" #include "restore.h" #include "thread.h" @@ -158,25 +159,27 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - fprintf (stdout, "Status view is not available during initialization phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - fprintf (stdout, "Status view is not available during autotune phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); return; } - fprintf (stdout, "STATUS\t%u\t", status_ctx->devices_status); + FILE *out = stdout; + + fprintf (out, "STATUS\t%u\t", status_ctx->devices_status); /** * speed new */ - fprintf (stdout, "SPEED\t"); + fprintf (out, "SPEED\t"); for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -196,14 +199,14 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) speed_cnt /= SPEED_CACHE; speed_ms /= SPEED_CACHE; - fprintf (stdout, "%" PRIu64 "\t%f\t", speed_cnt, speed_ms); + fprintf (out, "%" PRIu64 "\t%f\t", speed_cnt, speed_ms); } /** * exec time */ - fprintf (stdout, "EXEC_RUNTIME\t"); + fprintf (out, "EXEC_RUNTIME\t"); for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { @@ -213,7 +216,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) double exec_ms_avg = get_avg_exec_time (device_param, EXEC_CACHE); - fprintf (stdout, "%f\t", exec_ms_avg); + fprintf (out, "%f\t", exec_ms_avg); } /** @@ -222,7 +225,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) u64 words_cur = get_lowest_words_done (hashcat_ctx); - fprintf (stdout, "CURKU\t%" PRIu64 "\t", words_cur); + fprintf (out, "CURKU\t%" PRIu64 "\t", words_cur); /** * counter @@ -267,14 +270,14 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) u64 progress_cur_relative_skip = progress_cur - progress_skip; u64 progress_end_relative_skip = progress_end - progress_skip; - fprintf (stdout, "PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", progress_cur_relative_skip, progress_end_relative_skip); + fprintf (out, "PROGRESS\t%" PRIu64 "\t%" PRIu64 "\t", progress_cur_relative_skip, progress_end_relative_skip); /** * cracks */ - fprintf (stdout, "RECHASH\t%u\t%u\t", hashes->digests_done, hashes->digests_cnt); - fprintf (stdout, "RECSALT\t%u\t%u\t", hashes->salts_done, hashes->salts_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 @@ -282,7 +285,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) if (user_options->gpu_temp_disable == false) { - fprintf (stdout, "TEMP\t"); + fprintf (out, "TEMP\t"); hc_thread_mutex_lock (status_ctx->mux_hwmon); @@ -294,7 +297,7 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id); - fprintf (stdout, "%d\t", temp); + fprintf (out, "%d\t", temp); } hc_thread_mutex_unlock (status_ctx->mux_hwmon); @@ -304,9 +307,8 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) * flush */ - fputs (EOL, stdout); - - fflush (stdout); + fputs (EOL, out); + fflush (out); } void status_display (hashcat_ctx_t *hashcat_ctx) @@ -324,14 +326,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - fprintf (stdout, "Status view is not available during initialization phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - fprintf (stdout, "Status view is not available during autotune phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); return; } @@ -350,7 +352,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) u32 tmp_len = 0; - fprintf (stdout, "Session.Name...: %s", user_options->session); + event_log_info (hashcat_ctx, "Session.Name...: %s", user_options->session); char *status_type = strstatus (status_ctx->devices_status); @@ -358,7 +360,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) char *hash_type = strhashtype (hash_mode); // not a bug - fprintf (stdout, "Status.........: %s", status_type); + event_log_info (hashcat_ctx, "Status.........: %s", status_type); /** * show rules @@ -375,18 +377,18 @@ void status_display (hashcat_ctx_t *hashcat_ctx) snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, "File (%s)", user_options->rp_files[i]); - fprintf (stdout, "Rules.Type.....: %s", tmp_buf); + event_log_info (hashcat_ctx, "Rules.Type.....: %s", tmp_buf); tmp_len = 0; } if (user_options->rp_gen) { - fprintf (stdout, "Rules.Type.....: Generated (%u)", user_options->rp_gen); + event_log_info (hashcat_ctx, "Rules.Type.....: Generated (%u)", user_options->rp_gen); if (user_options->rp_gen_seed) { - fprintf (stdout, "Rules.Seed.....: %u", user_options->rp_gen_seed); + event_log_info (hashcat_ctx, "Rules.Seed.....: %u", user_options->rp_gen_seed); } } @@ -403,17 +405,17 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (user_options_extra->wordlist_mode == WL_MODE_FILE) { - fprintf (stdout, "Input.Mode.....: File (%s)", straight_ctx->dict); + event_log_info (hashcat_ctx, "Input.Mode.....: File (%s)", straight_ctx->dict); } else if (user_options_extra->wordlist_mode == WL_MODE_STDIN) { - fprintf (stdout, "Input.Mode.....: Pipe"); + event_log_info (hashcat_ctx, "Input.Mode.....: Pipe"); } } else if (user_options->attack_mode == ATTACK_MODE_COMBI) { - fprintf (stdout, "Input.Left.....: File (%s)", combinator_ctx->dict1); - fprintf (stdout, "Input.Right....: File (%s)", combinator_ctx->dict2); + event_log_info (hashcat_ctx, "Input.Left.....: File (%s)", combinator_ctx->dict1); + event_log_info (hashcat_ctx, "Input.Right....: File (%s)", combinator_ctx->dict2); } else if (user_options->attack_mode == ATTACK_MODE_BF) { @@ -449,7 +451,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) tmp_len += snprintf (tmp_buf + tmp_len, sizeof (tmp_buf) - tmp_len, " (%.02f%%)", mask_percentage * 100); } - fprintf (stdout, "Input.Mode.....: %s", tmp_buf); + event_log_info (hashcat_ctx, "Input.Mode.....: %s", tmp_buf); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -458,7 +460,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } @@ -466,8 +468,8 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { - fprintf (stdout, "Input.Left.....: File (%s)", straight_ctx->dict); - fprintf (stdout, "Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); + event_log_info (hashcat_ctx, "Input.Left.....: File (%s)", straight_ctx->dict); + event_log_info (hashcat_ctx, "Input.Right....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -476,13 +478,13 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { - fprintf (stdout, "Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); - fprintf (stdout, "Input.Right....: File (%s)", straight_ctx->dict); + event_log_info (hashcat_ctx, "Input.Left.....: Mask (%s) [%i]", mask_ctx->mask, mask_ctx->css_cnt); + event_log_info (hashcat_ctx, "Input.Right....: File (%s)", straight_ctx->dict); if ((custom_charset_1 != NULL) || (custom_charset_2 != NULL) || (custom_charset_3 != NULL) || (custom_charset_4 != NULL)) { @@ -491,7 +493,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (custom_charset_3 == NULL) custom_charset_3 = "Undefined"; if (custom_charset_4 == NULL) custom_charset_4 = "Undefined"; - fprintf (stdout, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); + event_log_info (hashcat_ctx, "Custom.Charset.: -1 %s, -2 %s, -3 %s, -4 %s", custom_charset_1, custom_charset_2, custom_charset_3, custom_charset_4); } } @@ -501,7 +503,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { wpa_t *wpa = (wpa_t *) hashes->esalts_buf; - fprintf (stdout, "Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)", + event_log_info (hashcat_ctx, "Hash.Target....: %s (%02x:%02x:%02x:%02x:%02x:%02x <-> %02x:%02x:%02x:%02x:%02x:%02x)", (char *) hashes->salts_buf[0].salt_buf, wpa->orig_mac1[0], wpa->orig_mac1[1], @@ -518,19 +520,19 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if (hashconfig->hash_mode == 5200) { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } else if (hashconfig->hash_mode == 9000) { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } else if ((hashconfig->hash_mode >= 6200) && (hashconfig->hash_mode <= 6299)) { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } else if ((hashconfig->hash_mode >= 13700) && (hashconfig->hash_mode <= 13799)) { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } else { @@ -547,7 +549,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) out_buf[44] = 0; } - fprintf (stdout, "Hash.Target....: %s", out_buf); + event_log_info (hashcat_ctx, "Hash.Target....: %s", out_buf); } } else @@ -560,15 +562,15 @@ void status_display (hashcat_ctx_t *hashcat_ctx) ascii_digest (hashcat_ctx, out_buf1, 0, 0); ascii_digest (hashcat_ctx, out_buf2, 0, 1); - fprintf (stdout, "Hash.Target....: %s, %s", out_buf1, out_buf2); + event_log_info (hashcat_ctx, "Hash.Target....: %s, %s", out_buf1, out_buf2); } else { - fprintf (stdout, "Hash.Target....: File (%s)", hashes->hashfile); + event_log_info (hashcat_ctx, "Hash.Target....: File (%s)", hashes->hashfile); } } - fprintf (stdout, "Hash.Type......: %s", hash_type); + event_log_info (hashcat_ctx, "Hash.Type......: %s", hash_type); /** * speed new @@ -691,12 +693,12 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (start[start_len - 1] == '\n') start[start_len - 1] = 0; if (start[start_len - 2] == '\r') start[start_len - 2] = 0; - fprintf (stdout, "Time.Started...: %s (%s)", start, display_run); + event_log_info (hashcat_ctx, "Time.Started...: %s (%s)", start, display_run); } } else { - fprintf (stdout, "Time.Started...: 0 secs"); + event_log_info (hashcat_ctx, "Time.Started...: 0 secs"); } /** @@ -784,7 +786,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((u64) sec_etc > SEC10YEARS) { - fprintf (stdout, "Time.Estimated.: > 10 Years"); + event_log_info (hashcat_ctx, "Time.Estimated.: > 10 Years"); } else { @@ -847,16 +849,16 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_timer_display (&tm_runtime, display_runtime, sizeof (display_runtime)); - fprintf (stdout, "Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limited (%s)", etc, display_etc, display_runtime); } else { - fprintf (stdout, "Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s), but limit exceeded", etc, display_etc); } } else { - fprintf (stdout, "Time.Estimated.: %s (%s)", etc, display_etc); + event_log_info (hashcat_ctx, "Time.Estimated.: %s (%s)", etc, display_etc); } } } @@ -875,7 +877,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_dev_ms[device_id] * 1000, display_dev_cur, sizeof (display_dev_cur)); - fprintf (stdout, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + event_log_info (hashcat_ctx, "Speed.Dev.#%d...: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } char display_all_cur[16] = { 0 }; @@ -884,12 +886,12 @@ void status_display (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*...: %9sH/s", display_all_cur); + if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*...: %9sH/s", display_all_cur); const double digests_percent = (double) hashes->digests_done / hashes->digests_cnt; const double salts_percent = (double) hashes->salts_done / hashes->salts_cnt; - fprintf (stdout, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); + event_log_info (hashcat_ctx, "Recovered......: %u/%u (%.2f%%) Digests, %u/%u (%.2f%%) Salts", hashes->digests_done, hashes->digests_cnt, digests_percent * 100, hashes->salts_done, hashes->salts_cnt, salts_percent * 100); // crack-per-time @@ -930,7 +932,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if ((cpt_ctx->cpt_start + 86400) < now) { - fprintf (stdout, "Recovered/Time.: CUR:%u,%u,%u AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",%" PRIu64 " AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_cur_day, @@ -940,7 +942,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 3600) < now) { - fprintf (stdout, "Recovered/Time.: CUR:%u,%u,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",%" PRIu64 ",N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_cur_hour, cpt_avg_min, @@ -949,7 +951,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else if ((cpt_ctx->cpt_start + 60) < now) { - fprintf (stdout, "Recovered/Time.: CUR:%u,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + event_log_info (hashcat_ctx, "Recovered/Time.: CUR:%" PRIu64 ",N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", cpt_cur_min, cpt_avg_min, cpt_avg_hour, @@ -957,7 +959,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) } else { - fprintf (stdout, "Recovered/Time.: CUR:N/A,N/A,N/A AVG:%0.2f,%0.2f,%0.2f (Min,Hour,Day)", + 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); @@ -986,14 +988,14 @@ void status_display (hashcat_ctx_t *hashcat_ctx) percent_rejected = (double) (all_rejected) / (double) progress_cur; } - fprintf (stdout, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); - fprintf (stdout, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", progress_cur_relative_skip, progress_end_relative_skip, percent_finished * 100); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", all_rejected, progress_cur_relative_skip, percent_rejected * 100); if (user_options->restore_disable == false) { if (percent_finished != 1) { - fprintf (stdout, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); + event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", restore_point, restore_total, percent_restore * 100); } } } @@ -1002,24 +1004,24 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { - fprintf (stdout, "Progress.......: 0/0 (100%%)"); - fprintf (stdout, "Rejected.......: 0/0 (100%%)"); + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); if (user_options->restore_disable == false) { - fprintf (stdout, "Restore.Point..: 0/0 (100%%)"); + event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "/%" PRIu64 " (%.02f%%)", 0ull, 0ull, 100); } } else { - fprintf (stdout, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); - fprintf (stdout, "Rejected.......: %" PRIu64 "", all_rejected); + event_log_info (hashcat_ctx, "Progress.......: %" PRIu64 "", progress_cur_relative_skip); + event_log_info (hashcat_ctx, "Rejected.......: %" PRIu64 "", all_rejected); // --restore not allowed if stdin is used -- really? why? //if (user_options->restore_disable == false) //{ - // fprintf (stdout, "Restore.Point..: %" PRIu64 "", restore_point); + // event_log_info (hashcat_ctx, "Restore.Point..: %" PRIu64 "", restore_point); //} } } @@ -1036,11 +1038,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) { if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - fprintf (stdout, "Candidates.#%d..: [Generating]", device_id + 1); + event_log_info (hashcat_ctx, "Candidates.#%d..: [Generating]", device_id + 1); } else { - fprintf (stdout, "Candidates.#%d..: [Copying]", device_id + 1); + event_log_info (hashcat_ctx, "Candidates.#%d..: [Copying]", device_id + 1); } continue; @@ -1078,11 +1080,11 @@ void status_display (hashcat_ctx_t *hashcat_ctx) plain_ptr1[plain_len1 * 2] = 0; plain_ptr2[plain_len2 * 2] = 0; - fprintf (stdout, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); + event_log_info (hashcat_ctx, "Candidates.#%d..: $HEX[%s] -> $HEX[%s]", device_id + 1, plain_ptr1, plain_ptr2); } else { - fprintf (stdout, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); + event_log_info (hashcat_ctx, "Candidates.#%d..: %s -> %s", device_id + 1, plain_ptr1, plain_ptr2); } } @@ -1164,7 +1166,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) output_len = strlen (output_buf); } - fprintf (stdout, "HWMon.Dev.#%d...:%s", device_id + 1, output_buf); + event_log_info (hashcat_ctx, "HWMon.Dev.#%d...:%s", device_id + 1, output_buf); } hc_thread_mutex_unlock (status_ctx->mux_hwmon); @@ -1179,14 +1181,14 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - fprintf (stdout, "Status view is not available during initialization phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - fprintf (stdout, "Status view is not available during autotune phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); return; } @@ -1226,7 +1228,7 @@ void status_benchmark_automate (hashcat_ctx_t *hashcat_ctx) if (device_param->skipped) continue; - fprintf (stdout, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); + event_log_info (hashcat_ctx, "%u:%u:%" PRIu64 "", device_id + 1, hashconfig->hash_mode, (hashes_dev_ms[device_id] * 1000)); } } @@ -1238,14 +1240,14 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (status_ctx->devices_status == STATUS_INIT) { - fprintf (stdout, "Status view is not available during initialization phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during initialization phase"); return; } if (status_ctx->devices_status == STATUS_AUTOTUNE) { - fprintf (stdout, "Status view is not available during autotune phase" EOL); + event_log_error (hashcat_ctx, "status view is not available during autotune phase"); return; } @@ -1323,11 +1325,11 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (opencl_ctx->devices_active >= 10) { - fprintf (stdout, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + event_log_info (hashcat_ctx, "Speed.Dev.#%d: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } else { - fprintf (stdout, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); + event_log_info (hashcat_ctx, "Speed.Dev.#%d.: %9sH/s (%0.2fms)", device_id + 1, display_dev_cur, exec_all_ms[device_id]); } } @@ -1337,7 +1339,7 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) format_speed_display ((double) hashes_all_ms * 1000, display_all_cur, sizeof (display_all_cur)); - if (opencl_ctx->devices_active > 1) fprintf (stdout, "Speed.Dev.#*.: %9sH/s", display_all_cur); + if (opencl_ctx->devices_active > 1) event_log_info (hashcat_ctx, "Speed.Dev.#*.: %9sH/s", display_all_cur); } int status_progress_init (hashcat_ctx_t *hashcat_ctx) diff --git a/src/terminal.c b/src/terminal.c index b0b07ca23..09b084045 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -5,6 +5,7 @@ #include "common.h" #include "types.h" +#include "event.h" #include "thread.h" #include "timer.h" #include "status.h" @@ -28,23 +29,23 @@ void welcome_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const { if (user_options->machine_readable == false) { - fprintf (stdout, "%s (%s) starting in benchmark-mode..." EOL, PROGNAME, version_tag); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, "%s (%s) starting in benchmark-mode...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, ""); } else { - fprintf (stdout, "# %s (%s) %s" EOL, 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) { - fprintf (stdout, "%s (%s) starting in restore-mode..." EOL, PROGNAME, version_tag); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, "%s (%s) starting in restore-mode...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, ""); } else { - fprintf (stdout, "%s (%s) starting..." EOL, PROGNAME, version_tag); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, "%s (%s) starting...", PROGNAME, version_tag); + event_log_info (hashcat_ctx, ""); } } @@ -58,8 +59,8 @@ 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; - fprintf (stdout, "Started: %s", ctime (&proc_start)); - fprintf (stdout, "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 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) @@ -69,21 +70,21 @@ int setup_console (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx) if (_setmode (_fileno (stdin), _O_BINARY) == -1) { - fprintf (stderr, "_setmode(): %s", strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", "stdin", strerror (errno)); return -1; } if (_setmode (_fileno (stdout), _O_BINARY) == -1) { - fprintf (stderr, "_setmode(): %s", strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", "stdout", strerror (errno)); return -1; } if (_setmode (_fileno (stderr), _O_BINARY) == -1) { - fprintf (stderr, "_setmode(): %s", strerror (errno)); + event_log_error (hashcat_ctx, "%s: %s", "stderr", strerror (errno)); return -1; } @@ -140,7 +141,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) hc_thread_mutex_lock (status_ctx->mux_display); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); switch (ch) { @@ -148,11 +149,11 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case '\r': case '\n': - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); status_display (hashcat_ctx); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -160,13 +161,13 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'b': - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); bypass (hashcat_ctx); - fprintf (stdout, "Next dictionary / mask in queue selected, bypassing current one" EOL); + event_log_info (hashcat_ctx, "Next dictionary / mask in queue selected, bypassing current one"); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -174,16 +175,16 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'p': - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); SuspendThreads (hashcat_ctx); if (status_ctx->devices_status == STATUS_PAUSED) { - fprintf (stdout, "Paused" EOL); + event_log_info (hashcat_ctx, "Paused"); } - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -191,16 +192,16 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'r': - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); ResumeThreads (hashcat_ctx); if (status_ctx->devices_status == STATUS_RUNNING) { - fprintf (stdout, "Resumed" EOL); + event_log_info (hashcat_ctx, "Resumed"); } - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -208,11 +209,11 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'c': - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); stop_at_checkpoint (hashcat_ctx); - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); if (quiet == false) send_prompt (); @@ -220,7 +221,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) case 'q': - fprintf (stdout, EOL); + event_log_info (hashcat_ctx, ""); myabort (hashcat_ctx);