1
0
mirror of https://github.com/hashcat/hashcat.git synced 2024-11-22 08:08:10 +00:00

Added option --opencl-device-types to filter for specific OpenCL device types

This commit is contained in:
Jens Steube 2016-01-12 00:44:28 +01:00
parent a1d470e932
commit 730044e26e
5 changed files with 69 additions and 14 deletions

View File

@ -38,6 +38,11 @@ File.: Host
Desc.: Added option --opencl-platform to select a single OpenCL platform in case multiple OpenCL platforms are present
Issue: 2
Type.: Feature
File.: Host
Desc.: Added option --opencl-device-types to filter for specific OpenCL device types
Issue: 2
Type.: Feature
File.: Host
Desc.: Implemented a new feature that allows to quit at next restore point update (and disable it)

View File

@ -174,6 +174,7 @@ _oclHashcat ()
local HASH_MODES="0 10 11 12 20 21 22 23 30 40 50 60 100 101 110 111 112 120 121 122 124 130 131 132 133 140 141 150 160 190 200 300 400 500 501 900 1000 1100 1400 1410 1420 1421 1430 1440 1441 1450 1460 1500 1600 1700 1710 1711 1720 1722 1730 1731 1740 1750 1760 1800 2100 2400 2410 2500 2600 2611 2612 2711 2811 3000 3100 3200 3710 3711 3800 4300 4400 4500 4700 4800 4900 5000 5100 5200 5300 5400 5500 5600 5700 5800 6000 6100 6211 6212 6213 6221 6222 6223 6231 6232 6233 6241 6242 6243 6300 6400 6500 6600 6700 6800 6900 7100 7200 7300 7400 7500 7600 7700 7800 7900 8000 8100 8200 8300 8400 8500 8600 8700 8800 8900 9000 9100 9200 9300 9400 9500 9600 9700 9710 9720 9800 9810 9820 9900 10000 10100 10200 10300 10400 10410 10420 10500 10600 10700 10800 10900 11000 11100 11200 11300 11400 11500 11600 11700 11800 11900 12000 12100 12200 12300 12400 12500 12600 12700 12800 12900 13000"
local ATTACK_MODES="0 1 3 6 7"
local OUTFILE_FORMATS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"
local OPENCL_DEVICE_TYPES="1 2 3"
local BENCHMARK_MODE="0 1"
local DEBUG_MODE="1 2 3 4"
local WORKLOAD_PROFILE="1 2 3"
@ -184,8 +185,8 @@ _oclHashcat ()
local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s'
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 -s -l"
local LONG_OPTS="--hash-type --attack-mode --version --help --eula --quiet --benchmark --benchmark-mode --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --status-automat --loopback --weak-hash-threshold --markov-hcstat --markov-disable --markov-classic --markov-threshold --runtime --session --restore --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --separator --show --left --username --remove --remove-timer --potfile-disable --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platform --workload-profile --kernel-accel --kernel-loops --gpu-temp-disable --gpu-temp-abort --gpu-temp-retain --powertune-enable --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --rules-cleanup --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --truecrypt-keyfiles"
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 --benchmark-mode --status-timer --weak-hash-threshold --markov-hcstat --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platform --workload-profile --kernel-accel --kernel-loops --gpu-temp-abort --gpu-temp-retain -disable --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"
local LONG_OPTS="--hash-type --attack-mode --version --help --eula --quiet --benchmark --benchmark-mode --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --status-automat --loopback --weak-hash-threshold --markov-hcstat --markov-disable --markov-classic --markov-threshold --runtime --session --restore --restore-disable --outfile --outfile-format --outfile-autohex-disable --outfile-check-timer --outfile-check-dir --separator --show --left --username --remove --remove-timer --potfile-disable --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platform --opencl-device-types --workload-profile --kernel-accel --kernel-loops --gpu-temp-disable --gpu-temp-abort --gpu-temp-retain --powertune-enable --skip --limit --keyspace --rule-left --rule-right --rules-file --generate-rules --generate-rules-func-min --generate-rules-func-max --generate-rules-seed --rules-cleanup --custom-charset1 --custom-charset2 --custom-charset3 --custom-charset4 --increment --increment-min --increment-max --logfile-disable --scrypt-tmto --truecrypt-keyfiles"
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 --benchmark-mode --status-timer --weak-hash-threshold --markov-hcstat --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --opencl-devices --opencl-platform --opencl-device-types --workload-profile --kernel-accel --kernel-loops --gpu-temp-abort --gpu-temp-retain -disable --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"
COMPREPLY=()
local cur="${COMP_WORDS[COMP_CWORD]}"
@ -265,6 +266,11 @@ _oclHashcat ()
return 0
;;
--opencl-device-types)
COMPREPLY=($(compgen -W "${OPENCL_DEVICE_TYPES}" -- ${cur}))
return 0
;;
--opencl-platform)
local icd_list=$(ls -1 /etc/OpenCL/vendors/*.icd 2> /dev/null)

View File

@ -1636,6 +1636,7 @@ void handle_show_request_lm (pot_t *pot, uint pot_cnt, char *input_buf, int inpu
void handle_left_request_lm (pot_t *pot, uint pot_cnt, char *input_buf, int input_len, hash_t *hash_left, hash_t *hash_right, int (*sort_by_pot) (const void *, const void *), FILE *out_fp);
uint devices_to_devicemask (char *opencl_devices);
cl_device_type setup_device_types_filter (char *opencl_device_types);
uint get_random_num (uint min, uint max);
uint32_t mydivc32 (const uint32_t dividend, const uint32_t divisor);
uint64_t mydivc64 (const uint64_t dividend, const uint64_t divisor);

View File

@ -386,6 +386,7 @@ const char *USAGE_BIG[] =
" --bitmap-max=NUM Maximum number of bits allowed for bitmaps",
" --cpu-affinity=STR Locks to CPU devices, separate with comma",
" -d, --opencl-devices=STR OpenCL devices to use, separate with comma",
" --opencl-device-types=STR OpenCL device-types to use, separate with comma, see references below",
" --opencl-platform=NUM OpenCL platform to use, in case multiple platforms are present",
" -w, --workload-profile=NUM Enable a specific workload profile, see references below",
" -n, --kernel-accel=NUM Workload tuning: 1, 8, 40, 80, 160",
@ -440,6 +441,12 @@ const char *USAGE_BIG[] =
" 0 = Manual Tuning",
" 1 = Performance Tuning, default",
"",
"* OpenCL device-types:",
"",
" 1 = CPU devices",
" 2 = GPU devices",
" 3 = Accelerator devices (FPGA, CELL Blade, etc.)",
"",
"* Outfile Formats:",
"",
" 1 = hash[:salt]",
@ -5102,6 +5109,7 @@ int main (int argc, char **argv)
char *cpu_affinity = NULL;
char *opencl_devices = NULL;
char *opencl_platform = NULL;
char *opencl_device_types = NULL;
char *truecrypt_keyfiles = NULL;
uint workload_profile = WORKLOAD_PROFILE;
uint kernel_accel = KERNEL_ACCEL;
@ -5176,6 +5184,7 @@ int main (int argc, char **argv)
#define IDX_CPU_AFFINITY 0xff25
#define IDX_OPENCL_DEVICES 'd'
#define IDX_OPENCL_PLATFORM 0xff72
#define IDX_OPENCL_DEVICE_TYPES 0xff73
#define IDX_WORKLOAD_PROFILE 'w'
#define IDX_KERNEL_ACCEL 'n'
#define IDX_KERNEL_LOOPS 'u'
@ -5256,6 +5265,7 @@ int main (int argc, char **argv)
{"cpu-affinity", required_argument, 0, IDX_CPU_AFFINITY},
{"opencl-devices", required_argument, 0, IDX_OPENCL_DEVICES},
{"opencl-platform", required_argument, 0, IDX_OPENCL_PLATFORM},
{"opencl-device-types", required_argument, 0, IDX_OPENCL_DEVICE_TYPES},
{"workload-profile", required_argument, 0, IDX_WORKLOAD_PROFILE},
{"kernel-accel", required_argument, 0, IDX_KERNEL_ACCEL},
{"kernel-loops", required_argument, 0, IDX_KERNEL_LOOPS},
@ -5544,6 +5554,8 @@ int main (int argc, char **argv)
case IDX_CPU_AFFINITY: cpu_affinity = optarg; break;
case IDX_OPENCL_DEVICES: opencl_devices = optarg; break;
case IDX_OPENCL_PLATFORM: opencl_platform = optarg; break;
case IDX_OPENCL_DEVICE_TYPES:
opencl_device_types = optarg; break;
case IDX_WORKLOAD_PROFILE: workload_profile = atoi (optarg); break;
case IDX_KERNEL_ACCEL: kernel_accel = atoi (optarg);
kernel_accel_chgd = 1; break;
@ -6377,6 +6389,7 @@ int main (int argc, char **argv)
logfile_top_string (debug_file);
logfile_top_string (opencl_devices);
logfile_top_string (opencl_platform);
logfile_top_string (opencl_device_types);
logfile_top_string (induction_dir);
logfile_top_string (markov_hcstat);
logfile_top_string (outfile);
@ -6386,6 +6399,12 @@ int main (int argc, char **argv)
logfile_top_string (session);
logfile_top_string (truecrypt_keyfiles);
/**
* device types filter
*/
cl_device_type device_types_filter = setup_device_types_filter (opencl_device_types);
/**
* devices
*/
@ -12405,7 +12424,6 @@ int main (int argc, char **argv)
CL_platform_sel -= 1;
cl_platform_id CL_platform = CL_platforms[CL_platform_sel];
char CL_platform_vendor[INFOSZ];
@ -12414,22 +12432,16 @@ int main (int argc, char **argv)
hc_clGetPlatformInfo (CL_platform, CL_PLATFORM_VENDOR, sizeof (CL_platform_vendor), CL_platform_vendor, NULL);
cl_device_type device_type_filter;
uint vendor_id;
if (strcmp (CL_platform_vendor, CL_VENDOR_AMD) == 0)
{
vendor_id = VENDOR_ID_AMD;
device_type_filter = CL_DEVICE_TYPE_GPU;
}
else if (strcmp (CL_platform_vendor, CL_VENDOR_NV) == 0)
{
vendor_id = VENDOR_ID_NV;
device_type_filter = CL_DEVICE_TYPE_GPU;
// make sure that we do not directly control the fan for NVidia
gpu_temp_retain = 0;
@ -12449,14 +12461,10 @@ int main (int argc, char **argv)
}
vendor_id = VENDOR_ID_GENERIC;
device_type_filter = CL_DEVICE_TYPE_DEFAULT;
}
else
{
vendor_id = VENDOR_ID_GENERIC;
device_type_filter = CL_DEVICE_TYPE_DEFAULT;
}
if (vendor_id == VENDOR_ID_GENERIC)
@ -12495,7 +12503,7 @@ int main (int argc, char **argv)
uint devices_all_cnt = 0;
hc_clGetDeviceIDs (CL_platform, device_type_filter, DEVICES_MAX, devices_all, (uint *) &devices_all_cnt);
hc_clGetDeviceIDs (CL_platform, device_types_filter, DEVICES_MAX, devices_all, (uint *) &devices_all_cnt);
int hm_adapters_all = devices_all_cnt;

View File

@ -5106,6 +5106,41 @@ void handle_left_request_lm (pot_t *pot, uint pot_cnt, char *input_buf, int inpu
if (weak_hash_found == 1) myfree (pot_right_ptr);
}
cl_device_type setup_device_types_filter (char *opencl_device_types)
{
cl_device_type device_types_filter = 0;
if (opencl_device_types)
{
char *device_types = strdup (opencl_device_types);
char *next = strtok (device_types, ",");
do
{
int device_type = atoi (next);
if (device_type < 1 || device_type > 3)
{
log_error ("ERROR: invalid device_type %u specified", device_type);
exit (-1);
}
device_types_filter |= 1 << device_type;
} while ((next = strtok (NULL, ",")) != NULL);
free (device_types);
}
else
{
device_types_filter = CL_DEVICE_TYPE_ALL;
}
return device_types_filter;
}
uint devices_to_devicemask (char *opencl_devices)
{
uint opencl_devicemask = 0;