From 52c52836e3971f98663b5fb3fe5198e01cfa073e Mon Sep 17 00:00:00 2001 From: jsteube Date: Sat, 1 Sep 2018 12:31:17 +0200 Subject: [PATCH] Add new option --slow-candidates which allows hashcat to generate passwords on-host --- docs/changes.txt | 6 + extra/tab_completion/hashcat.sh | 4 +- include/opencl.h | 4 +- include/slow_candidates.h | 36 + include/status.h | 171 ++-- include/types.h | 183 ++-- include/wordlist.h | 4 +- src/Makefile | 2 +- src/autotune.c | 15 +- src/combinator.c | 392 ++++---- src/dispatch.c | 1054 +++++++++++++------ src/hashcat.c | 40 +- src/induct.c | 3 +- src/interface.c | 81 +- src/mpsp.c | 80 +- src/opencl.c | 1674 ++++++++++++++++++------------- src/outfile.c | 330 +++--- src/selftest.c | 364 ++++--- src/slow_candidates.c | 163 +++ src/status.c | 38 +- src/terminal.c | 41 +- src/usage.c | 1 + src/user_options.c | 98 +- src/wordlist.c | 45 + 24 files changed, 3019 insertions(+), 1810 deletions(-) create mode 100644 include/slow_candidates.h create mode 100644 src/slow_candidates.c diff --git a/docs/changes.txt b/docs/changes.txt index b5821b764..f7716c439 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -1,5 +1,11 @@ * changes v4.2.1 -> xxx +## +## Features +## + +- Add new option --slow-candidates which allows hashcat to generate passwords on-host + ## ## Improvements ## diff --git a/extra/tab_completion/hashcat.sh b/extra/tab_completion/hashcat.sh index 933a0c5b6..ecb647671 100644 --- a/extra/tab_completion/hashcat.sh +++ b/extra/tab_completion/hashcat.sh @@ -188,8 +188,8 @@ _hashcat () local HIDDEN_FILES_AGGRESIVE="${HIDDEN_FILES}|hcmask|hcchr" 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" - 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 --nvidia-spin-damp --gpu-temp-disable --gpu-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 --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable" + 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 --nvidia-spin-damp --gpu-temp-disable --gpu-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 --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates" 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 --nvidia-spin-damp --gpu-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 --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to" COMPREPLY=() diff --git a/include/opencl.h b/include/opencl.h index c8b0a9a2a..06eb71fd2 100644 --- a/include/opencl.h +++ b/include/opencl.h @@ -74,8 +74,8 @@ int run_kernel_decompress (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 pws_cnt); int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const u64 pws_cnt); -void generate_source_kernel_filename (const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *shared_dir, char *source_file); -void generate_cached_kernel_filename (const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *profile_dir, const char *device_name_chksum, char *cached_file); +void generate_source_kernel_filename (const bool slow_candidates, const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *shared_dir, char *source_file); +void generate_cached_kernel_filename (const bool slow_candidates, const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *profile_dir, const char *device_name_chksum, char *cached_file); void generate_source_kernel_mp_filename (const u32 opti_type, const u64 opts_type, char *shared_dir, char *source_file); void generate_cached_kernel_mp_filename (const u32 opti_type, const u64 opts_type, char *profile_dir, const char *device_name_chksum, char *cached_file); void generate_source_kernel_amp_filename (const u32 attack_kern, char *shared_dir, char *source_file); diff --git a/include/slow_candidates.h b/include/slow_candidates.h new file mode 100644 index 000000000..0988eafc0 --- /dev/null +++ b/include/slow_candidates.h @@ -0,0 +1,36 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#ifndef _SLOW_CANDIDATES_H +#define _SLOW_CANDIDATES_H + +typedef struct extra_info_straight +{ + FILE *fd; + + u64 rule_pos_prev; + u64 rule_pos; + + u8 base_buf[256]; + u32 base_len; + + u8 out_buf[256]; + u32 out_len; + +} extra_info_straight_t; + +typedef struct extra_info_mask +{ + u64 pos; + + u8 out_buf[256]; + u32 out_len; + +} extra_info_mask_t; + +void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u64 cur, const u64 end); +void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info); + +#endif // _SLOW_CANDIDATES_H diff --git a/include/status.h b/include/status.h index bce8abc39..8427830f7 100644 --- a/include/status.h +++ b/include/status.h @@ -13,94 +13,95 @@ double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries); // should be static after refactoring -void format_timer_display (struct tm *tm, char *buf, size_t len); -void format_speed_display (double val, char *buf, size_t len); +void format_timer_display (struct tm *tm, char *buf, size_t len); +void format_speed_display (double val, char *buf, size_t len); +void format_speed_display_1k (double val, char *buf, size_t len); -int status_get_device_info_cnt (const hashcat_ctx_t *hashcat_ctx); -int status_get_device_info_active (const hashcat_ctx_t *hashcat_ctx); -bool status_get_skipped_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -char *status_get_session (const hashcat_ctx_t *hashcat_ctx); -const char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx); -int status_get_status_number (const hashcat_ctx_t *hashcat_ctx); -int status_get_guess_mode (const hashcat_ctx_t *hashcat_ctx); -char *status_get_guess_base (const hashcat_ctx_t *hashcat_ctx); -int status_get_guess_base_offset (const hashcat_ctx_t *hashcat_ctx); -int status_get_guess_base_count (const hashcat_ctx_t *hashcat_ctx); -double status_get_guess_base_percent (const hashcat_ctx_t *hashcat_ctx); -char *status_get_guess_mod (const hashcat_ctx_t *hashcat_ctx); -int status_get_guess_mod_offset (const hashcat_ctx_t *hashcat_ctx); -int status_get_guess_mod_count (const hashcat_ctx_t *hashcat_ctx); -double status_get_guess_mod_percent (const hashcat_ctx_t *hashcat_ctx); -char *status_get_guess_charset (const hashcat_ctx_t *hashcat_ctx); -int status_get_guess_mask_length (const hashcat_ctx_t *hashcat_ctx); -char *status_get_guess_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -const char *status_get_hash_type (const hashcat_ctx_t *hashcat_ctx); -const char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx); -int status_get_digests_done (const hashcat_ctx_t *hashcat_ctx); -int status_get_digests_cnt (const hashcat_ctx_t *hashcat_ctx); -double status_get_digests_percent (const hashcat_ctx_t *hashcat_ctx); -int status_get_salts_done (const hashcat_ctx_t *hashcat_ctx); -int status_get_salts_cnt (const hashcat_ctx_t *hashcat_ctx); -double status_get_salts_percent (const hashcat_ctx_t *hashcat_ctx); -double status_get_msec_running (const hashcat_ctx_t *hashcat_ctx); -double status_get_msec_paused (const hashcat_ctx_t *hashcat_ctx); -double status_get_msec_real (const hashcat_ctx_t *hashcat_ctx); -char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx); -char *status_get_time_started_relative (const hashcat_ctx_t *hashcat_ctx); -time_t status_get_sec_etc (const hashcat_ctx_t *hashcat_ctx); -char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx); -char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx); -u64 status_get_restore_point (const hashcat_ctx_t *hashcat_ctx); -u64 status_get_restore_total (const hashcat_ctx_t *hashcat_ctx); -double status_get_restore_percent (const hashcat_ctx_t *hashcat_ctx); -int status_get_progress_mode (const hashcat_ctx_t *hashcat_ctx); -double status_get_progress_finished_percent (const hashcat_ctx_t *hashcat_ctx); -u64 status_get_progress_done (const hashcat_ctx_t *hashcat_ctx); -u64 status_get_progress_rejected (const hashcat_ctx_t *hashcat_ctx); -double status_get_progress_rejected_percent (const hashcat_ctx_t *hashcat_ctx); -u64 status_get_progress_restored (const hashcat_ctx_t *hashcat_ctx); -u64 status_get_progress_cur (const hashcat_ctx_t *hashcat_ctx); -u64 status_get_progress_end (const hashcat_ctx_t *hashcat_ctx); -u64 status_get_progress_ignore (const hashcat_ctx_t *hashcat_ctx); -u64 status_get_progress_skip (const hashcat_ctx_t *hashcat_ctx); -u64 status_get_progress_cur_relative_skip (const hashcat_ctx_t *hashcat_ctx); -u64 status_get_progress_end_relative_skip (const hashcat_ctx_t *hashcat_ctx); -double status_get_hashes_msec_all (const hashcat_ctx_t *hashcat_ctx); -double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -double status_get_hashes_msec_dev_benchmark (const hashcat_ctx_t *hashcat_ctx, const int device_id); -double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx); -double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -char *status_get_speed_sec_all (const hashcat_ctx_t *hashcat_ctx); -char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -int status_get_cpt_cur_min (const hashcat_ctx_t *hashcat_ctx); -int status_get_cpt_cur_hour (const hashcat_ctx_t *hashcat_ctx); -int status_get_cpt_cur_day (const hashcat_ctx_t *hashcat_ctx); -int status_get_cpt_avg_min (const hashcat_ctx_t *hashcat_ctx); -int status_get_cpt_avg_hour (const hashcat_ctx_t *hashcat_ctx); -int status_get_cpt_avg_day (const hashcat_ctx_t *hashcat_ctx); -char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx); -int status_get_salt_pos_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -int status_get_innerloop_pos_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -int status_get_innerloop_left_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -int status_get_iteration_pos_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -int status_get_iteration_left_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -int status_get_corespeed_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -int status_get_memoryspeed_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -u64 status_get_progress_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -double status_get_runtime_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -int status_get_kernel_accel_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -int status_get_kernel_loops_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -int status_get_kernel_threads_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -int status_get_vector_width_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_device_info_cnt (const hashcat_ctx_t *hashcat_ctx); +int status_get_device_info_active (const hashcat_ctx_t *hashcat_ctx); +bool status_get_skipped_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +char *status_get_session (const hashcat_ctx_t *hashcat_ctx); +const char *status_get_status_string (const hashcat_ctx_t *hashcat_ctx); +int status_get_status_number (const hashcat_ctx_t *hashcat_ctx); +int status_get_guess_mode (const hashcat_ctx_t *hashcat_ctx); +char *status_get_guess_base (const hashcat_ctx_t *hashcat_ctx); +int status_get_guess_base_offset (const hashcat_ctx_t *hashcat_ctx); +int status_get_guess_base_count (const hashcat_ctx_t *hashcat_ctx); +double status_get_guess_base_percent (const hashcat_ctx_t *hashcat_ctx); +char *status_get_guess_mod (const hashcat_ctx_t *hashcat_ctx); +int status_get_guess_mod_offset (const hashcat_ctx_t *hashcat_ctx); +int status_get_guess_mod_count (const hashcat_ctx_t *hashcat_ctx); +double status_get_guess_mod_percent (const hashcat_ctx_t *hashcat_ctx); +char *status_get_guess_charset (const hashcat_ctx_t *hashcat_ctx); +int status_get_guess_mask_length (const hashcat_ctx_t *hashcat_ctx); +char *status_get_guess_candidates_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +const char *status_get_hash_type (const hashcat_ctx_t *hashcat_ctx); +const char *status_get_hash_target (const hashcat_ctx_t *hashcat_ctx); +int status_get_digests_done (const hashcat_ctx_t *hashcat_ctx); +int status_get_digests_cnt (const hashcat_ctx_t *hashcat_ctx); +double status_get_digests_percent (const hashcat_ctx_t *hashcat_ctx); +int status_get_salts_done (const hashcat_ctx_t *hashcat_ctx); +int status_get_salts_cnt (const hashcat_ctx_t *hashcat_ctx); +double status_get_salts_percent (const hashcat_ctx_t *hashcat_ctx); +double status_get_msec_running (const hashcat_ctx_t *hashcat_ctx); +double status_get_msec_paused (const hashcat_ctx_t *hashcat_ctx); +double status_get_msec_real (const hashcat_ctx_t *hashcat_ctx); +char *status_get_time_started_absolute (const hashcat_ctx_t *hashcat_ctx); +char *status_get_time_started_relative (const hashcat_ctx_t *hashcat_ctx); +time_t status_get_sec_etc (const hashcat_ctx_t *hashcat_ctx); +char *status_get_time_estimated_absolute (const hashcat_ctx_t *hashcat_ctx); +char *status_get_time_estimated_relative (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_restore_point (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_restore_total (const hashcat_ctx_t *hashcat_ctx); +double status_get_restore_percent (const hashcat_ctx_t *hashcat_ctx); +int status_get_progress_mode (const hashcat_ctx_t *hashcat_ctx); +double status_get_progress_finished_percent (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_done (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_rejected (const hashcat_ctx_t *hashcat_ctx); +double status_get_progress_rejected_percent (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_restored (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_cur (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_end (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_ignore (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_skip (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_cur_relative_skip (const hashcat_ctx_t *hashcat_ctx); +u64 status_get_progress_end_relative_skip (const hashcat_ctx_t *hashcat_ctx); +double status_get_hashes_msec_all (const hashcat_ctx_t *hashcat_ctx); +double status_get_hashes_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +double status_get_hashes_msec_dev_benchmark (const hashcat_ctx_t *hashcat_ctx, const int device_id); +double status_get_exec_msec_all (const hashcat_ctx_t *hashcat_ctx); +double status_get_exec_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +char *status_get_speed_sec_all (const hashcat_ctx_t *hashcat_ctx); +char *status_get_speed_sec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_cpt_cur_min (const hashcat_ctx_t *hashcat_ctx); +int status_get_cpt_cur_hour (const hashcat_ctx_t *hashcat_ctx); +int status_get_cpt_cur_day (const hashcat_ctx_t *hashcat_ctx); +int status_get_cpt_avg_min (const hashcat_ctx_t *hashcat_ctx); +int status_get_cpt_avg_hour (const hashcat_ctx_t *hashcat_ctx); +int status_get_cpt_avg_day (const hashcat_ctx_t *hashcat_ctx); +char *status_get_cpt (const hashcat_ctx_t *hashcat_ctx); +int status_get_salt_pos_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_innerloop_pos_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_innerloop_left_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_iteration_pos_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_iteration_left_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +char *status_get_hwmon_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_corespeed_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_memoryspeed_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +u64 status_get_progress_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +double status_get_runtime_msec_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_kernel_accel_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_kernel_loops_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_kernel_threads_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); +int status_get_vector_width_dev (const hashcat_ctx_t *hashcat_ctx, const int device_id); -int status_progress_init (hashcat_ctx_t *hashcat_ctx); -void status_progress_destroy (hashcat_ctx_t *hashcat_ctx); -void status_progress_reset (hashcat_ctx_t *hashcat_ctx); +int status_progress_init (hashcat_ctx_t *hashcat_ctx); +void status_progress_destroy (hashcat_ctx_t *hashcat_ctx); +void status_progress_reset (hashcat_ctx_t *hashcat_ctx); -int status_ctx_init (hashcat_ctx_t *hashcat_ctx); -void status_ctx_destroy (hashcat_ctx_t *hashcat_ctx); +int status_ctx_init (hashcat_ctx_t *hashcat_ctx); +void status_ctx_destroy (hashcat_ctx_t *hashcat_ctx); -void status_status_destroy (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *status_ctx); +void status_status_destroy (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *status_ctx); #endif // _STATUS_H diff --git a/include/types.h b/include/types.h index 6eed96c42..6992ddd96 100644 --- a/include/types.h +++ b/include/types.h @@ -529,8 +529,8 @@ typedef enum user_options_defaults { ADVICE_DISABLE = false, ATTACK_MODE = ATTACK_MODE_STRAIGHT, - BENCHMARK = false, BENCHMARK_ALL = false, + BENCHMARK = false, BITMAP_MAX = 24, BITMAP_MIN = 16, DEBUG_MODE = 0, @@ -566,13 +566,13 @@ typedef enum user_options_defaults OUTFILE_AUTOHEX = true, OUTFILE_CHECK_TIMER = 5, OUTFILE_FORMAT = 3, - WORDLIST_AUTOHEX_DISABLE = false, POTFILE_DISABLE = false, + PROGRESS_ONLY = false, QUIET = false, REMOVE = false, REMOVE_TIMER = 60, - RESTORE = false, RESTORE_DISABLE = false, + RESTORE = false, RESTORE_TIMER = 60, RP_GEN = 0, RP_GEN_FUNC_MAX = 4, @@ -580,19 +580,20 @@ typedef enum user_options_defaults RP_GEN_SEED = 0, RUNTIME = 0, SCRYPT_TMTO = 0, - SELF_TEST_DISABLE = false, SEGMENT_SIZE = 33554432, + SELF_TEST_DISABLE = false, SEPARATOR = ':', SHOW = false, SKIP = 0, + SLOW_CANDIDATES = false, + SPEED_ONLY = false, STATUS = false, STATUS_TIMER = 10, STDOUT_FLAG = false, - SPEED_ONLY = false, - PROGRESS_ONLY = false, USAGE = false, USERNAME = false, VERSION = false, + WORDLIST_AUTOHEX_DISABLE = false, WORKLOAD_PROFILE = 2, } user_options_defaults_t; @@ -601,94 +602,95 @@ typedef enum user_options_map { IDX_ADVICE_DISABLE = 0xff00, IDX_ATTACK_MODE = 'a', - IDX_BENCHMARK = 'b', IDX_BENCHMARK_ALL = 0xff01, + IDX_BENCHMARK = 'b', IDX_BITMAP_MAX = 0xff02, IDX_BITMAP_MIN = 0xff03, - IDX_CPU_AFFINITY = 0xff04, + IDX_CPU_AFFINITY = 0xff0a, IDX_CUSTOM_CHARSET_1 = '1', IDX_CUSTOM_CHARSET_2 = '2', IDX_CUSTOM_CHARSET_3 = '3', IDX_CUSTOM_CHARSET_4 = '4', - IDX_DEBUG_FILE = 0xff05, - IDX_DEBUG_MODE = 0xff06, - IDX_ENCODING_FROM = 0xff07, - IDX_ENCODING_TO = 0xff08, - IDX_EXAMPLE_HASHES = 0xff09, - IDX_FORCE = 0xff0a, - IDX_GPU_TEMP_ABORT = 0xff0b, - IDX_GPU_TEMP_DISABLE = 0xff0c, + IDX_DEBUG_FILE = 0xff0b, + IDX_DEBUG_MODE = 0xff0c, + IDX_ENCODING_FROM = 0xff0d, + IDX_ENCODING_TO = 0xff0e, + IDX_EXAMPLE_HASHES = 0xff0f, + IDX_FORCE = 0xff10, + IDX_GPU_TEMP_ABORT = 0xff11, + IDX_GPU_TEMP_DISABLE = 0xff12, IDX_HASH_MODE = 'm', - IDX_HCCAPX_MESSAGE_PAIR = 0xff0d, + IDX_HCCAPX_MESSAGE_PAIR = 0xff13, IDX_HELP = 'h', - IDX_HEX_CHARSET = 0xff0e, - IDX_HEX_SALT = 0xff0f, - IDX_HEX_WORDLIST = 0xff10, + IDX_HEX_CHARSET = 0xff14, + IDX_HEX_SALT = 0xff15, + IDX_HEX_WORDLIST = 0xff16, IDX_INCREMENT = 'i', - IDX_INCREMENT_MAX = 0xff11, - IDX_INCREMENT_MIN = 0xff12, - IDX_INDUCTION_DIR = 0xff13, - IDX_KEEP_GUESSING = 0xff14, + IDX_INCREMENT_MAX = 0xff17, + IDX_INCREMENT_MIN = 0xff18, + IDX_INDUCTION_DIR = 0xff19, + IDX_KEEP_GUESSING = 0xff1a, IDX_KERNEL_ACCEL = 'n', IDX_KERNEL_LOOPS = 'u', - IDX_KEYSPACE = 0xff15, - IDX_LEFT = 0xff16, + IDX_KEYSPACE = 0xff1b, + IDX_LEFT = 0xff1c, IDX_LIMIT = 'l', - IDX_LOGFILE_DISABLE = 0xff17, - IDX_LOOPBACK = 0xff18, - IDX_MACHINE_READABLE = 0xff19, - IDX_MARKOV_CLASSIC = 0xff1a, - IDX_MARKOV_DISABLE = 0xff1b, - IDX_MARKOV_HCSTAT2 = 0xff1c, + IDX_LOGFILE_DISABLE = 0xff1d, + IDX_LOOPBACK = 0xff1e, + IDX_MACHINE_READABLE = 0xff1f, + IDX_MARKOV_CLASSIC = 0xff20, + IDX_MARKOV_DISABLE = 0xff21, + IDX_MARKOV_HCSTAT2 = 0xff22, IDX_MARKOV_THRESHOLD = 't', - IDX_NONCE_ERROR_CORRECTIONS = 0xff1d, - IDX_NVIDIA_SPIN_DAMP = 0xff1e, + IDX_NONCE_ERROR_CORRECTIONS = 0xff23, + IDX_NVIDIA_SPIN_DAMP = 0xff24, IDX_OPENCL_DEVICES = 'd', IDX_OPENCL_DEVICE_TYPES = 'D', IDX_OPENCL_INFO = 'I', - IDX_OPENCL_PLATFORMS = 0xff1f, - IDX_OPENCL_VECTOR_WIDTH = 0xff20, + IDX_OPENCL_PLATFORMS = 0xff25, + IDX_OPENCL_VECTOR_WIDTH = 0xff26, IDX_OPTIMIZED_KERNEL_ENABLE = 'O', - IDX_OUTFILE_AUTOHEX_DISABLE = 0xff21, - IDX_OUTFILE_CHECK_DIR = 0xff22, - IDX_OUTFILE_CHECK_TIMER = 0xff23, - IDX_OUTFILE_FORMAT = 0xff24, + IDX_OUTFILE_AUTOHEX_DISABLE = 0xff27, + IDX_OUTFILE_CHECK_DIR = 0xff28, + IDX_OUTFILE_CHECK_TIMER = 0xff29, + IDX_OUTFILE_FORMAT = 0xff2a, IDX_OUTFILE = 'o', - IDX_WORDLIST_AUTOHEX_DISABLE = 0xff25, - IDX_POTFILE_DISABLE = 0xff26, - IDX_POTFILE_PATH = 0xff27, - IDX_QUIET = 0xff28, - IDX_REMOVE = 0xff29, - IDX_REMOVE_TIMER = 0xff2a, - IDX_RESTORE = 0xff2b, - IDX_RESTORE_DISABLE = 0xff2c, - IDX_RESTORE_FILE_PATH = 0xff2d, + IDX_POTFILE_DISABLE = 0xff2b, + IDX_POTFILE_PATH = 0xff2c, + IDX_PROGRESS_ONLY = 0xff2d, + IDX_QUIET = 0xff2e, + IDX_REMOVE = 0xff2f, + IDX_REMOVE_TIMER = 0xff30, + IDX_RESTORE = 0xff31, + IDX_RESTORE_DISABLE = 0xff32, + IDX_RESTORE_FILE_PATH = 0xff33, IDX_RP_FILE = 'r', - IDX_RP_GEN_FUNC_MAX = 0xff2e, - IDX_RP_GEN_FUNC_MIN = 0xff2f, + IDX_RP_GEN_FUNC_MAX = 0xff34, + IDX_RP_GEN_FUNC_MIN = 0xff35, IDX_RP_GEN = 'g', - IDX_RP_GEN_SEED = 0xff30, + IDX_RP_GEN_SEED = 0xff36, IDX_RULE_BUF_L = 'j', IDX_RULE_BUF_R = 'k', - IDX_RUNTIME = 0xff31, - IDX_SCRYPT_TMTO = 0xff32, - IDX_SELF_TEST_DISABLE = 0xff33, + IDX_RUNTIME = 0xff37, + IDX_SCRYPT_TMTO = 0xff38, IDX_SEGMENT_SIZE = 'c', + IDX_SELF_TEST_DISABLE = 0xff39, IDX_SEPARATOR = 'p', - IDX_SESSION = 0xff34, - IDX_SHOW = 0xff35, + IDX_SESSION = 0xff3a, + IDX_SHOW = 0xff3b, IDX_SKIP = 's', - IDX_STATUS = 0xff36, - IDX_STATUS_TIMER = 0xff37, - IDX_STDOUT_FLAG = 0xff38, - IDX_SPEED_ONLY = 0xff39, - IDX_PROGRESS_ONLY = 0xff3a, - IDX_TRUECRYPT_KEYFILES = 0xff3b, - IDX_USERNAME = 0xff3c, - IDX_VERACRYPT_KEYFILES = 0xff3d, - IDX_VERACRYPT_PIM = 0xff3e, + IDX_SLOW_CANDIDATES = 'S', + IDX_SPEED_ONLY = 0xff3c, + IDX_STATUS = 0xff3d, + IDX_STATUS_TIMER = 0xff3e, + IDX_STDOUT_FLAG = 0xff3f, + IDX_TRUECRYPT_KEYFILES = 0xff40, + IDX_USERNAME = 0xff41, + IDX_VERACRYPT_KEYFILES = 0xff42, + IDX_VERACRYPT_PIM = 0xff43, IDX_VERSION_LOWER = 'v', IDX_VERSION = 'V', + IDX_WORDLIST_AUTOHEX_DISABLE = 0xff44, IDX_WORKLOAD_PROFILE = 'w', } user_options_map_t; @@ -898,6 +900,18 @@ typedef struct pw } pw_t; +typedef struct pw_pre +{ + u32 pw_buf[64]; + u32 pw_len; + + u32 base_buf[64]; + u32 base_len; + + u32 rule_idx; + +} pw_pre_t; + typedef struct pw_idx { u32 off; @@ -1051,6 +1065,8 @@ typedef struct hc_device_param size_t size_pws_amp; size_t size_pws_comp; size_t size_pws_idx; + size_t size_pws_pre; + size_t size_pws_base; size_t size_tmps; size_t size_hooks; size_t size_bfs; @@ -1079,6 +1095,12 @@ typedef struct hc_device_param u32 *pws_comp; u64 pws_cnt; + pw_pre_t *pws_pre_buf; + u64 pws_pre_cnt; + + pw_pre_t *pws_base_buf; // for debug mode + u64 pws_base_cnt; + u64 words_off; u64 words_done; @@ -1596,20 +1618,20 @@ typedef struct user_options bool attack_mode_chgd; bool hash_mode_chgd; + bool hccapx_message_pair_chgd; bool increment_max_chgd; bool increment_min_chgd; bool kernel_accel_chgd; bool kernel_loops_chgd; + bool nonce_error_corrections_chgd; bool nvidia_spin_damp_chgd; bool opencl_vector_width_chgd; bool outfile_format_chgd; bool remove_timer_chgd; bool rp_gen_seed_chgd; bool runtime_chgd; - bool workload_profile_chgd; bool segment_size_chgd; - bool hccapx_message_pair_chgd; - bool nonce_error_corrections_chgd; + bool workload_profile_chgd; bool advice_disable; bool benchmark; @@ -1632,29 +1654,25 @@ typedef struct user_options bool opencl_info; bool optimized_kernel_enable; bool outfile_autohex; - bool wordlist_autohex_disable; bool potfile_disable; + bool progress_only; bool quiet; bool remove; bool restore; bool restore_disable; bool self_test_disable; bool show; + bool slow_candidates; + bool speed_only; bool status; bool stdout_flag; - bool speed_only; - bool progress_only; bool usage; bool username; bool version; + bool wordlist_autohex_disable; char *cpu_affinity; - const char *custom_charset_1; - const char *custom_charset_2; - const char *custom_charset_3; char *custom_charset_4; char *debug_file; - const char *encoding_from; - const char *encoding_to; char *induction_dir; char *markov_hcstat2; char *opencl_devices; @@ -1665,12 +1683,17 @@ typedef struct user_options char *potfile_path; char *restore_file_path; char **rp_files; - const char *rule_buf_l; - const char *rule_buf_r; char separator; - const char *session; char *truecrypt_keyfiles; char *veracrypt_keyfiles; + const char *custom_charset_1; + const char *custom_charset_2; + const char *custom_charset_3; + const char *encoding_from; + const char *encoding_to; + const char *rule_buf_l; + const char *rule_buf_r; + const char *session; u32 attack_mode; u32 bitmap_max; u32 bitmap_min; diff --git a/include/wordlist.h b/include/wordlist.h index 0c86d114c..8ee61ab88 100644 --- a/include/wordlist.h +++ b/include/wordlist.h @@ -11,7 +11,9 @@ size_t convert_from_hex (hashcat_ctx_t *hashcat_ctx, char *line_buf, const size_t line_len); -void pw_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len); +void pw_pre_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len, const u8 *base_buf, const int base_len, const int rule_idx); +void pw_base_add (hc_device_param_t *device_param, pw_pre_t *pw_pre); +void pw_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len); void get_next_word_lm (char *buf, u64 sz, u64 *len, u64 *off); void get_next_word_uc (char *buf, u64 sz, u64 *len, u64 *off); diff --git a/src/Makefile b/src/Makefile index d98e42c89..a023733c0 100644 --- a/src/Makefile +++ b/src/Makefile @@ -315,7 +315,7 @@ CFLAGS_CROSS_WIN64_LZMA := $(filter-out $(CFLAGS_REMOVE_LZMA),$(CFLAGS_CROSS_W ## Objects ## -OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md4 cpu_md5 cpu_sha1 cpu_sha256 debugfile dictstat dispatch dynloader event ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_sysfs ext_lzma filehandling folder hashcat hashes hlfmt hwmon induct interface locking logfile loopback memory monitor mpsp opencl outfile_check outfile pidfile potfile restore rp rp_cpu rp_kernel_on_cpu rp_kernel_on_cpu_optimized selftest shared status stdout straight terminal thread timer tuningdb usage user_options wordlist +OBJS_ALL := affinity autotune benchmark bitmap bitops combinator common convert cpt cpu_aes cpu_crc32 cpu_des cpu_md4 cpu_md5 cpu_sha1 cpu_sha256 debugfile dictstat dispatch dynloader event ext_ADL ext_nvapi ext_nvml ext_OpenCL ext_sysfs ext_lzma filehandling folder hashcat hashes hlfmt hwmon induct interface locking logfile loopback memory monitor mpsp opencl outfile_check outfile pidfile potfile restore rp rp_cpu rp_kernel_on_cpu rp_kernel_on_cpu_optimized selftest slow_candidates shared status stdout straight terminal thread timer tuningdb usage user_options wordlist NATIVE_STATIC_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.STATIC.o) NATIVE_SHARED_OBJS := $(foreach OBJ,$(OBJS_ALL),obj/$(OBJ).NATIVE.SHARED.o) diff --git a/src/autotune.c b/src/autotune.c index 04e212f89..2998ddd02 100644 --- a/src/autotune.c +++ b/src/autotune.c @@ -47,6 +47,7 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; const opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; const double target_msec = opencl_ctx->target_msec; @@ -103,13 +104,19 @@ static int autotune (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param if (CL_rc == -1) return -1; - if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + if (user_options->slow_candidates == true) + { + } + else { - if (straight_ctx->kernel_rules_cnt > 1) + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL); + if (straight_ctx->kernel_rules_cnt > 1) + { + CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, 0, 0, MIN (kernel_loops_max, KERNEL_RULES) * sizeof (kernel_rule_t), 0, NULL, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; + } } } diff --git a/src/combinator.c b/src/combinator.c index d9b50ba0d..e8be7fb7d 100644 --- a/src/combinator.c +++ b/src/combinator.c @@ -33,296 +33,302 @@ int combinator_ctx_init (hashcat_ctx_t *hashcat_ctx) combinator_ctx->enabled = true; - if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + if (user_options->slow_candidates == true) { - if (user_options->attack_mode == ATTACK_MODE_COMBI) + } + else + { + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) { - // display + if (user_options->attack_mode == ATTACK_MODE_COMBI) + { + // display - char *dictfile1 = user_options_extra->hc_workv[0]; - char *dictfile2 = user_options_extra->hc_workv[1]; + char *dictfile1 = user_options_extra->hc_workv[0]; + char *dictfile2 = user_options_extra->hc_workv[1]; - // at this point we know the file actually exist - // find the bigger dictionary and use as base + // at this point we know the file actually exist + // find the bigger dictionary and use as base - if (hc_path_is_file (dictfile1) == false) - { - event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile1); + if (hc_path_is_file (dictfile1) == false) + { + event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile1); - return -1; - } + return -1; + } - if (hc_path_is_file (dictfile2) == false) - { - event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile2); + if (hc_path_is_file (dictfile2) == false) + { + event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile2); - return -1; - } + return -1; + } - FILE *fp1 = NULL; - FILE *fp2 = NULL; + FILE *fp1 = NULL; + FILE *fp2 = NULL; - if ((fp1 = fopen (dictfile1, "rb")) == NULL) - { - event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno)); + if ((fp1 = fopen (dictfile1, "rb")) == NULL) + { + event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno)); - return -1; - } + return -1; + } - if ((fp2 = fopen (dictfile2, "rb")) == NULL) - { - event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno)); + if ((fp2 = fopen (dictfile2, "rb")) == NULL) + { + event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno)); - fclose (fp1); + fclose (fp1); - return -1; - } + return -1; + } - combinator_ctx->combs_cnt = 1; + combinator_ctx->combs_cnt = 1; - u64 words1_cnt = 0; + u64 words1_cnt = 0; - const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt); + const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt); - if (rc1 == -1) - { - event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1); + if (rc1 == -1) + { + event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1); - fclose (fp1); - fclose (fp2); + fclose (fp1); + fclose (fp2); - return -1; - } + return -1; + } - if (words1_cnt == 0) - { - event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); + if (words1_cnt == 0) + { + event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); - fclose (fp1); - fclose (fp2); + fclose (fp1); + fclose (fp2); - return -1; - } + return -1; + } - combinator_ctx->combs_cnt = 1; + combinator_ctx->combs_cnt = 1; - u64 words2_cnt = 0; + u64 words2_cnt = 0; - const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt); + const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt); - if (rc2 == -1) - { - event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile2); + if (rc2 == -1) + { + event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile2); - fclose (fp1); - fclose (fp2); + fclose (fp1); + fclose (fp2); - return -1; - } + return -1; + } - if (words2_cnt == 0) - { - event_log_error (hashcat_ctx, "%s: empty file.", dictfile2); + if (words2_cnt == 0) + { + event_log_error (hashcat_ctx, "%s: empty file.", dictfile2); + + fclose (fp1); + fclose (fp2); + + return -1; + } fclose (fp1); fclose (fp2); - return -1; - } + combinator_ctx->dict1 = dictfile1; + combinator_ctx->dict2 = dictfile2; - fclose (fp1); - fclose (fp2); + if (words1_cnt >= words2_cnt) + { + combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT; + combinator_ctx->combs_cnt = words2_cnt; + } + else + { + combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_RIGHT; + combinator_ctx->combs_cnt = words1_cnt; - combinator_ctx->dict1 = dictfile1; - combinator_ctx->dict2 = dictfile2; + // we also have to switch wordlist related rules! - if (words1_cnt >= words2_cnt) + const char *tmpc = user_options->rule_buf_l; + + user_options->rule_buf_l = user_options->rule_buf_r; + user_options->rule_buf_r = tmpc; + + u32 tmpi = user_options_extra->rule_len_l; + + user_options_extra->rule_len_l = user_options_extra->rule_len_r; + user_options_extra->rule_len_r = tmpi; + } + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT; - combinator_ctx->combs_cnt = words2_cnt; } - else + else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_RIGHT; - combinator_ctx->combs_cnt = words1_cnt; + } + } + else + { + // this is always need to be COMBINATOR_MODE_BASE_LEFT - // we also have to switch wordlist related rules! + if (user_options->attack_mode == ATTACK_MODE_COMBI) + { + // display - const char *tmpc = user_options->rule_buf_l; + char *dictfile1 = user_options_extra->hc_workv[0]; + char *dictfile2 = user_options_extra->hc_workv[1]; - user_options->rule_buf_l = user_options->rule_buf_r; - user_options->rule_buf_r = tmpc; + // at this point we know the file actually exist + // find the bigger dictionary and use as base - u32 tmpi = user_options_extra->rule_len_l; + if (hc_path_is_file (dictfile1) == false) + { + event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile1); - user_options_extra->rule_len_l = user_options_extra->rule_len_r; - user_options_extra->rule_len_r = tmpi; - } - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) - { - combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT; - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) - { - combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_RIGHT; - } - } - else - { - // this is always need to be COMBINATOR_MODE_BASE_LEFT + return -1; + } - if (user_options->attack_mode == ATTACK_MODE_COMBI) - { - // display + if (hc_path_is_file (dictfile2) == false) + { + event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile2); - char *dictfile1 = user_options_extra->hc_workv[0]; - char *dictfile2 = user_options_extra->hc_workv[1]; + return -1; + } - // at this point we know the file actually exist - // find the bigger dictionary and use as base + FILE *fp1 = NULL; + FILE *fp2 = NULL; - if (hc_path_is_file (dictfile1) == false) - { - event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile1); + if ((fp1 = fopen (dictfile1, "rb")) == NULL) + { + event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno)); - return -1; - } + return -1; + } - if (hc_path_is_file (dictfile2) == false) - { - event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile2); + if ((fp2 = fopen (dictfile2, "rb")) == NULL) + { + event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno)); - return -1; - } + fclose (fp1); - FILE *fp1 = NULL; - FILE *fp2 = NULL; + return -1; + } - if ((fp1 = fopen (dictfile1, "rb")) == NULL) - { - event_log_error (hashcat_ctx, "%s: %s", dictfile1, strerror (errno)); + combinator_ctx->combs_cnt = 1; - return -1; - } + u64 words1_cnt = 0; - if ((fp2 = fopen (dictfile2, "rb")) == NULL) - { - event_log_error (hashcat_ctx, "%s: %s", dictfile2, strerror (errno)); + const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt); - fclose (fp1); + if (rc1 == -1) + { + event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1); - return -1; - } + fclose (fp1); + fclose (fp2); - combinator_ctx->combs_cnt = 1; + return -1; + } - u64 words1_cnt = 0; + if (words1_cnt == 0) + { + event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); - const int rc1 = count_words (hashcat_ctx, fp1, dictfile1, &words1_cnt); + fclose (fp1); + fclose (fp2); - if (rc1 == -1) - { - event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile1); + return -1; + } - fclose (fp1); - fclose (fp2); + combinator_ctx->combs_cnt = 1; - return -1; - } + u64 words2_cnt = 0; - if (words1_cnt == 0) - { - event_log_error (hashcat_ctx, "%s: empty file.", dictfile1); + const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt); - fclose (fp1); - fclose (fp2); + if (rc2 == -1) + { + event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile2); - return -1; - } + fclose (fp1); + fclose (fp2); - combinator_ctx->combs_cnt = 1; + return -1; + } - u64 words2_cnt = 0; + if (words2_cnt == 0) + { + event_log_error (hashcat_ctx, "%s: empty file.", dictfile2); - const int rc2 = count_words (hashcat_ctx, fp2, dictfile2, &words2_cnt); + fclose (fp1); + fclose (fp2); - if (rc2 == -1) - { - event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile2); + return -1; + } fclose (fp1); fclose (fp2); - return -1; - } + combinator_ctx->dict1 = dictfile1; + combinator_ctx->dict2 = dictfile2; - if (words2_cnt == 0) + combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT; + combinator_ctx->combs_cnt = words2_cnt; + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { - event_log_error (hashcat_ctx, "%s: empty file.", dictfile2); - - fclose (fp1); - fclose (fp2); - - return -1; + combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT; } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) + { + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - fclose (fp1); - fclose (fp2); - - combinator_ctx->dict1 = dictfile1; - combinator_ctx->dict2 = dictfile2; + char *dictfile = user_options_extra->hc_workv[1]; - combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT; - combinator_ctx->combs_cnt = words2_cnt; - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) - { - combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT; - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) - { - mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + // at this point we know the file actually exist - char *dictfile = user_options_extra->hc_workv[1]; + if (hc_path_is_file (dictfile) == false) + { + event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile); - // at this point we know the file actually exist + return -1; + } - if (hc_path_is_file (dictfile) == false) - { - event_log_error (hashcat_ctx, "%s: Not a regular file.", dictfile); + FILE *fp = NULL; - return -1; - } + if ((fp = fopen (dictfile, "rb")) == NULL) + { + event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); - FILE *fp = NULL; + return -1; + } - if ((fp = fopen (dictfile, "rb")) == NULL) - { - event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); + mask_ctx->bfs_cnt = 1; - return -1; - } + u64 words_cnt = 0; - mask_ctx->bfs_cnt = 1; + const int rc = count_words (hashcat_ctx, fp, dictfile, &words_cnt); - u64 words_cnt = 0; + if (rc == -1) + { + event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile); - const int rc = count_words (hashcat_ctx, fp, dictfile, &words_cnt); + fclose (fp); - if (rc == -1) - { - event_log_error (hashcat_ctx, "Integer overflow detected in keyspace of wordlist: %s", dictfile); + return -1; + } fclose (fp); - return -1; + combinator_ctx->combs_cnt = words_cnt; + combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT; } - - fclose (fp); - - combinator_ctx->combs_cnt = words_cnt; - combinator_ctx->combs_mode = COMBINATOR_MODE_BASE_LEFT; } } diff --git a/src/dispatch.c b/src/dispatch.c index 5e69e34cf..10d624f0e 100644 --- a/src/dispatch.c +++ b/src/dispatch.c @@ -15,6 +15,7 @@ #include "filehandling.h" #include "rp.h" #include "rp_cpu.h" +#include "slow_candidates.h" #include "dispatch.h" static u64 get_lowest_words_done (const hashcat_ctx_t *hashcat_ctx) @@ -145,131 +146,298 @@ static int calc_stdin (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_par iconv_tmp = (char *) hcmalloc (HCBUFSIZ_TINY); } - while (status_ctx->run_thread_level1 == true) + if (user_options->slow_candidates == true) { - hc_thread_mutex_lock (status_ctx->mux_dispatcher); - - if (feof (stdin) != 0) + while (status_ctx->run_thread_level1 == true) { - hc_thread_mutex_unlock (status_ctx->mux_dispatcher); + hc_thread_mutex_lock (status_ctx->mux_dispatcher); - break; - } + if (feof (stdin) != 0) + { + hc_thread_mutex_unlock (status_ctx->mux_dispatcher); - u64 words_extra_total = 0; + break; + } - memset (device_param->pws_comp, 0, device_param->size_pws_comp); - memset (device_param->pws_idx, 0, device_param->size_pws_idx); + u64 words_extra_total = 0; - while (device_param->pws_cnt < device_param->kernel_power) - { - char *line_buf = fgets (buf, HCBUFSIZ_LARGE - 1, stdin); + memset (device_param->pws_comp, 0, device_param->size_pws_comp); + memset (device_param->pws_idx, 0, device_param->size_pws_idx); + memset (device_param->pws_pre_buf, 0, device_param->size_pws_pre); + memset (device_param->pws_base_buf, 0, device_param->size_pws_base); - if (line_buf == NULL) break; + device_param->pws_pre_cnt = 0; + device_param->pws_base_cnt = 0; - size_t line_len = in_superchop (line_buf); + while (device_param->pws_pre_cnt < device_param->kernel_power) + { + char *line_buf = fgets (buf, HCBUFSIZ_LARGE - 1, stdin); - line_len = convert_from_hex (hashcat_ctx, line_buf, (u32) line_len); + if (line_buf == NULL) break; - // do the on-the-fly encoding + size_t line_len = in_superchop (line_buf); - if (iconv_enabled == true) - { - char *iconv_ptr = iconv_tmp; - size_t iconv_sz = HCBUFSIZ_TINY; + line_len = convert_from_hex (hashcat_ctx, line_buf, (u32) line_len); + + // do the on-the-fly encoding + + if (iconv_enabled == true) + { + char *iconv_ptr = iconv_tmp; + size_t iconv_sz = HCBUFSIZ_TINY; + + const size_t iconv_rc = iconv (iconv_ctx, &line_buf, &line_len, &iconv_ptr, &iconv_sz); + + if (iconv_rc == (size_t) -1) continue; + + line_buf = iconv_tmp; + line_len = HCBUFSIZ_TINY - iconv_sz; + } + + // post-process rule engine + + char rule_buf_out[RP_PASSWORD_SIZE]; + + if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l)) + { + if (line_len >= RP_PASSWORD_SIZE) continue; + + memset (rule_buf_out, 0, sizeof (rule_buf_out)); + + const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out); + + if (rule_len_out < 0) continue; + + line_buf = rule_buf_out; + line_len = (size_t) rule_len_out; + } + + if (line_len >= PW_MAX) continue; + + // hmm that's always the case, or? + + const u32 attack_kern = user_options_extra->attack_kern; - const size_t iconv_rc = iconv (iconv_ctx, &line_buf, &line_len, &iconv_ptr, &iconv_sz); + if (attack_kern == ATTACK_KERN_STRAIGHT) + { + if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max)) + { + words_extra_total++; + + continue; + } + } - if (iconv_rc == (size_t) -1) continue; + pw_pre_add (device_param, (u8 *) line_buf, (int) line_len, NULL, 0, 0); - line_buf = iconv_tmp; - line_len = HCBUFSIZ_TINY - iconv_sz; + while (status_ctx->run_thread_level1 == false) break; } - // post-process rule engine + hc_thread_mutex_unlock (status_ctx->mux_dispatcher); - char rule_buf_out[RP_PASSWORD_SIZE]; + u64 pre_rejects = 0; - if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l)) + if (0) { - if (line_len >= RP_PASSWORD_SIZE) continue; - - memset (rule_buf_out, 0, sizeof (rule_buf_out)); + } + else + { + u64 pws_pre_cnt = device_param->pws_pre_cnt; - const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out); + for (u64 pws_pre_idx = 0; pws_pre_idx < pws_pre_cnt; pws_pre_idx++) + { + pw_pre_t *pw_pre = device_param->pws_pre_buf + pws_pre_idx; - if (rule_len_out < 0) continue; + pw_base_add (device_param, pw_pre); - line_buf = rule_buf_out; - line_len = (size_t) rule_len_out; + pw_add (device_param, (const u8 *) pw_pre->pw_buf, (const int) pw_pre->pw_len); + } } - if (line_len >= PW_MAX) continue; + words_extra_total += pre_rejects; + + if (words_extra_total > 0) + { + hc_thread_mutex_lock (status_ctx->mux_counter); + + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + { + status_ctx->words_progress_rejected[salt_pos] += words_extra_total * straight_ctx->kernel_rules_cnt; + } - // hmm that's always the case, or? + hc_thread_mutex_unlock (status_ctx->mux_counter); + } - const u32 attack_kern = user_options_extra->attack_kern; + if (status_ctx->run_thread_level1 == false) break; - if (attack_kern == ATTACK_KERN_STRAIGHT) + if (device_param->pws_cnt) { - if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max)) + // flush + + int CL_rc; + + CL_rc = run_copy (hashcat_ctx, device_param, device_param->pws_cnt); + + if (CL_rc == -1) { - words_extra_total++; + hcfree (buf); - continue; + return -1; } + + CL_rc = run_cracker (hashcat_ctx, device_param, device_param->pws_cnt); + + if (CL_rc == -1) + { + hcfree (buf); + + return -1; + } + + device_param->pws_cnt = 0; + + device_param->pws_base_cnt = 0; } - pw_add (device_param, (u8 *) line_buf, (int) line_len); + if (status_ctx->run_thread_level1 == false) break; - while (status_ctx->run_thread_level1 == false) break; + if (device_param->speed_only_finish == true) break; } + } + else + { + while (status_ctx->run_thread_level1 == true) + { + hc_thread_mutex_lock (status_ctx->mux_dispatcher); - hc_thread_mutex_unlock (status_ctx->mux_dispatcher); + if (feof (stdin) != 0) + { + hc_thread_mutex_unlock (status_ctx->mux_dispatcher); - if (words_extra_total > 0) - { - hc_thread_mutex_lock (status_ctx->mux_counter); + break; + } + + u64 words_extra_total = 0; - for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + memset (device_param->pws_comp, 0, device_param->size_pws_comp); + memset (device_param->pws_idx, 0, device_param->size_pws_idx); + + while (device_param->pws_cnt < device_param->kernel_power) { - status_ctx->words_progress_rejected[salt_pos] += words_extra_total * straight_ctx->kernel_rules_cnt; + char *line_buf = fgets (buf, HCBUFSIZ_LARGE - 1, stdin); + + if (line_buf == NULL) break; + + size_t line_len = in_superchop (line_buf); + + line_len = convert_from_hex (hashcat_ctx, line_buf, (u32) line_len); + + // do the on-the-fly encoding + + if (iconv_enabled == true) + { + char *iconv_ptr = iconv_tmp; + size_t iconv_sz = HCBUFSIZ_TINY; + + const size_t iconv_rc = iconv (iconv_ctx, &line_buf, &line_len, &iconv_ptr, &iconv_sz); + + if (iconv_rc == (size_t) -1) continue; + + line_buf = iconv_tmp; + line_len = HCBUFSIZ_TINY - iconv_sz; + } + + // post-process rule engine + + char rule_buf_out[RP_PASSWORD_SIZE]; + + if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l)) + { + if (line_len >= RP_PASSWORD_SIZE) continue; + + memset (rule_buf_out, 0, sizeof (rule_buf_out)); + + const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out); + + if (rule_len_out < 0) continue; + + line_buf = rule_buf_out; + line_len = (size_t) rule_len_out; + } + + if (line_len >= PW_MAX) continue; + + // hmm that's always the case, or? + + const u32 attack_kern = user_options_extra->attack_kern; + + if (attack_kern == ATTACK_KERN_STRAIGHT) + { + if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max)) + { + words_extra_total++; + + continue; + } + } + + pw_add (device_param, (const u8 *) line_buf, (const int) line_len); + + while (status_ctx->run_thread_level1 == false) break; } - hc_thread_mutex_unlock (status_ctx->mux_counter); - } + hc_thread_mutex_unlock (status_ctx->mux_dispatcher); - if (status_ctx->run_thread_level1 == false) break; + if (words_extra_total > 0) + { + hc_thread_mutex_lock (status_ctx->mux_counter); - if (device_param->pws_cnt == 0) break; + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + { + status_ctx->words_progress_rejected[salt_pos] += words_extra_total * straight_ctx->kernel_rules_cnt; + } - // flush + hc_thread_mutex_unlock (status_ctx->mux_counter); + } - int CL_rc; + if (status_ctx->run_thread_level1 == false) break; - CL_rc = run_copy (hashcat_ctx, device_param, device_param->pws_cnt); + if (device_param->pws_cnt == 0) break; - if (CL_rc == -1) - { - hcfree (buf); + // flush - return -1; - } + int CL_rc; - CL_rc = run_cracker (hashcat_ctx, device_param, device_param->pws_cnt); + CL_rc = run_copy (hashcat_ctx, device_param, device_param->pws_cnt); - if (CL_rc == -1) - { - hcfree (buf); + if (CL_rc == -1) + { + hcfree (buf); - return -1; - } + return -1; + } + + CL_rc = run_cracker (hashcat_ctx, device_param, device_param->pws_cnt); + + if (CL_rc == -1) + { + hcfree (buf); + + return -1; + } + + device_param->pws_cnt = 0; + + if (status_ctx->run_thread_level1 == false) break; - device_param->pws_cnt = 0; + if (device_param->speed_only_finish == true) break; + } - if (status_ctx->run_thread_level1 == false) break; + device_param->kernel_accel_prev = device_param->kernel_accel; + device_param->kernel_loops_prev = device_param->kernel_loops; - if (device_param->speed_only_finish == true) break; + device_param->kernel_accel = 0; + device_param->kernel_loops = 0; } device_param->kernel_accel_prev = device_param->kernel_accel; @@ -322,6 +490,7 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; @@ -329,318 +498,608 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) const u32 attack_mode = user_options->attack_mode; const u32 attack_kern = user_options_extra->attack_kern; - if ((attack_mode == ATTACK_MODE_BF) || (((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) && (attack_mode == ATTACK_MODE_HYBRID2))) + if (user_options->slow_candidates == true) { - if (((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) && (attack_mode == ATTACK_MODE_HYBRID2)) + // attack modes from here + + if (attack_mode == ATTACK_MODE_BF) { - char *dictfile = straight_ctx->dict; + extra_info_mask_t extra_info_mask; - FILE *combs_fp = fopen (dictfile, "rb"); + memset (&extra_info_mask, 0, sizeof (extra_info_mask)); - if (combs_fp == NULL) + extra_info_mask.out_len = mask_ctx->css_cnt; + + u64 words_cur = 0; + + while (status_ctx->run_thread_level1 == true) { - event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); + u64 words_fin = 0; - return -1; - } + memset (device_param->pws_comp, 0, device_param->size_pws_comp); + memset (device_param->pws_idx, 0, device_param->size_pws_idx); - device_param->combs_fp = combs_fp; - } + u64 pre_rejects = -1u; - while (status_ctx->run_thread_level1 == true) - { - const u64 work = get_work (hashcat_ctx, device_param, -1); + while (pre_rejects) + { + u64 words_extra_total = 0; - if (work == 0) break; + u64 words_extra = pre_rejects; - const u64 words_off = device_param->words_off; - const u64 words_fin = words_off + work; + pre_rejects = 0; - device_param->pws_cnt = work; + memset (device_param->pws_pre_buf, 0, device_param->size_pws_pre); - int CL_rc; + device_param->pws_pre_cnt = 0; - CL_rc = run_copy (hashcat_ctx, device_param, device_param->pws_cnt); + while (words_extra) + { + const u64 work = get_work (hashcat_ctx, device_param, words_extra); - if (CL_rc == -1) return -1; + if (work == 0) break; - CL_rc = run_cracker (hashcat_ctx, device_param, device_param->pws_cnt); + words_extra = 0; - if (CL_rc == -1) return -1; + u64 words_off = device_param->words_off; - device_param->pws_cnt = 0; + words_fin = words_off + work; - if (device_param->speed_only_finish == true) break; + words_cur = words_off; - if (status_ctx->run_thread_level2 == true) - { - device_param->words_done = words_fin; + for (u64 i = words_cur; i < words_fin; i++) + { + extra_info_mask.pos = i; - status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); - } + slow_candidates_next (hashcat_ctx, &extra_info_mask); - if (status_ctx->run_thread_level1 == false) break; - } - } - else - { - char *dictfile = straight_ctx->dict; + pw_pre_add (device_param, extra_info_mask.out_buf, extra_info_mask.out_len, NULL, 0, 0); - if (attack_mode == ATTACK_MODE_COMBI) - { - if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT) - { - dictfile = combinator_ctx->dict1; - } - else - { - dictfile = combinator_ctx->dict2; - } + if (status_ctx->run_thread_level1 == false) break; + } - const u32 combs_mode = combinator_ctx->combs_mode; + words_cur = words_fin; - if (combs_mode == COMBINATOR_MODE_BASE_LEFT) - { - const char *dictfilec = combinator_ctx->dict2; + words_extra_total += words_extra; - FILE *combs_fp = fopen (dictfilec, "rb"); + if (status_ctx->run_thread_level1 == false) break; + } - if (combs_fp == NULL) - { - event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno)); + if (0) + { + } + else + { + u64 pws_pre_cnt = device_param->pws_pre_cnt; - return -1; + for (u64 pws_pre_idx = 0; pws_pre_idx < pws_pre_cnt; pws_pre_idx++) + { + pw_pre_t *pw_pre = device_param->pws_pre_buf + pws_pre_idx; + + pw_add (device_param, (const u8 *) pw_pre->pw_buf, (const int) pw_pre->pw_len); + } + } + + words_extra_total += pre_rejects; + + if (status_ctx->run_thread_level1 == false) break; + + if (words_extra_total > 0) + { + hc_thread_mutex_lock (status_ctx->mux_counter); + + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + { + status_ctx->words_progress_rejected[salt_pos] += words_extra_total; + } + + hc_thread_mutex_unlock (status_ctx->mux_counter); + } } - device_param->combs_fp = combs_fp; - } - else if (combs_mode == COMBINATOR_MODE_BASE_RIGHT) - { - const char *dictfilec = combinator_ctx->dict1; + // + // flush + // - FILE *combs_fp = fopen (dictfilec, "rb"); + const u64 pws_cnt = device_param->pws_cnt; - if (combs_fp == NULL) + if (pws_cnt) { - event_log_error (hashcat_ctx, "%s: %s", dictfilec, strerror (errno)); + int CL_rc; - return -1; + CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) + { + return -1; + } + + CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) + { + return -1; + } + + device_param->pws_cnt = 0; } - device_param->combs_fp = combs_fp; - } - } + if (device_param->speed_only_finish == true) break; - FILE *fd = fopen (dictfile, "rb"); + if (status_ctx->run_thread_level2 == true) + { + device_param->words_done = words_fin; - if (fd == NULL) - { - event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); + status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + } - return -1; + if (status_ctx->run_thread_level1 == false) break; + + if (words_fin == 0) break; + } } - hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (sizeof (hashcat_ctx_t)); - - /* - hashcat_ctx_tmp->bitmap_ctx = hashcat_ctx->bitmap_ctx; - hashcat_ctx_tmp->combinator_ctx = hashcat_ctx->combinator_ctx; - hashcat_ctx_tmp->cpt_ctx = hashcat_ctx->cpt_ctx; - hashcat_ctx_tmp->debugfile_ctx = hashcat_ctx->debugfile_ctx; - hashcat_ctx_tmp->dictstat_ctx = hashcat_ctx->dictstat_ctx; - hashcat_ctx_tmp->folder_config = hashcat_ctx->folder_config; - hashcat_ctx_tmp->hashconfig = hashcat_ctx->hashconfig; - hashcat_ctx_tmp->hashes = hashcat_ctx->hashes; - hashcat_ctx_tmp->hwmon_ctx = hashcat_ctx->hwmon_ctx; - hashcat_ctx_tmp->induct_ctx = hashcat_ctx->induct_ctx; - hashcat_ctx_tmp->logfile_ctx = hashcat_ctx->logfile_ctx; - hashcat_ctx_tmp->loopback_ctx = hashcat_ctx->loopback_ctx; - hashcat_ctx_tmp->mask_ctx = hashcat_ctx->mask_ctx; - hashcat_ctx_tmp->opencl_ctx = hashcat_ctx->opencl_ctx; - hashcat_ctx_tmp->outcheck_ctx = hashcat_ctx->outcheck_ctx; - hashcat_ctx_tmp->outfile_ctx = hashcat_ctx->outfile_ctx; - hashcat_ctx_tmp->potfile_ctx = hashcat_ctx->potfile_ctx; - hashcat_ctx_tmp->restore_ctx = hashcat_ctx->restore_ctx; - hashcat_ctx_tmp->status_ctx = hashcat_ctx->status_ctx; - hashcat_ctx_tmp->straight_ctx = hashcat_ctx->straight_ctx; - hashcat_ctx_tmp->tuning_db = hashcat_ctx->tuning_db; - hashcat_ctx_tmp->user_options_extra = hashcat_ctx->user_options_extra; - hashcat_ctx_tmp->user_options = hashcat_ctx->user_options; - */ - - memcpy (hashcat_ctx_tmp, hashcat_ctx, sizeof (hashcat_ctx_t)); // yes we actually want to copy these pointers - - hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (sizeof (wl_data_t)); - - const int rc_wl_data_init = wl_data_init (hashcat_ctx_tmp); - - if (rc_wl_data_init == -1) + else if (attack_mode == ATTACK_MODE_STRAIGHT) { - if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); + char *dictfile = straight_ctx->dict; - fclose (fd); + FILE *fd = fopen (dictfile, "rb"); - hcfree (hashcat_ctx_tmp->wl_data); + if (fd == NULL) + { + event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); - hcfree (hashcat_ctx_tmp); + return -1; + } - return -1; - } + hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (sizeof (hashcat_ctx_t)); - u64 words_cur = 0; + memcpy (hashcat_ctx_tmp, hashcat_ctx, sizeof (hashcat_ctx_t)); // yes we actually want to copy these pointers - while (status_ctx->run_thread_level1 == true) - { - u64 words_off = 0; - u64 words_fin = 0; + hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (sizeof (wl_data_t)); - u64 words_extra = -1u; + const int rc_wl_data_init = wl_data_init (hashcat_ctx_tmp); - u64 words_extra_total = 0; + if (rc_wl_data_init == -1) + { + fclose (fd); - memset (device_param->pws_comp, 0, device_param->size_pws_comp); - memset (device_param->pws_idx, 0, device_param->size_pws_idx); + hcfree (hashcat_ctx_tmp->wl_data); - while (words_extra) - { - const u64 work = get_work (hashcat_ctx, device_param, words_extra); + hcfree (hashcat_ctx_tmp); - if (work == 0) break; + return -1; + } - words_extra = 0; + extra_info_straight_t extra_info_straight; - words_off = device_param->words_off; - words_fin = words_off + work; + memset (&extra_info_straight, 0, sizeof (extra_info_straight)); - char *line_buf; - u32 line_len; + extra_info_straight.fd = fd; - char rule_buf_out[RP_PASSWORD_SIZE]; + u64 words_cur = 0; + + while (status_ctx->run_thread_level1 == true) + { + u64 words_fin = 0; + + memset (device_param->pws_comp, 0, device_param->size_pws_comp); + memset (device_param->pws_idx, 0, device_param->size_pws_idx); + memset (device_param->pws_base_buf, 0, device_param->size_pws_base); - for ( ; words_cur < words_off; words_cur++) get_next_word (hashcat_ctx_tmp, fd, &line_buf, &line_len); + u64 pre_rejects = -1u; - for ( ; words_cur < words_fin; words_cur++) + while (pre_rejects) { - get_next_word (hashcat_ctx_tmp, fd, &line_buf, &line_len); + u64 words_extra_total = 0; + + u64 words_extra = pre_rejects; + + pre_rejects = 0; - line_len = (u32) convert_from_hex (hashcat_ctx, line_buf, line_len); + memset (device_param->pws_pre_buf, 0, device_param->size_pws_pre); - // post-process rule engine + device_param->pws_pre_cnt = 0; - if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l)) + while (words_extra) { - if (line_len >= RP_PASSWORD_SIZE) continue; + const u64 work = get_work (hashcat_ctx, device_param, words_extra); - memset (rule_buf_out, 0, sizeof (rule_buf_out)); + if (work == 0) break; - const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out); + words_extra = 0; - if (rule_len_out < 0) continue; + u64 words_off = device_param->words_off; - line_buf = rule_buf_out; - line_len = (u32) rule_len_out; + words_fin = words_off + work; + + slow_candidates_seek (hashcat_ctx_tmp, &extra_info_straight, words_cur, words_off); + + words_cur = words_off; + + for (u64 i = words_cur; i < words_fin; i++) + { + slow_candidates_next (hashcat_ctx_tmp, &extra_info_straight); + + if (attack_kern == ATTACK_KERN_STRAIGHT) + { + if ((extra_info_straight.out_len < hashconfig->pw_min) || (extra_info_straight.out_len > hashconfig->pw_max)) + { + words_extra++; + + continue; + } + } + else if (attack_kern == ATTACK_KERN_COMBI) + { + if ((extra_info_straight.out_len < hashconfig->pw_min) || (extra_info_straight.out_len > hashconfig->pw_max)) + { + words_extra++; + + continue; + } + } + + pw_pre_add (device_param, extra_info_straight.out_buf, extra_info_straight.out_len, extra_info_straight.base_buf, extra_info_straight.base_len, extra_info_straight.rule_pos_prev); + + if (status_ctx->run_thread_level1 == false) break; + } + + words_cur = words_fin; + + words_extra_total += words_extra; + + if (status_ctx->run_thread_level1 == false) break; } - if (attack_kern == ATTACK_KERN_STRAIGHT) + if (0) + { + } + else { - if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max)) + u64 pws_pre_cnt = device_param->pws_pre_cnt; + + for (u64 pws_pre_idx = 0; pws_pre_idx < pws_pre_cnt; pws_pre_idx++) { - words_extra++; + pw_pre_t *pw_pre = device_param->pws_pre_buf + pws_pre_idx; + + pw_base_add (device_param, pw_pre); - continue; + pw_add (device_param, (const u8 *) pw_pre->pw_buf, (const int) pw_pre->pw_len); } } - else if (attack_kern == ATTACK_KERN_COMBI) + + words_extra_total += pre_rejects; + + if (status_ctx->run_thread_level1 == false) break; + + if (words_extra_total > 0) { - // do not check if minimum restriction is satisfied (line_len >= hashconfig->pw_min) here - // since we still need to combine the plains + hc_thread_mutex_lock (status_ctx->mux_counter); - if (line_len > hashconfig->pw_max) + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) { - words_extra++; - - continue; + status_ctx->words_progress_rejected[salt_pos] += words_extra_total; } + + hc_thread_mutex_unlock (status_ctx->mux_counter); } + } - pw_add (device_param, (u8 *) line_buf, (int) line_len); + // + // flush + // - if (status_ctx->run_thread_level1 == false) break; + const u64 pws_cnt = device_param->pws_cnt; + + if (pws_cnt) + { + int CL_rc; + + CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) + { + fclose (fd); + + hcfree (hashcat_ctx_tmp->wl_data); + + hcfree (hashcat_ctx_tmp); + + return -1; + } + + CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) + { + fclose (fd); + + hcfree (hashcat_ctx_tmp->wl_data); + + hcfree (hashcat_ctx_tmp); + + return -1; + } + + device_param->pws_cnt = 0; + + device_param->pws_base_cnt = 0; } - words_extra_total += words_extra; + if (device_param->speed_only_finish == true) break; + + if (status_ctx->run_thread_level2 == true) + { + device_param->words_done = words_fin; + + status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + } if (status_ctx->run_thread_level1 == false) break; + + if (words_fin == 0) break; } - if (status_ctx->run_thread_level1 == false) break; + fclose (fd); - if (words_extra_total > 0) + wl_data_destroy (hashcat_ctx_tmp); + + hcfree (hashcat_ctx_tmp->wl_data); + + hcfree (hashcat_ctx_tmp); + } + } + else + { + if ((attack_mode == ATTACK_MODE_BF) || (((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) && (attack_mode == ATTACK_MODE_HYBRID2))) + { + if (((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) && (attack_mode == ATTACK_MODE_HYBRID2)) { - hc_thread_mutex_lock (status_ctx->mux_counter); + char *dictfile = straight_ctx->dict; - for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + FILE *combs_fp = fopen (dictfile, "rb"); + + if (combs_fp == NULL) { - if (attack_kern == ATTACK_KERN_STRAIGHT) + event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); + + return -1; + } + + device_param->combs_fp = combs_fp; + } + + while (status_ctx->run_thread_level1 == true) + { + const u64 work = get_work (hashcat_ctx, device_param, -1); + + if (work == 0) break; + + const u64 words_off = device_param->words_off; + const u64 words_fin = words_off + work; + + device_param->pws_cnt = work; + + int CL_rc; + + CL_rc = run_copy (hashcat_ctx, device_param, device_param->pws_cnt); + + if (CL_rc == -1) return -1; + + CL_rc = run_cracker (hashcat_ctx, device_param, device_param->pws_cnt); + + if (CL_rc == -1) return -1; + + device_param->pws_cnt = 0; + + if (device_param->speed_only_finish == true) break; + + if (status_ctx->run_thread_level2 == true) + { + device_param->words_done = words_fin; + + status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + } + } + } + else + { + char *dictfile = straight_ctx->dict; + + if (attack_mode == ATTACK_MODE_COMBI) + { + if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT) + { + dictfile = combinator_ctx->dict1; + } + else + { + dictfile = combinator_ctx->dict2; + } + + const u32 combs_mode = combinator_ctx->combs_mode; + + if (combs_mode == COMBINATOR_MODE_BASE_LEFT) + { + const char *dictfilec = combinator_ctx->dict2; + + FILE *combs_fp = fopen (dictfilec, "rb"); + + if (combs_fp == NULL) { - status_ctx->words_progress_rejected[salt_pos] += words_extra_total * straight_ctx->kernel_rules_cnt; + event_log_error (hashcat_ctx, "%s: %s", combinator_ctx->dict2, strerror (errno)); + + return -1; } - else if (attack_kern == ATTACK_KERN_COMBI) + + device_param->combs_fp = combs_fp; + } + else if (combs_mode == COMBINATOR_MODE_BASE_RIGHT) + { + const char *dictfilec = combinator_ctx->dict1; + + FILE *combs_fp = fopen (dictfilec, "rb"); + + if (combs_fp == NULL) { - status_ctx->words_progress_rejected[salt_pos] += words_extra_total * combinator_ctx->combs_cnt; + event_log_error (hashcat_ctx, "%s: %s", dictfilec, strerror (errno)); + + return -1; } + + device_param->combs_fp = combs_fp; } + } - hc_thread_mutex_unlock (status_ctx->mux_counter); + FILE *fd = fopen (dictfile, "rb"); + + if (fd == NULL) + { + event_log_error (hashcat_ctx, "%s: %s", dictfile, strerror (errno)); + + return -1; } - // - // flush - // + hashcat_ctx_t *hashcat_ctx_tmp = (hashcat_ctx_t *) hcmalloc (sizeof (hashcat_ctx_t)); + + memcpy (hashcat_ctx_tmp, hashcat_ctx, sizeof (hashcat_ctx_t)); // yes we actually want to copy these pointers - const u64 pws_cnt = device_param->pws_cnt; + hashcat_ctx_tmp->wl_data = (wl_data_t *) hcmalloc (sizeof (wl_data_t)); - if (pws_cnt) + const int rc_wl_data_init = wl_data_init (hashcat_ctx_tmp); + + if (rc_wl_data_init == -1) { - int CL_rc; + if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); - CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt); + fclose (fd); - if (CL_rc == -1) - { - if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); + hcfree (hashcat_ctx_tmp->wl_data); - fclose (fd); + hcfree (hashcat_ctx_tmp); - hcfree (hashcat_ctx_tmp->wl_data); + return -1; + } - hcfree (hashcat_ctx_tmp); + u64 words_cur = 0; - return -1; - } + while (status_ctx->run_thread_level1 == true) + { + u64 words_off = 0; + u64 words_fin = 0; - CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt); + u64 words_extra = -1u; - if (CL_rc == -1) + u64 words_extra_total = 0; + + memset (device_param->pws_comp, 0, device_param->size_pws_comp); + memset (device_param->pws_idx, 0, device_param->size_pws_idx); + + while (words_extra) { - if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); + const u64 work = get_work (hashcat_ctx, device_param, words_extra); - fclose (fd); + if (work == 0) break; - hcfree (hashcat_ctx_tmp->wl_data); + words_extra = 0; - hcfree (hashcat_ctx_tmp); + words_off = device_param->words_off; + words_fin = words_off + work; - return -1; + char *line_buf; + u32 line_len; + + char rule_buf_out[RP_PASSWORD_SIZE]; + + for ( ; words_cur < words_off; words_cur++) get_next_word (hashcat_ctx_tmp, fd, &line_buf, &line_len); + + for ( ; words_cur < words_fin; words_cur++) + { + get_next_word (hashcat_ctx_tmp, fd, &line_buf, &line_len); + + line_len = (u32) convert_from_hex (hashcat_ctx, line_buf, line_len); + + // post-process rule engine + + if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l)) + { + if (line_len >= RP_PASSWORD_SIZE) continue; + + memset (rule_buf_out, 0, sizeof (rule_buf_out)); + + const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out); + + if (rule_len_out < 0) continue; + + line_buf = rule_buf_out; + line_len = (u32) rule_len_out; + } + + if (attack_kern == ATTACK_KERN_STRAIGHT) + { + if ((line_len < hashconfig->pw_min) || (line_len > hashconfig->pw_max)) + { + words_extra++; + + continue; + } + } + else if (attack_kern == ATTACK_KERN_COMBI) + { + // do not check if minimum restriction is satisfied (line_len >= hashconfig->pw_min) here + // since we still need to combine the plains + + if (line_len > hashconfig->pw_max) + { + words_extra++; + + continue; + } + } + + pw_add (device_param, (const u8 *) line_buf, (const int) line_len); + + if (status_ctx->run_thread_level1 == false) break; + } + + words_extra_total += words_extra; + + if (status_ctx->run_thread_level1 == false) break; } - device_param->pws_cnt = 0; + if (status_ctx->run_thread_level1 == false) break; - /* - still required? - if (attack_kern == ATTACK_KERN_STRAIGHT) + if (words_extra_total > 0) { - CL_rc = run_kernel_bzero (device_param, device_param->d_rules_c, device_param->size_rules_c); + hc_thread_mutex_lock (status_ctx->mux_counter); + + for (u32 salt_pos = 0; salt_pos < hashes->salts_cnt; salt_pos++) + { + if (attack_kern == ATTACK_KERN_STRAIGHT) + { + status_ctx->words_progress_rejected[salt_pos] += words_extra_total * straight_ctx->kernel_rules_cnt; + } + else if (attack_kern == ATTACK_KERN_COMBI) + { + status_ctx->words_progress_rejected[salt_pos] += words_extra_total * combinator_ctx->combs_cnt; + } + } + + hc_thread_mutex_unlock (status_ctx->mux_counter); + } + + // + // flush + // + + const u64 pws_cnt = device_param->pws_cnt; + + if (pws_cnt) + { + int CL_rc; + + CL_rc = run_copy (hashcat_ctx, device_param, pws_cnt); if (CL_rc == -1) { @@ -654,10 +1113,8 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) return -1; } - } - else if (attack_kern == ATTACK_KERN_COMBI) - { - CL_rc = run_kernel_bzero (device_param, device_param->d_combs_c, device_param->size_combs); + + CL_rc = run_cracker (hashcat_ctx, device_param, pws_cnt); if (CL_rc == -1) { @@ -671,33 +1128,62 @@ static int calc (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param) return -1; } + + device_param->pws_cnt = 0; + + /* + still required? + if (attack_kern == ATTACK_KERN_STRAIGHT) + { + CL_rc = run_kernel_bzero (device_param, device_param->d_rules_c, device_param->size_rules_c); + if (CL_rc == -1) + { + if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); + fclose (fd); + hcfree (hashcat_ctx_tmp->wl_data); + hcfree (hashcat_ctx_tmp); + return -1; + } + } + else if (attack_kern == ATTACK_KERN_COMBI) + { + CL_rc = run_kernel_bzero (device_param, device_param->d_combs_c, device_param->size_combs); + if (CL_rc == -1) + { + if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); + fclose (fd); + hcfree (hashcat_ctx_tmp->wl_data); + hcfree (hashcat_ctx_tmp); + return -1; + } + } + */ } - */ - } - if (device_param->speed_only_finish == true) break; + if (device_param->speed_only_finish == true) break; - if (status_ctx->run_thread_level2 == true) - { - device_param->words_done = words_fin; + if (status_ctx->run_thread_level2 == true) + { + device_param->words_done = words_fin; - status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); - } + status_ctx->words_cur = get_lowest_words_done (hashcat_ctx); + } - if (status_ctx->run_thread_level1 == false) break; + if (status_ctx->run_thread_level1 == false) break; - if (words_fin == 0) break; - } + if (words_fin == 0) break; + } - if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); + if (attack_mode == ATTACK_MODE_COMBI) fclose (device_param->combs_fp); - fclose (fd); + fclose (fd); - wl_data_destroy (hashcat_ctx_tmp); + wl_data_destroy (hashcat_ctx_tmp); - hcfree (hashcat_ctx_tmp->wl_data); + hcfree (hashcat_ctx_tmp->wl_data); - hcfree (hashcat_ctx_tmp); + hcfree (hashcat_ctx_tmp); + } } device_param->kernel_accel_prev = device_param->kernel_accel; diff --git a/src/hashcat.c b/src/hashcat.c index 7b933d163..a7d1f29fa 100644 --- a/src/hashcat.c +++ b/src/hashcat.c @@ -1386,26 +1386,26 @@ int hashcat_get_status (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashcat_st { device_info_t *device_info = hashcat_status->device_info_buf + device_id; - device_info->skipped_dev = status_get_skipped_dev (hashcat_ctx, device_id); - device_info->hashes_msec_dev = status_get_hashes_msec_dev (hashcat_ctx, device_id); - device_info->hashes_msec_dev_benchmark = status_get_hashes_msec_dev_benchmark (hashcat_ctx, device_id); - device_info->exec_msec_dev = status_get_exec_msec_dev (hashcat_ctx, device_id); - device_info->speed_sec_dev = status_get_speed_sec_dev (hashcat_ctx, device_id); - device_info->guess_candidates_dev = status_get_guess_candidates_dev (hashcat_ctx, device_id); - device_info->hwmon_dev = status_get_hwmon_dev (hashcat_ctx, device_id); - device_info->corespeed_dev = status_get_corespeed_dev (hashcat_ctx, device_id); - device_info->memoryspeed_dev = status_get_memoryspeed_dev (hashcat_ctx, device_id); - device_info->progress_dev = status_get_progress_dev (hashcat_ctx, device_id); - device_info->runtime_msec_dev = status_get_runtime_msec_dev (hashcat_ctx, device_id); - device_info->kernel_accel_dev = status_get_kernel_accel_dev (hashcat_ctx, device_id); - device_info->kernel_loops_dev = status_get_kernel_loops_dev (hashcat_ctx, device_id); - device_info->kernel_threads_dev = status_get_kernel_threads_dev (hashcat_ctx, device_id); - device_info->vector_width_dev = status_get_vector_width_dev (hashcat_ctx, device_id); - device_info->salt_pos_dev = status_get_salt_pos_dev (hashcat_ctx, device_id); - device_info->innerloop_pos_dev = status_get_innerloop_pos_dev (hashcat_ctx, device_id); - device_info->innerloop_left_dev = status_get_innerloop_left_dev (hashcat_ctx, device_id); - device_info->iteration_pos_dev = status_get_iteration_pos_dev (hashcat_ctx, device_id); - device_info->iteration_left_dev = status_get_iteration_left_dev (hashcat_ctx, device_id); + device_info->skipped_dev = status_get_skipped_dev (hashcat_ctx, device_id); + device_info->hashes_msec_dev = status_get_hashes_msec_dev (hashcat_ctx, device_id); + device_info->hashes_msec_dev_benchmark = status_get_hashes_msec_dev_benchmark (hashcat_ctx, device_id); + device_info->exec_msec_dev = status_get_exec_msec_dev (hashcat_ctx, device_id); + device_info->speed_sec_dev = status_get_speed_sec_dev (hashcat_ctx, device_id); + device_info->guess_candidates_dev = status_get_guess_candidates_dev (hashcat_ctx, device_id); + device_info->hwmon_dev = status_get_hwmon_dev (hashcat_ctx, device_id); + device_info->corespeed_dev = status_get_corespeed_dev (hashcat_ctx, device_id); + device_info->memoryspeed_dev = status_get_memoryspeed_dev (hashcat_ctx, device_id); + device_info->progress_dev = status_get_progress_dev (hashcat_ctx, device_id); + device_info->runtime_msec_dev = status_get_runtime_msec_dev (hashcat_ctx, device_id); + device_info->kernel_accel_dev = status_get_kernel_accel_dev (hashcat_ctx, device_id); + device_info->kernel_loops_dev = status_get_kernel_loops_dev (hashcat_ctx, device_id); + device_info->kernel_threads_dev = status_get_kernel_threads_dev (hashcat_ctx, device_id); + device_info->vector_width_dev = status_get_vector_width_dev (hashcat_ctx, device_id); + device_info->salt_pos_dev = status_get_salt_pos_dev (hashcat_ctx, device_id); + device_info->innerloop_pos_dev = status_get_innerloop_pos_dev (hashcat_ctx, device_id); + device_info->innerloop_left_dev = status_get_innerloop_left_dev (hashcat_ctx, device_id); + device_info->iteration_pos_dev = status_get_iteration_pos_dev (hashcat_ctx, device_id); + device_info->iteration_left_dev = status_get_iteration_left_dev (hashcat_ctx, device_id); } hashcat_status->hashes_msec_all = status_get_hashes_msec_all (hashcat_ctx); diff --git a/src/induct.c b/src/induct.c index 675804986..42e39e11a 100644 --- a/src/induct.c +++ b/src/induct.c @@ -51,8 +51,7 @@ int induct_ctx_init (hashcat_ctx_t *hashcat_ctx) if (user_options->usage == true) return 0; if (user_options->version == true) return 0; - if (user_options->attack_mode == ATTACK_MODE_BF) return 0; - if (user_options->attack_mode == ATTACK_MODE_COMBI) return 0; + if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) return 0; induct_ctx->enabled = true; diff --git a/src/interface.c b/src/interface.c index c39d81448..d85ddd811 100644 --- a/src/interface.c +++ b/src/interface.c @@ -27322,11 +27322,11 @@ int hashconfig_init (hashcat_ctx_t *hashcat_ctx) char source_file[256] = { 0 }; - generate_source_kernel_filename (hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, false, folder_config->shared_dir, source_file); + generate_source_kernel_filename (user_options->slow_candidates, hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, false, folder_config->shared_dir, source_file); hashconfig->has_pure_kernel = hc_path_read (source_file); - generate_source_kernel_filename (hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, true, folder_config->shared_dir, source_file); + generate_source_kernel_filename (user_options->slow_candidates, hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, true, folder_config->shared_dir, source_file); hashconfig->has_optimized_kernel = hc_path_read (source_file); @@ -27730,14 +27730,30 @@ u32 hashconfig_get_kernel_loops (hashcat_ctx_t *hashcat_ctx) u32 kernel_loops_fixed = 0; - if (hashconfig->hash_mode == 1500 && user_options->attack_mode == ATTACK_MODE_BF) + if (user_options->slow_candidates == true) { - kernel_loops_fixed = 1024; } - - if (hashconfig->hash_mode == 3000 && user_options->attack_mode == ATTACK_MODE_BF) + else { - kernel_loops_fixed = 1024; + if (hashconfig->hash_mode == 1500 && user_options->attack_mode == ATTACK_MODE_BF) + { + kernel_loops_fixed = 1024; + } + + if (hashconfig->hash_mode == 3000 && user_options->attack_mode == ATTACK_MODE_BF) + { + kernel_loops_fixed = 1024; + } + + if (hashconfig->hash_mode == 14000 && user_options->attack_mode == ATTACK_MODE_BF) + { + kernel_loops_fixed = 1024; + } + + if (hashconfig->hash_mode == 14100 && user_options->attack_mode == ATTACK_MODE_BF) + { + kernel_loops_fixed = 1024; + } } if (hashconfig->hash_mode == 8900) @@ -27755,16 +27771,6 @@ u32 hashconfig_get_kernel_loops (hashcat_ctx_t *hashcat_ctx) kernel_loops_fixed = ROUNDS_RAR3 / 16; } - if (hashconfig->hash_mode == 14000 && user_options->attack_mode == ATTACK_MODE_BF) - { - kernel_loops_fixed = 1024; - } - - if (hashconfig->hash_mode == 14100 && user_options->attack_mode == ATTACK_MODE_BF) - { - kernel_loops_fixed = 1024; - } - if (hashconfig->hash_mode == 15700) { kernel_loops_fixed = 1; @@ -27828,17 +27834,11 @@ int hashconfig_get_pw_max (hashcat_ctx_t *hashcat_ctx, const bool optimized_kern if ((user_options->rp_files_cnt > 0) || (user_options->rp_gen > 0)) { - switch (user_options_extra->attack_kern) + if (user_options->slow_candidates == true) { - case ATTACK_KERN_STRAIGHT: pw_max = MIN (pw_max, PW_DICTMAX); - break; - case ATTACK_KERN_COMBI: pw_max = MIN (pw_max, PW_DICTMAX); - break; + pw_max = MIN (pw_max, PW_DICTMAX); } - } - else - { - if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + else { switch (user_options_extra->attack_kern) { @@ -27848,9 +27848,36 @@ int hashconfig_get_pw_max (hashcat_ctx_t *hashcat_ctx, const bool optimized_kern break; } } + } + else + { + if (user_options->slow_candidates == true) + { + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + { + pw_max = MIN (pw_max, PW_DICTMAX); + } + else + { + // If we have a NOOP rule then we can process words from wordlists > PW_DICTMAX for slow hashes + } + } else { - // If we have a NOOP rule then we can process words from wordlists > PW_DICTMAX for slow hashes + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + { + switch (user_options_extra->attack_kern) + { + case ATTACK_KERN_STRAIGHT: pw_max = MIN (pw_max, PW_DICTMAX); + break; + case ATTACK_KERN_COMBI: pw_max = MIN (pw_max, PW_DICTMAX); + break; + } + } + else + { + // If we have a NOOP rule then we can process words from wordlists > PW_DICTMAX for slow hashes + } } } diff --git a/src/mpsp.c b/src/mpsp.c index 991e78820..1a63fd1dc 100644 --- a/src/mpsp.c +++ b/src/mpsp.c @@ -37,64 +37,72 @@ static int sp_comp_val (const void *p1, const void *p2) static void mp_css_split_cnt (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_orig, u32 css_cnt_lr[2]) { - const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + const hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + const user_options_t *user_options = hashcat_ctx->user_options; u32 css_cnt_l = mask_ctx->css_cnt; u32 css_cnt_r; - if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + if (user_options->slow_candidates == true) { - if (css_cnt_orig < 6) - { - css_cnt_r = 1; - } - else if (css_cnt_orig == 6) - { - css_cnt_r = 2; - } - else + css_cnt_r = 0; + } + else + { + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - if ((hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE) || (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE)) + if (css_cnt_orig < 6) { - if (css_cnt_orig == 8 || css_cnt_orig == 10) - { - css_cnt_r = 2; - } - else - { - css_cnt_r = 4; - } + css_cnt_r = 1; + } + else if (css_cnt_orig == 6) + { + css_cnt_r = 2; } else { - if ((mask_ctx->css_buf[0].cs_len * mask_ctx->css_buf[1].cs_len * mask_ctx->css_buf[2].cs_len) > 256) + if ((hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE) || (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE)) { - css_cnt_r = 3; + if (css_cnt_orig == 8 || css_cnt_orig == 10) + { + css_cnt_r = 2; + } + else + { + css_cnt_r = 4; + } } else { - css_cnt_r = 4; + if ((mask_ctx->css_buf[0].cs_len * mask_ctx->css_buf[1].cs_len * mask_ctx->css_buf[2].cs_len) > 256) + { + css_cnt_r = 3; + } + else + { + css_cnt_r = 4; + } } } } - } - else - { - css_cnt_r = 1; + else + { + css_cnt_r = 1; - /* unfinished code? - int sum = css_buf[css_cnt_r - 1].cs_len; + /* unfinished code? + int sum = css_buf[css_cnt_r - 1].cs_len; - for (u32 i = 1; i < 4 && i < css_cnt; i++) - { - if (sum > 1) break; // we really don't need alot of amplifier them for slow hashes + for (u32 i = 1; i < 4 && i < css_cnt; i++) + { + if (sum > 1) break; // we really don't need alot of amplifier them for slow hashes - css_cnt_r++; + css_cnt_r++; - sum *= css_buf[css_cnt_r - 1].cs_len; + sum *= css_buf[css_cnt_r - 1].cs_len; + } + */ } - */ } css_cnt_l -= css_cnt_r; diff --git a/src/opencl.c b/src/opencl.c index 8e10a5f87..c8f618ae1 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -332,20 +332,27 @@ static int write_kernel_binary (hashcat_ctx_t *hashcat_ctx, char *kernel_file, c return 0; } -void generate_source_kernel_filename (const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *shared_dir, char *source_file) +void generate_source_kernel_filename (const bool slow_candidates, const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *shared_dir, char *source_file) { if (opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) { if (attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - if (attack_kern == ATTACK_KERN_STRAIGHT) - snprintf (source_file, 255, "%s/OpenCL/m%05d_a0-optimized.cl", shared_dir, (int) kern_type); - else if (attack_kern == ATTACK_KERN_COMBI) - snprintf (source_file, 255, "%s/OpenCL/m%05d_a1-optimized.cl", shared_dir, (int) kern_type); - else if (attack_kern == ATTACK_KERN_BF) - snprintf (source_file, 255, "%s/OpenCL/m%05d_a3-optimized.cl", shared_dir, (int) kern_type); - else if (attack_kern == ATTACK_KERN_NONE) + if (slow_candidates == true) + { snprintf (source_file, 255, "%s/OpenCL/m%05d_a0-optimized.cl", shared_dir, (int) kern_type); + } + else + { + if (attack_kern == ATTACK_KERN_STRAIGHT) + snprintf (source_file, 255, "%s/OpenCL/m%05d_a0-optimized.cl", shared_dir, (int) kern_type); + else if (attack_kern == ATTACK_KERN_COMBI) + snprintf (source_file, 255, "%s/OpenCL/m%05d_a1-optimized.cl", shared_dir, (int) kern_type); + else if (attack_kern == ATTACK_KERN_BF) + snprintf (source_file, 255, "%s/OpenCL/m%05d_a3-optimized.cl", shared_dir, (int) kern_type); + else if (attack_kern == ATTACK_KERN_NONE) + snprintf (source_file, 255, "%s/OpenCL/m%05d_a0-optimized.cl", shared_dir, (int) kern_type); + } } else { @@ -356,14 +363,21 @@ void generate_source_kernel_filename (const u32 attack_exec, const u32 attack_ke { if (attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - if (attack_kern == ATTACK_KERN_STRAIGHT) - snprintf (source_file, 255, "%s/OpenCL/m%05d_a0-pure.cl", shared_dir, (int) kern_type); - else if (attack_kern == ATTACK_KERN_COMBI) - snprintf (source_file, 255, "%s/OpenCL/m%05d_a1-pure.cl", shared_dir, (int) kern_type); - else if (attack_kern == ATTACK_KERN_BF) - snprintf (source_file, 255, "%s/OpenCL/m%05d_a3-pure.cl", shared_dir, (int) kern_type); - else if (attack_kern == ATTACK_KERN_NONE) + if (slow_candidates == true) + { snprintf (source_file, 255, "%s/OpenCL/m%05d_a0-pure.cl", shared_dir, (int) kern_type); + } + else + { + if (attack_kern == ATTACK_KERN_STRAIGHT) + snprintf (source_file, 255, "%s/OpenCL/m%05d_a0-pure.cl", shared_dir, (int) kern_type); + else if (attack_kern == ATTACK_KERN_COMBI) + snprintf (source_file, 255, "%s/OpenCL/m%05d_a1-pure.cl", shared_dir, (int) kern_type); + else if (attack_kern == ATTACK_KERN_BF) + snprintf (source_file, 255, "%s/OpenCL/m%05d_a3-pure.cl", shared_dir, (int) kern_type); + else if (attack_kern == ATTACK_KERN_NONE) + snprintf (source_file, 255, "%s/OpenCL/m%05d_a0-pure.cl", shared_dir, (int) kern_type); + } } else { @@ -372,20 +386,27 @@ void generate_source_kernel_filename (const u32 attack_exec, const u32 attack_ke } } -void generate_cached_kernel_filename (const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *profile_dir, const char *device_name_chksum, char *cached_file) +void generate_cached_kernel_filename (const bool slow_candidates, const u32 attack_exec, const u32 attack_kern, const u32 kern_type, const u32 opti_type, char *profile_dir, const char *device_name_chksum, char *cached_file) { if (opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) { if (attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - if (attack_kern == ATTACK_KERN_STRAIGHT) - snprintf (cached_file, 255, "%s/kernels/m%05d_a0-optimized.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); - else if (attack_kern == ATTACK_KERN_COMBI) - snprintf (cached_file, 255, "%s/kernels/m%05d_a1-optimized.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); - else if (attack_kern == ATTACK_KERN_BF) - snprintf (cached_file, 255, "%s/kernels/m%05d_a3-optimized.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); - else if (attack_kern == ATTACK_KERN_NONE) + if (slow_candidates == true) + { snprintf (cached_file, 255, "%s/kernels/m%05d_a0-optimized.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); + } + else + { + if (attack_kern == ATTACK_KERN_STRAIGHT) + snprintf (cached_file, 255, "%s/kernels/m%05d_a0-optimized.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); + else if (attack_kern == ATTACK_KERN_COMBI) + snprintf (cached_file, 255, "%s/kernels/m%05d_a1-optimized.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); + else if (attack_kern == ATTACK_KERN_BF) + snprintf (cached_file, 255, "%s/kernels/m%05d_a3-optimized.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); + else if (attack_kern == ATTACK_KERN_NONE) + snprintf (cached_file, 255, "%s/kernels/m%05d_a0-optimized.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); + } } else { @@ -396,14 +417,21 @@ void generate_cached_kernel_filename (const u32 attack_exec, const u32 attack_ke { if (attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - if (attack_kern == ATTACK_KERN_STRAIGHT) - snprintf (cached_file, 255, "%s/kernels/m%05d_a0-pure.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); - else if (attack_kern == ATTACK_KERN_COMBI) - snprintf (cached_file, 255, "%s/kernels/m%05d_a1-pure.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); - else if (attack_kern == ATTACK_KERN_BF) - snprintf (cached_file, 255, "%s/kernels/m%05d_a3-pure.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); - else if (attack_kern == ATTACK_KERN_NONE) + if (slow_candidates == true) + { snprintf (cached_file, 255, "%s/kernels/m%05d_a0-pure.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); + } + else + { + if (attack_kern == ATTACK_KERN_STRAIGHT) + snprintf (cached_file, 255, "%s/kernels/m%05d_a0-pure.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); + else if (attack_kern == ATTACK_KERN_COMBI) + snprintf (cached_file, 255, "%s/kernels/m%05d_a1-pure.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); + else if (attack_kern == ATTACK_KERN_BF) + snprintf (cached_file, 255, "%s/kernels/m%05d_a3-pure.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); + else if (attack_kern == ATTACK_KERN_NONE) + snprintf (cached_file, 255, "%s/kernels/m%05d_a0-pure.%s.kernel", profile_dir, (int) kern_type, device_name_chksum); + } } else { @@ -1193,21 +1221,27 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, { if (user_options->attack_mode == ATTACK_MODE_BF) { - if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) + if (user_options->slow_candidates == true) { - const u32 size_tm = 32 * sizeof (bs_word_t); + } + else + { + if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) + { + const u32 size_tm = 32 * sizeof (bs_word_t); - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_tm_c, size_tm); + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_tm_c, size_tm); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = run_kernel_tm (hashcat_ctx, device_param); + CL_rc = run_kernel_tm (hashcat_ctx, device_param); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_tm_c, device_param->d_bfs_c, 0, 0, size_tm, 0, NULL, NULL); + CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_tm_c, device_param->d_bfs_c, 0, 0, size_tm, 0, NULL, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; + } } } @@ -1251,9 +1285,15 @@ int choose_kernel (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, if (CL_rc == -1) return -1; - CL_rc = run_kernel_amp (hashcat_ctx, device_param, pws_cnt); + if (user_options->slow_candidates == true) + { + } + else + { + CL_rc = run_kernel_amp (hashcat_ctx, device_param, pws_cnt); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; + } CL_rc = run_kernel (hashcat_ctx, device_param, KERN_RUN_1, pws_cnt, false, 0); @@ -2053,7 +2093,7 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const } #endif - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + if (user_options->slow_candidates == true) { int CL_rc; @@ -2076,36 +2116,10 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const if (CL_rc == -1) return -1; } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + else { - if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) { - if (user_options->attack_mode == ATTACK_MODE_COMBI) - { - if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_RIGHT) - { - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) - { - rebuild_pws_compressed_append (device_param, pws_cnt, 0x01); - } - else if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) - { - rebuild_pws_compressed_append (device_param, pws_cnt, 0x80); - } - } - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) - { - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) - { - rebuild_pws_compressed_append (device_param, pws_cnt, 0x01); - } - else if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) - { - rebuild_pws_compressed_append (device_param, pws_cnt, 0x80); - } - } - int CL_rc; CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_idx, CL_TRUE, 0, pws_cnt * sizeof (pw_idx_t), device_param->pws_idx, 0, NULL, NULL); @@ -2127,10 +2141,36 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const if (CL_rc == -1) return -1; } - else + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { - if (user_options->attack_mode == ATTACK_MODE_COMBI) + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) { + if (user_options->attack_mode == ATTACK_MODE_COMBI) + { + if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_RIGHT) + { + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) + { + rebuild_pws_compressed_append (device_param, pws_cnt, 0x01); + } + else if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) + { + rebuild_pws_compressed_append (device_param, pws_cnt, 0x80); + } + } + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) + { + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) + { + rebuild_pws_compressed_append (device_param, pws_cnt, 0x01); + } + else if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) + { + rebuild_pws_compressed_append (device_param, pws_cnt, 0x80); + } + } + int CL_rc; CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_idx, CL_TRUE, 0, pws_cnt * sizeof (pw_idx_t), device_param->pws_idx, 0, NULL, NULL); @@ -2152,50 +2192,76 @@ int run_copy (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const if (CL_rc == -1) return -1; } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) + else { - int CL_rc; + if (user_options->attack_mode == ATTACK_MODE_COMBI) + { + int CL_rc; - CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_idx, CL_TRUE, 0, pws_cnt * sizeof (pw_idx_t), device_param->pws_idx, 0, NULL, NULL); + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_idx, CL_TRUE, 0, pws_cnt * sizeof (pw_idx_t), device_param->pws_idx, 0, NULL, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - const pw_idx_t *pw_idx = device_param->pws_idx + pws_cnt; + const pw_idx_t *pw_idx = device_param->pws_idx + pws_cnt; - const u32 off = pw_idx->off; + const u32 off = pw_idx->off; - if (off) - { - CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_comp_buf, CL_TRUE, 0, off * sizeof (u32), device_param->pws_comp, 0, NULL, NULL); + if (off) + { + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_comp_buf, CL_TRUE, 0, off * sizeof (u32), device_param->pws_comp, 0, NULL, NULL); + + if (CL_rc == -1) return -1; + } + + CL_rc = run_kernel_decompress (hashcat_ctx, device_param, pws_cnt); if (CL_rc == -1) return -1; } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) + { + int CL_rc; - CL_rc = run_kernel_decompress (hashcat_ctx, device_param, pws_cnt); + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_idx, CL_TRUE, 0, pws_cnt * sizeof (pw_idx_t), device_param->pws_idx, 0, NULL, NULL); - if (CL_rc == -1) return -1; - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) - { - const u64 off = device_param->words_off; + if (CL_rc == -1) return -1; - device_param->kernel_params_mp_buf64[3] = off; + const pw_idx_t *pw_idx = device_param->pws_idx + pws_cnt; - const int CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, pws_cnt); + const u32 off = pw_idx->off; - if (CL_rc == -1) return -1; + if (off) + { + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_comp_buf, CL_TRUE, 0, off * sizeof (u32), device_param->pws_comp, 0, NULL, NULL); + + if (CL_rc == -1) return -1; + } + + CL_rc = run_kernel_decompress (hashcat_ctx, device_param, pws_cnt); + + if (CL_rc == -1) return -1; + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) + { + const u64 off = device_param->words_off; + + device_param->kernel_params_mp_buf64[3] = off; + + const int CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, pws_cnt); + + if (CL_rc == -1) return -1; + } } } - } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) - { - const u64 off = device_param->words_off; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + const u64 off = device_param->words_off; - device_param->kernel_params_mp_l_buf64[3] = off; + device_param->kernel_params_mp_l_buf64[3] = off; - const int CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP_L, pws_cnt); + const int CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP_L, pws_cnt); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; + } } return 0; @@ -2216,16 +2282,30 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co u32 highest_pw_len = 0; - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) - { - } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + if (user_options->slow_candidates == true) { + /* + for (u64 pws_idx = 0; pws_idx < pws_cnt; pws_idx++) + { + pw_idx_t *pw_idx = device_param->pws_idx + pws_idx; + + highest_pw_len = MAX (highest_pw_len, pw_idx->len); + } + */ } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + else { - highest_pw_len = device_param->kernel_params_mp_l_buf32[4] - + device_param->kernel_params_mp_l_buf32[5]; + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + { + } + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + { + } + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + highest_pw_len = device_param->kernel_params_mp_l_buf32[4] + + device_param->kernel_params_mp_l_buf32[5]; + } } // we make use of this in status view @@ -2249,9 +2329,15 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co FILE *combs_fp = device_param->combs_fp; - if ((user_options->attack_mode == ATTACK_MODE_COMBI) || (((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) && (user_options->attack_mode == ATTACK_MODE_HYBRID2))) + if (user_options->slow_candidates == true) + { + } + else { - rewind (combs_fp); + if ((user_options->attack_mode == ATTACK_MODE_COMBI) || (((hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) == 0) && (user_options->attack_mode == ATTACK_MODE_HYBRID2))) + { + rewind (combs_fp); + } } // iteration type @@ -2259,12 +2345,20 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co u32 innerloop_step = 0; u32 innerloop_cnt = 0; - if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) innerloop_step = device_param->kernel_loops; - else innerloop_step = 1; + if (user_options->slow_candidates == true) + { + innerloop_step = 1; + innerloop_cnt = 1; + } + else + { + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) innerloop_step = device_param->kernel_loops; + else innerloop_step = 1; - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = (u32) straight_ctx->kernel_rules_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = (u32) combinator_ctx->combs_cnt; - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) innerloop_cnt = (u32) mask_ctx->bfs_cnt; + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = (u32) straight_ctx->kernel_rules_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = (u32) combinator_ctx->combs_cnt; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) innerloop_cnt = (u32) mask_ctx->bfs_cnt; + } // innerloops @@ -2303,250 +2397,256 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co // initialize and copy amplifiers - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + if (user_options->slow_candidates == true) { - const int CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, innerloop_pos * sizeof (kernel_rule_t), 0, innerloop_left * sizeof (kernel_rule_t), 0, NULL, NULL); - - if (CL_rc == -1) return -1; } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + else { - if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) { - if (user_options->attack_mode == ATTACK_MODE_COMBI) - { - char *line_buf = device_param->scratch_buf; - - u32 i = 0; + const int CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, device_param->d_rules_c, innerloop_pos * sizeof (kernel_rule_t), 0, innerloop_left * sizeof (kernel_rule_t), 0, NULL, NULL); - while (i < innerloop_left) + if (CL_rc == -1) return -1; + } + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + { + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + if (user_options->attack_mode == ATTACK_MODE_COMBI) { - if (feof (combs_fp)) break; + char *line_buf = device_param->scratch_buf; - size_t line_len = fgetl (combs_fp, line_buf); + u32 i = 0; - line_len = convert_from_hex (hashcat_ctx, line_buf, line_len); - - if (line_len >= PW_MAX) continue; + while (i < innerloop_left) + { + if (feof (combs_fp)) break; - char *line_buf_new = line_buf; + size_t line_len = fgetl (combs_fp, line_buf); - char rule_buf_out[RP_PASSWORD_SIZE]; + line_len = convert_from_hex (hashcat_ctx, line_buf, line_len); - if (run_rule_engine (user_options_extra->rule_len_r, user_options->rule_buf_r)) - { - if (line_len >= RP_PASSWORD_SIZE) continue; + if (line_len >= PW_MAX) continue; - memset (rule_buf_out, 0, sizeof (rule_buf_out)); + char *line_buf_new = line_buf; - const int rule_len_out = _old_apply_rule (user_options->rule_buf_r, user_options_extra->rule_len_r, line_buf, (u32) line_len, rule_buf_out); + char rule_buf_out[RP_PASSWORD_SIZE]; - if (rule_len_out < 0) + if (run_rule_engine (user_options_extra->rule_len_r, user_options->rule_buf_r)) { - status_ctx->words_progress_rejected[salt_pos] += pws_cnt; + if (line_len >= RP_PASSWORD_SIZE) continue; - continue; - } + memset (rule_buf_out, 0, sizeof (rule_buf_out)); - line_len = rule_len_out; + const int rule_len_out = _old_apply_rule (user_options->rule_buf_r, user_options_extra->rule_len_r, line_buf, (u32) line_len, rule_buf_out); - line_buf_new = rule_buf_out; - } + if (rule_len_out < 0) + { + status_ctx->words_progress_rejected[salt_pos] += pws_cnt; - line_len = MIN (line_len, PW_MAX - 1); + continue; + } - u8 *ptr = (u8 *) device_param->combs_buf[i].i; + line_len = rule_len_out; - memcpy (ptr, line_buf_new, line_len); + line_buf_new = rule_buf_out; + } - memset (ptr + line_len, 0, PW_MAX - line_len); + line_len = MIN (line_len, PW_MAX - 1); - if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) - { - uppercase (ptr, line_len); - } + u8 *ptr = (u8 *) device_param->combs_buf[i].i; - if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT) - { - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) + memcpy (ptr, line_buf_new, line_len); + + memset (ptr + line_len, 0, PW_MAX - line_len); + + if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) { - ptr[line_len] = 0x80; + uppercase (ptr, line_len); } - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) + if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT) { - ptr[line_len] = 0x01; + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) + { + ptr[line_len] = 0x80; + } + + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) + { + ptr[line_len] = 0x01; + } } - } - device_param->combs_buf[i].pw_len = (u32) line_len; + device_param->combs_buf[i].pw_len = (u32) line_len; - i++; - } + i++; + } - for (u32 j = i; j < innerloop_left; j++) - { - memset (&device_param->combs_buf[j], 0, sizeof (pw_t)); - } + for (u32 j = i; j < innerloop_left; j++) + { + memset (&device_param->combs_buf[j], 0, sizeof (pw_t)); + } - innerloop_left = i; + innerloop_left = i; - const int CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, innerloop_left * sizeof (pw_t), device_param->combs_buf, 0, NULL, NULL); + const int CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, innerloop_left * sizeof (pw_t), device_param->combs_buf, 0, NULL, NULL); - if (CL_rc == -1) return -1; - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) - { - u64 off = innerloop_pos; + if (CL_rc == -1) return -1; + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) + { + u64 off = innerloop_pos; - device_param->kernel_params_mp_buf64[3] = off; + device_param->kernel_params_mp_buf64[3] = off; - int CL_rc; + int CL_rc; - CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left); + CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (pw_t), 0, NULL, NULL); + CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (pw_t), 0, NULL, NULL); - if (CL_rc == -1) return -1; - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) - { - u64 off = innerloop_pos; + if (CL_rc == -1) return -1; + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) + { + u64 off = innerloop_pos; - device_param->kernel_params_mp_buf64[3] = off; + device_param->kernel_params_mp_buf64[3] = off; - int CL_rc; + int CL_rc; - CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left); + CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (pw_t), 0, NULL, NULL); + CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (pw_t), 0, NULL, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; + } } - } - else - { - if ((user_options->attack_mode == ATTACK_MODE_COMBI) || (user_options->attack_mode == ATTACK_MODE_HYBRID2)) + else { - char *line_buf = device_param->scratch_buf; - - u32 i = 0; - - while (i < innerloop_left) + if ((user_options->attack_mode == ATTACK_MODE_COMBI) || (user_options->attack_mode == ATTACK_MODE_HYBRID2)) { - if (feof (combs_fp)) break; + char *line_buf = device_param->scratch_buf; - size_t line_len = fgetl (combs_fp, line_buf); + u32 i = 0; - line_len = convert_from_hex (hashcat_ctx, line_buf, line_len); - - if (line_len >= PW_MAX) continue; + while (i < innerloop_left) + { + if (feof (combs_fp)) break; - char *line_buf_new = line_buf; + size_t line_len = fgetl (combs_fp, line_buf); - char rule_buf_out[RP_PASSWORD_SIZE]; + line_len = convert_from_hex (hashcat_ctx, line_buf, line_len); - if (run_rule_engine (user_options_extra->rule_len_r, user_options->rule_buf_r)) - { - if (line_len >= RP_PASSWORD_SIZE) continue; + if (line_len >= PW_MAX) continue; - memset (rule_buf_out, 0, sizeof (rule_buf_out)); + char *line_buf_new = line_buf; - const int rule_len_out = _old_apply_rule (user_options->rule_buf_r, user_options_extra->rule_len_r, line_buf, (u32) line_len, rule_buf_out); + char rule_buf_out[RP_PASSWORD_SIZE]; - if (rule_len_out < 0) + if (run_rule_engine (user_options_extra->rule_len_r, user_options->rule_buf_r)) { - status_ctx->words_progress_rejected[salt_pos] += pws_cnt; + if (line_len >= RP_PASSWORD_SIZE) continue; - continue; - } + memset (rule_buf_out, 0, sizeof (rule_buf_out)); - line_len = rule_len_out; + const int rule_len_out = _old_apply_rule (user_options->rule_buf_r, user_options_extra->rule_len_r, line_buf, (u32) line_len, rule_buf_out); - line_buf_new = rule_buf_out; - } + if (rule_len_out < 0) + { + status_ctx->words_progress_rejected[salt_pos] += pws_cnt; + + continue; + } - line_len = MIN (line_len, PW_MAX - 1); + line_len = rule_len_out; - u8 *ptr = (u8 *) device_param->combs_buf[i].i; + line_buf_new = rule_buf_out; + } - memcpy (ptr, line_buf_new, line_len); + line_len = MIN (line_len, PW_MAX - 1); - memset (ptr + line_len, 0, PW_MAX - line_len); + u8 *ptr = (u8 *) device_param->combs_buf[i].i; - if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) - { - uppercase (ptr, line_len); - } + memcpy (ptr, line_buf_new, line_len); - /* - if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT) - { - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) + memset (ptr + line_len, 0, PW_MAX - line_len); + + if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) { - ptr[line_len] = 0x80; + uppercase (ptr, line_len); } - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) + /* + if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT) { - ptr[line_len] = 0x01; + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) + { + ptr[line_len] = 0x80; + } + + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) + { + ptr[line_len] = 0x01; + } } - } - */ + */ - device_param->combs_buf[i].pw_len = (u32) line_len; + device_param->combs_buf[i].pw_len = (u32) line_len; - i++; - } + i++; + } - for (u32 j = i; j < innerloop_left; j++) - { - memset (&device_param->combs_buf[j], 0, sizeof (pw_t)); - } + for (u32 j = i; j < innerloop_left; j++) + { + memset (&device_param->combs_buf[j], 0, sizeof (pw_t)); + } - innerloop_left = i; + innerloop_left = i; - const int CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, innerloop_left * sizeof (pw_t), device_param->combs_buf, 0, NULL, NULL); + const int CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, innerloop_left * sizeof (pw_t), device_param->combs_buf, 0, NULL, NULL); - if (CL_rc == -1) return -1; - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) - { - u64 off = innerloop_pos; + if (CL_rc == -1) return -1; + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) + { + u64 off = innerloop_pos; - device_param->kernel_params_mp_buf64[3] = off; + device_param->kernel_params_mp_buf64[3] = off; - int CL_rc; + int CL_rc; - CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left); + CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP, innerloop_left); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (pw_t), 0, NULL, NULL); + CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs, device_param->d_combs_c, 0, 0, innerloop_left * sizeof (pw_t), 0, NULL, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; + } } } - } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) - { - u64 off = innerloop_pos; + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + u64 off = innerloop_pos; - device_param->kernel_params_mp_r_buf64[3] = off; + device_param->kernel_params_mp_r_buf64[3] = off; - int CL_rc; + int CL_rc; - CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP_R, innerloop_left); + CL_rc = run_kernel_mp (hashcat_ctx, device_param, KERN_RUN_MP_R, innerloop_left); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bfs, device_param->d_bfs_c, 0, 0, innerloop_left * sizeof (bf_t), 0, NULL, NULL); + CL_rc = hc_clEnqueueCopyBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bfs, device_param->d_bfs_c, 0, 0, innerloop_left * sizeof (bf_t), 0, NULL, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; + } } const int rc = choose_kernel (hashcat_ctx, device_param, highest_pw_len, pws_cnt, fast_iteration, salt_pos); @@ -3917,6 +4017,7 @@ void opencl_ctx_devices_kernel_loops (hashcat_ctx_t *hashcat_ctx) mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + user_options_t *user_options = hashcat_ctx->user_options; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; if (opencl_ctx->enabled == false) return; @@ -3936,9 +4037,16 @@ void opencl_ctx_devices_kernel_loops (hashcat_ctx_t *hashcat_ctx) if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = MIN (KERNEL_RULES, (u32) straight_ctx->kernel_rules_cnt); - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = MIN (KERNEL_COMBS, (u32) combinator_ctx->combs_cnt); - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) innerloop_cnt = MIN (KERNEL_BFS, (u32) mask_ctx->bfs_cnt); + if (user_options->slow_candidates == true) + { + innerloop_cnt = 1; + } + else + { + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) innerloop_cnt = MIN (KERNEL_RULES, (u32) straight_ctx->kernel_rules_cnt); + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) innerloop_cnt = MIN (KERNEL_COMBS, (u32) combinator_ctx->combs_cnt); + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) innerloop_cnt = MIN (KERNEL_BFS, (u32) mask_ctx->bfs_cnt); + } } else { @@ -4045,7 +4153,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { opencl_ctx->force_jit_compilation = 15700; } - else if (hashconfig->hash_mode == 1500 && user_options->attack_mode == ATTACK_MODE_BF && hashes->salts_cnt == 1) + else if (hashconfig->hash_mode == 1500 && user_options->attack_mode == ATTACK_MODE_BF && hashes->salts_cnt == 1 && user_options->slow_candidates == false) { opencl_ctx->force_jit_compilation = 1500; } @@ -4109,13 +4217,22 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) { // tuning db - tuning_db_entry_t *tuningdb_entry = tuning_db_search (hashcat_ctx, device_param->device_name, device_param->device_type, user_options->attack_mode, hashconfig->hash_mode); + tuning_db_entry_t *tuningdb_entry; - if (tuningdb_entry == NULL || tuningdb_entry->vector_width == -1) + if (user_options->slow_candidates == true) { - if (hashconfig->opti_type & OPTI_TYPE_USES_BITS_64) - { - CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, sizeof (vector_width), &vector_width, NULL); + tuningdb_entry = tuning_db_search (hashcat_ctx, device_param->device_name, device_param->device_type, 0, hashconfig->hash_mode); + } + else + { + tuningdb_entry = tuning_db_search (hashcat_ctx, device_param->device_name, device_param->device_type, user_options->attack_mode, hashconfig->hash_mode); + } + + if (tuningdb_entry == NULL || tuningdb_entry->vector_width == -1) + { + if (hashconfig->opti_type & OPTI_TYPE_USES_BITS_64) + { + CL_rc = hc_clGetDeviceInfo (hashcat_ctx, device_param->device, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, sizeof (vector_width), &vector_width, NULL); if (CL_rc == -1) return -1; } @@ -4162,7 +4279,16 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->kernel_loops_min = 1; device_param->kernel_loops_max = 1024; - tuning_db_entry_t *tuningdb_entry = tuning_db_search (hashcat_ctx, device_param->device_name, device_param->device_type, user_options->attack_mode, hashconfig->hash_mode); + tuning_db_entry_t *tuningdb_entry; + + if (user_options->slow_candidates == true) + { + tuningdb_entry = tuning_db_search (hashcat_ctx, device_param->device_name, device_param->device_type, 0, hashconfig->hash_mode); + } + else + { + tuningdb_entry = tuning_db_search (hashcat_ctx, device_param->device_name, device_param->device_type, user_options->attack_mode, hashconfig->hash_mode); + } if (tuningdb_entry != NULL) { @@ -4216,24 +4342,30 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->kernel_accel_max = MIN (device_param->kernel_accel_max, SCRYPT_MAX_ACCEL); } - // we have some absolute limits for fast hashes (because of limit constant memory), make sure not to overstep - - if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + if (user_options->slow_candidates == true) { - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) - { - device_param->kernel_loops_min = MIN (device_param->kernel_loops_min, KERNEL_RULES); - device_param->kernel_loops_max = MIN (device_param->kernel_loops_max, KERNEL_RULES); - } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) - { - device_param->kernel_loops_min = MIN (device_param->kernel_loops_min, KERNEL_COMBS); - device_param->kernel_loops_max = MIN (device_param->kernel_loops_max, KERNEL_COMBS); - } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + } + else + { + // we have some absolute limits for fast hashes (because of limit constant memory), make sure not to overstep + + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - device_param->kernel_loops_min = MIN (device_param->kernel_loops_min, KERNEL_BFS); - device_param->kernel_loops_max = MIN (device_param->kernel_loops_max, KERNEL_BFS); + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + { + device_param->kernel_loops_min = MIN (device_param->kernel_loops_min, KERNEL_RULES); + device_param->kernel_loops_max = MIN (device_param->kernel_loops_max, KERNEL_RULES); + } + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + { + device_param->kernel_loops_min = MIN (device_param->kernel_loops_min, KERNEL_COMBS); + device_param->kernel_loops_max = MIN (device_param->kernel_loops_max, KERNEL_COMBS); + } + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + device_param->kernel_loops_min = MIN (device_param->kernel_loops_min, KERNEL_BFS); + device_param->kernel_loops_max = MIN (device_param->kernel_loops_max, KERNEL_BFS); + } } } @@ -4700,7 +4832,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) char source_file[256] = { 0 }; - generate_source_kernel_filename (hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, hashconfig->opti_type, folder_config->shared_dir, source_file); + generate_source_kernel_filename (user_options->slow_candidates, hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, hashconfig->opti_type, folder_config->shared_dir, source_file); if (hc_path_read (source_file) == false) { @@ -4715,7 +4847,7 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) char cached_file[256] = { 0 }; - generate_cached_kernel_filename (hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, hashconfig->opti_type, folder_config->profile_dir, device_name_chksum, cached_file); + generate_cached_kernel_filename (user_options->slow_candidates, hashconfig->attack_exec, user_options_extra->attack_kern, hashconfig->kern_type, hashconfig->opti_type, folder_config->profile_dir, device_name_chksum, cached_file); bool cached = true; @@ -4897,278 +5029,290 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * word generator kernel */ - if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) + if (user_options->slow_candidates == true) { - /** - * kernel mp source filename - */ + } + else + { + if (user_options->attack_mode != ATTACK_MODE_STRAIGHT) + { + /** + * kernel mp source filename + */ - char source_file[256] = { 0 }; + char source_file[256] = { 0 }; - generate_source_kernel_mp_filename (hashconfig->opti_type, hashconfig->opts_type, folder_config->shared_dir, source_file); + generate_source_kernel_mp_filename (hashconfig->opti_type, hashconfig->opts_type, folder_config->shared_dir, source_file); - if (hc_path_read (source_file) == false) - { - event_log_error (hashcat_ctx, "%s: %s", source_file, strerror (errno)); + if (hc_path_read (source_file) == false) + { + event_log_error (hashcat_ctx, "%s: %s", source_file, strerror (errno)); - return -1; - } + return -1; + } - /** - * kernel mp cached filename - */ + /** + * kernel mp cached filename + */ - char cached_file[256] = { 0 }; + char cached_file[256] = { 0 }; - generate_cached_kernel_mp_filename (hashconfig->opti_type, hashconfig->opts_type, folder_config->profile_dir, device_name_chksum_amp_mp, cached_file); + generate_cached_kernel_mp_filename (hashconfig->opti_type, hashconfig->opts_type, folder_config->profile_dir, device_name_chksum_amp_mp, cached_file); - bool cached = true; + bool cached = true; - if (hc_path_read (cached_file) == false) - { - cached = false; - } + if (hc_path_read (cached_file) == false) + { + cached = false; + } - if (hc_path_is_empty (cached_file) == true) - { - cached = false; - } + if (hc_path_is_empty (cached_file) == true) + { + cached = false; + } - /** - * kernel compile or load - */ + /** + * kernel compile or load + */ - size_t kernel_lengths_buf = 0; + size_t kernel_lengths_buf = 0; - size_t *kernel_lengths = &kernel_lengths_buf; + size_t *kernel_lengths = &kernel_lengths_buf; - char *kernel_sources_buf = NULL; + char *kernel_sources_buf = NULL; - char **kernel_sources = &kernel_sources_buf; + char **kernel_sources = &kernel_sources_buf; - if (cached == false) - { - #if defined (DEBUG) - if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); - #endif + if (cached == false) + { + #if defined (DEBUG) + if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); + #endif - const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, kernel_lengths, kernel_sources, true); + const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, kernel_lengths, kernel_sources, true); - if (rc_read_kernel == -1) return -1; + if (rc_read_kernel == -1) return -1; - CL_rc = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, kernel_sources, NULL, &device_param->program_mp); + CL_rc = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, kernel_sources, NULL, &device_param->program_mp); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); + CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); - //if (CL_rc == -1) return -1; + //if (CL_rc == -1) return -1; - size_t build_log_size = 0; + size_t build_log_size = 0; - hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); + hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - //if (CL_rc == -1) return -1; + //if (CL_rc == -1) return -1; - #if defined (DEBUG) - if ((build_log_size > 1) || (CL_rc == -1)) - #else - if (CL_rc == -1) - #endif - { - char *build_log = (char *) hcmalloc (build_log_size + 1); + #if defined (DEBUG) + if ((build_log_size > 1) || (CL_rc == -1)) + #else + if (CL_rc == -1) + #endif + { + char *build_log = (char *) hcmalloc (build_log_size + 1); - int CL_rc_build = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + int CL_rc_build = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_mp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - if (CL_rc_build == -1) return -1; + if (CL_rc_build == -1) return -1; - puts (build_log); + puts (build_log); - hcfree (build_log); - } + hcfree (build_log); + } - if (CL_rc == -1) - { - device_param->skipped = true; + if (CL_rc == -1) + { + device_param->skipped = true; - event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed - proceeding without this device.", device_id + 1, source_file); + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed - proceeding without this device.", device_id + 1, source_file); - continue; - } + continue; + } - size_t binary_size; + size_t binary_size; - CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - char *binary = (char *) hcmalloc (binary_size); + char *binary = (char *) hcmalloc (binary_size); - CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_mp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); + write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); - hcfree (binary); - } - else - { - const int rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, kernel_lengths, kernel_sources, false); + hcfree (binary); + } + else + { + const int rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, kernel_lengths, kernel_sources, false); - if (rc_read_kernel == -1) return -1; + if (rc_read_kernel == -1) return -1; - CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (unsigned char **) kernel_sources, NULL, &device_param->program_mp); + CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (unsigned char **) kernel_sources, NULL, &device_param->program_mp); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); + CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program_mp, 1, &device_param->device, build_opts, NULL, NULL); - if (CL_rc == -1) return -1; - } + if (CL_rc == -1) return -1; + } - hcfree (kernel_sources[0]); + hcfree (kernel_sources[0]); + } } /** * amplifier kernel */ - if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + if (user_options->slow_candidates == true) { - } else { - /** - * kernel amp source filename - */ + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + { - char source_file[256] = { 0 }; + } + else + { + /** + * kernel amp source filename + */ - generate_source_kernel_amp_filename (user_options_extra->attack_kern, folder_config->shared_dir, source_file); + char source_file[256] = { 0 }; - if (hc_path_read (source_file) == false) - { - event_log_error (hashcat_ctx, "%s: %s", source_file, strerror (errno)); + generate_source_kernel_amp_filename (user_options_extra->attack_kern, folder_config->shared_dir, source_file); - return -1; - } + if (hc_path_read (source_file) == false) + { + event_log_error (hashcat_ctx, "%s: %s", source_file, strerror (errno)); - /** - * kernel amp cached filename - */ + return -1; + } - char cached_file[256] = { 0 }; + /** + * kernel amp cached filename + */ - generate_cached_kernel_amp_filename (user_options_extra->attack_kern, folder_config->profile_dir, device_name_chksum_amp_mp, cached_file); + char cached_file[256] = { 0 }; - bool cached = true; + generate_cached_kernel_amp_filename (user_options_extra->attack_kern, folder_config->profile_dir, device_name_chksum_amp_mp, cached_file); - if (hc_path_read (cached_file) == false) - { - cached = false; - } + bool cached = true; - if (hc_path_is_empty (cached_file) == true) - { - cached = false; - } + if (hc_path_read (cached_file) == false) + { + cached = false; + } - /** - * kernel compile or load - */ + if (hc_path_is_empty (cached_file) == true) + { + cached = false; + } - size_t kernel_lengths_buf = 0; + /** + * kernel compile or load + */ - size_t *kernel_lengths = &kernel_lengths_buf; + size_t kernel_lengths_buf = 0; - char *kernel_sources_buf = NULL; + size_t *kernel_lengths = &kernel_lengths_buf; - char **kernel_sources = &kernel_sources_buf; + char *kernel_sources_buf = NULL; - if (cached == false) - { - #if defined (DEBUG) - if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); - #endif + char **kernel_sources = &kernel_sources_buf; - const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, kernel_lengths, kernel_sources, true); + if (cached == false) + { + #if defined (DEBUG) + if (user_options->quiet == false) event_log_warning (hashcat_ctx, "* Device #%u: Kernel %s not found in cache! Building may take a while...", device_id + 1, filename_from_filepath (cached_file)); + #endif - if (rc_read_kernel == -1) return -1; + const int rc_read_kernel = read_kernel_binary (hashcat_ctx, source_file, kernel_lengths, kernel_sources, true); - CL_rc = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, kernel_sources, NULL, &device_param->program_amp); + if (rc_read_kernel == -1) return -1; - if (CL_rc == -1) return -1; + CL_rc = hc_clCreateProgramWithSource (hashcat_ctx, device_param->context, 1, kernel_sources, NULL, &device_param->program_amp); - CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); + if (CL_rc == -1) return -1; - //if (CL_rc == -1) return -1; + CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); - size_t build_log_size = 0; + //if (CL_rc == -1) return -1; - hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); + size_t build_log_size = 0; - //if (CL_rc == -1) return -1; + hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, 0, NULL, &build_log_size); - #if defined (DEBUG) - if ((build_log_size > 1) || (CL_rc == -1)) - #else - if (CL_rc == -1) - #endif - { - char *build_log = (char *) hcmalloc (build_log_size + 1); + //if (CL_rc == -1) return -1; - int CL_rc_build_info = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); + #if defined (DEBUG) + if ((build_log_size > 1) || (CL_rc == -1)) + #else + if (CL_rc == -1) + #endif + { + char *build_log = (char *) hcmalloc (build_log_size + 1); - if (CL_rc_build_info == -1) return -1; + int CL_rc_build_info = hc_clGetProgramBuildInfo (hashcat_ctx, device_param->program_amp, device_param->device, CL_PROGRAM_BUILD_LOG, build_log_size, build_log, NULL); - puts (build_log); + if (CL_rc_build_info == -1) return -1; - hcfree (build_log); - } + puts (build_log); - if (CL_rc == -1) - { - device_param->skipped = true; + hcfree (build_log); + } - event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed - proceeding without this device.", device_id + 1, source_file); + if (CL_rc == -1) + { + device_param->skipped = true; - continue; - } + event_log_error (hashcat_ctx, "* Device #%u: Kernel %s build failed - proceeding without this device.", device_id + 1, source_file); + + continue; + } - size_t binary_size; + size_t binary_size; - CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARY_SIZES, sizeof (size_t), &binary_size, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - char *binary = (char *) hcmalloc (binary_size); + char *binary = (char *) hcmalloc (binary_size); - CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); + CL_rc = hc_clGetProgramInfo (hashcat_ctx, device_param->program_amp, CL_PROGRAM_BINARIES, sizeof (char *), &binary, NULL); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); + write_kernel_binary (hashcat_ctx, cached_file, binary, binary_size); + + hcfree (binary); + } + else + { + const int rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, kernel_lengths, kernel_sources, false); - hcfree (binary); - } - else - { - const int rc_read_kernel = read_kernel_binary (hashcat_ctx, cached_file, kernel_lengths, kernel_sources, false); + if (rc_read_kernel == -1) return -1; - if (rc_read_kernel == -1) return -1; + CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (unsigned char **) kernel_sources, NULL, &device_param->program_amp); - CL_rc = hc_clCreateProgramWithBinary (hashcat_ctx, device_param->context, 1, &device_param->device, kernel_lengths, (unsigned char **) kernel_sources, NULL, &device_param->program_amp); + if (CL_rc == -1) return -1; - if (CL_rc == -1) return -1; + CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); - CL_rc = hc_clBuildProgram (hashcat_ctx, device_param->program_amp, 1, &device_param->device, build_opts, NULL, NULL); + if (CL_rc == -1) return -1; + } - if (CL_rc == -1) return -1; + hcfree (kernel_sources[0]); } - - hcfree (kernel_sources[0]); } hcfree (device_name_chksum); @@ -5223,27 +5367,34 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * special buffers */ - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + if (user_options->slow_candidates == true) { - CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_rules, NULL, &device_param->d_rules); if (CL_rc == -1) return -1; CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_rules_c, NULL, &device_param->d_rules_c); if (CL_rc == -1) return -1; - - CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, straight_ctx->kernel_rules_buf, 0, NULL, NULL); if (CL_rc == -1) return -1; } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) - { - CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs); if (CL_rc == -1) return -1; - CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs_c); if (CL_rc == -1) return -1; - CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL, &device_param->d_root_css_buf); if (CL_rc == -1) return -1; - CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL, &device_param->d_markov_css_buf); if (CL_rc == -1) return -1; - } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + else { - CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs); if (CL_rc == -1) return -1; - CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs_c); if (CL_rc == -1) return -1; - CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_tm, NULL, &device_param->d_tm_c); if (CL_rc == -1) return -1; - CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL, &device_param->d_root_css_buf); if (CL_rc == -1) return -1; - CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL, &device_param->d_markov_css_buf); if (CL_rc == -1) return -1; + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + { + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_rules, NULL, &device_param->d_rules); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_rules_c, NULL, &device_param->d_rules_c); if (CL_rc == -1) return -1; + + CL_rc = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_rules, CL_TRUE, 0, size_rules, straight_ctx->kernel_rules_buf, 0, NULL, NULL); if (CL_rc == -1) return -1; + } + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + { + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_combs, NULL, &device_param->d_combs_c); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL, &device_param->d_root_css_buf); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL, &device_param->d_markov_css_buf); if (CL_rc == -1) return -1; + } + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_bfs, NULL, &device_param->d_bfs_c); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_tm, NULL, &device_param->d_tm_c); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_root_css, NULL, &device_param->d_root_css_buf); if (CL_rc == -1) return -1; + CL_rc = hc_clCreateBuffer (hashcat_ctx, device_param->context, CL_MEM_READ_ONLY, size_markov_css, NULL, &device_param->d_markov_css_buf); if (CL_rc == -1) return -1; + } } if (size_esalts) @@ -5326,91 +5477,97 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->kernel_params[33] = &device_param->kernel_params_buf32[33]; device_param->kernel_params[34] = &device_param->kernel_params_buf64[34]; - device_param->kernel_params_mp_buf64[3] = 0; - device_param->kernel_params_mp_buf32[4] = 0; - device_param->kernel_params_mp_buf32[5] = 0; - device_param->kernel_params_mp_buf32[6] = 0; - device_param->kernel_params_mp_buf32[7] = 0; - device_param->kernel_params_mp_buf64[8] = 0; - - if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + if (user_options->slow_candidates == true) { - device_param->kernel_params_mp[0] = &device_param->d_combs; } else { - if (user_options->attack_mode == ATTACK_MODE_HYBRID1) + device_param->kernel_params_mp_buf64[3] = 0; + device_param->kernel_params_mp_buf32[4] = 0; + device_param->kernel_params_mp_buf32[5] = 0; + device_param->kernel_params_mp_buf32[6] = 0; + device_param->kernel_params_mp_buf32[7] = 0; + device_param->kernel_params_mp_buf64[8] = 0; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) { device_param->kernel_params_mp[0] = &device_param->d_combs; } else { - device_param->kernel_params_mp[0] = NULL; // (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) - // ? &device_param->d_pws_buf - // : &device_param->d_pws_amp_buf; + if (user_options->attack_mode == ATTACK_MODE_HYBRID1) + { + device_param->kernel_params_mp[0] = &device_param->d_combs; + } + else + { + device_param->kernel_params_mp[0] = NULL; // (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + // ? &device_param->d_pws_buf + // : &device_param->d_pws_amp_buf; + } } - } - device_param->kernel_params_mp[1] = &device_param->d_root_css_buf; - device_param->kernel_params_mp[2] = &device_param->d_markov_css_buf; - device_param->kernel_params_mp[3] = &device_param->kernel_params_mp_buf64[3]; - device_param->kernel_params_mp[4] = &device_param->kernel_params_mp_buf32[4]; - device_param->kernel_params_mp[5] = &device_param->kernel_params_mp_buf32[5]; - device_param->kernel_params_mp[6] = &device_param->kernel_params_mp_buf32[6]; - device_param->kernel_params_mp[7] = &device_param->kernel_params_mp_buf32[7]; - device_param->kernel_params_mp[8] = &device_param->kernel_params_mp_buf64[8]; - - device_param->kernel_params_mp_l_buf64[3] = 0; - device_param->kernel_params_mp_l_buf32[4] = 0; - device_param->kernel_params_mp_l_buf32[5] = 0; - device_param->kernel_params_mp_l_buf32[6] = 0; - device_param->kernel_params_mp_l_buf32[7] = 0; - device_param->kernel_params_mp_l_buf32[8] = 0; - device_param->kernel_params_mp_l_buf64[9] = 0; - - device_param->kernel_params_mp_l[0] = NULL; // (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) - // ? &device_param->d_pws_buf - // : &device_param->d_pws_amp_buf; - device_param->kernel_params_mp_l[1] = &device_param->d_root_css_buf; - device_param->kernel_params_mp_l[2] = &device_param->d_markov_css_buf; - device_param->kernel_params_mp_l[3] = &device_param->kernel_params_mp_l_buf64[3]; - device_param->kernel_params_mp_l[4] = &device_param->kernel_params_mp_l_buf32[4]; - device_param->kernel_params_mp_l[5] = &device_param->kernel_params_mp_l_buf32[5]; - device_param->kernel_params_mp_l[6] = &device_param->kernel_params_mp_l_buf32[6]; - device_param->kernel_params_mp_l[7] = &device_param->kernel_params_mp_l_buf32[7]; - device_param->kernel_params_mp_l[8] = &device_param->kernel_params_mp_l_buf32[8]; - device_param->kernel_params_mp_l[9] = &device_param->kernel_params_mp_l_buf64[9]; + device_param->kernel_params_mp[1] = &device_param->d_root_css_buf; + device_param->kernel_params_mp[2] = &device_param->d_markov_css_buf; + device_param->kernel_params_mp[3] = &device_param->kernel_params_mp_buf64[3]; + device_param->kernel_params_mp[4] = &device_param->kernel_params_mp_buf32[4]; + device_param->kernel_params_mp[5] = &device_param->kernel_params_mp_buf32[5]; + device_param->kernel_params_mp[6] = &device_param->kernel_params_mp_buf32[6]; + device_param->kernel_params_mp[7] = &device_param->kernel_params_mp_buf32[7]; + device_param->kernel_params_mp[8] = &device_param->kernel_params_mp_buf64[8]; + + device_param->kernel_params_mp_l_buf64[3] = 0; + device_param->kernel_params_mp_l_buf32[4] = 0; + device_param->kernel_params_mp_l_buf32[5] = 0; + device_param->kernel_params_mp_l_buf32[6] = 0; + device_param->kernel_params_mp_l_buf32[7] = 0; + device_param->kernel_params_mp_l_buf32[8] = 0; + device_param->kernel_params_mp_l_buf64[9] = 0; - device_param->kernel_params_mp_r_buf64[3] = 0; - device_param->kernel_params_mp_r_buf32[4] = 0; - device_param->kernel_params_mp_r_buf32[5] = 0; - device_param->kernel_params_mp_r_buf32[6] = 0; - device_param->kernel_params_mp_r_buf32[7] = 0; - device_param->kernel_params_mp_r_buf64[8] = 0; - - device_param->kernel_params_mp_r[0] = &device_param->d_bfs; - device_param->kernel_params_mp_r[1] = &device_param->d_root_css_buf; - device_param->kernel_params_mp_r[2] = &device_param->d_markov_css_buf; - device_param->kernel_params_mp_r[3] = &device_param->kernel_params_mp_r_buf64[3]; - device_param->kernel_params_mp_r[4] = &device_param->kernel_params_mp_r_buf32[4]; - device_param->kernel_params_mp_r[5] = &device_param->kernel_params_mp_r_buf32[5]; - device_param->kernel_params_mp_r[6] = &device_param->kernel_params_mp_r_buf32[6]; - device_param->kernel_params_mp_r[7] = &device_param->kernel_params_mp_r_buf32[7]; - device_param->kernel_params_mp_r[8] = &device_param->kernel_params_mp_r_buf64[8]; - - device_param->kernel_params_amp_buf32[5] = 0; // combs_mode - device_param->kernel_params_amp_buf64[6] = 0; // gid_max - - device_param->kernel_params_amp[0] = NULL; // &device_param->d_pws_buf; - device_param->kernel_params_amp[1] = NULL; // &device_param->d_pws_amp_buf; - device_param->kernel_params_amp[2] = &device_param->d_rules_c; - device_param->kernel_params_amp[3] = &device_param->d_combs_c; - device_param->kernel_params_amp[4] = &device_param->d_bfs_c; - device_param->kernel_params_amp[5] = &device_param->kernel_params_amp_buf32[5]; - device_param->kernel_params_amp[6] = &device_param->kernel_params_amp_buf64[6]; - - device_param->kernel_params_tm[0] = &device_param->d_bfs_c; - device_param->kernel_params_tm[1] = &device_param->d_tm_c; + device_param->kernel_params_mp_l[0] = NULL; // (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + // ? &device_param->d_pws_buf + // : &device_param->d_pws_amp_buf; + device_param->kernel_params_mp_l[1] = &device_param->d_root_css_buf; + device_param->kernel_params_mp_l[2] = &device_param->d_markov_css_buf; + device_param->kernel_params_mp_l[3] = &device_param->kernel_params_mp_l_buf64[3]; + device_param->kernel_params_mp_l[4] = &device_param->kernel_params_mp_l_buf32[4]; + device_param->kernel_params_mp_l[5] = &device_param->kernel_params_mp_l_buf32[5]; + device_param->kernel_params_mp_l[6] = &device_param->kernel_params_mp_l_buf32[6]; + device_param->kernel_params_mp_l[7] = &device_param->kernel_params_mp_l_buf32[7]; + device_param->kernel_params_mp_l[8] = &device_param->kernel_params_mp_l_buf32[8]; + device_param->kernel_params_mp_l[9] = &device_param->kernel_params_mp_l_buf64[9]; + + device_param->kernel_params_mp_r_buf64[3] = 0; + device_param->kernel_params_mp_r_buf32[4] = 0; + device_param->kernel_params_mp_r_buf32[5] = 0; + device_param->kernel_params_mp_r_buf32[6] = 0; + device_param->kernel_params_mp_r_buf32[7] = 0; + device_param->kernel_params_mp_r_buf64[8] = 0; + + device_param->kernel_params_mp_r[0] = &device_param->d_bfs; + device_param->kernel_params_mp_r[1] = &device_param->d_root_css_buf; + device_param->kernel_params_mp_r[2] = &device_param->d_markov_css_buf; + device_param->kernel_params_mp_r[3] = &device_param->kernel_params_mp_r_buf64[3]; + device_param->kernel_params_mp_r[4] = &device_param->kernel_params_mp_r_buf32[4]; + device_param->kernel_params_mp_r[5] = &device_param->kernel_params_mp_r_buf32[5]; + device_param->kernel_params_mp_r[6] = &device_param->kernel_params_mp_r_buf32[6]; + device_param->kernel_params_mp_r[7] = &device_param->kernel_params_mp_r_buf32[7]; + device_param->kernel_params_mp_r[8] = &device_param->kernel_params_mp_r_buf64[8]; + + device_param->kernel_params_amp_buf32[5] = 0; // combs_mode + device_param->kernel_params_amp_buf64[6] = 0; // gid_max + + device_param->kernel_params_amp[0] = NULL; // &device_param->d_pws_buf; + device_param->kernel_params_amp[1] = NULL; // &device_param->d_pws_amp_buf; + device_param->kernel_params_amp[2] = &device_param->d_rules_c; + device_param->kernel_params_amp[3] = &device_param->d_combs_c; + device_param->kernel_params_amp[4] = &device_param->d_bfs_c; + device_param->kernel_params_amp[5] = &device_param->kernel_params_amp_buf32[5]; + device_param->kernel_params_amp[6] = &device_param->kernel_params_amp_buf64[6]; + + device_param->kernel_params_tm[0] = &device_param->d_bfs_c; + device_param->kernel_params_tm[1] = &device_param->d_tm_c; + } device_param->kernel_params_memset_buf32[1] = 0; // value device_param->kernel_params_memset_buf64[2] = 0; // gid_max @@ -5612,27 +5769,33 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) } } - if (user_options->attack_mode == ATTACK_MODE_BF) + if (user_options->slow_candidates == true) { - if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) + } + else + { + if (user_options->attack_mode == ATTACK_MODE_BF) { - snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_tm", hashconfig->kern_type); + if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) + { + snprintf (kernel_name, sizeof (kernel_name) - 1, "m%05u_tm", hashconfig->kern_type); - CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_tm); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program, kernel_name, &device_param->kernel_tm); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_tm, &device_param->kernel_wgs_tm); + CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_tm, &device_param->kernel_wgs_tm); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_tm, &device_param->kernel_local_mem_size_tm); + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_tm, &device_param->kernel_local_mem_size_tm); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_tm, &device_param->kernel_preferred_wgs_multiple_tm); + CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_tm, &device_param->kernel_preferred_wgs_multiple_tm); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; + } } } } @@ -5951,135 +6114,147 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) // MP start - if (user_options->attack_mode == ATTACK_MODE_BF) + if (user_options->slow_candidates == true) + { + } + else { - // mp_l + if (user_options->attack_mode == ATTACK_MODE_BF) + { + // mp_l - CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "l_markov", &device_param->kernel_mp_l); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "l_markov", &device_param->kernel_mp_l); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_mp_l, &device_param->kernel_wgs_mp_l); + CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_mp_l, &device_param->kernel_wgs_mp_l); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_mp_l, &device_param->kernel_local_mem_size_mp_l); + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_mp_l, &device_param->kernel_local_mem_size_mp_l); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_mp_l, &device_param->kernel_preferred_wgs_multiple_mp_l); + CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_mp_l, &device_param->kernel_preferred_wgs_multiple_mp_l); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - // mp_r + // mp_r - CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "r_markov", &device_param->kernel_mp_r); + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "r_markov", &device_param->kernel_mp_r); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_mp_r, &device_param->kernel_wgs_mp_r); + CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_mp_r, &device_param->kernel_wgs_mp_r); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_mp_r, &device_param->kernel_local_mem_size_mp_r); + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_mp_r, &device_param->kernel_local_mem_size_mp_r); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_mp_r, &device_param->kernel_preferred_wgs_multiple_mp_r); + CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_mp_r, &device_param->kernel_preferred_wgs_multiple_mp_r); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) - { - CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]); if (CL_rc == -1) return -1; - CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]); if (CL_rc == -1) return -1; + if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) + { + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_tm, 0, sizeof (cl_mem), device_param->kernel_params_tm[0]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_tm, 1, sizeof (cl_mem), device_param->kernel_params_tm[1]); if (CL_rc == -1) return -1; + } } - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) - { - CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "C_markov", &device_param->kernel_mp); + else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) + { + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "C_markov", &device_param->kernel_mp); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_wgs_mp); + CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_wgs_mp); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_local_mem_size_mp); + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_local_mem_size_mp); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_preferred_wgs_multiple_mp); + CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_preferred_wgs_multiple_mp); - if (CL_rc == -1) return -1; - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) - { - CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "C_markov", &device_param->kernel_mp); + if (CL_rc == -1) return -1; + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) + { + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_mp, "C_markov", &device_param->kernel_mp); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_wgs_mp); + CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_wgs_mp); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_local_mem_size_mp); + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_local_mem_size_mp); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_preferred_wgs_multiple_mp); + CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_mp, &device_param->kernel_preferred_wgs_multiple_mp); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; + } } - if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + if (user_options->slow_candidates == true) { - // nothing to do } else { - CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_amp, "amp", &device_param->kernel_amp); - - if (CL_rc == -1) return -1; - - CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_amp, &device_param->kernel_wgs_amp); + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + { + // nothing to do + } + else + { + CL_rc = hc_clCreateKernel (hashcat_ctx, device_param->program_amp, "amp", &device_param->kernel_amp); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_amp, &device_param->kernel_local_mem_size_amp); + CL_rc = get_kernel_wgs (hashcat_ctx, device_param, device_param->kernel_amp, &device_param->kernel_wgs_amp); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; - CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_amp, &device_param->kernel_preferred_wgs_multiple_amp); + CL_rc = get_kernel_local_mem_size (hashcat_ctx, device_param, device_param->kernel_amp, &device_param->kernel_local_mem_size_amp); - if (CL_rc == -1) return -1; - } + if (CL_rc == -1) return -1; - if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) - { - // nothing to do - } - else - { - for (u32 i = 0; i < 5; i++) - { - CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, i, sizeof (cl_mem), device_param->kernel_params_amp[i]); + CL_rc = get_kernel_preferred_wgs_multiple (hashcat_ctx, device_param, device_param->kernel_amp, &device_param->kernel_preferred_wgs_multiple_amp); if (CL_rc == -1) return -1; } - for (u32 i = 5; i < 6; i++) + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, i, sizeof (cl_uint), device_param->kernel_params_amp[i]); - - if (CL_rc == -1) return -1; + // nothing to do } - - for (u32 i = 6; i < 7; i++) + else { - CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, i, sizeof (cl_ulong), device_param->kernel_params_amp[i]); + for (u32 i = 0; i < 5; i++) + { + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, i, sizeof (cl_mem), device_param->kernel_params_amp[i]); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; + } + + for (u32 i = 5; i < 6; i++) + { + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, i, sizeof (cl_uint), device_param->kernel_params_amp[i]); + + if (CL_rc == -1) return -1; + } + + for (u32 i = 6; i < 7; i++) + { + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, i, sizeof (cl_ulong), device_param->kernel_params_amp[i]); + + if (CL_rc == -1) return -1; + } } } @@ -6093,69 +6268,82 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) * special buffers */ - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + if (user_options->slow_candidates == true) { CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_rules_c, size_rules_c); if (CL_rc == -1) return -1; } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + else { - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_combs, size_combs); if (CL_rc == -1) return -1; - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_combs_c, size_combs); if (CL_rc == -1) return -1; - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_root_css_buf, size_root_css); if (CL_rc == -1) return -1; - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_markov_css_buf, size_markov_css); if (CL_rc == -1) return -1; + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + { + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_rules_c, size_rules_c); if (CL_rc == -1) return -1; + } + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + { + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_combs, size_combs); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_combs_c, size_combs); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_root_css_buf, size_root_css); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_markov_css_buf, size_markov_css); if (CL_rc == -1) return -1; + } + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_bfs, size_bfs); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_bfs_c, size_bfs); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_tm_c, size_tm); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_root_css_buf, size_root_css); if (CL_rc == -1) return -1; + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_markov_css_buf, size_markov_css); if (CL_rc == -1) return -1; + } } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + + if (user_options->slow_candidates == true) { - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_bfs, size_bfs); if (CL_rc == -1) return -1; - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_bfs_c, size_bfs); if (CL_rc == -1) return -1; - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_tm_c, size_tm); if (CL_rc == -1) return -1; - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_root_css_buf, size_root_css); if (CL_rc == -1) return -1; - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_markov_css_buf, size_markov_css); if (CL_rc == -1) return -1; } - - if ((user_options->attack_mode == ATTACK_MODE_HYBRID1) || (user_options->attack_mode == ATTACK_MODE_HYBRID2)) + else { - /** - * prepare mp - */ - - if (user_options->attack_mode == ATTACK_MODE_HYBRID1) + if ((user_options->attack_mode == ATTACK_MODE_HYBRID1) || (user_options->attack_mode == ATTACK_MODE_HYBRID2)) { - device_param->kernel_params_mp_buf32[5] = 0; - device_param->kernel_params_mp_buf32[6] = 0; - device_param->kernel_params_mp_buf32[7] = 0; + /** + * prepare mp + */ + + if (user_options->attack_mode == ATTACK_MODE_HYBRID1) + { + device_param->kernel_params_mp_buf32[5] = 0; + device_param->kernel_params_mp_buf32[6] = 0; + device_param->kernel_params_mp_buf32[7] = 0; + + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_buf32[5] = full01; + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_buf32[5] = full80; + if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_buf32[6] = 1; + if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_buf32[7] = 1; + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) + { + device_param->kernel_params_mp_buf32[5] = 0; + device_param->kernel_params_mp_buf32[6] = 0; + device_param->kernel_params_mp_buf32[7] = 0; + } - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_buf32[5] = full01; - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_buf32[5] = full80; - if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_buf32[6] = 1; - if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_buf32[7] = 1; + for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_mem), device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; } } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) + else if (user_options->attack_mode == ATTACK_MODE_BF) { - device_param->kernel_params_mp_buf32[5] = 0; - device_param->kernel_params_mp_buf32[6] = 0; - device_param->kernel_params_mp_buf32[7] = 0; - } - - for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, i, sizeof (cl_mem), device_param->kernel_params_mp[i]); if (CL_rc == -1) return -1; } - } - else if (user_options->attack_mode == ATTACK_MODE_BF) - { - /** - * prepare mp_r and mp_l - */ + /** + * prepare mp_r and mp_l + */ - device_param->kernel_params_mp_l_buf32[6] = 0; - device_param->kernel_params_mp_l_buf32[7] = 0; - device_param->kernel_params_mp_l_buf32[8] = 0; + device_param->kernel_params_mp_l_buf32[6] = 0; + device_param->kernel_params_mp_l_buf32[7] = 0; + device_param->kernel_params_mp_l_buf32[8] = 0; - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_l_buf32[6] = full01; - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_l_buf32[6] = full80; - if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_l_buf32[7] = 1; - if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_l_buf32[8] = 1; + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) device_param->kernel_params_mp_l_buf32[6] = full01; + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) device_param->kernel_params_mp_l_buf32[6] = full80; + if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS14) device_param->kernel_params_mp_l_buf32[7] = 1; + if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS15) device_param->kernel_params_mp_l_buf32[8] = 1; - for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_mem), device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; } - for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_mem), device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; } + for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, i, sizeof (cl_mem), device_param->kernel_params_mp_l[i]); if (CL_rc == -1) return -1; } + for (u32 i = 0; i < 3; i++) { CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_r, i, sizeof (cl_mem), device_param->kernel_params_mp_r[i]); if (CL_rc == -1) return -1; } + } } /** @@ -6177,6 +6365,8 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) size_t size_pws_amp = 4; size_t size_pws_comp = 4; size_t size_pws_idx = 4; + size_t size_pws_pre = 4; + size_t size_pws_base = 4; size_t size_tmps = 4; size_t size_hooks = 4; @@ -6217,6 +6407,17 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) size_hooks = (size_t) kernel_power_max * hashconfig->hook_size; + if (user_options->slow_candidates == true) + { + // size_pws_pre + + size_pws_pre = (size_t) kernel_power_max * sizeof (pw_pre_t); + + // size_pws_base + + size_pws_base = (size_t) kernel_power_max * sizeof (pw_pre_t); + } + // now check if all device-memory sizes which depend on the kernel_accel_max amplifier are within its boundaries // if not, decrease amplifier and try again @@ -6266,6 +6467,15 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) if ((size_total + EXTRA_SPACE) > device_param->device_available_mem) memory_limit_hit = 1; + const size_t size_total_host + = size_pws_comp + + size_pws_idx + + size_hooks + + size_pws_pre + + size_pws_base; + + if ((size_total_host + EXTRA_SPACE) > device_param->device_maxmem_alloc) memory_limit_hit = 1; + if (memory_limit_hit == 1) { kernel_accel_max--; @@ -6290,6 +6500,8 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->size_pws_amp = size_pws_amp; device_param->size_pws_comp = size_pws_comp; device_param->size_pws_idx = size_pws_idx; + device_param->size_pws_pre = size_pws_pre; + device_param->size_pws_base = size_pws_base; device_param->size_tmps = size_tmps; device_param->size_hooks = size_hooks; @@ -6331,6 +6543,14 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->scratch_buf = scratch_buf; + pw_pre_t *pws_pre_buf = (pw_pre_t *) hcmalloc (size_pws_pre); + + device_param->pws_pre_buf = pws_pre_buf; + + pw_pre_t *pws_base_buf = (pw_pre_t *) hcmalloc (size_pws_base); + + device_param->pws_base_buf = pws_base_buf; + /** * kernel args */ @@ -6339,45 +6559,50 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) device_param->kernel_params[ 4] = &device_param->d_tmps; device_param->kernel_params[ 5] = &device_param->d_hooks; - if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + if (user_options->slow_candidates == true) { - // nothing to do } else { - if (user_options->attack_mode == ATTACK_MODE_HYBRID2) + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + // nothing to do + } + else { - device_param->kernel_params_mp[0] = (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) - ? &device_param->d_pws_buf - : &device_param->d_pws_amp_buf; + if (user_options->attack_mode == ATTACK_MODE_HYBRID2) + { + device_param->kernel_params_mp[0] = (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + ? &device_param->d_pws_buf + : &device_param->d_pws_amp_buf; - CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, 0, sizeof (cl_mem), device_param->kernel_params_mp[0]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp, 0, sizeof (cl_mem), device_param->kernel_params_mp[0]); if (CL_rc == -1) return -1; + } } - } - if (user_options->attack_mode == ATTACK_MODE_BF) - { - device_param->kernel_params_mp_l[0] = (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) - ? &device_param->d_pws_buf - : &device_param->d_pws_amp_buf; + if (user_options->attack_mode == ATTACK_MODE_BF) + { + device_param->kernel_params_mp_l[0] = (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + ? &device_param->d_pws_buf + : &device_param->d_pws_amp_buf; - CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, 0, sizeof (cl_mem), device_param->kernel_params_mp_l[0]); if (CL_rc == -1) return -1; - } + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_mp_l, 0, sizeof (cl_mem), device_param->kernel_params_mp_l[0]); if (CL_rc == -1) return -1; + } - if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) - { - // nothing to do - } - else - { - device_param->kernel_params_amp[0] = &device_param->d_pws_buf; - device_param->kernel_params_amp[1] = &device_param->d_pws_amp_buf; + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + { + // nothing to do + } + else + { + device_param->kernel_params_amp[0] = &device_param->d_pws_buf; + device_param->kernel_params_amp[1] = &device_param->d_pws_amp_buf; - CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, 0, sizeof (cl_mem), device_param->kernel_params_amp[0]); if (CL_rc == -1) return -1; - CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, 1, sizeof (cl_mem), device_param->kernel_params_amp[1]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, 0, sizeof (cl_mem), device_param->kernel_params_amp[0]); if (CL_rc == -1) return -1; + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, 1, sizeof (cl_mem), device_param->kernel_params_amp[1]); if (CL_rc == -1) return -1; + } } - device_param->kernel_params_decompress[0] = &device_param->d_pws_idx; device_param->kernel_params_decompress[1] = &device_param->d_pws_comp_buf; device_param->kernel_params_decompress[2] = (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) @@ -6432,6 +6657,8 @@ void opencl_session_destroy (hashcat_ctx_t *hashcat_ctx) hcfree (device_param->pws_comp); hcfree (device_param->pws_idx); + hcfree (device_param->pws_pre_buf); + hcfree (device_param->pws_base_buf); hcfree (device_param->combs_buf); hcfree (device_param->hooks_buf); hcfree (device_param->scratch_buf); @@ -6504,6 +6731,8 @@ void opencl_session_destroy (hashcat_ctx_t *hashcat_ctx) device_param->pws_comp = NULL; device_param->pws_idx = NULL; + device_param->pws_pre_buf = NULL; + device_param->pws_base_buf = NULL; device_param->combs_buf = NULL; device_param->hooks_buf = NULL; @@ -6626,6 +6855,7 @@ int opencl_session_update_combinator (hashcat_ctx_t *hashcat_ctx) combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; hashconfig_t *hashconfig = hashcat_ctx->hashconfig; opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + user_options_t *user_options = hashcat_ctx->user_options; if (opencl_ctx->enabled == false) return 0; @@ -6655,15 +6885,21 @@ int opencl_session_update_combinator (hashcat_ctx_t *hashcat_ctx) // kernel_params_amp - device_param->kernel_params_amp_buf32[5] = combinator_ctx->combs_mode; - - if (hashconfig->attack_exec == ATTACK_EXEC_OUTSIDE_KERNEL) + if (user_options->slow_candidates == true) { - int CL_rc; + } + else + { + device_param->kernel_params_amp_buf32[5] = combinator_ctx->combs_mode; + + if (hashconfig->attack_exec == ATTACK_EXEC_OUTSIDE_KERNEL) + { + int CL_rc; - CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, 5, sizeof (cl_uint), device_param->kernel_params_amp[5]); + CL_rc = hc_clSetKernelArg (hashcat_ctx, device_param->kernel_amp, 5, sizeof (cl_uint), device_param->kernel_params_amp[5]); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; + } } } @@ -6672,11 +6908,14 @@ int opencl_session_update_combinator (hashcat_ctx_t *hashcat_ctx) int opencl_session_update_mp (hashcat_ctx_t *hashcat_ctx) { - mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + user_options_t *user_options = hashcat_ctx->user_options; if (opencl_ctx->enabled == false) return 0; + if (user_options->slow_candidates == true) return 0; + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; @@ -6700,11 +6939,14 @@ int opencl_session_update_mp (hashcat_ctx_t *hashcat_ctx) int opencl_session_update_mp_rl (hashcat_ctx_t *hashcat_ctx, const u32 css_cnt_l, const u32 css_cnt_r) { - mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; - opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + opencl_ctx_t *opencl_ctx = hashcat_ctx->opencl_ctx; + user_options_t *user_options = hashcat_ctx->user_options; if (opencl_ctx->enabled == false) return 0; + if (user_options->slow_candidates == true) return 0; + for (u32 device_id = 0; device_id < opencl_ctx->devices_cnt; device_id++) { hc_device_param_t *device_param = &opencl_ctx->devices_param[device_id]; diff --git a/src/outfile.c b/src/outfile.c index d33a2ace3..db3c1f5a4 100644 --- a/src/outfile.c +++ b/src/outfile.c @@ -35,7 +35,7 @@ int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl u8 *plain_ptr = (u8 *) plain_buf; - if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) + if (user_options->slow_candidates == true) { pw_t pw; @@ -43,101 +43,89 @@ int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl if (rc == -1) return -1; - const u64 off = device_param->innerloop_pos + il_pos; + memcpy (plain_buf, pw.i, pw.pw_len); - if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) - { - for (int i = 0; i < 8; i++) - { - plain_buf[i] = pw.i[i]; - } - - plain_len = apply_rules_optimized (straight_ctx->kernel_rules_buf[off].cmds, &plain_buf[0], &plain_buf[4], pw.pw_len); - } - else - { - for (int i = 0; i < 64; i++) - { - plain_buf[i] = pw.i[i]; - } - - plain_len = apply_rules (straight_ctx->kernel_rules_buf[off].cmds, plain_buf, pw.pw_len); - } + plain_len = pw.pw_len; } - else if (user_options->attack_mode == ATTACK_MODE_COMBI) + else { - pw_t pw; + if (user_options->attack_mode == ATTACK_MODE_STRAIGHT) + { + pw_t pw; - const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); - if (rc == -1) return -1; + if (rc == -1) return -1; - for (int i = 0; i < 64; i++) - { - plain_buf[i] = pw.i[i]; - } + const u64 off = device_param->innerloop_pos + il_pos; - plain_len = (int) pw.pw_len; + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + for (int i = 0; i < 8; i++) + { + plain_buf[i] = pw.i[i]; + } - char *comb_buf = (char *) device_param->combs_buf[il_pos].i; - u32 comb_len = device_param->combs_buf[il_pos].pw_len; + plain_len = apply_rules_optimized (straight_ctx->kernel_rules_buf[off].cmds, &plain_buf[0], &plain_buf[4], pw.pw_len); + } + else + { + for (int i = 0; i < 64; i++) + { + plain_buf[i] = pw.i[i]; + } - if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT) - { - memcpy (plain_ptr + plain_len, comb_buf, (size_t) comb_len); + plain_len = apply_rules (straight_ctx->kernel_rules_buf[off].cmds, plain_buf, pw.pw_len); + } } - else + else if (user_options->attack_mode == ATTACK_MODE_COMBI) { - memmove (plain_ptr + comb_len, plain_ptr, (size_t) plain_len); - - memcpy (plain_ptr, comb_buf, comb_len); - } + pw_t pw; - plain_len += comb_len; - } - else if (user_options->attack_mode == ATTACK_MODE_BF) - { - u64 l_off = device_param->kernel_params_mp_l_buf64[3] + gidvid; - u64 r_off = device_param->kernel_params_mp_r_buf64[3] + il_pos; + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); - u32 l_start = device_param->kernel_params_mp_l_buf32[5]; - u32 r_start = device_param->kernel_params_mp_r_buf32[5]; + if (rc == -1) return -1; - u32 l_stop = device_param->kernel_params_mp_l_buf32[4]; - u32 r_stop = device_param->kernel_params_mp_r_buf32[4]; + for (int i = 0; i < 64; i++) + { + plain_buf[i] = pw.i[i]; + } - sp_exec (l_off, (char *) plain_ptr + l_start, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, l_start, l_start + l_stop); - sp_exec (r_off, (char *) plain_ptr + r_start, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, r_start, r_start + r_stop); + plain_len = (int) pw.pw_len; - plain_len = (int) mask_ctx->css_cnt; - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) - { - pw_t pw; + char *comb_buf = (char *) device_param->combs_buf[il_pos].i; + u32 comb_len = device_param->combs_buf[il_pos].pw_len; - const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + if (combinator_ctx->combs_mode == COMBINATOR_MODE_BASE_LEFT) + { + memcpy (plain_ptr + plain_len, comb_buf, (size_t) comb_len); + } + else + { + memmove (plain_ptr + comb_len, plain_ptr, (size_t) plain_len); - if (rc == -1) return -1; + memcpy (plain_ptr, comb_buf, comb_len); + } - for (int i = 0; i < 64; i++) - { - plain_buf[i] = pw.i[i]; + plain_len += comb_len; } + else if (user_options->attack_mode == ATTACK_MODE_BF) + { + u64 l_off = device_param->kernel_params_mp_l_buf64[3] + gidvid; + u64 r_off = device_param->kernel_params_mp_r_buf64[3] + il_pos; - plain_len = (int) pw.pw_len; - - u64 off = device_param->kernel_params_mp_buf64[3] + il_pos; + u32 l_start = device_param->kernel_params_mp_l_buf32[5]; + u32 r_start = device_param->kernel_params_mp_r_buf32[5]; - u32 start = 0; - u32 stop = device_param->kernel_params_mp_buf32[4]; + u32 l_stop = device_param->kernel_params_mp_l_buf32[4]; + u32 r_stop = device_param->kernel_params_mp_r_buf32[4]; - sp_exec (off, (char *) plain_ptr + plain_len, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop); + sp_exec (l_off, (char *) plain_ptr + l_start, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, l_start, l_start + l_stop); + sp_exec (r_off, (char *) plain_ptr + r_start, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, r_start, r_start + r_stop); - plain_len += start + stop; - } - else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) - { - if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + plain_len = (int) mask_ctx->css_cnt; + } + else if (user_options->attack_mode == ATTACK_MODE_HYBRID1) { pw_t pw; @@ -157,67 +145,94 @@ int build_plain (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, pl u32 start = 0; u32 stop = device_param->kernel_params_mp_buf32[4]; - memmove (plain_ptr + stop, plain_ptr, plain_len); - - sp_exec (off, (char *) plain_ptr, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop); + sp_exec (off, (char *) plain_ptr + plain_len, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop); plain_len += start + stop; } - else + else if (user_options->attack_mode == ATTACK_MODE_HYBRID2) { - pw_t pw; + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + pw_t pw; - const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); - if (rc == -1) return -1; + if (rc == -1) return -1; - u64 off = device_param->kernel_params_mp_buf64[3] + gidvid; + for (int i = 0; i < 64; i++) + { + plain_buf[i] = pw.i[i]; + } - u32 start = 0; - u32 stop = device_param->kernel_params_mp_buf32[4]; + plain_len = (int) pw.pw_len; - sp_exec (off, (char *) plain_ptr, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop); + u64 off = device_param->kernel_params_mp_buf64[3] + il_pos; - plain_len = stop; + u32 start = 0; + u32 stop = device_param->kernel_params_mp_buf32[4]; - char *comb_buf = (char *) device_param->combs_buf[il_pos].i; - u32 comb_len = device_param->combs_buf[il_pos].pw_len; + memmove (plain_ptr + stop, plain_ptr, plain_len); - memcpy (plain_ptr + plain_len, comb_buf, comb_len); + sp_exec (off, (char *) plain_ptr, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop); - plain_len += comb_len; + plain_len += start + stop; + } + else + { + pw_t pw; + + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + + if (rc == -1) return -1; + + u64 off = device_param->kernel_params_mp_buf64[3] + gidvid; + + u32 start = 0; + u32 stop = device_param->kernel_params_mp_buf32[4]; + + sp_exec (off, (char *) plain_ptr, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, start, start + stop); + + plain_len = stop; + + char *comb_buf = (char *) device_param->combs_buf[il_pos].i; + u32 comb_len = device_param->combs_buf[il_pos].pw_len; + + memcpy (plain_ptr + plain_len, comb_buf, comb_len); + + plain_len += comb_len; + } } - } - if (user_options->attack_mode == ATTACK_MODE_BF) - { - if (hashconfig->opti_type & OPTI_TYPE_BRUTE_FORCE) // lots of optimizations can happen here + if (user_options->attack_mode == ATTACK_MODE_BF) { - if (hashconfig->opti_type & OPTI_TYPE_SINGLE_HASH) + if (hashconfig->opti_type & OPTI_TYPE_BRUTE_FORCE) // lots of optimizations can happen here { - if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT) + if (hashconfig->opti_type & OPTI_TYPE_SINGLE_HASH) { - plain_len = plain_len - hashes->salts_buf[0].salt_len; + if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT) + { + plain_len = plain_len - hashes->salts_buf[0].salt_len; + } } - } - if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE) - { - for (int i = 0, j = 0; i < plain_len; i += 2, j += 1) + if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE) { - plain_ptr[j] = plain_ptr[i]; - } + for (int i = 0, j = 0; i < plain_len; i += 2, j += 1) + { + plain_ptr[j] = plain_ptr[i]; + } - plain_len = plain_len / 2; - } - else if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE) - { - for (int i = 1, j = 0; i < plain_len; i += 2, j += 1) - { - plain_ptr[j] = plain_ptr[i]; + plain_len = plain_len / 2; } + else if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE) + { + for (int i = 1, j = 0; i < plain_len; i += 2, j += 1) + { + plain_ptr[j] = plain_ptr[i]; + } - plain_len = plain_len / 2; + plain_len = plain_len / 2; + } } } } @@ -238,6 +253,7 @@ int build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; const u64 gidvid = plain->gidvid; @@ -245,23 +261,30 @@ int build_crackpos (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, u64 crackpos = device_param->words_off; - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) - { - crackpos += gidvid; - crackpos *= straight_ctx->kernel_rules_cnt; - crackpos += device_param->innerloop_pos + il_pos; - } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + if (user_options->slow_candidates == true) { - crackpos += gidvid; - crackpos *= combinator_ctx->combs_cnt; - crackpos += device_param->innerloop_pos + il_pos; + crackpos = gidvid; } - else if (user_options_extra->attack_kern == ATTACK_MODE_BF) + else { - crackpos += gidvid; - crackpos *= mask_ctx->bfs_cnt; - crackpos += device_param->innerloop_pos + il_pos; + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + { + crackpos += gidvid; + crackpos *= straight_ctx->kernel_rules_cnt; + crackpos += device_param->innerloop_pos + il_pos; + } + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + { + crackpos += gidvid; + crackpos *= combinator_ctx->combs_cnt; + crackpos += device_param->innerloop_pos + il_pos; + } + else if (user_options_extra->attack_kern == ATTACK_MODE_BF) + { + crackpos += gidvid; + crackpos *= mask_ctx->bfs_cnt; + crackpos += device_param->innerloop_pos + il_pos; + } } *out_pos = crackpos; @@ -284,34 +307,61 @@ int build_debugdata (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param if (debug_mode == 0) return 0; - pw_t pw; + if (user_options->slow_candidates == true) + { + pw_pre_t *pw_base = device_param->pws_base_buf + gidvid; + + // save rule + if ((debug_mode == 1) || (debug_mode == 3) || (debug_mode == 4)) + { + const int len = kernel_rule_to_cpu_rule ((char *) debug_rule_buf, &straight_ctx->kernel_rules_buf[pw_base->rule_idx]); - const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); + debug_rule_buf[len] = 0; - if (rc == -1) return -1; + *debug_rule_len = len; + } - int plain_len = (int) pw.pw_len; + // save plain + if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4)) + { + memcpy (debug_plain_ptr, pw_base->base_buf, pw_base->base_len); - const u64 off = device_param->innerloop_pos + il_pos; + debug_plain_ptr[pw_base->base_len] = 0; - // save rule - if ((debug_mode == 1) || (debug_mode == 3) || (debug_mode == 4)) + *debug_plain_len = pw_base->base_len; + } + } + else { - const int len = kernel_rule_to_cpu_rule ((char *) debug_rule_buf, &straight_ctx->kernel_rules_buf[off]); + pw_t pw; - debug_rule_buf[len] = 0; + const int rc = gidd_to_pw_t (hashcat_ctx, device_param, gidvid, &pw); - *debug_rule_len = len; - } + if (rc == -1) return -1; - // save plain - if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4)) - { - memcpy (debug_plain_ptr, (char *) pw.i, (size_t) plain_len); + int plain_len = (int) pw.pw_len; + + const u64 off = device_param->innerloop_pos + il_pos; - debug_plain_ptr[plain_len] = 0; + // save rule + if ((debug_mode == 1) || (debug_mode == 3) || (debug_mode == 4)) + { + const int len = kernel_rule_to_cpu_rule ((char *) debug_rule_buf, &straight_ctx->kernel_rules_buf[off]); + + debug_rule_buf[len] = 0; + + *debug_rule_len = len; + } - *debug_plain_len = plain_len; + // save plain + if ((debug_mode == 2) || (debug_mode == 3) || (debug_mode == 4)) + { + memcpy (debug_plain_ptr, (char *) pw.i, (size_t) plain_len); + + debug_plain_ptr[plain_len] = 0; + + *debug_plain_len = plain_len; + } } return 0; diff --git a/src/selftest.c b/src/selftest.c index 935f4a0f2..ebc61194a 100644 --- a/src/selftest.c +++ b/src/selftest.c @@ -18,6 +18,7 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param hashconfig_t *hashconfig = hashcat_ctx->hashconfig; hashes_t *hashes = hashcat_ctx->hashes; status_ctx_t *status_ctx = hashcat_ctx->status_ctx; + user_options_t *user_options = hashcat_ctx->user_options; user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; cl_int CL_err; @@ -39,252 +40,276 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param u32 highest_pw_len = 0; - if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) + if (user_options->slow_candidates == true) { - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { device_param->kernel_params_buf32[30] = 1; + } - pw_t pw; memset (&pw, 0, sizeof (pw)); - - char *pw_ptr = (char *) &pw.i; + pw_t pw; memset (&pw, 0, sizeof (pw)); - const size_t pw_len = strlen (hashconfig->st_pass); + char *pw_ptr = (char *) &pw.i; - memcpy (pw_ptr, hashconfig->st_pass, pw_len); + const size_t pw_len = strlen (hashconfig->st_pass); - pw.pw_len = (u32) pw_len; + memcpy (pw_ptr, hashconfig->st_pass, pw_len); - if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) - { - uppercase ((u8 *) pw_ptr, pw.pw_len); - } + pw.pw_len = (u32) pw_len; - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL); + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) return -1; - } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + if (CL_err != CL_SUCCESS) return -1; + } + else + { + if (hashconfig->attack_exec == ATTACK_EXEC_INSIDE_KERNEL) { - device_param->kernel_params_buf32[30] = 1; - device_param->kernel_params_buf32[33] = COMBINATOR_MODE_BASE_LEFT; - - pw_t pw; memset (&pw, 0, sizeof (pw)); - - char *pw_ptr = (char *) &pw.i; - - const size_t pw_len = strlen (hashconfig->st_pass); + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + { + device_param->kernel_params_buf32[30] = 1; - memcpy (pw_ptr, hashconfig->st_pass, pw_len - 1); + pw_t pw; memset (&pw, 0, sizeof (pw)); - pw.pw_len = (u32) pw_len - 1; + char *pw_ptr = (char *) &pw.i; - if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) - { - uppercase ((u8 *) pw_ptr, pw.pw_len); - } + const size_t pw_len = strlen (hashconfig->st_pass); - pw_t comb; memset (&comb, 0, sizeof (comb)); + memcpy (pw_ptr, hashconfig->st_pass, pw_len); - char *comb_ptr = (char *) &comb.i; + pw.pw_len = (u32) pw_len; - memcpy (comb_ptr, hashconfig->st_pass + pw_len - 1, 1); + if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) + { + uppercase ((u8 *) pw_ptr, pw.pw_len); + } - comb.pw_len = 1; + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL); - if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) - { - uppercase ((u8 *) comb_ptr, comb.pw_len); + if (CL_err != CL_SUCCESS) return -1; } - - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { - comb_ptr[comb.pw_len] = 0x01; - } + device_param->kernel_params_buf32[30] = 1; + device_param->kernel_params_buf32[33] = COMBINATOR_MODE_BASE_LEFT; - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) - { - comb_ptr[comb.pw_len] = 0x80; - } + pw_t pw; memset (&pw, 0, sizeof (pw)); - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, 1 * sizeof (pw_t), &comb, 0, NULL, NULL); + char *pw_ptr = (char *) &pw.i; - if (CL_err != CL_SUCCESS) return -1; + const size_t pw_len = strlen (hashconfig->st_pass); - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL); + memcpy (pw_ptr, hashconfig->st_pass, pw_len - 1); - if (CL_err != CL_SUCCESS) return -1; - } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) - { - device_param->kernel_params_buf32[30] = 1; + pw.pw_len = (u32) pw_len - 1; - if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) - { - pw_t pw; memset (&pw, 0, sizeof (pw)); + if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) + { + uppercase ((u8 *) pw_ptr, pw.pw_len); + } - char *pw_ptr = (char *) &pw.i; + pw_t comb; memset (&comb, 0, sizeof (comb)); - const size_t pw_len = strlen (hashconfig->st_pass); + char *comb_ptr = (char *) &comb.i; - memcpy (pw_ptr, hashconfig->st_pass, pw_len); + memcpy (comb_ptr, hashconfig->st_pass + pw_len - 1, 1); + + comb.pw_len = 1; if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) { - uppercase ((u8 *) pw_ptr, pw_len); + uppercase ((u8 *) comb_ptr, comb.pw_len); } - pw.pw_len = (u32) pw_len; + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) + { + comb_ptr[comb.pw_len] = 0x01; + } + + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) + { + comb_ptr[comb.pw_len] = 0x80; + } + + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_combs_c, CL_TRUE, 0, 1 * sizeof (pw_t), &comb, 0, NULL, NULL); + + if (CL_err != CL_SUCCESS) return -1; CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL); if (CL_err != CL_SUCCESS) return -1; } - else + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) { - bf_t bf; memset (&bf, 0, sizeof (bf)); + device_param->kernel_params_buf32[30] = 1; - char *bf_ptr = (char *) &bf.i; + if (hashconfig->opts_type & OPTS_TYPE_PT_BITSLICE) + { + pw_t pw; memset (&pw, 0, sizeof (pw)); - memcpy (bf_ptr, hashconfig->st_pass, 1); + char *pw_ptr = (char *) &pw.i; - if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE) - { - memset (bf_ptr, 0, 4); + const size_t pw_len = strlen (hashconfig->st_pass); + + memcpy (pw_ptr, hashconfig->st_pass, pw_len); - for (int i = 0, j = 0; i < 1; i += 1, j += 2) + if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) { - bf_ptr[j + 0] = hashconfig->st_pass[i]; - bf_ptr[j + 1] = 0; + uppercase ((u8 *) pw_ptr, pw_len); } + + pw.pw_len = (u32) pw_len; + + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL); + + if (CL_err != CL_SUCCESS) return -1; } - else if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE) + else { - memset (bf_ptr, 0, 4); + bf_t bf; memset (&bf, 0, sizeof (bf)); + + char *bf_ptr = (char *) &bf.i; - for (int i = 0, j = 0; i < 1; i += 1, j += 2) + memcpy (bf_ptr, hashconfig->st_pass, 1); + + if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE) { - bf_ptr[j + 0] = 0; - bf_ptr[j + 1] = hashconfig->st_pass[i]; + memset (bf_ptr, 0, 4); + + for (int i = 0, j = 0; i < 1; i += 1, j += 2) + { + bf_ptr[j + 0] = hashconfig->st_pass[i]; + bf_ptr[j + 1] = 0; + } } - } + else if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE) + { + memset (bf_ptr, 0, 4); - if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) - { - uppercase ((u8 *) bf_ptr, 4); - } + for (int i = 0, j = 0; i < 1; i += 1, j += 2) + { + bf_ptr[j + 0] = 0; + bf_ptr[j + 1] = hashconfig->st_pass[i]; + } + } - if (hashconfig->opts_type & OPTS_TYPE_PT_GENERATE_BE) - { - bf.i = byte_swap_32 (bf.i); - } + if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) + { + uppercase ((u8 *) bf_ptr, 4); + } - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bfs_c, CL_TRUE, 0, 1 * sizeof (bf_t), &bf, 0, NULL, NULL); + if (hashconfig->opts_type & OPTS_TYPE_PT_GENERATE_BE) + { + bf.i = byte_swap_32 (bf.i); + } - if (CL_err != CL_SUCCESS) return -1; + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_bfs_c, CL_TRUE, 0, 1 * sizeof (bf_t), &bf, 0, NULL, NULL); - pw_t pw; memset (&pw, 0, sizeof (pw)); + if (CL_err != CL_SUCCESS) return -1; - char *pw_ptr = (char *) &pw.i; + pw_t pw; memset (&pw, 0, sizeof (pw)); - const size_t pw_len = strlen (hashconfig->st_pass); + char *pw_ptr = (char *) &pw.i; - memcpy (pw_ptr + 1, hashconfig->st_pass + 1, pw_len - 1); + const size_t pw_len = strlen (hashconfig->st_pass); - size_t new_pass_len = pw_len; + memcpy (pw_ptr + 1, hashconfig->st_pass + 1, pw_len - 1); - if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE) - { - memset (pw_ptr, 0, pw_len); + size_t new_pass_len = pw_len; - for (size_t i = 1, j = 2; i < new_pass_len; i += 1, j += 2) + if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16LE) { - pw_ptr[j + 0] = hashconfig->st_pass[i]; - pw_ptr[j + 1] = 0; - } + memset (pw_ptr, 0, pw_len); - new_pass_len *= 2; - } - else if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE) - { - memset (pw_ptr, 0, pw_len); + for (size_t i = 1, j = 2; i < new_pass_len; i += 1, j += 2) + { + pw_ptr[j + 0] = hashconfig->st_pass[i]; + pw_ptr[j + 1] = 0; + } - for (size_t i = 1, j = 2; i < new_pass_len; i += 1, j += 2) - { - pw_ptr[j + 0] = 0; - pw_ptr[j + 1] = hashconfig->st_pass[i]; + new_pass_len *= 2; } + else if (hashconfig->opts_type & OPTS_TYPE_PT_UTF16BE) + { + memset (pw_ptr, 0, pw_len); - new_pass_len *= 2; - } + for (size_t i = 1, j = 2; i < new_pass_len; i += 1, j += 2) + { + pw_ptr[j + 0] = 0; + pw_ptr[j + 1] = hashconfig->st_pass[i]; + } - if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) - { - uppercase ((u8 *) pw_ptr, new_pass_len); - } + new_pass_len *= 2; + } - if (hashconfig->opti_type & OPTI_TYPE_SINGLE_HASH) - { - if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT) + if (hashconfig->opts_type & OPTS_TYPE_PT_UPPER) + { + uppercase ((u8 *) pw_ptr, new_pass_len); + } + + if (hashconfig->opti_type & OPTI_TYPE_SINGLE_HASH) { - memcpy (pw_ptr + new_pass_len, (char *) hashes->st_salts_buf[0].salt_buf, 64 - new_pass_len); + if (hashconfig->opti_type & OPTI_TYPE_APPENDED_SALT) + { + memcpy (pw_ptr + new_pass_len, (char *) hashes->st_salts_buf[0].salt_buf, 64 - new_pass_len); - new_pass_len += hashes->st_salts_buf[0].salt_len; + new_pass_len += hashes->st_salts_buf[0].salt_len; + } } - } - pw.pw_len = (u32) new_pass_len; + pw.pw_len = (u32) new_pass_len; - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) - { - pw_ptr[new_pass_len] = 0x01; - } + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD01) + { + pw_ptr[new_pass_len] = 0x01; + } - if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) - { - pw_ptr[new_pass_len] = 0x80; - } + if (hashconfig->opts_type & OPTS_TYPE_PT_ADD80) + { + pw_ptr[new_pass_len] = 0x80; + } - if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS14) - { - pw.i[14] = (u32) new_pass_len * 8; - pw.i[15] = 0; - } + if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS14) + { + pw.i[14] = (u32) new_pass_len * 8; + pw.i[15] = 0; + } - if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS15) - { - pw.i[14] = 0; - pw.i[15] = (u32) new_pass_len * 8; - } + if (hashconfig->opts_type & OPTS_TYPE_PT_ADDBITS15) + { + pw.i[14] = 0; + pw.i[15] = (u32) new_pass_len * 8; + } - if (hashconfig->opts_type & OPTS_TYPE_PT_GENERATE_BE) - { - for (int i = 0; i < 14; i++) pw.i[i] = byte_swap_32 (pw.i[i]); - } + if (hashconfig->opts_type & OPTS_TYPE_PT_GENERATE_BE) + { + for (int i = 0; i < 14; i++) pw.i[i] = byte_swap_32 (pw.i[i]); + } - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL); + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) return -1; + if (CL_err != CL_SUCCESS) return -1; - highest_pw_len = pw.pw_len; + highest_pw_len = pw.pw_len; + } } } - } - else - { - pw_t pw; memset (&pw, 0, sizeof (pw)); + else + { + pw_t pw; memset (&pw, 0, sizeof (pw)); - char *pw_ptr = (char *) &pw.i; + char *pw_ptr = (char *) &pw.i; - const size_t pw_len = strlen (hashconfig->st_pass); + const size_t pw_len = strlen (hashconfig->st_pass); - memcpy (pw_ptr, hashconfig->st_pass, pw_len); + memcpy (pw_ptr, hashconfig->st_pass, pw_len); - pw.pw_len = (u32) pw_len; + pw.pw_len = (u32) pw_len; - CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL); + CL_err = hc_clEnqueueWriteBuffer (hashcat_ctx, device_param->command_queue, device_param->d_pws_buf, CL_TRUE, 0, 1 * sizeof (pw_t), &pw, 0, NULL, NULL); - if (CL_err != CL_SUCCESS) return -1; + if (CL_err != CL_SUCCESS) return -1; + } } // main : run the kernel @@ -479,23 +504,32 @@ static int selftest (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_digests_shown, device_param->size_shown); if (CL_rc == -1) return -1; CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_result, device_param->size_results); if (CL_rc == -1) return -1; - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + if (user_options->slow_candidates == true) { CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_rules_c, device_param->size_rules_c); if (CL_rc == -1) return -1; } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + else { - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_combs_c, device_param->size_combs); + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + { + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_rules_c, device_param->size_rules_c); - if (CL_rc == -1) return -1; - } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) - { - CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_bfs_c, device_param->size_bfs); + if (CL_rc == -1) return -1; + } + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + { + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_combs_c, device_param->size_combs); - if (CL_rc == -1) return -1; + if (CL_rc == -1) return -1; + } + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + CL_rc = run_kernel_bzero (hashcat_ctx, device_param, device_param->d_bfs_c, device_param->size_bfs); + + if (CL_rc == -1) return -1; + } } // check return diff --git a/src/slow_candidates.c b/src/slow_candidates.c new file mode 100644 index 000000000..fdf289646 --- /dev/null +++ b/src/slow_candidates.c @@ -0,0 +1,163 @@ +/** + * Author......: See docs/credits.txt + * License.....: MIT + */ + +#include "common.h" +#include "types.h" +#include "rp.h" +#include "rp_cpu.h" +#include "rp_kernel_on_cpu.h" +#include "rp_kernel_on_cpu_optimized.h" +#include "wordlist.h" +#include "mpsp.h" +#include "slow_candidates.h" + +void slow_candidates_seek (hashcat_ctx_t *hashcat_ctx, void *extra_info, const u64 cur, const u64 end) +{ + straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + user_options_t *user_options = hashcat_ctx->user_options; + user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + const u32 attack_mode = user_options->attack_mode; + + if (attack_mode == ATTACK_MODE_STRAIGHT) + { + extra_info_straight_t *extra_info_straight = (extra_info_straight_t *) extra_info; + + FILE *fd = extra_info_straight->fd; + + const u64 overlap = end % straight_ctx->kernel_rules_cnt; + + const u64 init = end - overlap; + + for (u64 i = cur; i < init; i += straight_ctx->kernel_rules_cnt) + { + char *line_buf; + u32 line_len; + + while (1) + { + get_next_word (hashcat_ctx, fd, &line_buf, &line_len); + + // post-process rule engine + + char rule_buf_out[RP_PASSWORD_SIZE]; + + if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l)) + { + if (line_len >= RP_PASSWORD_SIZE) continue; + + memset (rule_buf_out, 0, sizeof (rule_buf_out)); + + const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out); + + if (rule_len_out < 0) continue; + + line_buf = rule_buf_out; + line_len = (u32) rule_len_out; + } + + break; + } + + memcpy (extra_info_straight->base_buf, line_buf, line_len); + + extra_info_straight->base_len = line_len; + } + + extra_info_straight->rule_pos_prev = overlap; + extra_info_straight->rule_pos = overlap; + } + else if (attack_mode == ATTACK_MODE_BF) + { + // nothing to do + } +} + +void slow_candidates_next (hashcat_ctx_t *hashcat_ctx, void *extra_info) +{ + hashconfig_t *hashconfig = hashcat_ctx->hashconfig; + mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; + straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + user_options_t *user_options = hashcat_ctx->user_options; + user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; + + const u32 attack_mode = user_options->attack_mode; + + if (attack_mode == ATTACK_MODE_STRAIGHT) + { + extra_info_straight_t *extra_info_straight = (extra_info_straight_t *) extra_info; + + FILE *fd = extra_info_straight->fd; + + if (extra_info_straight->rule_pos == 0) + { + char *line_buf; + u32 line_len; + + while (1) + { + get_next_word (hashcat_ctx, fd, &line_buf, &line_len); + + line_len = (u32) convert_from_hex (hashcat_ctx, line_buf, line_len); + + // post-process rule engine + + char rule_buf_out[RP_PASSWORD_SIZE]; + + if (run_rule_engine ((int) user_options_extra->rule_len_l, user_options->rule_buf_l)) + { + if (line_len >= RP_PASSWORD_SIZE) continue; + + memset (rule_buf_out, 0, sizeof (rule_buf_out)); + + const int rule_len_out = _old_apply_rule (user_options->rule_buf_l, (int) user_options_extra->rule_len_l, line_buf, (int) line_len, rule_buf_out); + + if (rule_len_out < 0) continue; + + line_buf = rule_buf_out; + line_len = (u32) rule_len_out; + } + + break; + } + + memcpy (extra_info_straight->base_buf, line_buf, line_len); + + extra_info_straight->base_len = line_len; + } + + memcpy (extra_info_straight->out_buf, extra_info_straight->base_buf, extra_info_straight->base_len); + + extra_info_straight->out_len = extra_info_straight->base_len; + + memset (extra_info_straight->out_buf + extra_info_straight->base_len, 0, sizeof (extra_info_straight->out_buf) - extra_info_straight->out_len); + + u32 *out_ptr = (u32 *) extra_info_straight->out_buf; + + if (hashconfig->opti_type & OPTI_TYPE_OPTIMIZED_KERNEL) + { + extra_info_straight->out_len = apply_rules_optimized (straight_ctx->kernel_rules_buf[extra_info_straight->rule_pos].cmds, &out_ptr[0], &out_ptr[4], extra_info_straight->out_len); + } + else + { + extra_info_straight->out_len = apply_rules (straight_ctx->kernel_rules_buf[extra_info_straight->rule_pos].cmds, out_ptr, extra_info_straight->out_len); + } + + extra_info_straight->rule_pos_prev = extra_info_straight->rule_pos; + + extra_info_straight->rule_pos++; + + if (extra_info_straight->rule_pos == straight_ctx->kernel_rules_cnt) + { + extra_info_straight->rule_pos = 0; + } + } + else if (attack_mode == ATTACK_MODE_BF) + { + extra_info_mask_t *extra_info_mask = (extra_info_mask_t *) extra_info; + + sp_exec (extra_info_mask->pos, (char *) extra_info_mask->out_buf, mask_ctx->root_css_buf, mask_ctx->markov_css_buf, 0, mask_ctx->css_cnt); + } +} diff --git a/src/status.c b/src/status.c index 3f38ada96..2f4f19719 100644 --- a/src/status.c +++ b/src/status.c @@ -141,6 +141,38 @@ void format_speed_display (double val, char *buf, size_t len) } } +void format_speed_display_1k (double val, char *buf, size_t len) +{ + if (val <= 0) + { + buf[0] = '0'; + buf[1] = ' '; + buf[2] = 0; + + return; + } + + u32 level = 0; + + while (val > 999) + { + val /= 1000; + + level++; + } + + /* generate output */ + + if (level == 0) + { + snprintf (buf, len - 1, "%.0f ", val); + } + else + { + snprintf (buf, len - 1, "%.1f %c", val, UNITS[level]); + } +} + double get_avg_exec_time (hc_device_param_t *device_param, const int last_num_entries) { int exec_pos = (int) device_param->exec_pos - last_num_entries; @@ -2029,8 +2061,8 @@ void status_status_destroy (hashcat_ctx_t *hashcat_ctx, hashcat_status_t *hashca hcfree (device_info->guess_candidates_dev); hcfree (device_info->hwmon_dev); - device_info->speed_sec_dev = NULL; - device_info->guess_candidates_dev = NULL; - device_info->hwmon_dev = NULL; + device_info->speed_sec_dev = NULL; + device_info->guess_candidates_dev = NULL; + device_info->hwmon_dev = NULL; } } diff --git a/src/terminal.c b/src/terminal.c index 04a592b08..6f5737fa7 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1216,7 +1216,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (device_info->skipped_dev == true) continue; event_log_info (hashcat_ctx, - "Speed.Dev.#%d.....: %9sH/s (%0.2fms) @ Accel:%d Loops:%d Thr:%d Vec:%d", device_id + 1, + "Speed.#%d.........: %9sH/s (%0.2fms) @ Accel:%d Loops:%d Thr:%d Vec:%d", device_id + 1, device_info->speed_sec_dev, device_info->exec_msec_dev, device_info->kernel_accel_dev, @@ -1228,7 +1228,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (hashcat_status->device_info_active > 1) { event_log_info (hashcat_ctx, - "Speed.Dev.#*.....: %9sH/s", + "Speed.#*.........: %9sH/s", hashcat_status->speed_sec_all); } @@ -1264,12 +1264,6 @@ void status_display (hashcat_ctx_t *hashcat_ctx) hashcat_status->progress_cur_relative_skip, hashcat_status->progress_rejected_percent); - event_log_info (hashcat_ctx, - "Restore.Point....: %" PRIu64 "/%" PRIu64 " (%.02f%%)", - hashcat_status->restore_point, - hashcat_status->restore_total, - hashcat_status->restore_percent); - break; case PROGRESS_MODE_KEYSPACE_UNKNOWN: @@ -1282,6 +1276,23 @@ void status_display (hashcat_ctx_t *hashcat_ctx) "Rejected.........: %" PRIu64, hashcat_status->progress_rejected); + break; + } + + switch (hashcat_status->progress_mode) + { + case PROGRESS_MODE_KEYSPACE_KNOWN: + + event_log_info (hashcat_ctx, + "Restore.Point....: %" PRIu64 "/%" PRIu64 " (%.02f%%)", + hashcat_status->restore_point, + hashcat_status->restore_total, + hashcat_status->restore_percent); + + break; + + case PROGRESS_MODE_KEYSPACE_UNKNOWN: + event_log_info (hashcat_ctx, "Restore.Point....: %" PRIu64, hashcat_status->restore_point); @@ -1328,7 +1339,7 @@ void status_display (hashcat_ctx_t *hashcat_ctx) if (device_info->hwmon_dev == NULL) continue; event_log_info (hashcat_ctx, - "HWMon.Dev.#%d.....: %s", device_id + 1, + "Hardware.Mon.#%d..: %s", device_id + 1, device_info->hwmon_dev); } } @@ -1398,7 +1409,7 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (device_info->skipped_dev == true) continue; event_log_info (hashcat_ctx, - "Speed.Dev.#%d.....: %9sH/s (%0.2fms) @ Accel:%d Loops:%d Thr:%d Vec:%d", device_id + 1, + "Speed.#%d.........: %9sH/s (%0.2fms) @ Accel:%d Loops:%d Thr:%d Vec:%d", device_id + 1, device_info->speed_sec_dev, device_info->exec_msec_dev, device_info->kernel_accel_dev, @@ -1410,7 +1421,7 @@ void status_benchmark (hashcat_ctx_t *hashcat_ctx) if (hashcat_status->device_info_active > 1) { event_log_info (hashcat_ctx, - "Speed.Dev.#*.....: %9sH/s", + "Speed.#*.........: %9sH/s", hashcat_status->speed_sec_all); } @@ -1475,7 +1486,7 @@ void status_speed (hashcat_ctx_t *hashcat_ctx) if (device_info->skipped_dev == true) continue; event_log_info (hashcat_ctx, - "Speed.Dev.#%d.....: %9sH/s (%0.2fms)", device_id + 1, + "Speed.#%d.........: %9sH/s (%0.2fms)", device_id + 1, device_info->speed_sec_dev, device_info->exec_msec_dev); } @@ -1483,7 +1494,7 @@ void status_speed (hashcat_ctx_t *hashcat_ctx) if (hashcat_status->device_info_active > 1) { event_log_info (hashcat_ctx, - "Speed.Dev.#*.....: %9sH/s", + "Speed.#*.........: %9sH/s", hashcat_status->speed_sec_all); } @@ -1548,7 +1559,7 @@ void status_progress (hashcat_ctx_t *hashcat_ctx) if (device_info->skipped_dev == true) continue; event_log_info (hashcat_ctx, - "Progress.Dev.#%d..: %" PRIu64, device_id + 1, + "Progress.#%d......: %" PRIu64, device_id + 1, device_info->progress_dev); } @@ -1559,7 +1570,7 @@ void status_progress (hashcat_ctx_t *hashcat_ctx) if (device_info->skipped_dev == true) continue; event_log_info (hashcat_ctx, - "Runtime.Dev.#%d...: %0.2fms", device_id + 1, + "Runtime.#%d.......: %0.2fms", device_id + 1, device_info->runtime_msec_dev); } diff --git a/src/usage.c b/src/usage.c index 0fa380260..e272e903d 100644 --- a/src/usage.c +++ b/src/usage.c @@ -115,6 +115,7 @@ static const char *const USAGE_BIG[] = " -i, --increment | | Enable mask increment mode |", " --increment-min | Num | Start mask incrementing at X | --increment-min=4", " --increment-max | Num | Stop mask incrementing at X | --increment-max=8", + " -S, --slow-candidates | | Enable slower (but advanced) candidate generators |", "", "- [ Hash modes ] -", "", diff --git a/src/user_options.c b/src/user_options.c index bad70d582..a473ebb03 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -14,14 +14,14 @@ #include "outfile.h" #include "user_options.h" -static const char *short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:c:p:s:l:1:2:3:4:iIbw:O"; +static const char *short_options = "hVvm:a:r:j:k:g:o:t:d:D:n:u:c:p:s:l:1:2:3:4:iIbw:OS"; static const struct option long_options[] = { {"advice-disable", no_argument, NULL, IDX_ADVICE_DISABLE}, {"attack-mode", required_argument, NULL, IDX_ATTACK_MODE}, - {"benchmark", no_argument, NULL, IDX_BENCHMARK}, {"benchmark-all", no_argument, NULL, IDX_BENCHMARK_ALL}, + {"benchmark", no_argument, NULL, IDX_BENCHMARK}, {"bitmap-max", required_argument, NULL, IDX_BITMAP_MAX}, {"bitmap-min", required_argument, NULL, IDX_BITMAP_MIN}, {"cpu-affinity", required_argument, NULL, IDX_CPU_AFFINITY}, @@ -77,9 +77,9 @@ static const struct option long_options[] = {"outfile-check-timer", required_argument, NULL, IDX_OUTFILE_CHECK_TIMER}, {"outfile-format", required_argument, NULL, IDX_OUTFILE_FORMAT}, {"outfile", required_argument, NULL, IDX_OUTFILE}, - {"wordlist-autohex-disable", no_argument, NULL, IDX_WORDLIST_AUTOHEX_DISABLE}, {"potfile-disable", no_argument, NULL, IDX_POTFILE_DISABLE}, {"potfile-path", required_argument, NULL, IDX_POTFILE_PATH}, + {"progress-only", no_argument, NULL, IDX_PROGRESS_ONLY}, {"quiet", no_argument, NULL, IDX_QUIET}, {"remove", no_argument, NULL, IDX_REMOVE}, {"remove-timer", required_argument, NULL, IDX_REMOVE_TIMER}, @@ -91,23 +91,24 @@ static const struct option long_options[] = {"rules-file", required_argument, NULL, IDX_RP_FILE}, {"runtime", required_argument, NULL, IDX_RUNTIME}, {"scrypt-tmto", required_argument, NULL, IDX_SCRYPT_TMTO}, - {"self-test-disable", no_argument, NULL, IDX_SELF_TEST_DISABLE}, {"segment-size", required_argument, NULL, IDX_SEGMENT_SIZE}, + {"self-test-disable", no_argument, NULL, IDX_SELF_TEST_DISABLE}, {"separator", required_argument, NULL, IDX_SEPARATOR}, {"seperator", required_argument, NULL, IDX_SEPARATOR}, {"session", required_argument, NULL, IDX_SESSION}, {"show", no_argument, NULL, IDX_SHOW}, {"skip", required_argument, NULL, IDX_SKIP}, + {"slow-candidates", no_argument, NULL, IDX_SLOW_CANDIDATES}, + {"speed-only", no_argument, NULL, IDX_SPEED_ONLY}, {"status", no_argument, NULL, IDX_STATUS}, {"status-timer", required_argument, NULL, IDX_STATUS_TIMER}, {"stdout", no_argument, NULL, IDX_STDOUT_FLAG}, - {"speed-only", no_argument, NULL, IDX_SPEED_ONLY}, - {"progress-only", no_argument, NULL, IDX_PROGRESS_ONLY}, {"truecrypt-keyfiles", required_argument, NULL, IDX_TRUECRYPT_KEYFILES}, {"username", no_argument, NULL, IDX_USERNAME}, {"veracrypt-keyfiles", required_argument, NULL, IDX_VERACRYPT_KEYFILES}, {"veracrypt-pim", required_argument, NULL, IDX_VERACRYPT_PIM}, {"version", no_argument, NULL, IDX_VERSION}, + {"wordlist-autohex-disable", no_argument, NULL, IDX_WORDLIST_AUTOHEX_DISABLE}, {"workload-profile", required_argument, NULL, IDX_WORKLOAD_PROFILE}, {NULL, 0, NULL, 0 } }; @@ -128,8 +129,8 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->advice_disable = ADVICE_DISABLE; user_options->attack_mode = ATTACK_MODE; - user_options->benchmark = BENCHMARK; user_options->benchmark_all = BENCHMARK_ALL; + user_options->benchmark = BENCHMARK; user_options->bitmap_max = BITMAP_MAX; user_options->bitmap_min = BITMAP_MIN; user_options->cpu_affinity = NULL; @@ -139,9 +140,9 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->custom_charset_4 = NULL; user_options->debug_file = NULL; user_options->debug_mode = DEBUG_MODE; - user_options->example_hashes = EXAMPLE_HASHES; user_options->encoding_from = ENCODING_FROM; user_options->encoding_to = ENCODING_TO; + user_options->example_hashes = EXAMPLE_HASHES; user_options->force = FORCE; user_options->gpu_temp_abort = GPU_TEMP_ABORT; user_options->gpu_temp_disable = GPU_TEMP_DISABLE; @@ -154,9 +155,9 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->increment_max = INCREMENT_MAX; user_options->increment_min = INCREMENT_MIN; user_options->induction_dir = NULL; + user_options->keep_guessing = KEEP_GUESSING; user_options->kernel_accel = KERNEL_ACCEL; user_options->kernel_loops = KERNEL_LOOPS; - user_options->keep_guessing = KEEP_GUESSING; user_options->keyspace = KEYSPACE; user_options->left = LEFT; user_options->limit = LIMIT; @@ -175,7 +176,6 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->opencl_platforms = NULL; user_options->opencl_vector_width = OPENCL_VECTOR_WIDTH; user_options->optimized_kernel_enable = OPTIMIZED_KERNEL_ENABLE; - user_options->wordlist_autohex_disable = WORDLIST_AUTOHEX_DISABLE; user_options->outfile_autohex = OUTFILE_AUTOHEX; user_options->outfile_check_dir = NULL; user_options->outfile_check_timer = OUTFILE_CHECK_TIMER; @@ -183,6 +183,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->outfile = NULL; user_options->potfile_disable = POTFILE_DISABLE; user_options->potfile_path = NULL; + user_options->progress_only = PROGRESS_ONLY; user_options->quiet = QUIET; user_options->remove = REMOVE; user_options->remove_timer = REMOVE_TIMER; @@ -198,23 +199,24 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx) user_options->rule_buf_r = RULE_BUF_R; user_options->runtime = RUNTIME; user_options->scrypt_tmto = SCRYPT_TMTO; - user_options->self_test_disable = SELF_TEST_DISABLE; user_options->segment_size = SEGMENT_SIZE; + user_options->self_test_disable = SELF_TEST_DISABLE; user_options->separator = SEPARATOR; user_options->session = PROGNAME; user_options->show = SHOW; user_options->skip = SKIP; + user_options->slow_candidates = SLOW_CANDIDATES; + user_options->speed_only = SPEED_ONLY; user_options->status = STATUS; user_options->status_timer = STATUS_TIMER; user_options->stdout_flag = STDOUT_FLAG; - user_options->speed_only = SPEED_ONLY; - user_options->progress_only = PROGRESS_ONLY; user_options->truecrypt_keyfiles = NULL; user_options->usage = USAGE; user_options->username = USERNAME; user_options->veracrypt_keyfiles = NULL; user_options->veracrypt_pim = 0; user_options->version = VERSION; + user_options->wordlist_autohex_disable = WORDLIST_AUTOHEX_DISABLE; user_options->workload_profile = WORKLOAD_PROFILE; user_options->rp_files_cnt = 0; user_options->rp_files = (char **) hccalloc (256, sizeof (char *)); @@ -416,6 +418,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv) case IDX_CUSTOM_CHARSET_2: user_options->custom_charset_2 = optarg; break; case IDX_CUSTOM_CHARSET_3: user_options->custom_charset_3 = optarg; break; case IDX_CUSTOM_CHARSET_4: user_options->custom_charset_4 = optarg; break; + case IDX_SLOW_CANDIDATES: user_options->slow_candidates = true; break; } } @@ -445,16 +448,29 @@ int user_options_sanity (hashcat_ctx_t *hashcat_ctx) return -1; } - if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT) - && (user_options->attack_mode != ATTACK_MODE_COMBI) - && (user_options->attack_mode != ATTACK_MODE_BF) - && (user_options->attack_mode != ATTACK_MODE_HYBRID1) - && (user_options->attack_mode != ATTACK_MODE_HYBRID2) - && (user_options->attack_mode != ATTACK_MODE_NONE)) + if (user_options->slow_candidates == true) { - event_log_error (hashcat_ctx, "Invalid attack mode (-a) value specified."); + if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT) + && (user_options->attack_mode != ATTACK_MODE_BF)) + { + event_log_error (hashcat_ctx, "Invalid attack mode (-a) value specified in slow-candidates mode."); - return -1; + return -1; + } + } + else + { + if ((user_options->attack_mode != ATTACK_MODE_STRAIGHT) + && (user_options->attack_mode != ATTACK_MODE_COMBI) + && (user_options->attack_mode != ATTACK_MODE_BF) + && (user_options->attack_mode != ATTACK_MODE_HYBRID1) + && (user_options->attack_mode != ATTACK_MODE_HYBRID2) + && (user_options->attack_mode != ATTACK_MODE_NONE)) + { + event_log_error (hashcat_ctx, "Invalid attack mode (-a) value specified."); + + return -1; + } } if (user_options->hccapx_message_pair_chgd == true) @@ -1278,6 +1294,11 @@ void user_options_preprocess (hashcat_ctx_t *hashcat_ctx) user_options->quiet = true; } + if (user_options->slow_candidates == true) + { + user_options->opencl_vector_width = 1; + } + if (user_options->stdout_flag == true) { user_options->force = true; @@ -1646,27 +1667,35 @@ u64 user_options_extra_amplifier (hashcat_ctx_t *hashcat_ctx) const combinator_ctx_t *combinator_ctx = hashcat_ctx->combinator_ctx; const mask_ctx_t *mask_ctx = hashcat_ctx->mask_ctx; const straight_ctx_t *straight_ctx = hashcat_ctx->straight_ctx; + const user_options_t *user_options = hashcat_ctx->user_options; const user_options_extra_t *user_options_extra = hashcat_ctx->user_options_extra; - if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) + if (user_options->slow_candidates == true) { - if (straight_ctx->kernel_rules_cnt) - { - return straight_ctx->kernel_rules_cnt; - } + return 1; } - else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) + else { - if (combinator_ctx->combs_cnt) + if (user_options_extra->attack_kern == ATTACK_KERN_STRAIGHT) { - return combinator_ctx->combs_cnt; + if (straight_ctx->kernel_rules_cnt) + { + return straight_ctx->kernel_rules_cnt; + } } - } - else if (user_options_extra->attack_kern == ATTACK_KERN_BF) - { - if (mask_ctx->bfs_cnt) + else if (user_options_extra->attack_kern == ATTACK_KERN_COMBI) { - return mask_ctx->bfs_cnt; + if (combinator_ctx->combs_cnt) + { + return combinator_ctx->combs_cnt; + } + } + else if (user_options_extra->attack_kern == ATTACK_KERN_BF) + { + if (mask_ctx->bfs_cnt) + { + return mask_ctx->bfs_cnt; + } } } @@ -2340,6 +2369,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx) logfile_top_uint (user_options->scrypt_tmto); logfile_top_uint (user_options->segment_size); logfile_top_uint (user_options->self_test_disable); + logfile_top_uint (user_options->slow_candidates); logfile_top_uint (user_options->show); logfile_top_uint (user_options->speed_only); logfile_top_uint (user_options->status); diff --git a/src/wordlist.c b/src/wordlist.c index 5fc83c946..386c9819d 100644 --- a/src/wordlist.c +++ b/src/wordlist.c @@ -238,6 +238,51 @@ void get_next_word (hashcat_ctx_t *hashcat_ctx, FILE *fd, char **out_buf, u32 *o get_next_word (hashcat_ctx, fd, out_buf, out_len); } +void pw_pre_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len, const u8 *base_buf, const int base_len, const int rule_idx) +{ + if (device_param->pws_pre_cnt < device_param->kernel_power) + { + pw_pre_t *pw_pre = device_param->pws_pre_buf + device_param->pws_pre_cnt; + + memcpy (pw_pre->pw_buf, pw_buf, pw_len); + + pw_pre->pw_len = pw_len; + + if (base_buf != NULL) + { + memcpy (pw_pre->base_buf, base_buf, base_len); + + pw_pre->base_len = base_len; + } + + pw_pre->rule_idx = rule_idx; + + device_param->pws_pre_cnt++; + } + else + { + fprintf (stdout, "BUG pw_pre_add()!!\n"); + + return; + } +} + +void pw_base_add (hc_device_param_t *device_param, pw_pre_t *pw_pre) +{ + if (device_param->pws_base_cnt < device_param->kernel_power) + { + memcpy (device_param->pws_base_buf + device_param->pws_base_cnt, pw_pre, sizeof (pw_pre_t)); + + device_param->pws_base_cnt++; + } + else + { + fprintf (stderr, "BUG pw_base_add()!!\n"); + + return; + } +} + void pw_add (hc_device_param_t *device_param, const u8 *pw_buf, const int pw_len) { if (device_param->pws_cnt < device_param->kernel_power)