diff --git a/include/types.h b/include/types.h index e6ea946f9..e193d77e6 100644 --- a/include/types.h +++ b/include/types.h @@ -636,6 +636,9 @@ typedef enum user_options_defaults BRAIN_SERVER = false, BRAIN_SESSION = 0, #endif + #if !defined(_WIN) + COLOR = false, + #endif DEBUG_MODE = 0, DEPRECATED_CHECK = true, DYNAMIC_X = false, @@ -750,6 +753,9 @@ typedef enum user_options_map IDX_BRAIN_SESSION = 0xff0f, IDX_BRAIN_SESSION_WHITELIST = 0xff10, #endif + #if !defined(_WIN) + IDX_COLOR = 0xff56, + #endif IDX_CPU_AFFINITY = 0xff11, IDX_CUSTOM_CHARSET_1 = '1', IDX_CUSTOM_CHARSET_2 = '2', @@ -2340,6 +2346,9 @@ typedef struct user_options bool brain_client; bool brain_server; #endif + #if !defined(_WIN) + bool color; + #endif bool force; bool deprecated_check; bool dynamic_x; diff --git a/src/main.c b/src/main.c index fffaa3ef1..d6c213093 100644 --- a/src/main.c +++ b/src/main.c @@ -352,16 +352,11 @@ static void main_cracker_hash_cracked (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx, if (outfile_ctx->filename == NULL) if (user_options->quiet == false) clear_prompt (hashcat_ctx); } - #if defined (_WIN) + // cyan color for cracked hashes + if (user_options->color == true) fputs("\033[0;36m", stdout); fwrite (buf, len, 1, stdout); + if (user_options->color == true) fwrite("\033[0m", 4, 1, stdout); fwrite (EOL, strlen (EOL), 1, stdout); - #else - // make cracked hash output in cyan - fputs("\033[36m", stdout); - fwrite (buf, len, 1, stdout); - fwrite("\033[0m", 4, 1, stdout); - fwrite (EOL, strlen (EOL), 1, stdout); - #endif if ((user_options_extra->wordlist_mode == WL_MODE_FILE) || (user_options_extra->wordlist_mode == WL_MODE_MASK)) { diff --git a/src/usage.c b/src/usage.c index 7cbf22348..7864086ae 100644 --- a/src/usage.c +++ b/src/usage.c @@ -146,6 +146,9 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --brain-session | Hex | Overrides automatically calculated brain session | --brain-session=0x2ae611db", " --brain-session-whitelist | Hex | Allow given sessions only, separated with commas | --brain-session-whitelist=0x2ae611db", #endif + #if !defined(_WIN) + " --color | | Enables color output for cracked hashes |", + #endif "", NULL }; diff --git a/src/user_options.c b/src/user_options.c index b1ed588f4..4d5676226 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -154,6 +154,9 @@ static const struct option long_options[] = {"brain-session", required_argument, NULL, IDX_BRAIN_SESSION}, {"brain-session-whitelist", required_argument, NULL, IDX_BRAIN_SESSION_WHITELIST}, #endif + #if !defined(_WIN) + {"color", no_argument, NULL, IDX_COLOR}, + #endif {NULL, 0, NULL, 0 } }; @@ -198,6 +201,9 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->brain_session = BRAIN_SESSION; user_options->brain_session_whitelist = NULL; #endif + #if !defined(_WIN) + user_options->color = COLOR; + #endif user_options->cpu_affinity = NULL; user_options->custom_charset_1 = NULL; user_options->custom_charset_2 = NULL; @@ -548,6 +554,9 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_BRAIN_SESSION: user_options->brain_session = hc_strtoul (optarg, NULL, 16); break; case IDX_BRAIN_SESSION_WHITELIST: user_options->brain_session_whitelist = optarg; break; #endif + #if !defined(_WIN) + case IDX_COLOR: user_options->color = true; break; + #endif } }