Prepare new --hook-threads feature

pull/2216/head
Jens Steube 5 years ago
parent 9a4bb20135
commit d71afd6d7a

@ -250,8 +250,8 @@ _hashcat ()
local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s ?h ?H'
local SHORT_OPTS="-m -a -V -h -b -t -T -o -p -c -d -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-json --status-timer --stdin-timeout-abort --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 --backend-info --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password"
local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --stdin-timeout-abort --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 --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-session-whitelist"
local LONG_OPTS="--hash-type --attack-mode --version --help --quiet --benchmark --benchmark-all --hex-salt --hex-wordlist --hex-charset --force --status --status-json --status-timer --stdin-timeout-abort --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 --backend-info --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-disable --hwmon-temp-abort --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --stdout --keep-guessing --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --optimized-kernel-enable --self-test-disable --slow-candidates --brain-server --brain-client --brain-client-features --brain-host --brain-port --brain-session --brain-session-whitelist --brain-password"
local OPTIONS="-m -a -t -o -p -c -d -w -n -u -j -k -r -g -1 -2 -3 -4 -s -l --hash-type --attack-mode --status-timer --stdin-timeout-abort --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 --backend-devices --opencl-device-types --backend-vector-width --workload-profile --kernel-accel --kernel-loops --kernel-threads --spin-damp --hwmon-temp-abort --skip --limit --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --hook-threads --increment-min --increment-max --scrypt-tmto --keyboard-layout-mapping --truecrypt-keyfiles --veracrypt-keyfiles --veracrypt-pim-start --veracrypt-pim-stop --hccapx-message-pair --nonce-error-corrections --encoding-from --encoding-to --brain-client-features --brain-host --brain-password --brain-port --brain-session --brain-session-whitelist"
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"

@ -64,6 +64,8 @@ bool hc_string_is_digit (const char *s);
void hc_string_trim_trailing (char *s);
void hc_string_trim_leading (char *s);
int hc_get_processor_count ();
bool hc_same_files (char *file1, char *file2);
u32 hc_strtoul (const char *nptr, char **endptr, int base);

@ -583,6 +583,7 @@ typedef enum user_options_defaults
HEX_CHARSET = false,
HEX_SALT = false,
HEX_WORDLIST = false,
HOOK_THREADS = 0,
INCREMENT = false,
INCREMENT_MAX = PW_MAX,
INCREMENT_MIN = 1,
@ -647,60 +648,61 @@ typedef enum user_options_map
IDX_ATTACK_MODE = 'a',
IDX_BACKEND_DEVICES = 'd',
IDX_BACKEND_INFO = 'I',
IDX_BACKEND_VECTOR_WIDTH = 0xff27,
IDX_BENCHMARK_ALL = 0xff01,
IDX_BACKEND_VECTOR_WIDTH = 0xff01,
IDX_BENCHMARK_ALL = 0xff02,
IDX_BENCHMARK = 'b',
IDX_BITMAP_MAX = 0xff02,
IDX_BITMAP_MIN = 0xff03,
IDX_BITMAP_MAX = 0xff03,
IDX_BITMAP_MIN = 0xff04,
#ifdef WITH_BRAIN
IDX_BRAIN_CLIENT = 'z',
IDX_BRAIN_CLIENT_FEATURES = 0xff04,
IDX_BRAIN_HOST = 0xff05,
IDX_BRAIN_PASSWORD = 0xff06,
IDX_BRAIN_PORT = 0xff07,
IDX_BRAIN_SERVER = 0xff08,
IDX_BRAIN_SESSION = 0xff09,
IDX_BRAIN_SESSION_WHITELIST = 0xff0a,
IDX_BRAIN_CLIENT_FEATURES = 0xff05,
IDX_BRAIN_HOST = 0xff06,
IDX_BRAIN_PASSWORD = 0xff07,
IDX_BRAIN_PORT = 0xff08,
IDX_BRAIN_SERVER = 0xff09,
IDX_BRAIN_SESSION = 0xff0a,
IDX_BRAIN_SESSION_WHITELIST = 0xff0b,
#endif
IDX_CPU_AFFINITY = 0xff0b,
IDX_CPU_AFFINITY = 0xff0c,
IDX_CUSTOM_CHARSET_1 = '1',
IDX_CUSTOM_CHARSET_2 = '2',
IDX_CUSTOM_CHARSET_3 = '3',
IDX_CUSTOM_CHARSET_4 = '4',
IDX_DEBUG_FILE = 0xff0c,
IDX_DEBUG_MODE = 0xff0d,
IDX_ENCODING_FROM = 0xff0e,
IDX_ENCODING_TO = 0xff0f,
IDX_EXAMPLE_HASHES = 0xff10,
IDX_FORCE = 0xff11,
IDX_HWMON_DISABLE = 0xff12,
IDX_HWMON_TEMP_ABORT = 0xff13,
IDX_DEBUG_FILE = 0xff0d,
IDX_DEBUG_MODE = 0xff0e,
IDX_ENCODING_FROM = 0xff0f,
IDX_ENCODING_TO = 0xff10,
IDX_EXAMPLE_HASHES = 0xff11,
IDX_FORCE = 0xff12,
IDX_HWMON_DISABLE = 0xff13,
IDX_HWMON_TEMP_ABORT = 0xff14,
IDX_HASH_MODE = 'm',
IDX_HCCAPX_MESSAGE_PAIR = 0xff14,
IDX_HCCAPX_MESSAGE_PAIR = 0xff15,
IDX_HELP = 'h',
IDX_HEX_CHARSET = 0xff15,
IDX_HEX_SALT = 0xff16,
IDX_HEX_WORDLIST = 0xff17,
IDX_HEX_CHARSET = 0xff16,
IDX_HEX_SALT = 0xff17,
IDX_HEX_WORDLIST = 0xff18,
IDX_HOOK_THREADS = 0xff19,
IDX_INCREMENT = 'i',
IDX_INCREMENT_MAX = 0xff18,
IDX_INCREMENT_MIN = 0xff19,
IDX_INDUCTION_DIR = 0xff1a,
IDX_KEEP_GUESSING = 0xff1b,
IDX_INCREMENT_MAX = 0xff1a,
IDX_INCREMENT_MIN = 0xff1b,
IDX_INDUCTION_DIR = 0xff1c,
IDX_KEEP_GUESSING = 0xff1d,
IDX_KERNEL_ACCEL = 'n',
IDX_KERNEL_LOOPS = 'u',
IDX_KERNEL_THREADS = 'T',
IDX_KEYBOARD_LAYOUT_MAPPING = 0xff1c,
IDX_KEYSPACE = 0xff1d,
IDX_LEFT = 0xff1e,
IDX_KEYBOARD_LAYOUT_MAPPING = 0xff1e,
IDX_KEYSPACE = 0xff1f,
IDX_LEFT = 0xff20,
IDX_LIMIT = 'l',
IDX_LOGFILE_DISABLE = 0xff1f,
IDX_LOOPBACK = 0xff20,
IDX_MACHINE_READABLE = 0xff21,
IDX_MARKOV_CLASSIC = 0xff22,
IDX_MARKOV_DISABLE = 0xff23,
IDX_MARKOV_HCSTAT2 = 0xff24,
IDX_LOGFILE_DISABLE = 0xff21,
IDX_LOOPBACK = 0xff22,
IDX_MACHINE_READABLE = 0xff23,
IDX_MARKOV_CLASSIC = 0xff24,
IDX_MARKOV_DISABLE = 0xff25,
IDX_MARKOV_HCSTAT2 = 0xff26,
IDX_MARKOV_THRESHOLD = 't',
IDX_NONCE_ERROR_CORRECTIONS = 0xff25,
IDX_NONCE_ERROR_CORRECTIONS = 0xff27,
IDX_OPENCL_DEVICE_TYPES = 'D',
IDX_OPTIMIZED_KERNEL_ENABLE = 'O',
IDX_OUTFILE_AUTOHEX_DISABLE = 0xff28,
@ -1916,6 +1918,7 @@ typedef struct user_options
u32 hwmon_temp_abort;
int hash_mode;
u32 hccapx_message_pair;
u32 hook_threads;
u32 increment_max;
u32 increment_min;
u32 kernel_accel;

@ -1043,6 +1043,12 @@ int hashcat_session_init (hashcat_ctx_t *hashcat_ctx, const char *install_folder
setup_umask ();
/**
* Find number of physical CPU cores
*/
user_options->hook_threads = hc_get_processor_count ();
/**
* tuning db
*/

@ -609,6 +609,27 @@ void hc_string_trim_trailing (char *s)
s[new_len] = 0;
}
int hc_get_processor_count ()
{
int cnt = 0;
#if defined (_WIN)
SYSTEM_INFO info;
GetSystemInfo (&info);
cnt = (int) info.dwNumberOfProcessors;
#else
cnt = (int) sysconf (_SC_NPROCESSORS_ONLN);
#endif
return cnt;
}
bool hc_same_files (char *file1, char *file2)
{
if ((file1 != NULL) && (file2 != NULL))

@ -88,6 +88,7 @@ static const char *const USAGE_BIG_PRE_HASHMODES[] =
" --bitmap-min | Num | Sets minimum bits allowed for bitmaps to X | --bitmap-min=24",
" --bitmap-max | Num | Sets maximum bits allowed for bitmaps to X | --bitmap-max=24",
" --cpu-affinity | Str | Locks to CPU devices, separated with commas | --cpu-affinity=1,2,3",
" --hook-threads | Num | Sets number of threads for a hook (per compute unit) | --hook-threads=8",
" --example-hashes | | Show an example hash for each hash-mode |",
" -I, --backend-info | | Show info about detected backend API devices | -I",
" -d, --backend-devices | Str | Backend devices to use, separated with commas | -d 1",

@ -58,6 +58,7 @@ static const struct option long_options[] =
{"hex-charset", no_argument, NULL, IDX_HEX_CHARSET},
{"hex-salt", no_argument, NULL, IDX_HEX_SALT},
{"hex-wordlist", no_argument, NULL, IDX_HEX_WORDLIST},
{"hook-threads", required_argument, NULL, IDX_HOOK_THREADS},
{"increment-max", required_argument, NULL, IDX_INCREMENT_MAX},
{"increment-min", required_argument, NULL, IDX_INCREMENT_MIN},
{"increment", no_argument, NULL, IDX_INCREMENT},
@ -185,6 +186,7 @@ int user_options_init (hashcat_ctx_t *hashcat_ctx)
user_options->hex_charset = HEX_CHARSET;
user_options->hex_salt = HEX_SALT;
user_options->hex_wordlist = HEX_WORDLIST;
user_options->hook_threads = HOOK_THREADS;
user_options->increment = INCREMENT;
user_options->increment_max = INCREMENT_MAX;
user_options->increment_min = INCREMENT_MIN;
@ -321,6 +323,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
case IDX_BITMAP_MAX:
case IDX_INCREMENT_MIN:
case IDX_INCREMENT_MAX:
case IDX_HOOK_THREADS:
#ifdef WITH_BRAIN
case IDX_BRAIN_PORT:
#endif
@ -457,6 +460,7 @@ int user_options_getopt (hashcat_ctx_t *hashcat_ctx, int argc, char **argv)
case IDX_SEPARATOR: user_options->separator = optarg[0]; break;
case IDX_BITMAP_MIN: user_options->bitmap_min = hc_strtoul (optarg, NULL, 10); break;
case IDX_BITMAP_MAX: user_options->bitmap_max = hc_strtoul (optarg, NULL, 10); break;
case IDX_HOOK_THREADS: user_options->hook_threads = hc_strtoul (optarg, NULL, 10); break;
case IDX_INCREMENT: user_options->increment = true; break;
case IDX_INCREMENT_MIN: user_options->increment_min = hc_strtoul (optarg, NULL, 10);
user_options->increment_min_chgd = true; break;
@ -2822,6 +2826,7 @@ void user_options_logger (hashcat_ctx_t *hashcat_ctx)
logfile_top_uint (user_options->hex_charset);
logfile_top_uint (user_options->hex_salt);
logfile_top_uint (user_options->hex_wordlist);
logfile_top_uint (user_options->hook_threads);
logfile_top_uint (user_options->increment);
logfile_top_uint (user_options->increment_max);
logfile_top_uint (user_options->increment_min);

Loading…
Cancel
Save