1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-21 23:58:07 +00:00

Prepare for --status_json

add option, enum, autocomplete, status function placeholders
This commit is contained in:
Chick3nman 2019-03-27 05:09:24 -05:00
parent 537516f694
commit 2358220cbe
4 changed files with 98 additions and 10 deletions

View File

@ -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=()

View File

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

View File

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

View File

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