1
mirror of https://github.com/hashcat/hashcat synced 2024-12-27 05:13:45 +01:00

Show [r]esume in prompt in pause mode only and show [p]ause in prompt in resume mode only

Fixes https://github.com/hashcat/hashcat/issues/1459
This commit is contained in:
jsteube 2017-11-26 10:50:22 +01:00
parent f70999b305
commit 04a30e6071
5 changed files with 89 additions and 48 deletions

View File

@ -14,6 +14,12 @@
- Fixed a hash parsing problem for 7-Zip hashes: allow a longer crc32 data length field within the hash format
- Fixed the output of --show if $HEX[] passwords are present within the potfile
##
## Improvements
##
- Show [r]esume in prompt in pause mode only and show [p]ause in prompt in resume mode only
##
## Technical
##

View File

@ -26,8 +26,8 @@ void goodbye_screen (hashcat_ctx_t *hashcat_ctx, const hc_time_t proc_start, con
int setup_console (void);
void send_prompt (void);
void clear_prompt (void);
void send_prompt (hashcat_ctx_t *hashcat_ctx);
void clear_prompt (hashcat_ctx_t *hashcat_ctx);
void *thread_keypress (void *p);

View File

@ -340,7 +340,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
if (user_options->quiet == false)
{
clear_prompt ();
clear_prompt (hashcat_ctx);
printf
(
@ -350,7 +350,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param
device_param->device_id + 1, kernel_loops
);
send_prompt ();
send_prompt (hashcat_ctx);
}
#endif

View File

@ -234,7 +234,7 @@ static void main_cracker_starting (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB
{
event_log_info_nn (hashcat_ctx, NULL);
send_prompt ();
send_prompt (hashcat_ctx);
}
}
else if (user_options_extra->wordlist_mode == WL_MODE_STDIN)
@ -261,7 +261,7 @@ static void main_cracker_finished (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYB
{
if ((user_options->speed_only == false) && (user_options->quiet == false))
{
clear_prompt ();
clear_prompt (hashcat_ctx);
}
}
@ -322,7 +322,7 @@ static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx,
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt ();
if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt (hashcat_ctx);
}
hc_fwrite (buf, len, 1, stdout);
@ -332,7 +332,7 @@ static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx,
{
if (status_ctx->devices_status != STATUS_CRACKED)
{
if (outfile_ctx->filename == NULL) if (user_options->quiet == false) send_prompt ();
if (outfile_ctx->filename == NULL) if (user_options->quiet == false) send_prompt (hashcat_ctx);
}
}
}
@ -571,12 +571,12 @@ static void main_set_kernel_power_final (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx
if (user_options->quiet == true) return;
clear_prompt ();
clear_prompt (hashcat_ctx);
event_log_advice (hashcat_ctx, "Approaching final keyspace - workload adjusted.");
event_log_advice (hashcat_ctx, NULL);
send_prompt ();
send_prompt (hashcat_ctx);
}
static void main_monitor_throttle1 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const void *buf, MAYBE_UNUSED const size_t len)
@ -588,7 +588,7 @@ static void main_monitor_throttle1 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
clear_prompt ();
clear_prompt (hashcat_ctx);
}
const u32 *device_id = (const u32 *) buf;
@ -597,7 +597,7 @@ static void main_monitor_throttle1 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
send_prompt ();
send_prompt (hashcat_ctx);
}
}
@ -610,7 +610,7 @@ static void main_monitor_throttle2 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
clear_prompt ();
clear_prompt (hashcat_ctx);
}
const u32 *device_id = (const u32 *) buf;
@ -619,7 +619,7 @@ static void main_monitor_throttle2 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
send_prompt ();
send_prompt (hashcat_ctx);
}
}
@ -632,7 +632,7 @@ static void main_monitor_throttle3 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
clear_prompt ();
clear_prompt (hashcat_ctx);
}
const u32 *device_id = (const u32 *) buf;
@ -642,7 +642,7 @@ static void main_monitor_throttle3 (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MAY
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
send_prompt ();
send_prompt (hashcat_ctx);
}
}
@ -656,7 +656,7 @@ static void main_monitor_performance_hint (MAYBE_UNUSED hashcat_ctx_t *hashcat_c
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
clear_prompt ();
clear_prompt (hashcat_ctx);
}
event_log_advice (hashcat_ctx, "Cracking performance lower than expected?");
@ -689,7 +689,7 @@ static void main_monitor_performance_hint (MAYBE_UNUSED hashcat_ctx_t *hashcat_c
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
send_prompt ();
send_prompt (hashcat_ctx);
}
}
@ -702,7 +702,7 @@ static void main_monitor_temp_abort (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, MA
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
clear_prompt ();
clear_prompt (hashcat_ctx);
}
const u32 *device_id = (const u32 *) buf;
@ -719,7 +719,7 @@ static void main_monitor_runtime_limit (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx,
if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK))
{
clear_prompt ();
clear_prompt (hashcat_ctx);
}
event_log_warning (hashcat_ctx, "Runtime limit reached, aborting...");
@ -737,7 +737,7 @@ static void main_monitor_status_refresh (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx
{
if (user_options->quiet == false)
{
//clear_prompt ();
//clear_prompt (hashcat_ctx);
event_log_info (hashcat_ctx, NULL);
event_log_info (hashcat_ctx, NULL);
@ -752,7 +752,7 @@ static void main_monitor_status_refresh (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx
{
event_log_info (hashcat_ctx, NULL);
send_prompt ();
send_prompt (hashcat_ctx);
}
}

View File

@ -21,7 +21,8 @@
static const size_t TERMINAL_LINE_LENGTH = 79;
static const char *PROMPT = "[s]tatus [p]ause [r]esume [b]ypass [c]heckpoint [q]uit => ";
static const char *PROMPT_ACTIVE = "[s]tatus [p]ause [b]ypass [c]heckpoint [q]uit => ";
static const char *PROMPT_PAUSED = "[s]tatus [r]esume [b]ypass [c]heckpoint [q]uit => ";
void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag)
{
@ -124,18 +125,40 @@ int setup_console ()
return 0;
}
void send_prompt ()
void send_prompt (hashcat_ctx_t *hashcat_ctx)
{
fprintf (stdout, "%s", PROMPT);
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
if (status_ctx->devices_status == STATUS_PAUSED)
{
fprintf (stdout, "%s", PROMPT_PAUSED);
}
else
{
fprintf (stdout, "%s", PROMPT_ACTIVE);
}
fflush (stdout);
}
void clear_prompt ()
void clear_prompt (hashcat_ctx_t *hashcat_ctx)
{
const status_ctx_t *status_ctx = hashcat_ctx->status_ctx;
size_t prompt_sz = 0;
if (status_ctx->devices_status == STATUS_PAUSED)
{
prompt_sz = strlen (PROMPT_PAUSED);
}
else
{
prompt_sz = strlen (PROMPT_ACTIVE);
}
fputc ('\r', stdout);
for (size_t i = 0; i < strlen (PROMPT); i++)
for (size_t i = 0; i < prompt_sz; i++)
{
fputc (' ', stdout);
}
@ -186,7 +209,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx)
event_log_info (hashcat_ctx, NULL);
if (quiet == false) send_prompt ();
if (quiet == false) send_prompt (hashcat_ctx);
break;
@ -200,41 +223,47 @@ static void keypress (hashcat_ctx_t *hashcat_ctx)
event_log_info (hashcat_ctx, NULL);
if (quiet == false) send_prompt ();
if (quiet == false) send_prompt (hashcat_ctx);
break;
case 'p':
event_log_info (hashcat_ctx, NULL);
SuspendThreads (hashcat_ctx);
if (status_ctx->devices_status == STATUS_PAUSED)
if (status_ctx->devices_status != STATUS_PAUSED)
{
event_log_info (hashcat_ctx, "Paused");
event_log_info (hashcat_ctx, NULL);
SuspendThreads (hashcat_ctx);
if (status_ctx->devices_status == STATUS_PAUSED)
{
event_log_info (hashcat_ctx, "Paused");
}
event_log_info (hashcat_ctx, NULL);
}
event_log_info (hashcat_ctx, NULL);
if (quiet == false) send_prompt ();
if (quiet == false) send_prompt (hashcat_ctx);
break;
case 'r':
event_log_info (hashcat_ctx, NULL);
ResumeThreads (hashcat_ctx);
if (status_ctx->devices_status == STATUS_RUNNING)
if (status_ctx->devices_status == STATUS_PAUSED)
{
event_log_info (hashcat_ctx, "Resumed");
event_log_info (hashcat_ctx, NULL);
ResumeThreads (hashcat_ctx);
if (status_ctx->devices_status != STATUS_PAUSED)
{
event_log_info (hashcat_ctx, "Resumed");
}
event_log_info (hashcat_ctx, NULL);
}
event_log_info (hashcat_ctx, NULL);
if (quiet == false) send_prompt ();
if (quiet == false) send_prompt (hashcat_ctx);
break;
@ -255,7 +284,7 @@ static void keypress (hashcat_ctx_t *hashcat_ctx)
event_log_info (hashcat_ctx, NULL);
if (quiet == false) send_prompt ();
if (quiet == false) send_prompt (hashcat_ctx);
break;
@ -265,6 +294,12 @@ static void keypress (hashcat_ctx_t *hashcat_ctx)
myquit (hashcat_ctx);
break;
default:
if (quiet == false) send_prompt (hashcat_ctx);
break;
}