From 47134e363ecc09155ff20ea81a1977b220000ad7 Mon Sep 17 00:00:00 2001 From: Gabriele Gristina Date: Sat, 12 Feb 2022 02:03:48 +0100 Subject: [PATCH] Backend Info: Added folder_config info to output --- docs/changes.txt | 1 + src/folder.c | 31 ++++++++++++++++--------------- src/terminal.c | 17 ++++++++++++++++- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 9a0eaa984..663b89fc8 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -45,6 +45,7 @@ - Association Attack: Enable module specific pw_min and pw_max settings to avoid false positives in -a 9 attack-mode - Autotune: Added error handling. By default skipping device on error, with --force using accel/loops/threads min values instead +- Backend Info: Added folder_config info to output - Backend Info: Added generic system info to output (must be completed on Windows side) - Backend Info: Added local memory size to output - Backend: with kernel build options, switch from -I to -D INCLUDE_PATH, in order to support Apple Metal runtime diff --git a/src/folder.c b/src/folder.c index 8a50eeb9c..531b2e4af 100644 --- a/src/folder.c +++ b/src/folder.c @@ -22,7 +22,7 @@ static int get_exec_path (char *exec_path, const size_t exec_path_sz) { #if defined (__linux__) || defined (__CYGWIN__) - char *tmp; + char *tmp = NULL; hc_asprintf (&tmp, "/proc/%d/exe", getpid ()); @@ -147,7 +147,7 @@ static void get_session_dir (char *session_dir, const char *profile_dir) { snprintf (session_dir, HCBUFSIZ_TINY, "%s/%s", profile_dir, SESSIONS_FOLDER); } -#endif +#endif // _POSIX int count_dictionaries (char **dictionary_files) { @@ -160,12 +160,12 @@ int count_dictionaries (char **dictionary_files) cnt++; } - return (cnt); + return cnt; } char *first_file_in_directory (const char *path) { - DIR *d; + DIR *d = NULL; if ((d = opendir (path)) != NULL) { @@ -187,7 +187,7 @@ char *first_file_in_directory (const char *path) #else - struct dirent *de; + struct dirent *de = NULL; while ((de = readdir (d)) != NULL) { @@ -246,7 +246,7 @@ char **scan_directory (const char *path) #else - struct dirent *de; + struct dirent *de = NULL; while ((de = readdir (d)) != NULL) { @@ -255,11 +255,11 @@ char **scan_directory (const char *path) if (de->d_name[0] == '.') continue; - char *path_file; + char *path_file = NULL; hc_asprintf (&path_file, "%s/%s", tmp_path, de->d_name); - DIR *d_test; + DIR *d_test = NULL; if ((d_test = opendir (path_file)) != NULL) { @@ -294,7 +294,7 @@ char **scan_directory (const char *path) hcfree (tmp_path); - return (files); + return files; } int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *install_folder, MAYBE_UNUSED const char *shared_folder) @@ -393,10 +393,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins if (strcmp (install_dir, resolved_install_folder) == 0) { struct passwd pw; - struct passwd *pwp; + struct passwd *pwp = NULL; char buf[HCBUFSIZ_TINY]; + memset (buf, 0, sizeof (buf)); + memset (&pw, 0, sizeof (pw)); + getpwuid_r (getuid (), &pw, buf, HCBUFSIZ_TINY, &pwp); const char *home_dir = pwp->pw_dir; @@ -448,13 +451,13 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * The best workaround found so far is to modify the TMP variable (only inside hashcat process) before the runtime is loaded. */ - char *cpath; + char *cpath = NULL; #if defined (_WIN) hc_asprintf (&cpath, "%s\\OpenCL\\", shared_dir); - char *cpath_real; + char *cpath_real = NULL; hc_asprintf (&cpath_real, "%s\\OpenCL\\", shared_dir); @@ -481,7 +484,6 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins shared_dir = NULL; - hcfree (profile_dir); if (session_dir == profile_dir) session_dir = NULL; @@ -489,7 +491,6 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins profile_dir = NULL; - hcfree (cache_dir); if (session_dir == cache_dir) session_dir = NULL; @@ -536,7 +537,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins * kernel cache, we need to make sure folder exist */ - char *kernels_folder; + char *kernels_folder = NULL; hc_asprintf (&kernels_folder, "%s/kernels", cache_dir); diff --git a/src/terminal.c b/src/terminal.c index aab94cc84..1a98c7d98 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -799,7 +799,8 @@ void hash_info (hashcat_ctx_t *hashcat_ctx) void backend_info (hashcat_ctx_t *hashcat_ctx) { - const backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; + const backend_ctx_t *backend_ctx = hashcat_ctx->backend_ctx; + const folder_config_t *folder_config = hashcat_ctx->folder_config; event_log_info (hashcat_ctx, "System Info:"); event_log_info (hashcat_ctx, "============"); @@ -860,6 +861,20 @@ void backend_info (hashcat_ctx_t *hashcat_ctx) event_log_info (hashcat_ctx, NULL); + event_log_info (hashcat_ctx, "Environment Info:"); + event_log_info (hashcat_ctx, "================="); + event_log_info (hashcat_ctx, NULL); + + event_log_info (hashcat_ctx, "Cur.Work.Dir.: %s", folder_config->cwd); + event_log_info (hashcat_ctx, "Install.Dir..: %s", folder_config->install_dir); + event_log_info (hashcat_ctx, "Profile.Dir..: %s", folder_config->profile_dir); + event_log_info (hashcat_ctx, "Cache.Dir....: %s", folder_config->cache_dir); + event_log_info (hashcat_ctx, "Session.Dir..: %s", folder_config->session_dir); + event_log_info (hashcat_ctx, "Shared.Dir...: %s", folder_config->shared_dir); + event_log_info (hashcat_ctx, "CL.Inc.Path..: %s", folder_config->cpath_real); + + event_log_info (hashcat_ctx, NULL); + if (backend_ctx->cuda) { event_log_info (hashcat_ctx, "CUDA Info:");