fixes #1744: added --stdin-timeout-abort to allow a custom time (in seconds) to wait before abort (use 0 to disabled it)

This commit is contained in:
philsmd
2018-10-31 11:37:06 +01:00
parent 80737b1f8d
commit dbb81fb48e
7 changed files with 52 additions and 20 deletions
+15 -11
View File
@@ -284,25 +284,29 @@ static int monitor (hashcat_ctx_t *hashcat_ctx)
}
// stdin read timeout check
// note: we skip the stdin timeout check if it was disabled with stdin_timeout_abort set to 0
if (status_get_progress_done (hashcat_ctx) == 0)
if (user_options->stdin_timeout_abort != 0)
{
if (status_ctx->stdin_read_timeout_cnt >= STDIN_TIMEOUT_MIN)
if (status_get_progress_done (hashcat_ctx) == 0)
{
if (status_ctx->stdin_read_timeout_cnt >= STDIN_TIMEOUT_MAX)
if (status_ctx->stdin_read_timeout_cnt > 0)
{
EVENT_DATA (EVENT_MONITOR_NOINPUT_ABORT, NULL, 0);
if (status_ctx->stdin_read_timeout_cnt >= user_options->stdin_timeout_abort)
{
EVENT_DATA (EVENT_MONITOR_NOINPUT_ABORT, NULL, 0);
myabort (hashcat_ctx);
myabort (hashcat_ctx);
status_ctx->shutdown_inner = true;
status_ctx->shutdown_inner = true;
break;
}
break;
}
if ((status_ctx->stdin_read_timeout_cnt % STDIN_TIMEOUT_MIN) == 0)
{
EVENT_DATA (EVENT_MONITOR_NOINPUT_HINT, NULL, 0);
if ((status_ctx->stdin_read_timeout_cnt % STDIN_TIMEOUT_WARN) == 0)
{
EVENT_DATA (EVENT_MONITOR_NOINPUT_HINT, NULL, 0);
}
}
}
}
+1
View File
@@ -37,6 +37,7 @@ static const char *const USAGE_BIG[] =
" --force | | Ignore warnings |",
" --status | | Enable automatic update of the status screen |",
" --status-timer | Num | Sets seconds between status screen updates to X | --status-timer=1",
" --stdin-timeout-abort | Num | Abort if there is no input from stdin for X seconds | --stdin-timeout-abort=300",
" --machine-readable | | Display the status view in a machine-readable format |",
" --keep-guessing | | Keep guessing the hash after it has been cracked |",
" --self-test-disable | | Disable self-test functionality on startup |",
+23
View File
@@ -111,6 +111,7 @@ static const struct option long_options[] =
{"status", no_argument, NULL, IDX_STATUS},
{"status-timer", required_argument, NULL, IDX_STATUS_TIMER},
{"stdout", no_argument, NULL, IDX_STDOUT_FLAG},
{"stdin-timeout-abort", required_argument, NULL, IDX_STDIN_TIMEOUT_ABORT},
{"truecrypt-keyfiles", required_argument, NULL, IDX_TRUECRYPT_KEYFILES},
{"username", no_argument, NULL, IDX_USERNAME},
{"veracrypt-keyfiles", required_argument, NULL, IDX_VERACRYPT_KEYFILES},
@@ -236,6 +237,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx)
user_options->speed_only = SPEED_ONLY;
user_options->status = STATUS;
user_options->status_timer = STATUS_TIMER;
user_options->stdin_timeout_abort = STDIN_TIMEOUT_ABORT;
user_options->stdout_flag = STDOUT_FLAG;
user_options->truecrypt_keyfiles = NULL;
user_options->usage = USAGE;
@@ -373,6 +375,8 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
case IDX_BENCHMARK: user_options->benchmark = true; break;
case IDX_BENCHMARK_ALL: user_options->benchmark_all = true; break;
case IDX_STDOUT_FLAG: user_options->stdout_flag = true; break;
case IDX_STDIN_TIMEOUT_ABORT: user_options->stdin_timeout_abort = hc_strtoul (optarg, NULL, 10);
user_options->stdin_timeout_abort_chgd = true; break;
case IDX_SPEED_ONLY: user_options->speed_only = true; break;
case IDX_PROGRESS_ONLY: user_options->progress_only = true; break;
case IDX_RESTORE_DISABLE: user_options->restore_disable = true; break;
@@ -1058,6 +1062,25 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx)
}
}
if (user_options->stdin_timeout_abort_chgd == true)
{
if (user_options->attack_mode != ATTACK_MODE_STRAIGHT)
{
event_log_error (hashcat_ctx, "Use of --stdin-timeout-abort is only allowed in attack mode 0 (straight).");
return -1;
}
// --stdin-timeout-abort can only be used in stdin mode
if (user_options->hc_argc != 1)
{
event_log_error (hashcat_ctx, "Use of --stdin-timeout-abort is only allowed in stdin mode (pipe).");
return -1;
}
}
#ifdef WITH_BRAIN
if ((user_options->brain_client == true) && (user_options->remove == true))
{