1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-03-06 18:16:12 +00:00

color cracked hash as an option

This commit is contained in:
banderlog 2025-01-17 11:54:39 +02:00
parent 9e4e7c1c60
commit c1459cd2d6
4 changed files with 24 additions and 8 deletions

View File

@ -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;

View File

@ -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))
{

View File

@ -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
};

View File

@ -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
}
}