From 2358220cbe4498b3137ce034921cd3ad4b63488f Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Wed, 27 Mar 2019 05:09:24 -0500 Subject: [PATCH 01/20] Prepare for --status_json add option, enum, autocomplete, status function placeholders --- extra/tab_completion/hashcat.sh | 2 +- include/types.h | 20 ++++---- src/terminal.c | 82 +++++++++++++++++++++++++++++++++ src/user_options.c | 4 ++ 4 files changed, 98 insertions(+), 10 deletions(-) diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index 482488337..1be8ecf03 100644 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -189,7 +189,7 @@ _hashcat () local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s ?h ?H' local SHORT_OPTS="-m -a -V -v -h -b -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -i -I -s -l -O -S -z" - local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --opencl-info --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password" + local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-json --status-timer --machine-readable --loopback --markov-hcstat2 --markov-disable --markov-classic --markov-threshold --runtime --session --speed-only --progress-only --restore --restore-file-path --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --wordlist-autohex-disable --separator --show --left --username --remove --remove-timer --potfile-disable --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --example-hashes --opencl-info --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password" local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --markov-hcstat2 --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-path --restore-file-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platforms --opencl-device-types --opencl-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-whitelist-session --stdin-timeout-abort" COMPREPLY=() diff --git a/include/types.h b/include/types.h index 69fac18f5..b009d7222 100644 --- a/include/types.h +++ b/include/types.h @@ -670,6 +670,7 @@ typedef enum user_options_defaults SPEED_ONLY = false, SPIN_DAMP = 8, STATUS = false, + STATUS_JSON = false, STATUS_TIMER = 10, STDIN_TIMEOUT_ABORT = 120, STDOUT_FLAG = false, @@ -777,17 +778,18 @@ typedef enum user_options_map IDX_SPEED_ONLY = 0xff3d, IDX_SPIN_DAMP = 0xff3e, IDX_STATUS = 0xff3f, - IDX_STATUS_TIMER = 0xff40, - IDX_STDOUT_FLAG = 0xff41, - IDX_STDIN_TIMEOUT_ABORT = 0xff42, - IDX_TRUECRYPT_KEYFILES = 0xff43, - IDX_USERNAME = 0xff44, - IDX_VERACRYPT_KEYFILES = 0xff45, - IDX_VERACRYPT_PIM_START = 0xff46, - IDX_VERACRYPT_PIM_STOP = 0xff47, + IDX_STATUS_JSON = 0xff40 + IDX_STATUS_TIMER = 0xff41, + IDX_STDOUT_FLAG = 0xff42, + IDX_STDIN_TIMEOUT_ABORT = 0xff43, + IDX_TRUECRYPT_KEYFILES = 0xff44, + IDX_USERNAME = 0xff45, + IDX_VERACRYPT_KEYFILES = 0xff46, + IDX_VERACRYPT_PIM_START = 0xff47, + IDX_VERACRYPT_PIM_STOP = 0xff48, IDX_VERSION_LOWER = 'v', IDX_VERSION = 'V', - IDX_WORDLIST_AUTOHEX_DISABLE = 0xff48, + IDX_WORDLIST_AUTOHEX_DISABLE = 0xff49, IDX_WORKLOAD_PROFILE = 'w', } user_options_map_t; diff --git a/src/terminal.c b/src/terminal.c index 3beab641c..638cae011 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -725,6 +725,7 @@ void opencl_info_compact (hashcat_ctx_t *hashcat_ctx) if (user_options->quiet == true) return; if (user_options->machine_readable == true) return; + if (user_options->status_json == true) return; cl_uint platforms_cnt = opencl_ctx->platforms_cnt; cl_platform_id *platforms = opencl_ctx->platforms; @@ -887,6 +888,28 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) hcfree (hashcat_status); } + + +void status_display_status_json (hashcat_ctx_t *hashcat_ctx) +{ + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); + + const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); + + if (rc_status == -1) + { + hcfree (hashcat_status); + + return; + } + + /** + * build status in json + */ + +} + + void status_display (hashcat_ctx_t *hashcat_ctx) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; @@ -899,6 +922,13 @@ void status_display (hashcat_ctx_t *hashcat_ctx) return; } + + if (user_options->status_json == true) + { + status_display_status_json (hashcat_ctx); + + return; + } hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); @@ -1564,6 +1594,25 @@ void status_speed_machine_readable (hashcat_ctx_t *hashcat_ctx) hcfree (hashcat_status); } +void status_speed_json (hashcat_ctx_t *hashcat_ctx) +{ + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); + + const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); + + if (rc_status == -1) + { + hcfree (hashcat_status); + + return; + } + + /** + * build status speed in json + */ + +} + void status_speed (hashcat_ctx_t *hashcat_ctx) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -1574,6 +1623,13 @@ void status_speed (hashcat_ctx_t *hashcat_ctx) return; } + + if (user_options->status_json == true) + { + status_speed_json (hashcat_ctx); + + return; + } hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); @@ -1641,6 +1697,25 @@ void status_progress_machine_readable (hashcat_ctx_t *hashcat_ctx) hcfree (hashcat_status); } +void status_progress_json (hashcat_ctx_t *hashcat_ctx) +{ + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); + + const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); + + if (rc_status == -1) + { + hcfree (hashcat_status); + + return; + } + + /** + * build status progress in json + */ + +} + void status_progress (hashcat_ctx_t *hashcat_ctx) { const user_options_t *user_options = hashcat_ctx->user_options; @@ -1651,6 +1726,13 @@ void status_progress (hashcat_ctx_t *hashcat_ctx) return; } + + if (user_options->status_json == true) + { + status_progress_json (hashcat_ctx); + + return; + } hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); diff --git a/src/user_options.c b/src/user_options.c index 87d7fe061..a7eab1a0b 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -112,6 +112,7 @@ static const struct option long_options[] = {"speed-only", no_argument, NULL, IDX_SPEED_ONLY}, {"spin-damp", required_argument, NULL, IDX_SPIN_DAMP}, {"status", no_argument, NULL, IDX_STATUS}, + {"status-json", no_argument, NULL, IDX_STATUS_JSON}, {"status-timer", required_argument, NULL, IDX_STATUS_TIMER}, {"stdout", no_argument, NULL, IDX_STDOUT_FLAG}, {"stdin-timeout-abort", required_argument, NULL, IDX_STDIN_TIMEOUT_ABORT}, @@ -242,6 +243,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->speed_only = SPEED_ONLY; user_options->spin_damp = SPIN_DAMP; user_options->status = STATUS; + user_options->status_json = STATUS_JSON; user_options->status_timer = STATUS_TIMER; user_options->stdin_timeout_abort = STDIN_TIMEOUT_ABORT; user_options->stdout_flag = STDOUT_FLAG; @@ -391,6 +393,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_RESTORE_DISABLE: user_options->restore_disable = true; break; case IDX_RESTORE_FILE_PATH: user_options->restore_file_path = optarg; break; case IDX_STATUS: user_options->status = true; break; + case IDX_STATUS_JSON: user_options->status_json = true; break; case IDX_STATUS_TIMER: user_options->status_timer = hc_strtoul (optarg, NULL, 10); break; case IDX_MACHINE_READABLE: user_options->machine_readable = true; break; case IDX_LOOPBACK: user_options->loopback = true; break; @@ -2787,6 +2790,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_uint (user_options->speed_only); logfile_top_uint (user_options->spin_damp); logfile_top_uint (user_options->status); + logfile_top_uint (user_options->status_json); logfile_top_uint (user_options->status_timer); logfile_top_uint (user_options->stdout_flag); logfile_top_uint (user_options->usage); From 20aa7da205f2cd5a58b298d039e769d7cb3856b5 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Wed, 27 Mar 2019 05:39:10 -0500 Subject: [PATCH 02/20] Fixed typo --- include/types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/types.h b/include/types.h index b009d7222..fb2d2d79e 100644 --- a/include/types.h +++ b/include/types.h @@ -778,7 +778,7 @@ typedef enum user_options_map IDX_SPEED_ONLY = 0xff3d, IDX_SPIN_DAMP = 0xff3e, IDX_STATUS = 0xff3f, - IDX_STATUS_JSON = 0xff40 + IDX_STATUS_JSON = 0xff40, IDX_STATUS_TIMER = 0xff41, IDX_STDOUT_FLAG = 0xff42, IDX_STDIN_TIMEOUT_ABORT = 0xff43, From 81bc4b9ee90c3c5566686c94ca4ef39e2c7fdcbe Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Wed, 27 Mar 2019 05:44:09 -0500 Subject: [PATCH 03/20] Fixed Typo --- src/user_options.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/user_options.c b/src/user_options.c index a7eab1a0b..4d45f9e85 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -393,7 +393,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_RESTORE_DISABLE: user_options->restore_disable = true; break; case IDX_RESTORE_FILE_PATH: user_options->restore_file_path = optarg; break; case IDX_STATUS: user_options->status = true; break; - case IDX_STATUS_JSON: user_options->status_json = true; break; + case IDX_STATUS_JSON: user_options->status_json = true; break; case IDX_STATUS_TIMER: user_options->status_timer = hc_strtoul (optarg, NULL, 10); break; case IDX_MACHINE_READABLE: user_options->machine_readable = true; break; case IDX_LOOPBACK: user_options->loopback = true; break; From cac6522cd790bd94489e722479fc658d3468143b Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Wed, 27 Mar 2019 06:10:28 -0500 Subject: [PATCH 04/20] More prep --- src/terminal.c | 15 ++++++++++++--- src/usage.c | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 638cae011..cafccd235 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -906,7 +906,10 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) /** * build status in json */ - + + status_status_destroy (hashcat_ctx, hashcat_status); + + hcfree (hashcat_status); } @@ -1610,7 +1613,10 @@ void status_speed_json (hashcat_ctx_t *hashcat_ctx) /** * build status speed in json */ - + + status_status_destroy (hashcat_ctx, hashcat_status); + + hcfree (hashcat_status); } void status_speed (hashcat_ctx_t *hashcat_ctx) @@ -1713,7 +1719,10 @@ void status_progress_json (hashcat_ctx_t *hashcat_ctx) /** * build status progress in json */ - + + status_status_destroy (hashcat_ctx, hashcat_status); + + hcfree (hashcat_status); } void status_progress (hashcat_ctx_t *hashcat_ctx) diff --git a/src/usage.c b/src/usage.c index bc4ba0d02..cf17c12e1 100644 --- a/src/usage.c +++ b/src/usage.c @@ -36,6 +36,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] = " --hex-wordlist | | Assume words in wordlist are given in hex |", " --force | | Ignore warnings |", " --status | | Enable automatic update of the status screen |", + " --status-json | | Enable JSON format for status ouput |", " --status-timer | Num | Sets seconds between status screen updates to X | --status-timer=1", " --stdin-timeout-abort | Num | Abort if there is no input from stdin for X seconds | --stdin-timeout-abort=300", " --machine-readable | | Display the status view in a machine-readable format |", From f4348099212f4bd63d11bdb13b3fcb15c5bea532 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Wed, 27 Mar 2019 06:15:58 -0500 Subject: [PATCH 05/20] More Prep --- include/types.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/types.h b/include/types.h index fb2d2d79e..9cb4ad1b2 100644 --- a/include/types.h +++ b/include/types.h @@ -1860,6 +1860,7 @@ typedef struct user_options bool slow_candidates; bool speed_only; bool status; + bool status_json; bool stdout_flag; bool stdin_timeout_abort_chgd; bool usage; From 0cc365139bdff7a772f5160894859ff5224e27f2 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Wed, 27 Mar 2019 06:53:34 -0500 Subject: [PATCH 06/20] Added sanity check to confirm --machine-readable and --status-json do not run at the same time. Fixed typo in existing sanity check. --- src/terminal.c | 1 - src/user_options.c | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index cafccd235..eebc7e545 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -889,7 +889,6 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) } - void status_display_status_json (hashcat_ctx_t *hashcat_ctx) { hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); diff --git a/src/user_options.c b/src/user_options.c index 4d45f9e85..62e6457fc 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -913,12 +913,22 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } } - + + if (user_options->machine_readable == true) + { + if (user_options->status_json == true) + { + event_log_error (hashcat_ctx, "The --status-json flag can not be used with --machine-readable."); + + return -1; + } + } + if (user_options->remove_timer_chgd == true) { if (user_options->remove == false) { - event_log_error (hashcat_ctx, "The --remove-timer requires --remove."); + event_log_error (hashcat_ctx, "The --remove-timer flag requires --remove."); return -1; } @@ -1110,7 +1120,7 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } } - + if (user_options->stdin_timeout_abort_chgd == true) { if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) From ea141f43da45604ff1c7c5b184386b1dee576f8b Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 13:11:55 -0500 Subject: [PATCH 07/20] Formatting for json status --- src/terminal.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index eebc7e545..6ee926be0 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -888,9 +888,10 @@ void status_display_machine_readable (hashcat_ctx_t *hashcat_ctx) hcfree (hashcat_status); } - void status_display_status_json (hashcat_ctx_t *hashcat_ctx) { + const hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); @@ -901,17 +902,52 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) return; } + printf ("\{ \"session\": \"%s\",", hashcat_status->session); + printf (" \"status\": %d,", hashcat_status->status_number); + printf (" \"progress\": \[%," PRIu64 " %\]," PRIu64, hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip); + printf (" \"restore_point\": %," PRIu64, hashcat_status->restore_point); + printf (" \"recovered_hashes\": \[%d, %d\],", hashcat_status->digests_done, hashcat_status->digests_cnt); + printf (" \"recovered_salts\": \[%d, %d\],", hashcat_status->salts_done, hashcat_status->salts_cnt); + printf (" \"rejected\": %," PRIu64, hashcat_status->progress_rejected); + printf (" \"devices\": \["); + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) + { + const device_info_t *device_info = hashcat_status->device_info_buf + device_id; + + if (device_info->skipped_dev == true) continue; + + if (device_info->skipped_warning_dev == true) continue; + if (device_id != 0) + { + printf(","); + } + printf (" \"device_id\": %d", device_id + 1); + printf (" \"speed\": %," PRIu64, (u64) (device_info->hashes_msec_dev * 1000)); + + if (hwmon_ctx->enabled == true) + { + const int temp = hm_get_temperature_with_device_id (hashcat_ctx, device_id); + + printf (" \"temp\": %d,", temp); + } + + const int util = hm_get_utilization_with_device_id (hashcat_ctx, device_id); + + printf (" \"util\": %d \}", util); + } + printf ("\]"); + //printf ( the fucking time started) + //printf ( the fucking time estimated) - /** - * build status in json - */ + hc_fwrite (EOL, strlen (EOL), 1, stdout); + + fflush (stdout); status_status_destroy (hashcat_ctx, hashcat_status); hcfree (hashcat_status); } - void status_display (hashcat_ctx_t *hashcat_ctx) { const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; From 4d60c7514a586f98c26e0f852dcd2e6c80fa3669 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 13:25:36 -0500 Subject: [PATCH 08/20] Fixed formatting for speed and progress --- src/terminal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 6ee926be0..7748a0a7c 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -904,11 +904,11 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) } printf ("\{ \"session\": \"%s\",", hashcat_status->session); printf (" \"status\": %d,", hashcat_status->status_number); - printf (" \"progress\": \[%," PRIu64 " %\]," PRIu64, hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip); + printf (" \"progress\": \[%" PRIu64 ", %" PRIu64 "\],", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip); printf (" \"restore_point\": %," PRIu64, hashcat_status->restore_point); printf (" \"recovered_hashes\": \[%d, %d\],", hashcat_status->digests_done, hashcat_status->digests_cnt); printf (" \"recovered_salts\": \[%d, %d\],", hashcat_status->salts_done, hashcat_status->salts_cnt); - printf (" \"rejected\": %," PRIu64, hashcat_status->progress_rejected); + printf (" \"rejected\": %" PRIu64 ",", hashcat_status->progress_rejected); printf (" \"devices\": \["); for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { @@ -922,7 +922,7 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) printf(","); } printf (" \"device_id\": %d", device_id + 1); - printf (" \"speed\": %," PRIu64, (u64) (device_info->hashes_msec_dev * 1000)); + printf (" \"speed\": %" PRIu64 ",", (u64) (device_info->hashes_msec_dev * 1000)); if (hwmon_ctx->enabled == true) { From 7bbf4eb1836a6ed818d727627ddf2668ed40be33 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 13:26:46 -0500 Subject: [PATCH 09/20] Fixed restore point number formatting --- src/terminal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terminal.c b/src/terminal.c index 7748a0a7c..06b98a7ea 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -905,7 +905,7 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) printf ("\{ \"session\": \"%s\",", hashcat_status->session); printf (" \"status\": %d,", hashcat_status->status_number); printf (" \"progress\": \[%" PRIu64 ", %" PRIu64 "\],", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip); - printf (" \"restore_point\": %," PRIu64, hashcat_status->restore_point); + printf (" \"restore_point\": %" PRIu64 ",", hashcat_status->restore_point); printf (" \"recovered_hashes\": \[%d, %d\],", hashcat_status->digests_done, hashcat_status->digests_cnt); printf (" \"recovered_salts\": \[%d, %d\],", hashcat_status->salts_done, hashcat_status->salts_cnt); printf (" \"rejected\": %" PRIu64 ",", hashcat_status->progress_rejected); From b55159208260cf420755b8dda457d63fcd3b0517 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 14:55:05 -0500 Subject: [PATCH 10/20] Add start and estimated end times, fix formatting --- src/terminal.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 06b98a7ea..b8eb38d53 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -892,8 +892,10 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) { const hwmon_ctx_t *hwmon_ctx = hashcat_ctx->hwmon_ctx; + const status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + hashcat_status_t *hashcat_status = (hashcat_status_t *) hcmalloc (sizeof (hashcat_status_t)); - + const int rc_status = hashcat_get_status (hashcat_ctx, hashcat_status); if (rc_status == -1) @@ -902,8 +904,25 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) return; } + + time_t time_now; + + time (&time_now); + + time_t sec_etc = status_get_sec_etc (hashcat_ctx); + + if (overflow_check_u64_add (time_now, sec_etc) == false) + { + end = -1; + } + else + { + time_t end = time_now + sec_etc; + } + printf ("\{ \"session\": \"%s\",", hashcat_status->session); printf (" \"status\": %d,", hashcat_status->status_number); + printf (" \"target\": \"%s\",", hashcat_status->hash_target); printf (" \"progress\": \[%" PRIu64 ", %" PRIu64 "\],", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip); printf (" \"restore_point\": %" PRIu64 ",", hashcat_status->restore_point); printf (" \"recovered_hashes\": \[%d, %d\],", hashcat_status->digests_done, hashcat_status->digests_cnt); @@ -935,9 +954,9 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) printf (" \"util\": %d \}", util); } - printf ("\]"); - //printf ( the fucking time started) - //printf ( the fucking time estimated) + printf (" \]"); + printf (" \"time_start\": %d,", status_ctx->runtime_start); + printf (" \"estimated_stop\": %d \}", end); hc_fwrite (EOL, strlen (EOL), 1, stdout); From e696e0a87daee28231ee8aa99ea69d886a14ac99 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 14:59:10 -0500 Subject: [PATCH 11/20] Fix time formatting --- src/terminal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index b8eb38d53..5108c89a1 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -913,7 +913,7 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) if (overflow_check_u64_add (time_now, sec_etc) == false) { - end = -1; + time_t end = 1; } else { @@ -955,8 +955,8 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) printf (" \"util\": %d \}", util); } printf (" \]"); - printf (" \"time_start\": %d,", status_ctx->runtime_start); - printf (" \"estimated_stop\": %d \}", end); + printf (" \"time_start\": %" PRIu64 ",", status_ctx->runtime_start); + printf (" \"estimated_stop\": %" PRIu64 "\}", end); hc_fwrite (EOL, strlen (EOL), 1, stdout); From c2c656edbe91ee2370c986f00e3ad7c2fcf3a566 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 15:00:56 -0500 Subject: [PATCH 12/20] Fix missing line --- src/terminal.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/terminal.c b/src/terminal.c index 5108c89a1..1f479ddd6 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -909,6 +909,8 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) time (&time_now); + char *end; + time_t sec_etc = status_get_sec_etc (hashcat_ctx); if (overflow_check_u64_add (time_now, sec_etc) == false) From 71c02cad5e7afec3461333b05d7bc337e48228f9 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 15:32:25 -0500 Subject: [PATCH 13/20] Add --speed-only and --progress-only support --- src/terminal.c | 52 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 1f479ddd6..c8166676d 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -915,11 +915,11 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) if (overflow_check_u64_add (time_now, sec_etc) == false) { - time_t end = 1; + end = 1; } else { - time_t end = time_now + sec_etc; + end = time_now + sec_etc; } printf ("\{ \"session\": \"%s\",", hashcat_status->session); @@ -958,7 +958,7 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) } printf (" \]"); printf (" \"time_start\": %" PRIu64 ",", status_ctx->runtime_start); - printf (" \"estimated_stop\": %" PRIu64 "\}", end); + printf (" \"estimated_stop\": %" PRIu64 " \}", end); hc_fwrite (EOL, strlen (EOL), 1, stdout); @@ -1666,10 +1666,26 @@ void status_speed_json (hashcat_ctx_t *hashcat_ctx) return; } - /** - * build status speed in json - */ + printf ("\{ \"devices\": ["); + + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) + { + const device_info_t *device_info = hashcat_status->device_info_buf + device_id; + if (device_info->skipped_dev == true) continue; + + if (device_info->skipped_warning_dev == true) continue; + + if (device_id != 0) + { + printf(","); + } + + printf (" \{ \"device\": %d,", device_id + 1); + printf (" \"progress\": %" PRIu64 " \}", (u64) (device_info->hashes_msec_dev_benchmark * 1000)); + + } + printf(" \] \}") status_status_destroy (hashcat_ctx, hashcat_status); hcfree (hashcat_status); @@ -1772,10 +1788,28 @@ void status_progress_json (hashcat_ctx_t *hashcat_ctx) return; } - /** - * build status progress in json - */ + printf ("\{ \"devices\": ["); + + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) + { + const device_info_t *device_info = hashcat_status->device_info_buf + device_id; + + if (device_info->skipped_dev == true) continue; + + if (device_info->skipped_warning_dev == true) continue; + + if (device_id != 0) + { + printf(","); + } + + printf (" \{ \"device\": %d,", device_id + 1); + printf (" \"progress\": %" PRIu64 ",", device_info->progress_dev); + printf (" \"runtime\": %0.2f \}", device_info->runtime_msec_dev); + } + printf(" \] \}") + status_status_destroy (hashcat_ctx, hashcat_status); hcfree (hashcat_status); From 3e13739aa6bc9dfc3b20eb8557f01825be7a8b84 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 15:40:27 -0500 Subject: [PATCH 14/20] Fix Typo --- src/terminal.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index c8166676d..ca2f26bd8 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1685,7 +1685,8 @@ void status_speed_json (hashcat_ctx_t *hashcat_ctx) printf (" \"progress\": %" PRIu64 " \}", (u64) (device_info->hashes_msec_dev_benchmark * 1000)); } - printf(" \] \}") + printf(" \] \}"); + status_status_destroy (hashcat_ctx, hashcat_status); hcfree (hashcat_status); @@ -1808,7 +1809,7 @@ void status_progress_json (hashcat_ctx_t *hashcat_ctx) printf (" \"runtime\": %0.2f \}", device_info->runtime_msec_dev); } - printf(" \] \}") + printf(" \] \}"); status_status_destroy (hashcat_ctx, hashcat_status); From 64f093130136367fdf50893c4615231fd75b61c2 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 15:48:15 -0500 Subject: [PATCH 15/20] Switched key name from progress to speed --- src/terminal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terminal.c b/src/terminal.c index ca2f26bd8..bf16f3c84 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1682,7 +1682,7 @@ void status_speed_json (hashcat_ctx_t *hashcat_ctx) } printf (" \{ \"device\": %d,", device_id + 1); - printf (" \"progress\": %" PRIu64 " \}", (u64) (device_info->hashes_msec_dev_benchmark * 1000)); + printf (" \"speed\": %" PRIu64 " \}", (u64) (device_info->hashes_msec_dev_benchmark * 1000)); } printf(" \] \}"); From 5e307603d6cbed5b68e6d9f27f15df248267b2e4 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 16:06:18 -0500 Subject: [PATCH 16/20] Fix formatting --- src/terminal.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index bf16f3c84..5cdfcd32a 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -922,15 +922,15 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) end = time_now + sec_etc; } - printf ("\{ \"session\": \"%s\",", hashcat_status->session); + printf ("{ \"session\": \"%s\",", hashcat_status->session); printf (" \"status\": %d,", hashcat_status->status_number); printf (" \"target\": \"%s\",", hashcat_status->hash_target); - printf (" \"progress\": \[%" PRIu64 ", %" PRIu64 "\],", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip); + printf (" \"progress\": [%" PRIu64 ", %" PRIu64 "\],", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip); printf (" \"restore_point\": %" PRIu64 ",", hashcat_status->restore_point); - printf (" \"recovered_hashes\": \[%d, %d\],", hashcat_status->digests_done, hashcat_status->digests_cnt); - printf (" \"recovered_salts\": \[%d, %d\],", hashcat_status->salts_done, hashcat_status->salts_cnt); + printf (" \"recovered_hashes\": [%d, %d],", hashcat_status->digests_done, hashcat_status->digests_cnt); + printf (" \"recovered_salts\": [%d, %d],", hashcat_status->salts_done, hashcat_status->salts_cnt); printf (" \"rejected\": %" PRIu64 ",", hashcat_status->progress_rejected); - printf (" \"devices\": \["); + printf (" \"devices\": ["); for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { const device_info_t *device_info = hashcat_status->device_info_buf + device_id; @@ -942,7 +942,7 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) { printf(","); } - printf (" \"device_id\": %d", device_id + 1); + printf (" { \"device_id\": %d", device_id + 1); printf (" \"speed\": %" PRIu64 ",", (u64) (device_info->hashes_msec_dev * 1000)); if (hwmon_ctx->enabled == true) @@ -956,9 +956,9 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) printf (" \"util\": %d \}", util); } - printf (" \]"); + printf (" \],"); printf (" \"time_start\": %" PRIu64 ",", status_ctx->runtime_start); - printf (" \"estimated_stop\": %" PRIu64 " \}", end); + printf (" \"estimated_stop\": %" PRIu64 " }", end); hc_fwrite (EOL, strlen (EOL), 1, stdout); @@ -1666,7 +1666,7 @@ void status_speed_json (hashcat_ctx_t *hashcat_ctx) return; } - printf ("\{ \"devices\": ["); + printf ("{ \"devices\": ["); for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { @@ -1681,11 +1681,11 @@ void status_speed_json (hashcat_ctx_t *hashcat_ctx) printf(","); } - printf (" \{ \"device\": %d,", device_id + 1); - printf (" \"speed\": %" PRIu64 " \}", (u64) (device_info->hashes_msec_dev_benchmark * 1000)); + printf (" { \"device_id\": %d,", device_id + 1); + printf (" \"speed\": %" PRIu64 " }", (u64) (device_info->hashes_msec_dev_benchmark * 1000)); } - printf(" \] \}"); + printf(" ] }"); status_status_destroy (hashcat_ctx, hashcat_status); @@ -1789,7 +1789,7 @@ void status_progress_json (hashcat_ctx_t *hashcat_ctx) return; } - printf ("\{ \"devices\": ["); + printf ("{ \"devices\": ["); for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { @@ -1804,12 +1804,12 @@ void status_progress_json (hashcat_ctx_t *hashcat_ctx) printf(","); } - printf (" \{ \"device\": %d,", device_id + 1); + printf (" { \"device_id\": %d,", device_id + 1); printf (" \"progress\": %" PRIu64 ",", device_info->progress_dev); - printf (" \"runtime\": %0.2f \}", device_info->runtime_msec_dev); + printf (" \"runtime\": %0.2f }", device_info->runtime_msec_dev); } - printf(" \] \}"); + printf(" ] }"); status_status_destroy (hashcat_ctx, hashcat_status); From 5b20662c7fb21c4e1d7be540ac4c30a88173ecec Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 16:10:23 -0500 Subject: [PATCH 17/20] Fix Formatting --- src/terminal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 5cdfcd32a..88ced5a41 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -925,7 +925,7 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) printf ("{ \"session\": \"%s\",", hashcat_status->session); printf (" \"status\": %d,", hashcat_status->status_number); printf (" \"target\": \"%s\",", hashcat_status->hash_target); - printf (" \"progress\": [%" PRIu64 ", %" PRIu64 "\],", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip); + printf (" \"progress\": [%" PRIu64 ", %" PRIu64 "],", hashcat_status->progress_cur_relative_skip, hashcat_status->progress_end_relative_skip); printf (" \"restore_point\": %" PRIu64 ",", hashcat_status->restore_point); printf (" \"recovered_hashes\": [%d, %d],", hashcat_status->digests_done, hashcat_status->digests_cnt); printf (" \"recovered_salts\": [%d, %d],", hashcat_status->salts_done, hashcat_status->salts_cnt); @@ -942,7 +942,7 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) { printf(","); } - printf (" { \"device_id\": %d", device_id + 1); + printf (" { \"device_id\": %d,", device_id + 1); printf (" \"speed\": %" PRIu64 ",", (u64) (device_info->hashes_msec_dev * 1000)); if (hwmon_ctx->enabled == true) @@ -954,7 +954,7 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) const int util = hm_get_utilization_with_device_id (hashcat_ctx, device_id); - printf (" \"util\": %d \}", util); + printf (" \"util\": %d }", util); } printf (" \],"); printf (" \"time_start\": %" PRIu64 ",", status_ctx->runtime_start); From dc1fc28733c163cab88705c0065c93cba0625d10 Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 16:10:54 -0500 Subject: [PATCH 18/20] Fix Formatting --- src/terminal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terminal.c b/src/terminal.c index 88ced5a41..b00ae40fa 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -956,7 +956,7 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) printf (" \"util\": %d }", util); } - printf (" \],"); + printf (" ],"); printf (" \"time_start\": %" PRIu64 ",", status_ctx->runtime_start); printf (" \"estimated_stop\": %" PRIu64 " }", end); From 1cf2a4fea6f56995374bdb4b534031d50558bd9d Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 16:23:05 -0500 Subject: [PATCH 19/20] Fix type missmatch --- src/terminal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/terminal.c b/src/terminal.c index b00ae40fa..76eedf699 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -909,7 +909,7 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) time (&time_now); - char *end; + time_t end; time_t sec_etc = status_get_sec_etc (hashcat_ctx); From fc1aa8354168a39d3746244bed5f28b8832c205f Mon Sep 17 00:00:00 2001 From: Chick3nman Date: Tue, 2 Apr 2019 16:53:59 -0500 Subject: [PATCH 20/20] Change logic for formatting with multiple devices when some are skipped --- src/terminal.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/terminal.c b/src/terminal.c index 76eedf699..72797fc94 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -931,6 +931,9 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) printf (" \"recovered_salts\": [%d, %d],", hashcat_status->salts_done, hashcat_status->salts_cnt); printf (" \"rejected\": %" PRIu64 ",", hashcat_status->progress_rejected); printf (" \"devices\": ["); + + int device_num = 0; + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { const device_info_t *device_info = hashcat_status->device_info_buf + device_id; @@ -938,7 +941,8 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) if (device_info->skipped_dev == true) continue; if (device_info->skipped_warning_dev == true) continue; - if (device_id != 0) + + if (device_num != 0) { printf(","); } @@ -955,6 +959,8 @@ void status_display_status_json (hashcat_ctx_t *hashcat_ctx) const int util = hm_get_utilization_with_device_id (hashcat_ctx, device_id); printf (" \"util\": %d }", util); + + device_num++; } printf (" ],"); printf (" \"time_start\": %" PRIu64 ",", status_ctx->runtime_start); @@ -1668,6 +1674,8 @@ void status_speed_json (hashcat_ctx_t *hashcat_ctx) printf ("{ \"devices\": ["); + int device_num = 0; + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { const device_info_t *device_info = hashcat_status->device_info_buf + device_id; @@ -1676,14 +1684,14 @@ void status_speed_json (hashcat_ctx_t *hashcat_ctx) if (device_info->skipped_warning_dev == true) continue; - if (device_id != 0) + if (device_num != 0) { printf(","); } printf (" { \"device_id\": %d,", device_id + 1); printf (" \"speed\": %" PRIu64 " }", (u64) (device_info->hashes_msec_dev_benchmark * 1000)); - + device_num++; } printf(" ] }"); @@ -1791,6 +1799,8 @@ void status_progress_json (hashcat_ctx_t *hashcat_ctx) printf ("{ \"devices\": ["); + int device_num = 0; + for (int device_id = 0; device_id < hashcat_status->device_info_cnt; device_id++) { const device_info_t *device_info = hashcat_status->device_info_buf + device_id; @@ -1799,7 +1809,7 @@ void status_progress_json (hashcat_ctx_t *hashcat_ctx) if (device_info->skipped_warning_dev == true) continue; - if (device_id != 0) + if (device_num != 0) { printf(","); } @@ -1807,7 +1817,7 @@ void status_progress_json (hashcat_ctx_t *hashcat_ctx) printf (" { \"device_id\": %d,", device_id + 1); printf (" \"progress\": %" PRIu64 ",", device_info->progress_dev); printf (" \"runtime\": %0.2f }", device_info->runtime_msec_dev); - + device_num++; } printf(" ] }");