diff --git a/docs/changes.txt b/docs/changes.txt index 4a42c4ccb..68ff8802b 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -34,6 +34,7 @@ ## - Fixed keys extraction in luks2hashcat - now extracts all active keys +- Prevent Hashcat from hanging by checking during startup that the output file is a named pipe ## ## Technical diff --git a/include/shared.h b/include/shared.h index 95c89cb9f..0538ebf24 100644 --- a/include/shared.h +++ b/include/shared.h @@ -55,6 +55,7 @@ void *hc_bsearch_r (const void *key, const void *base, size_t nmemb, size_t size bool hc_path_is_file (const char *path); bool hc_path_is_directory (const char *path); +bool hc_path_is_fifo (const char *path); bool hc_path_is_empty (const char *path); bool hc_path_exist (const char *path); bool hc_path_read (const char *path); diff --git a/src/shared.c b/src/shared.c index f79e2e66a..79b56e5c7 100644 --- a/src/shared.c +++ b/src/shared.c @@ -340,6 +340,19 @@ bool hc_path_is_directory (const char *path) return false; } +bool hc_path_is_fifo (const char *path) +{ + struct stat s; + + memset (&s, 0, sizeof (s)); + + if (stat (path, &s) == -1) return false; + + if (S_ISFIFO (s.st_mode) == true) return true; + + return false; +} + bool hc_path_is_empty (const char *path) { struct stat s; diff --git a/src/user_options.c b/src/user_options.c index 4dd2dce39..48dd0033a 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -2731,6 +2731,13 @@ int user_options_check_files (hashcat_ctx_t *hashcat_ctx) { if (hc_path_exist (outfile_ctx->filename) == true) { + if (hc_path_is_fifo (outfile_ctx->filename) == true) + { + event_log_error (hashcat_ctx, "%s: A fifo cannot be used as an outfile.", outfile_ctx->filename); + + return -1; + } + if (hc_path_is_directory (outfile_ctx->filename) == true) { event_log_error (hashcat_ctx, "%s: A directory cannot be used as an outfile.", outfile_ctx->filename);