From 32b40d5c53e0c438576f33bfa03d8fe6b87d08e8 Mon Sep 17 00:00:00 2001 From: Jens Steube Date: Wed, 5 May 2021 22:53:04 +0200 Subject: [PATCH] Added command prompt [f]inish to instruct hashcat to finish the current attack and quit afterwards --- docs/changes.txt | 5 +- include/hashcat.h | 1 + include/thread.h | 2 + include/types.h | 2 + src/hashcat.c | 12 +++++ .../{module_21501.c => module_25100.c} | 0 src/status.c | 9 ++++ src/terminal.c | 25 ++++++++- src/thread.c | 52 ++++++++++++++++++- tools/test_modules/{m21501.pm => m25100.pm} | 0 10 files changed, 103 insertions(+), 5 deletions(-) rename src/modules/{module_21501.c => module_25100.c} (100%) rename tools/test_modules/{m21501.pm => m25100.pm} (100%) diff --git a/docs/changes.txt b/docs/changes.txt index 966ba6d5f..3dfb53585 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -20,6 +20,8 @@ - Added hash-mode: RAR3-p (Compressed) - Added hash-mode: RAR3-p (Uncompressed) - Added hash-mode: RSA/DSA/EC/OPENSSH Private Keys +- Added hash-mode: SolarWinds Orion v2 +- Added hash-mode: SolarWinds Serv-U - Added hash-mode: SQLCipher - Added hash-mode: Stargazer Stellar Wallet XLM - Added hash-mode: Stuffit5 @@ -27,13 +29,12 @@ - Added hash-mode: Umbraco HMAC-SHA1 - Added hash-mode: sha1($salt.sha1($pass.$salt)) - Added hash-mode: sha1(sha1($pass).$salt) -- Added hash-mode: SolarWinds Orion v2 -- Added hash-mode: SolarWinds Serv-U ## ## Features ## +- Added command prompt [f]inish to instruct hashcat to finish the current attack and quit afterwards - Added support for true UTF8 to UTF16 conversion in kernel crypto library - Added option --hash-info to show generic information for each hash-mode - Removed option --example-hashes, now is an alias of --hash-info diff --git a/include/hashcat.h b/include/hashcat.h index d075fe756..49cfc91df 100644 --- a/include/hashcat.h +++ b/include/hashcat.h @@ -15,6 +15,7 @@ int hashcat_session_pause (hashcat_ctx_t *hashcat_ctx); int hashcat_session_resume (hashcat_ctx_t *hashcat_ctx); int hashcat_session_bypass (hashcat_ctx_t *hashcat_ctx); int hashcat_session_checkpoint (hashcat_ctx_t *hashcat_ctx); +int hashcat_session_finish (hashcat_ctx_t *hashcat_ctx); int hashcat_session_quit (hashcat_ctx_t *hashcat_ctx); int hashcat_session_destroy (hashcat_ctx_t *hashcat_ctx); diff --git a/include/thread.h b/include/thread.h index 8f06d0e29..61a7447d9 100644 --- a/include/thread.h +++ b/include/thread.h @@ -77,11 +77,13 @@ void hc_signal (void (callback) (int)); int mycracked (hashcat_ctx_t *hashcat_ctx); int myabort_runtime (hashcat_ctx_t *hashcat_ctx); int myabort_checkpoint (hashcat_ctx_t *hashcat_ctx); +int myabort_finish (hashcat_ctx_t *hashcat_ctx); int myabort (hashcat_ctx_t *hashcat_ctx); int myquit (hashcat_ctx_t *hashcat_ctx); int bypass (hashcat_ctx_t *hashcat_ctx); int SuspendThreads (hashcat_ctx_t *hashcat_ctx); int ResumeThreads (hashcat_ctx_t *hashcat_ctx); int stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx); +int finish_after_attack (hashcat_ctx_t *hashcat_ctx); #endif // _THREAD_H diff --git a/include/types.h b/include/types.h index 45645d46f..3063a8e84 100644 --- a/include/types.h +++ b/include/types.h @@ -209,6 +209,7 @@ typedef enum status_rc STATUS_ABORTED_CHECKPOINT = 10, STATUS_ABORTED_RUNTIME = 11, STATUS_ERROR = 13, + STATUS_ABORTED_FINISH = 14, } status_rc_t; @@ -2348,6 +2349,7 @@ typedef struct status_ctx bool shutdown_outer; bool checkpoint_shutdown; + bool finish_shutdown; hc_thread_mutex_t mux_dispatcher; hc_thread_mutex_t mux_counter; diff --git a/src/hashcat.c b/src/hashcat.c index c03141e1b..7fa047ca7 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -270,10 +270,16 @@ static int inner2_loop (hashcat_ctx_t *hashcat_ctx) myabort_checkpoint (hashcat_ctx); } + if ((status_ctx->devices_status == STATUS_RUNNING) && (status_ctx->finish_shutdown == true)) + { + myabort_finish (hashcat_ctx); + } + if ((status_ctx->devices_status != STATUS_CRACKED) && (status_ctx->devices_status != STATUS_ERROR) && (status_ctx->devices_status != STATUS_ABORTED) && (status_ctx->devices_status != STATUS_ABORTED_CHECKPOINT) + && (status_ctx->devices_status != STATUS_ABORTED_FINISH) && (status_ctx->devices_status != STATUS_ABORTED_RUNTIME) && (status_ctx->devices_status != STATUS_QUIT) && (status_ctx->devices_status != STATUS_BYPASS)) @@ -1234,6 +1240,7 @@ int hashcat_session_execute (hashcat_ctx_t *hashcat_ctx) if (rc_final == 0) { + if (status_ctx->devices_status == STATUS_ABORTED_FINISH) rc_final = 5; if (status_ctx->devices_status == STATUS_ABORTED_RUNTIME) rc_final = 4; if (status_ctx->devices_status == STATUS_ABORTED_CHECKPOINT) rc_final = 3; if (status_ctx->devices_status == STATUS_ABORTED) rc_final = 2; @@ -1278,6 +1285,11 @@ int hashcat_session_checkpoint (hashcat_ctx_t *hashcat_ctx) return stop_at_checkpoint (hashcat_ctx); } +int hashcat_session_finish (hashcat_ctx_t *hashcat_ctx) +{ + return finish_after_attack (hashcat_ctx); +} + int hashcat_session_quit (hashcat_ctx_t *hashcat_ctx) { return myabort (hashcat_ctx); diff --git a/src/modules/module_21501.c b/src/modules/module_25100.c similarity index 100% rename from src/modules/module_21501.c rename to src/modules/module_25100.c diff --git a/src/status.c b/src/status.c index a9f56190a..dc39cf71e 100644 --- a/src/status.c +++ b/src/status.c @@ -32,6 +32,8 @@ static const char *ST_0010 = "Aborted (Checkpoint)"; static const char *ST_0011 = "Aborted (Runtime)"; static const char *ST_0012 = "Running (Checkpoint Quit requested)"; static const char *ST_0013 = "Error"; +static const char *ST_0014 = "Aborted (Finish)"; +static const char *ST_0015 = "Running (Quit after attack requested)"; static const char *ST_9999 = "Unknown! Bug!"; static const char UNITS[7] = { ' ', 'k', 'M', 'G', 'T', 'P', 'E' }; @@ -267,6 +269,11 @@ const char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx) { return ST_0012; } + + if (status_ctx->finish_shutdown == true) + { + return ST_0015; + } } switch (devices_status) @@ -284,6 +291,7 @@ const char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx) case STATUS_ABORTED_CHECKPOINT: return ST_0010; case STATUS_ABORTED_RUNTIME: return ST_0011; case STATUS_ERROR: return ST_0013; + case STATUS_ABORTED_FINISH: return ST_0014; } return ST_9999; @@ -2197,6 +2205,7 @@ int status_ctx_init (hashcat_ctx_t *hashcat_ctx) status_ctx->shutdown_outer = false; status_ctx->checkpoint_shutdown = false; + status_ctx->finish_shutdown = false; status_ctx->hashcat_status_final = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); diff --git a/src/terminal.c b/src/terminal.c index 403d4a956..4a663b759 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -18,8 +18,8 @@ static const size_t TERMINAL_LINE_LENGTH = 79; -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 => "; +static const char *PROMPT_ACTIVE = "[s]tatus [p]ause [b]ypass [c]heckpoint [f]inish [q]uit => "; +static const char *PROMPT_PAUSED = "[s]tatus [r]esume [b]ypass [c]heckpoint [f]inish [q]uit => "; void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag) { @@ -292,6 +292,27 @@ static void keypress (hashcat_ctx_t *hashcat_ctx) break; + case 'f': + + event_log_info (hashcat_ctx, NULL); + + finish_after_attack (hashcat_ctx); + + if (status_ctx->finish_shutdown == true) + { + event_log_info (hashcat_ctx, "Finish enabled. Will quit after this attack."); + } + else + { + event_log_info (hashcat_ctx, "Finish disabled. Will continue after this attack."); + } + + event_log_info (hashcat_ctx, NULL); + + if (quiet == false) send_prompt (hashcat_ctx); + + break; + case 'q': event_log_info (hashcat_ctx, NULL); diff --git a/src/thread.c b/src/thread.c index c601955d2..c33d25b8d 100644 --- a/src/thread.c +++ b/src/thread.c @@ -144,6 +144,21 @@ int myabort_checkpoint (hashcat_ctx_t *hashcat_ctx) return 0; } +int myabort_finish (hashcat_ctx_t *hashcat_ctx) +{ + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + status_ctx->devices_status = STATUS_ABORTED_FINISH; + + status_ctx->run_main_level1 = false; + status_ctx->run_main_level2 = false; + status_ctx->run_main_level3 = false; + status_ctx->run_thread_level1 = false; + status_ctx->run_thread_level2 = false; + + return 0; +} + int myabort_runtime (hashcat_ctx_t *hashcat_ctx) { status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -209,6 +224,9 @@ int bypass (hashcat_ctx_t *hashcat_ctx) status_ctx->run_thread_level1 = false; status_ctx->run_thread_level2 = false; + status_ctx->checkpoint_shutdown = false; + status_ctx->finish_shutdown = false; + return 0; } @@ -242,7 +260,7 @@ int ResumeThreads (hashcat_ctx_t *hashcat_ctx) int stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx) { - status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; if (status_ctx->devices_status != STATUS_RUNNING) return -1; @@ -282,3 +300,35 @@ int stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx) return 0; } + +int finish_after_attack (hashcat_ctx_t *hashcat_ctx) +{ + status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + + if (status_ctx->devices_status != STATUS_RUNNING) return -1; + + // Enable or Disable + + if (status_ctx->finish_shutdown == false) + { + status_ctx->finish_shutdown = true; + + status_ctx->run_main_level1 = false; + status_ctx->run_main_level2 = false; + status_ctx->run_main_level3 = false; + status_ctx->run_thread_level1 = true; + status_ctx->run_thread_level2 = true; + } + else + { + status_ctx->finish_shutdown = false; + + status_ctx->run_main_level1 = true; + status_ctx->run_main_level2 = true; + status_ctx->run_main_level3 = true; + status_ctx->run_thread_level1 = true; + status_ctx->run_thread_level2 = true; + } + + return 0; +} diff --git a/tools/test_modules/m21501.pm b/tools/test_modules/m25100.pm similarity index 100% rename from tools/test_modules/m21501.pm rename to tools/test_modules/m25100.pm