1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-28 19:08:19 +00:00

Prevent Hashcat from hanging by checking during startup that the output file is a named pipe

This commit is contained in:
jsteube 2023-01-19 15:54:26 +00:00
parent 98d721cf69
commit 17b2e9062b
4 changed files with 22 additions and 0 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;

View File

@ -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);