diff --git a/docs/changes.txt b/docs/changes.txt index a3e754257..a8ca396bb 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -121,6 +121,7 @@ - Modules: Added support of a custom charset setting for benchmarks to the module interface - Modules: Added suffix *legacy* to old VeraCrypt modules (13711-13783). - Terminal: Increased size of hash name column in `--help` and `--identify` options. +- Terminal: Limit output length of example hash in --example-hash mode to 200. Use --mach to see full example hash - Modules: New LUKS v1 modules (29511-29543) which do not use `module_hash_binary_parse` to get data from containers anymore (use new tool `tools/luks2hashcat.py`). - Modules: Renamed old LUKS module into LUKS v1 and added suffix *legacy* (14600). - Workflow: Added basic workflow for GitHub Actions. diff --git a/src/terminal.c b/src/terminal.c index d011ad573..2bb2e6dc6 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -17,7 +17,7 @@ #include "timer.h" #include "terminal.h" -#define MAXIMUM_EXAMPLE_HASH_LENGTH (128) +static const size_t MAXIMUM_EXAMPLE_HASH_LENGTH = 200; static const size_t TERMINAL_LINE_LENGTH = 79; @@ -843,15 +843,18 @@ void hash_info_single (hashcat_ctx_t *hashcat_ctx, user_options_extra_t *user_op event_log_info (hashcat_ctx, " Example.Hash.Format.: plain"); } - if (strlen (hashconfig->st_hash) > MAXIMUM_EXAMPLE_HASH_LENGTH) { - char st_hash[MAXIMUM_EXAMPLE_HASH_LENGTH + 1] = { '\0' }; + if (strlen (hashconfig->st_hash) > MAXIMUM_EXAMPLE_HASH_LENGTH) + { + char *st_hash = hcstrdup (hashconfig->st_hash); + + compress_terminal_line_length (st_hash, 24, 5); - strncpy (st_hash, hashconfig->st_hash, MAXIMUM_EXAMPLE_HASH_LENGTH - 3); - strcpy (st_hash + MAXIMUM_EXAMPLE_HASH_LENGTH - 3, "..."); + event_log_info (hashcat_ctx, " Example.Hash........: %s [Truncated, use --mach for full length]", st_hash); - event_log_info (hashcat_ctx, " Example.Hash........: [too long example hash for your terminal, use --machine-readable]"); - event_log_info (hashcat_ctx, " %s", st_hash); - } else { + hcfree (st_hash); + } + else + { event_log_info (hashcat_ctx, " Example.Hash........: %s", hashconfig->st_hash); }