2016-09-11 09:42:19 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2016-09-11 09:42:19 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common.h"
|
2016-09-15 02:04:54 +00:00
|
|
|
#include "types.h"
|
|
|
|
#include "memory.h"
|
2016-10-09 20:41:55 +00:00
|
|
|
#include "event.h"
|
2016-09-30 10:28:29 +00:00
|
|
|
#include "outfile_check.h"
|
|
|
|
|
|
|
|
#include "convert.h"
|
2016-09-15 02:04:54 +00:00
|
|
|
#include "folder.h"
|
2016-09-30 07:25:51 +00:00
|
|
|
#include "hashes.h"
|
2016-09-30 10:28:29 +00:00
|
|
|
#include "interface.h"
|
2016-09-15 02:04:54 +00:00
|
|
|
#include "shared.h"
|
2016-09-30 10:28:29 +00:00
|
|
|
#include "thread.h"
|
2018-08-31 10:55:05 +00:00
|
|
|
#include "bitops.h"
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
static int outfile_remove (hashcat_ctx_t *hashcat_ctx)
|
2016-09-15 02:04:54 +00:00
|
|
|
{
|
|
|
|
// some hash-dependent constants
|
|
|
|
|
2016-09-30 20:52:44 +00:00
|
|
|
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
|
|
|
hashes_t *hashes = hashcat_ctx->hashes;
|
2018-12-14 11:22:13 +00:00
|
|
|
module_ctx_t *module_ctx = hashcat_ctx->module_ctx;
|
2016-09-30 20:52:44 +00:00
|
|
|
outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx;
|
|
|
|
status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
|
|
|
|
user_options_t *user_options = hashcat_ctx->user_options;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-02-08 18:13:29 +00:00
|
|
|
size_t dgst_size = hashconfig->dgst_size;
|
|
|
|
bool is_salted = hashconfig->is_salted;
|
|
|
|
size_t esalt_size = hashconfig->esalt_size;
|
|
|
|
size_t hook_salt_size = hashconfig->hook_salt_size;
|
|
|
|
char separator = hashconfig->separator;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
salt_t *salts_buf = hashes->salts_buf;
|
|
|
|
const u32 salts_cnt = hashes->salts_cnt;
|
|
|
|
|
|
|
|
char *digests_buf = hashes->digests_buf;
|
|
|
|
|
2016-09-22 20:40:47 +00:00
|
|
|
char *root_directory = outcheck_ctx->root_directory;
|
2016-10-04 09:22:08 +00:00
|
|
|
u32 outfile_check_timer = user_options->outfile_check_timer;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
|
|
|
// buffers
|
2017-01-24 14:23:48 +00:00
|
|
|
hash_t hash_buf = { 0, 0, 0, 0, 0, 0, NULL, 0 };
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2016-11-20 21:54:52 +00:00
|
|
|
hash_buf.digest = hcmalloc (dgst_size);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2017-09-16 20:33:04 +00:00
|
|
|
if (is_salted == true) hash_buf.salt = (salt_t *) hcmalloc (sizeof (salt_t));
|
2017-11-05 08:52:29 +00:00
|
|
|
if (esalt_size > 0) hash_buf.esalt = hcmalloc (esalt_size);
|
|
|
|
if (hook_salt_size > 0) hash_buf.hook_salt = hcmalloc (hook_salt_size);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
|
|
|
outfile_data_t *out_info = NULL;
|
|
|
|
|
|
|
|
char **out_files = NULL;
|
|
|
|
|
2017-12-10 00:40:45 +00:00
|
|
|
time_t folder_mtime = 0;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2016-09-28 11:15:23 +00:00
|
|
|
int out_cnt = 0;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2016-10-04 09:22:08 +00:00
|
|
|
u32 check_left = outfile_check_timer; // or 1 if we want to check it at startup
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2016-09-29 21:49:33 +00:00
|
|
|
while (status_ctx->shutdown_inner == false)
|
2016-09-15 02:04:54 +00:00
|
|
|
{
|
2017-09-23 20:02:34 +00:00
|
|
|
sleep (1);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2016-09-29 21:25:29 +00:00
|
|
|
if (status_ctx->devices_status != STATUS_RUNNING) continue;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
|
|
|
check_left--;
|
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (check_left != 0) continue;
|
|
|
|
|
|
|
|
check_left = outfile_check_timer;
|
|
|
|
|
|
|
|
if (hc_path_exist (root_directory) == false) continue;
|
|
|
|
|
|
|
|
const bool is_dir = hc_path_is_directory (root_directory);
|
|
|
|
|
|
|
|
if (is_dir == false) continue;
|
|
|
|
|
|
|
|
struct stat outfile_check_stat;
|
|
|
|
|
|
|
|
if (stat (root_directory, &outfile_check_stat) == -1)
|
2016-09-15 02:04:54 +00:00
|
|
|
{
|
2018-08-31 10:55:05 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: %s", root_directory, strerror (errno));
|
|
|
|
|
|
|
|
hcfree (out_files);
|
|
|
|
hcfree (out_info);
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (outfile_check_stat.st_mtime > folder_mtime)
|
|
|
|
{
|
|
|
|
char **out_files_new = scan_directory (root_directory);
|
|
|
|
|
|
|
|
int out_cnt_new = count_dictionaries (out_files_new);
|
|
|
|
|
|
|
|
outfile_data_t *out_info_new = NULL;
|
|
|
|
|
|
|
|
if (out_cnt_new > 0)
|
2016-09-15 02:04:54 +00:00
|
|
|
{
|
2018-08-31 10:55:05 +00:00
|
|
|
out_info_new = (outfile_data_t *) hccalloc (out_cnt_new, sizeof (outfile_data_t));
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
for (int i = 0; i < out_cnt_new; i++)
|
2016-09-15 02:04:54 +00:00
|
|
|
{
|
2018-08-31 10:55:05 +00:00
|
|
|
out_info_new[i].file_name = out_files_new[i];
|
2017-01-27 10:46:45 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
// check if there are files that we have seen/checked before (and not changed)
|
|
|
|
|
|
|
|
for (int j = 0; j < out_cnt; j++)
|
2017-01-27 10:46:45 +00:00
|
|
|
{
|
2018-08-31 10:55:05 +00:00
|
|
|
if (strcmp (out_info[j].file_name, out_info_new[i].file_name) != 0) continue;
|
|
|
|
|
|
|
|
struct stat outfile_stat;
|
|
|
|
|
|
|
|
if (stat (out_info_new[i].file_name, &outfile_stat) != 0) continue;
|
2017-01-27 10:46:45 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (outfile_stat.st_ctime != out_info[j].ctime) continue;
|
2017-02-14 12:44:31 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
out_info_new[i].ctime = out_info[j].ctime;
|
|
|
|
out_info_new[i].seek = out_info[j].seek;
|
2017-01-27 10:46:45 +00:00
|
|
|
}
|
2018-08-31 10:55:05 +00:00
|
|
|
}
|
|
|
|
}
|
2017-01-27 10:46:45 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
hcfree (out_info);
|
|
|
|
hcfree (out_files);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
out_files = out_files_new;
|
|
|
|
out_cnt = out_cnt_new;
|
|
|
|
out_info = out_info_new;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
folder_mtime = outfile_check_stat.st_mtime;
|
|
|
|
}
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
for (int j = 0; j < out_cnt; j++)
|
|
|
|
{
|
|
|
|
FILE *fp = fopen (out_info[j].file_name, "rb");
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (fp == NULL) continue;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
//hc_thread_mutex_lock (status_ctx->mux_display);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
struct stat outfile_stat;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (fstat (fileno (fp), &outfile_stat))
|
|
|
|
{
|
|
|
|
fclose (fp);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
continue;
|
|
|
|
}
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (outfile_stat.st_ctime > out_info[j].ctime)
|
|
|
|
{
|
|
|
|
out_info[j].ctime = outfile_stat.st_ctime;
|
|
|
|
out_info[j].seek = 0;
|
|
|
|
}
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
fseeko (fp, out_info[j].seek, SEEK_SET);
|
2017-02-14 16:02:52 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
char *line_buf = (char *) hcmalloc (HCBUFSIZ_LARGE);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
while (!feof (fp))
|
|
|
|
{
|
|
|
|
char *ptr = fgets (line_buf, HCBUFSIZ_LARGE - 1, fp);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (ptr == NULL) break;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
size_t line_len = strlen (line_buf);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (line_len == 0) continue;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
size_t cut_tries = 5;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
for (size_t i = line_len - 1; i && cut_tries; i--, line_len--)
|
|
|
|
{
|
|
|
|
if (line_buf[i] != separator) continue;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
cut_tries--;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (is_salted == true) memset (hash_buf.salt, 0, sizeof (salt_t)); // needed ? (let's play it safe!)
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
int parser_status = PARSER_HASH_LENGTH;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2019-01-05 19:17:12 +00:00
|
|
|
if (module_ctx->module_hash_decode_outfile == MODULE_DEFAULT)
|
2018-08-31 10:55:05 +00:00
|
|
|
{
|
2019-01-05 19:17:12 +00:00
|
|
|
// "normal" case: hash in the outfile is the same as the hash in the original hash file
|
|
|
|
|
|
|
|
parser_status = module_ctx->module_hash_decode (hashconfig, hash_buf.digest, hash_buf.salt, hash_buf.esalt, line_buf, line_len - 1);
|
2018-08-31 10:55:05 +00:00
|
|
|
}
|
2019-01-05 19:17:12 +00:00
|
|
|
else
|
2018-08-31 10:55:05 +00:00
|
|
|
{
|
2019-01-05 19:17:12 +00:00
|
|
|
parser_status = module_ctx->module_hash_decode_outfile (hashconfig, hash_buf.digest, hash_buf.salt, hash_buf.esalt, line_buf, line_len - 1);
|
2018-08-31 10:55:05 +00:00
|
|
|
}
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (parser_status != PARSER_OK) continue;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
salt_t *salt_buf = salts_buf;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (is_salted == true)
|
|
|
|
{
|
|
|
|
salt_buf = (salt_t *) hc_bsearch_r (hash_buf.salt, salts_buf, salts_cnt, sizeof (salt_t), sort_by_salt_buf, (void *) hashconfig);
|
|
|
|
}
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (salt_buf == NULL) continue;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
u32 salt_pos = salt_buf - salts_buf; // the offset from the start of the array (unit: sizeof (salt_t))
|
2018-08-26 15:51:40 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (hashes->salts_shown[salt_pos] == 1) break; // already marked as cracked (no action needed)
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
u32 idx = salt_buf->digests_offset;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
bool cracked = false;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-12-20 09:43:57 +00:00
|
|
|
if (hashconfig->outfile_check_nocomp == true)
|
2018-08-31 10:55:05 +00:00
|
|
|
{
|
|
|
|
cracked = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char *digests_buf_ptr = digests_buf + (salt_buf->digests_offset * dgst_size);
|
|
|
|
u32 digests_buf_cnt = salt_buf->digests_cnt;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
char *digest_buf = (char *) hc_bsearch_r (hash_buf.digest, digests_buf_ptr, digests_buf_cnt, dgst_size, sort_by_digest_p0p1, (void *) hashconfig);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (digest_buf != NULL)
|
|
|
|
{
|
|
|
|
idx += (digest_buf - digests_buf_ptr) / dgst_size;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (hashes->digests_shown[idx] == 1) break;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
cracked = true;
|
2016-09-15 02:04:54 +00:00
|
|
|
}
|
2018-08-31 10:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cracked == true)
|
|
|
|
{
|
|
|
|
hashes->digests_shown[idx] = 1;
|
|
|
|
|
|
|
|
hashes->digests_done++;
|
|
|
|
|
|
|
|
salt_buf->digests_done++;
|
|
|
|
|
|
|
|
if (salt_buf->digests_done == salt_buf->digests_cnt)
|
|
|
|
{
|
|
|
|
hashes->salts_shown[salt_pos] = 1;
|
|
|
|
|
|
|
|
hashes->salts_done++;
|
2018-08-26 15:51:40 +00:00
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
if (hashes->salts_done == salts_cnt) mycracked (hashcat_ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2016-09-15 02:04:54 +00:00
|
|
|
}
|
2018-08-31 10:55:05 +00:00
|
|
|
|
|
|
|
if (status_ctx->shutdown_inner == true) break;
|
2016-09-15 02:04:54 +00:00
|
|
|
}
|
2018-08-31 10:55:05 +00:00
|
|
|
|
|
|
|
if (status_ctx->shutdown_inner == true) break;
|
2016-09-15 02:04:54 +00:00
|
|
|
}
|
|
|
|
|
2018-08-31 10:55:05 +00:00
|
|
|
hcfree (line_buf);
|
|
|
|
|
|
|
|
out_info[j].seek = ftello (fp);
|
|
|
|
|
|
|
|
//hc_thread_mutex_unlock (status_ctx->mux_display);
|
|
|
|
|
|
|
|
fclose (fp);
|
|
|
|
|
|
|
|
if (status_ctx->shutdown_inner == true) break;
|
2016-09-15 02:04:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (hash_buf.esalt);
|
2017-01-24 14:23:48 +00:00
|
|
|
hcfree (hash_buf.hook_salt);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (hash_buf.salt);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (hash_buf.digest);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (out_info);
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2016-10-10 09:03:11 +00:00
|
|
|
hcfree (out_files);
|
2016-10-13 08:07:04 +00:00
|
|
|
|
|
|
|
return 0;
|
2016-09-30 20:52:44 +00:00
|
|
|
}
|
|
|
|
|
2018-09-18 21:37:30 +00:00
|
|
|
HC_API_CALL void *thread_outfile_remove (void *p)
|
2016-09-30 20:52:44 +00:00
|
|
|
{
|
|
|
|
hashcat_ctx_t *hashcat_ctx = (hashcat_ctx_t *) p;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2018-12-20 10:04:37 +00:00
|
|
|
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
|
|
|
const outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx;
|
|
|
|
|
|
|
|
if (hashconfig->outfile_check_disable == true) return NULL;
|
|
|
|
|
|
|
|
if (outcheck_ctx->enabled == false) return NULL;
|
|
|
|
|
2016-10-13 08:07:04 +00:00
|
|
|
const int rc = outfile_remove (hashcat_ctx);
|
|
|
|
|
|
|
|
if (rc == -1) return NULL;
|
2016-09-15 02:04:54 +00:00
|
|
|
|
2016-09-30 20:52:44 +00:00
|
|
|
return NULL;
|
2016-09-15 02:04:54 +00:00
|
|
|
}
|
2016-09-22 20:40:47 +00:00
|
|
|
|
2016-10-06 14:43:02 +00:00
|
|
|
int outcheck_ctx_init (hashcat_ctx_t *hashcat_ctx)
|
2016-09-22 20:40:47 +00:00
|
|
|
{
|
2018-12-20 09:33:29 +00:00
|
|
|
const folder_config_t *folder_config = hashcat_ctx->folder_config;
|
|
|
|
const hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
|
|
|
outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx;
|
|
|
|
const user_options_t *user_options = hashcat_ctx->user_options;
|
2016-10-06 14:43:02 +00:00
|
|
|
|
2016-09-22 20:40:47 +00:00
|
|
|
outcheck_ctx->enabled = false;
|
|
|
|
|
2017-08-22 09:09:46 +00:00
|
|
|
if (user_options->keyspace == true) return 0;
|
|
|
|
if (user_options->benchmark == true) return 0;
|
|
|
|
if (user_options->example_hashes == true) return 0;
|
|
|
|
if (user_options->speed_only == true) return 0;
|
|
|
|
if (user_options->progress_only == true) return 0;
|
|
|
|
if (user_options->opencl_info == true) return 0;
|
2016-09-22 20:40:47 +00:00
|
|
|
|
2018-12-20 09:33:29 +00:00
|
|
|
if (hashconfig->outfile_check_disable == true) return 0;
|
2016-09-22 20:40:47 +00:00
|
|
|
|
2018-12-20 10:04:37 +00:00
|
|
|
if (user_options->outfile_check_timer == 0) return 0;
|
|
|
|
|
2016-09-22 20:40:47 +00:00
|
|
|
if (user_options->outfile_check_dir == NULL)
|
|
|
|
{
|
2016-12-23 23:40:40 +00:00
|
|
|
hc_asprintf (&outcheck_ctx->root_directory, "%s/%s.%s", folder_config->session_dir, user_options->session, OUTFILES_DIR);
|
2016-09-22 20:40:47 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
outcheck_ctx->root_directory = user_options->outfile_check_dir;
|
|
|
|
}
|
|
|
|
|
2017-01-27 13:50:39 +00:00
|
|
|
outcheck_ctx->enabled = true;
|
2016-09-22 20:40:47 +00:00
|
|
|
|
2017-01-27 13:50:39 +00:00
|
|
|
if (hc_path_exist (outcheck_ctx->root_directory) == false)
|
2016-09-22 20:40:47 +00:00
|
|
|
{
|
2016-10-01 11:51:06 +00:00
|
|
|
if (hc_mkdir (outcheck_ctx->root_directory, 0700) == -1)
|
2016-09-22 20:40:47 +00:00
|
|
|
{
|
2017-02-04 01:53:50 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: %s", outcheck_ctx->root_directory, strerror (errno));
|
2016-09-22 20:40:47 +00:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-10-06 14:43:02 +00:00
|
|
|
void outcheck_ctx_destroy (hashcat_ctx_t *hashcat_ctx)
|
2016-09-22 20:40:47 +00:00
|
|
|
{
|
2018-12-20 10:04:37 +00:00
|
|
|
hashconfig_t *hashconfig = hashcat_ctx->hashconfig;
|
2016-10-06 14:43:02 +00:00
|
|
|
outcheck_ctx_t *outcheck_ctx = hashcat_ctx->outcheck_ctx;
|
2016-11-14 13:07:30 +00:00
|
|
|
user_options_t *user_options = hashcat_ctx->user_options;
|
2016-10-06 14:43:02 +00:00
|
|
|
|
2016-10-01 22:00:21 +00:00
|
|
|
if (outcheck_ctx->enabled == false) return;
|
2016-09-22 20:40:47 +00:00
|
|
|
|
2018-12-20 10:04:37 +00:00
|
|
|
if (hashconfig->outfile_check_disable == true) return;
|
|
|
|
|
2016-09-22 20:40:47 +00:00
|
|
|
if (rmdir (outcheck_ctx->root_directory) == -1)
|
|
|
|
{
|
|
|
|
if (errno == ENOENT)
|
|
|
|
{
|
|
|
|
// good, we can ignore
|
|
|
|
}
|
|
|
|
else if (errno == ENOTEMPTY)
|
|
|
|
{
|
|
|
|
// good, we can ignore
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-02-04 01:53:50 +00:00
|
|
|
event_log_error (hashcat_ctx, "%s: %s", outcheck_ctx->root_directory, strerror (errno));
|
2016-09-22 20:40:47 +00:00
|
|
|
|
|
|
|
//return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-14 13:07:30 +00:00
|
|
|
if (user_options->outfile_check_dir == NULL)
|
|
|
|
{
|
|
|
|
hcfree (outcheck_ctx->root_directory);
|
|
|
|
}
|
2016-09-22 20:40:47 +00:00
|
|
|
|
2016-10-01 22:00:21 +00:00
|
|
|
memset (outcheck_ctx, 0, sizeof (outcheck_ctx_t));
|
2016-09-22 20:40:47 +00:00
|
|
|
}
|