From e6715fbd89686fbe28eb068fdf0763307863ab0a Mon Sep 17 00:00:00 2001 From: jsteube Date: Fri, 6 Oct 2023 08:21:07 +0000 Subject: [PATCH] Prepare options and usage for --outfile-json --- src/usage.c | 1 + src/user_options.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/src/usage.c b/src/usage.c index 03d676741..e81ad2c04 100644 --- a/src/usage.c +++ b/src/usage.c @@ -57,6 +57,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --restore-file-path | File | Specific path to restore file | --restore-file-path=x.restore", " -o, --outfile | File | Define outfile for recovered hash | -o outfile.txt", " --outfile-format | Str | Outfile format to use, separated with commas | --outfile-format=1,3", + " --outfile-json | | Force JSON format in outfile format |", " --outfile-autohex-disable | | Disable the use of $HEX[] in output plains |", " --outfile-check-timer | Num | Sets seconds between outfile checks to X | --outfile-check-timer=30", " --wordlist-autohex-disable | | Disable the conversion of $HEX[] from the wordlist |", diff --git a/src/user_options.c b/src/user_options.c index 57845e257..9c7bd193e 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -103,6 +103,7 @@ static const struct option long_options[] = {"outfile-check-dir", required_argument, NULL, IDX_OUTFILE_CHECK_DIR}, {"outfile-check-timer", required_argument, NULL, IDX_OUTFILE_CHECK_TIMER}, {"outfile-format", required_argument, NULL, IDX_OUTFILE_FORMAT}, + {"outfile-json", no_argument, NULL, IDX_OUTFILE_JSON}, {"outfile", required_argument, NULL, IDX_OUTFILE}, {"potfile-disable", no_argument, NULL, IDX_POTFILE_DISABLE}, {"potfile-path", required_argument, NULL, IDX_POTFILE_PATH}, @@ -246,6 +247,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->outfile_check_dir = NULL; user_options->outfile_check_timer = OUTFILE_CHECK_TIMER; user_options->outfile_format = OUTFILE_FORMAT; + user_options->outfile_json = OUTFILE_JSON; user_options->outfile = NULL; user_options->potfile_disable = POTFILE_DISABLE; user_options->potfile_path = NULL; @@ -463,6 +465,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) user_options->outfile_chgd = true; break; case IDX_OUTFILE_FORMAT: user_options->outfile_format = outfile_format_parse (optarg); user_options->outfile_format_chgd = true; break; + case IDX_OUTFILE_JSON: user_options->outfile_json = true; break; case IDX_OUTFILE_AUTOHEX_DISABLE: user_options->outfile_autohex = false; break; case IDX_OUTFILE_CHECK_TIMER: user_options->outfile_check_timer = hc_strtoul (optarg, NULL, 10); break; case IDX_WORDLIST_AUTOHEX_DISABLE: user_options->wordlist_autohex_disable = true; break; @@ -1078,6 +1081,13 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } + + if (user_options->outfile_json == false) + { + event_log_error (hashcat_ctx, "Mixing --outfile-json is not allowed with --show."); + + return -1; + } } if (user_options->keyspace == true) @@ -3252,6 +3262,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_uint (user_options->outfile_autohex); logfile_top_uint (user_options->outfile_check_timer); logfile_top_uint (user_options->outfile_format); + logfile_top_uint (user_options->outfile_json); logfile_top_uint (user_options->wordlist_autohex_disable); logfile_top_uint (user_options->potfile_disable); logfile_top_uint (user_options->progress_only);