mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-23 00:28:11 +00:00
Merge pull request #1748 from philsmd/master
fixes #1744: added --stdin-timeout-abort to allow a custom time to wait before abort
This commit is contained in:
commit
3faf92a261
@ -4,6 +4,7 @@
|
|||||||
## Features
|
## Features
|
||||||
##
|
##
|
||||||
|
|
||||||
|
- Added new option --stdin-timeout-abort which allows to set the time hashcat should wait for input in stdin mode before aborting
|
||||||
|
|
||||||
##
|
##
|
||||||
## Algorithms
|
## Algorithms
|
||||||
|
@ -190,7 +190,7 @@ _hashcat ()
|
|||||||
|
|
||||||
local SHORT_OPTS="-m -a -V -v -h -b -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l -O -S -z"
|
local SHORT_OPTS="-m -a -V -v -h -b -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l -O -S -z"
|
||||||
local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --opencl-info --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-disable --gpu-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password"
|
local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --opencl-info --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-disable --gpu-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password"
|
||||||
local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --markov-hcstat2 --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-host --brain-password --brain-port --brain-session --brain-whitelist-session"
|
local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --markov-hcstat2 --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --nvidia-spin-damp --gpu-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-host --brain-password --brain-port --brain-session --brain-whitelist-session --stdin-timeout-abort"
|
||||||
|
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
@ -363,7 +363,7 @@ _hashcat ()
|
|||||||
--status-timer|--markov-threshold|--runtime|--session|--separator|--segment-size|--rule-left|--rule-right| \
|
--status-timer|--markov-threshold|--runtime|--session|--separator|--segment-size|--rule-left|--rule-right| \
|
||||||
--nvidia-spin-damp|--gpu-temp-abort|--generate-rules|--generate-rules-func-min|--generate-rules-func-max| \
|
--nvidia-spin-damp|--gpu-temp-abort|--generate-rules|--generate-rules-func-min|--generate-rules-func-max| \
|
||||||
--increment-min|--increment-max|--remove-timer|--bitmap-min|--bitmap-max|--skip|--limit|--generate-rules-seed| \
|
--increment-min|--increment-max|--remove-timer|--bitmap-min|--bitmap-max|--skip|--limit|--generate-rules-seed| \
|
||||||
--outfile-check-timer|--outfile-check-dir|--induction-dir|--scrypt-tmto|--encoding-from|--encoding-to|--optimized-kernel-enable|--brain-host|--brain-port|--brain-password)
|
--outfile-check-timer|--outfile-check-dir|--induction-dir|--scrypt-tmto|--encoding-from|--encoding-to|--optimized-kernel-enable|--brain-host|--brain-port|--brain-password|--stdin-timeout-abort)
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
@ -6,8 +6,7 @@
|
|||||||
#ifndef _MONITOR_H
|
#ifndef _MONITOR_H
|
||||||
#define _MONITOR_H
|
#define _MONITOR_H
|
||||||
|
|
||||||
#define STDIN_TIMEOUT_MIN 20 // warn after no input from stdin for x seconds
|
#define STDIN_TIMEOUT_WARN 20 // warn if no input from stdin for x seconds
|
||||||
#define STDIN_TIMEOUT_MAX 120 // abort after no input from stdin for x seconds
|
|
||||||
|
|
||||||
int get_runtime_left (const hashcat_ctx_t *hashcat_ctx);
|
int get_runtime_left (const hashcat_ctx_t *hashcat_ctx);
|
||||||
|
|
||||||
|
@ -599,6 +599,7 @@ typedef enum user_options_defaults
|
|||||||
SPEED_ONLY = false,
|
SPEED_ONLY = false,
|
||||||
STATUS = false,
|
STATUS = false,
|
||||||
STATUS_TIMER = 10,
|
STATUS_TIMER = 10,
|
||||||
|
STDIN_TIMEOUT_ABORT = 120,
|
||||||
STDOUT_FLAG = false,
|
STDOUT_FLAG = false,
|
||||||
USAGE = false,
|
USAGE = false,
|
||||||
USERNAME = false,
|
USERNAME = false,
|
||||||
@ -704,13 +705,14 @@ typedef enum user_options_map
|
|||||||
IDX_STATUS = 0xff3e,
|
IDX_STATUS = 0xff3e,
|
||||||
IDX_STATUS_TIMER = 0xff3f,
|
IDX_STATUS_TIMER = 0xff3f,
|
||||||
IDX_STDOUT_FLAG = 0xff40,
|
IDX_STDOUT_FLAG = 0xff40,
|
||||||
IDX_TRUECRYPT_KEYFILES = 0xff41,
|
IDX_STDIN_TIMEOUT_ABORT = 0xff41,
|
||||||
IDX_USERNAME = 0xff42,
|
IDX_TRUECRYPT_KEYFILES = 0xff42,
|
||||||
IDX_VERACRYPT_KEYFILES = 0xff43,
|
IDX_USERNAME = 0xff43,
|
||||||
IDX_VERACRYPT_PIM = 0xff44,
|
IDX_VERACRYPT_KEYFILES = 0xff44,
|
||||||
|
IDX_VERACRYPT_PIM = 0xff45,
|
||||||
IDX_VERSION_LOWER = 'v',
|
IDX_VERSION_LOWER = 'v',
|
||||||
IDX_VERSION = 'V',
|
IDX_VERSION = 'V',
|
||||||
IDX_WORDLIST_AUTOHEX_DISABLE = 0xff45,
|
IDX_WORDLIST_AUTOHEX_DISABLE = 0xff46,
|
||||||
IDX_WORKLOAD_PROFILE = 'w',
|
IDX_WORKLOAD_PROFILE = 'w',
|
||||||
|
|
||||||
} user_options_map_t;
|
} user_options_map_t;
|
||||||
@ -1730,6 +1732,7 @@ typedef struct user_options
|
|||||||
bool speed_only;
|
bool speed_only;
|
||||||
bool status;
|
bool status;
|
||||||
bool stdout_flag;
|
bool stdout_flag;
|
||||||
|
bool stdin_timeout_abort_chgd;
|
||||||
bool usage;
|
bool usage;
|
||||||
bool username;
|
bool username;
|
||||||
bool version;
|
bool version;
|
||||||
@ -1797,6 +1800,7 @@ typedef struct user_options
|
|||||||
u32 scrypt_tmto;
|
u32 scrypt_tmto;
|
||||||
u32 segment_size;
|
u32 segment_size;
|
||||||
u32 status_timer;
|
u32 status_timer;
|
||||||
|
u32 stdin_timeout_abort;
|
||||||
u32 veracrypt_pim;
|
u32 veracrypt_pim;
|
||||||
u32 workload_profile;
|
u32 workload_profile;
|
||||||
u64 limit;
|
u64 limit;
|
||||||
|
@ -284,25 +284,29 @@ static int monitor (hashcat_ctx_t *hashcat_ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stdin read timeout check
|
// 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)
|
if ((status_ctx->stdin_read_timeout_cnt % STDIN_TIMEOUT_WARN) == 0)
|
||||||
{
|
{
|
||||||
EVENT_DATA (EVENT_MONITOR_NOINPUT_HINT, NULL, 0);
|
EVENT_DATA (EVENT_MONITOR_NOINPUT_HINT, NULL, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,6 +37,7 @@ static const char *const USAGE_BIG[] =
|
|||||||
" --force | | Ignore warnings |",
|
" --force | | Ignore warnings |",
|
||||||
" --status | | Enable automatic update of the status screen |",
|
" --status | | Enable automatic update of the status screen |",
|
||||||
" --status-timer | Num | Sets seconds between status screen updates to X | --status-timer=1",
|
" --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 |",
|
" --machine-readable | | Display the status view in a machine-readable format |",
|
||||||
" --keep-guessing | | Keep guessing the hash after it has been cracked |",
|
" --keep-guessing | | Keep guessing the hash after it has been cracked |",
|
||||||
" --self-test-disable | | Disable self-test functionality on startup |",
|
" --self-test-disable | | Disable self-test functionality on startup |",
|
||||||
|
@ -111,6 +111,7 @@ static const struct option long_options[] =
|
|||||||
{"status", no_argument, NULL, IDX_STATUS},
|
{"status", no_argument, NULL, IDX_STATUS},
|
||||||
{"status-timer", required_argument, NULL, IDX_STATUS_TIMER},
|
{"status-timer", required_argument, NULL, IDX_STATUS_TIMER},
|
||||||
{"stdout", no_argument, NULL, IDX_STDOUT_FLAG},
|
{"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},
|
{"truecrypt-keyfiles", required_argument, NULL, IDX_TRUECRYPT_KEYFILES},
|
||||||
{"username", no_argument, NULL, IDX_USERNAME},
|
{"username", no_argument, NULL, IDX_USERNAME},
|
||||||
{"veracrypt-keyfiles", required_argument, NULL, IDX_VERACRYPT_KEYFILES},
|
{"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->speed_only = SPEED_ONLY;
|
||||||
user_options->status = STATUS;
|
user_options->status = STATUS;
|
||||||
user_options->status_timer = STATUS_TIMER;
|
user_options->status_timer = STATUS_TIMER;
|
||||||
|
user_options->stdin_timeout_abort = STDIN_TIMEOUT_ABORT;
|
||||||
user_options->stdout_flag = STDOUT_FLAG;
|
user_options->stdout_flag = STDOUT_FLAG;
|
||||||
user_options->truecrypt_keyfiles = NULL;
|
user_options->truecrypt_keyfiles = NULL;
|
||||||
user_options->usage = USAGE;
|
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: user_options->benchmark = true; break;
|
||||||
case IDX_BENCHMARK_ALL: user_options->benchmark_all = true; break;
|
case IDX_BENCHMARK_ALL: user_options->benchmark_all = true; break;
|
||||||
case IDX_STDOUT_FLAG: user_options->stdout_flag = 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_SPEED_ONLY: user_options->speed_only = true; break;
|
||||||
case IDX_PROGRESS_ONLY: user_options->progress_only = true; break;
|
case IDX_PROGRESS_ONLY: user_options->progress_only = true; break;
|
||||||
case IDX_RESTORE_DISABLE: user_options->restore_disable = 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
|
#ifdef WITH_BRAIN
|
||||||
if ((user_options->brain_client == true) && (user_options->remove == true))
|
if ((user_options->brain_client == true) && (user_options->remove == true))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user