From 3ce57b5d2aa0c710599b358e91ed69bd1944ec76 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 29 Jan 2022 08:15:28 +0100 Subject: [PATCH] Added generic system info to backend_info() --- include/terminal.h | 7 ++++++ src/terminal.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/include/terminal.h b/include/terminal.h index b40ec9ed3..c89deed67 100644 --- a/include/terminal.h +++ b/include/terminal.h @@ -21,6 +21,13 @@ #endif // __APPLE__ #endif // _WIN +#if !defined (_WIN) && !defined (__CYGWIN__) && !defined (__MSYS__) +#include +#if !defined (__linux__) +#include +#endif // ! __linux__ +#endif // ! _WIN && | __CYGWIN__ && ! __MSYS__ + void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag); void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const time_t proc_start, const time_t proc_stop); diff --git a/src/terminal.c b/src/terminal.c index 13f46c1ee..6c5c686b1 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -801,6 +801,62 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) { const backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; + event_log_info (hashcat_ctx, "System Info:"); + event_log_info (hashcat_ctx, "============"); + event_log_info (hashcat_ctx, NULL); + + #if defined (_WIN) || defined (__CYGWIN__) || defined (__MSYS__) + // TODO + event_log_info (hashcat_ctx, "OS.Name......: N/A"); + event_log_info (hashcat_ctx, "OS.Release...: N/A"); + event_log_info (hashcat_ctx, "HW.Platform..: N/A"); + event_log_info (hashcat_ctx, "HW.Model.....: N/A"); + #else + struct utsname utsbuf; + + bool rc_uname = false; + bool rc_sysctl = false; + + char *hw_model = NULL; + size_t hw_model_len = 0; + + #if !defined (__linux__) + + if (sysctlbyname ("hw.model", NULL, &hw_model_len, NULL, 0) == 0 && hw_model_len > 0) + { + hw_model = (char *) hcmalloc (hw_model_len); + + if (sysctlbyname ("hw.model", hw_model, &hw_model_len, NULL, 0) != 0) + { + hw_model = NULL; + hw_model_len = 0; + + hcfree (hw_model); + } + else + { + rc_sysctl = true; + } + } + #endif // ! __linux__ + + if (uname (&utsbuf) == 0) + { + rc_uname = true; + } + + event_log_info (hashcat_ctx, "OS.Name......: %s", (rc_uname == true) ? utsbuf.sysname : "N/A"); + event_log_info (hashcat_ctx, "OS.Release...: %s", (rc_uname == true) ? utsbuf.release : "N/A"); + event_log_info (hashcat_ctx, "HW.Model.....: %s", (rc_sysctl == true) ? hw_model : "N/A"); + event_log_info (hashcat_ctx, "HW.Platform..: %s", (rc_uname == true) ? utsbuf.machine : "N/A"); + event_log_info (hashcat_ctx, NULL); + + if (rc_sysctl == true) + { + hcfree (hw_model); + } + #endif // _WIN || __CYGWIN__ || __MSYS__ + if (backend_ctx->cuda) { event_log_info (hashcat_ctx, "CUDA Info:");