diff --git a/BUILD.md b/BUILD.md index 9a71eb9be..8e8952559 100644 --- a/BUILD.md +++ b/BUILD.md @@ -31,7 +31,7 @@ The install target is linux FHS compatible and can be used like this: $ make install ``` -If you install it, cached kernels, session files, restore- and pot-files etc. will go to $HOME/.hashcat/ +If you install it, cached kernels, session files, restore- and pot-files etc. will go to either $HOME/.hashcat/, if that already exists, otherwise to $XDG_DATA_HOME/hashcat/ or ~/.local/share/hashcat/, if that environment variable is not set. ### Building hashcat for Windows (using Windows Subsystem for Linux) ### diff --git a/src/folder.c b/src/folder.c index 84fad8ef6..9a8ce6cbb 100644 --- a/src/folder.c +++ b/src/folder.c @@ -93,6 +93,15 @@ static void get_install_dir (char *install_dir, const char *exec_path) static void get_profile_dir (char *profile_dir, const char *home_dir) { snprintf (profile_dir, HCBUFSIZ_TINY, "%s/%s", home_dir, DOT_HASHCAT); + struct stat st = {0}; + if (stat(profile_dir, &st) == 0 && S_ISDIR(st.st_mode)) + return; + + if (getenv("XDG_DATA_HOME")) { + snprintf(profile_dir, HCBUFSIZ_TINY, "%s/hashcat", getenv("XDG_DATA_HOME")); + } else { + snprintf(profile_dir, HCBUFSIZ_TINY, "%s/.local/share/hashcat", home_dir); + } } static void get_session_dir (char *session_dir, const char *profile_dir)