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

pull/3583/head
jsteube 1 year ago
parent 98d721cf69
commit 17b2e9062b

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

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

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

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

Loading…
Cancel
Save