mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-25 09:28:20 +00:00
Add option for show opencl info and exit
This commit is contained in:
parent
438898bd43
commit
fdbc44ce6c
@ -187,8 +187,8 @@ _hashcat ()
|
||||
local HIDDEN_FILES_AGGRESIVE="exe|bin|pot|hcstat|dictstat|hcmask|hcchr|accepted|sh|cmd|restore"
|
||||
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-repeats --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --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 --potfile-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-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 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"
|
||||
local LONG_OPTS="--hash-type --attack-mode --version --help --eula --quiet --benchmark --benchmark-repeats --hex-salt --hex-wordlist --hex-charset --force --status --status-timer --machine-readable --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 --potfile-path --debug-mode --debug-file --induction-dir --segment-size --bitmap-min --bitmap-max --cpu-affinity --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 --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-repeats --status-timer --weak-hash-threshold --markov-hcstat --markov-threshold --runtime --session --timer --outfile --outfile-format --outfile-check-timer --outfile-check-dir --separator --remove-timer --potfile-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 --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=()
|
||||
|
@ -19,7 +19,7 @@ void check_hash (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, plai
|
||||
|
||||
int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hashconfig_t *hashconfig, hashes_t *hashes, const uint salt_pos);
|
||||
|
||||
int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfile_ctx_t *potfile_ctx, outfile_ctx_t *outfile_ctx, char *hash_or_file, const uint keyspace, const uint quiet, const uint benchmark, const uint stdout_flag, const uint username, const uint remove, const uint show, const uint left);
|
||||
int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfile_ctx_t *potfile_ctx, outfile_ctx_t *outfile_ctx, char *hash_or_file, const uint keyspace, const uint quiet, const uint benchmark, const bool opencl_info, const uint stdout_flag, const uint username, const uint remove, const uint show, const uint left);
|
||||
int hashes_init_stage2 (hashes_t *hashes, const hashconfig_t *hashconfig, opencl_ctx_t *opencl_ctx, const uint username, const uint remove, const uint show);
|
||||
|
||||
void hashes_destroy (hashes_t *hashes);
|
||||
|
@ -63,7 +63,7 @@ int run_cracker (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, hash
|
||||
int opencl_ctx_init (opencl_ctx_t *opencl_ctx, const char *opencl_platforms, const char *opencl_devices, const char *opencl_device_types, const uint opencl_vector_width, const uint opencl_vector_width_chgd, const uint nvidia_spin_damp, const uint nvidia_spin_damp_chgd, const uint workload_profile, const uint kernel_accel, const uint kernel_accel_chgd, const uint kernel_loops, const uint kernel_loops_chgd, const uint keyspace, const uint stdout_flag);
|
||||
void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx);
|
||||
|
||||
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const tuning_db_t *tuning_db, const uint attack_mode, const bool quiet, const bool force, const bool benchmark, const bool machine_readable, const uint algorithm_pos);
|
||||
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const tuning_db_t *tuning_db, const uint attack_mode, const bool quiet, const bool force, const bool benchmark, const bool opencl_info, const bool machine_readable, const uint algorithm_pos);
|
||||
void opencl_ctx_devices_destroy (opencl_ctx_t *opencl_ctx);
|
||||
|
||||
int opencl_session_begin (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const hashes_t *hashes, const session_ctx_t *session_ctx);
|
||||
|
@ -626,7 +626,7 @@ int check_cracked (opencl_ctx_t *opencl_ctx, hc_device_param_t *device_param, ha
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfile_ctx_t *potfile_ctx, outfile_ctx_t *outfile_ctx, char *hash_or_file, const uint keyspace, const uint quiet, const uint benchmark, const uint stdout_flag, const uint username, const uint remove, const uint show, const uint left)
|
||||
int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfile_ctx_t *potfile_ctx, outfile_ctx_t *outfile_ctx, char *hash_or_file, const uint keyspace, const uint quiet, const uint benchmark, const bool opencl_info, const uint stdout_flag, const uint username, const uint remove, const uint show, const uint left)
|
||||
{
|
||||
/**
|
||||
* load hashes, part I: find input mode, count hashes
|
||||
@ -811,7 +811,7 @@ int hashes_init_stage1 (hashes_t *hashes, const hashconfig_t *hashconfig, potfil
|
||||
|
||||
uint hashes_cnt = 0;
|
||||
|
||||
if (benchmark == 0)
|
||||
if (benchmark == 0 && !opencl_info)
|
||||
{
|
||||
if (keyspace == 1)
|
||||
{
|
||||
|
@ -248,6 +248,7 @@ int main (int argc, char **argv)
|
||||
uint increment_min = INCREMENT_MIN;
|
||||
uint increment_max = INCREMENT_MAX;
|
||||
char *cpu_affinity = NULL;
|
||||
bool opencl_info = 0;
|
||||
char *opencl_devices = NULL;
|
||||
char *opencl_platforms = NULL;
|
||||
char *opencl_device_types = NULL;
|
||||
@ -330,6 +331,7 @@ int main (int argc, char **argv)
|
||||
#define IDX_MARKOV_THRESHOLD 't'
|
||||
#define IDX_MARKOV_HCSTAT 0xff24
|
||||
#define IDX_CPU_AFFINITY 0xff25
|
||||
#define IDX_OPENCL_INFO 'I'
|
||||
#define IDX_OPENCL_DEVICES 'd'
|
||||
#define IDX_OPENCL_PLATFORMS 0xff72
|
||||
#define IDX_OPENCL_DEVICE_TYPES 'D'
|
||||
@ -356,7 +358,7 @@ int main (int argc, char **argv)
|
||||
#define IDX_CUSTOM_CHARSET_3 '3'
|
||||
#define IDX_CUSTOM_CHARSET_4 '4'
|
||||
|
||||
char short_options[] = "hVvm:a:r:j:k:g:o:t:d:D:n:u:c:p:s:l:1:2:3:4:ibw:";
|
||||
char short_options[] = "hVvm:a:r:j:k:g:o:t:d:D:n:u:c:p:s:l:1:2:3:4:iIbw:";
|
||||
|
||||
struct option long_options[] =
|
||||
{
|
||||
@ -410,6 +412,7 @@ int main (int argc, char **argv)
|
||||
{"markov-threshold", required_argument, 0, IDX_MARKOV_THRESHOLD},
|
||||
{"markov-hcstat", required_argument, 0, IDX_MARKOV_HCSTAT},
|
||||
{"cpu-affinity", required_argument, 0, IDX_CPU_AFFINITY},
|
||||
{"opencl-info", no_argument, 0, IDX_OPENCL_INFO},
|
||||
{"opencl-devices", required_argument, 0, IDX_OPENCL_DEVICES},
|
||||
{"opencl-platforms", required_argument, 0, IDX_OPENCL_PLATFORMS},
|
||||
{"opencl-device-types", required_argument, 0, IDX_OPENCL_DEVICE_TYPES},
|
||||
@ -790,6 +793,7 @@ int main (int argc, char **argv)
|
||||
case IDX_HEX_SALT: hex_salt = 1; break;
|
||||
case IDX_HEX_WORDLIST: hex_wordlist = 1; break;
|
||||
case IDX_CPU_AFFINITY: cpu_affinity = optarg; break;
|
||||
case IDX_OPENCL_INFO: opencl_info = 1; break;
|
||||
case IDX_OPENCL_DEVICES: opencl_devices = optarg; break;
|
||||
case IDX_OPENCL_PLATFORMS: opencl_platforms = optarg; break;
|
||||
case IDX_OPENCL_DEVICE_TYPES: opencl_device_types = optarg; break;
|
||||
@ -841,6 +845,17 @@ int main (int argc, char **argv)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (opencl_info)
|
||||
{
|
||||
quiet = 1;
|
||||
gpu_temp_disable = 1;
|
||||
potfile_disable = 1;
|
||||
restore_disable = 1;
|
||||
markov_disable = 1;
|
||||
logfile_disable = 1;
|
||||
stdout_flag = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inform user things getting started,
|
||||
* - this is giving us a visual header before preparations start, so we do not need to clear them afterwards
|
||||
@ -1701,6 +1716,13 @@ int main (int argc, char **argv)
|
||||
|
||||
data.opencl_ctx = opencl_ctx;
|
||||
|
||||
if (opencl_info)
|
||||
{
|
||||
opencl_platforms = NULL;
|
||||
opencl_devices = NULL;
|
||||
opencl_device_types = strdup("1,2,3");
|
||||
}
|
||||
|
||||
opencl_ctx_init (opencl_ctx, opencl_platforms, opencl_devices, opencl_device_types, opencl_vector_width, opencl_vector_width_chgd, nvidia_spin_damp, nvidia_spin_damp_chgd, workload_profile, kernel_accel, kernel_accel_chgd, kernel_loops, kernel_loops_chgd, keyspace, stdout_flag);
|
||||
|
||||
/**
|
||||
@ -1892,7 +1914,7 @@ int main (int argc, char **argv)
|
||||
|
||||
data.hashes = hashes;
|
||||
|
||||
const int rc_hashes_init_stage1 = hashes_init_stage1 (hashes, hashconfig, potfile_ctx, outfile_ctx, myargv[optind], keyspace, quiet, benchmark, stdout_flag, username, remove, show, left);
|
||||
const int rc_hashes_init_stage1 = hashes_init_stage1 (hashes, hashconfig, potfile_ctx, outfile_ctx, myargv[optind], keyspace, quiet, benchmark, opencl_info, stdout_flag, username, remove, show, left);
|
||||
|
||||
if (rc_hashes_init_stage1 == -1) return -1;
|
||||
|
||||
@ -2390,7 +2412,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
const int rc_devices_init = opencl_ctx_devices_init (opencl_ctx, hashconfig, tuning_db, attack_mode, quiet, force, benchmark, machine_readable, algorithm_pos);
|
||||
const int rc_devices_init = opencl_ctx_devices_init (opencl_ctx, hashconfig, tuning_db, attack_mode, quiet, force, benchmark, opencl_info, machine_readable, algorithm_pos);
|
||||
|
||||
if (rc_devices_init == -1) return -1;
|
||||
|
||||
|
55
src/opencl.c
55
src/opencl.c
@ -1497,7 +1497,7 @@ void opencl_ctx_destroy (opencl_ctx_t *opencl_ctx)
|
||||
myfree (opencl_ctx);
|
||||
}
|
||||
|
||||
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const tuning_db_t *tuning_db, const uint attack_mode, const bool quiet, const bool force, const bool benchmark, const bool machine_readable, const uint algorithm_pos)
|
||||
int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashconfig, const tuning_db_t *tuning_db, const uint attack_mode, const bool quiet, const bool force, const bool benchmark, const bool opencl_info, const bool machine_readable, const uint algorithm_pos)
|
||||
{
|
||||
if (opencl_ctx->disable == 1) return 0;
|
||||
|
||||
@ -1519,6 +1519,10 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
|
||||
|
||||
u32 devices_active = 0;
|
||||
|
||||
if (opencl_info) {
|
||||
fprintf(stdout, "OpenCL Info:\n");
|
||||
}
|
||||
|
||||
for (uint platform_id = 0; platform_id < platforms_cnt; platform_id++)
|
||||
{
|
||||
cl_int CL_err = CL_SUCCESS;
|
||||
@ -1592,6 +1596,33 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
|
||||
platform_skipped = 2;
|
||||
}
|
||||
|
||||
if (opencl_info)
|
||||
{
|
||||
char platform_name[HCBUFSIZ_TINY] = { 0 };
|
||||
|
||||
CL_err = hc_clGetPlatformInfo (opencl_ctx->ocl, platform, CL_PLATFORM_NAME, HCBUFSIZ_TINY, platform_name, NULL);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: clGetPlatformInfo(): %s\n", val2cstr_cl (CL_err));
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
char platform_version[HCBUFSIZ_TINY] = { 0 };
|
||||
|
||||
CL_err = hc_clGetPlatformInfo (opencl_ctx->ocl, platform, CL_PLATFORM_VERSION, sizeof (platform_version), platform_version, NULL);
|
||||
|
||||
if (CL_err != CL_SUCCESS)
|
||||
{
|
||||
log_error ("ERROR: clGetPlatformInfo(): %s\n", val2cstr_cl (CL_err));
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
fprintf (stdout, "\nPlatform ID #%u\n Vendor : %s\n Name : %s\n Version : %s\n\n", platform_id, platform_vendor, platform_name, platform_version);
|
||||
}
|
||||
|
||||
if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
|
||||
{
|
||||
if (machine_readable == 0)
|
||||
@ -1796,8 +1827,6 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
|
||||
|
||||
device_param->opencl_v12 = device_opencl_version[9] > '1' || device_opencl_version[11] >= '2';
|
||||
|
||||
myfree (device_opencl_version);
|
||||
|
||||
// vector_width
|
||||
|
||||
cl_uint vector_width;
|
||||
@ -2229,6 +2258,21 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
|
||||
|
||||
// display results
|
||||
|
||||
if (opencl_info)
|
||||
{
|
||||
char *format = " Device ID #%u\n Type : %s\n Vendor ID : %u\n Vendor : %s\n Name : %s\n Processor(s) : %u\n Clock : %u\n Memory : %lu/%lu MB allocatable\n OpenCL Version : %s\n\n";
|
||||
|
||||
fprintf(stdout, format, device_id,
|
||||
((device_type & CL_DEVICE_TYPE_CPU) ? "Cpu" : ((device_type & CL_DEVICE_TYPE_GPU) ? "Gpu" : "Accelerator")),
|
||||
device_vendor_id, device_vendor,
|
||||
device_name, device_processors,
|
||||
device_maxclock_frequency,
|
||||
device_maxmem_alloc/1024/1024, device_global_mem/1024/1024,
|
||||
device_opencl_version);
|
||||
}
|
||||
|
||||
myfree (device_opencl_version);
|
||||
|
||||
if ((benchmark == 1 || quiet == 0) && (algorithm_pos == 0))
|
||||
{
|
||||
if (machine_readable == 0)
|
||||
@ -2409,6 +2453,11 @@ int opencl_ctx_devices_init (opencl_ctx_t *opencl_ctx, const hashconfig_t *hashc
|
||||
}
|
||||
}
|
||||
|
||||
if (opencl_info)
|
||||
{
|
||||
exit(0);
|
||||
}
|
||||
|
||||
if (devices_active == 0)
|
||||
{
|
||||
log_error ("ERROR: No devices found/left");
|
||||
|
@ -73,6 +73,7 @@ static const char *USAGE_BIG[] =
|
||||
" --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, separate with comma | --cpu-affinity=1,2,3",
|
||||
" -I, --opencl-info | | Show info about OpenCL platforms/devices detected | -I",
|
||||
" --opencl-platforms | Str | OpenCL platforms to use, separate with comma | --opencl-platforms=2",
|
||||
" -d, --opencl-devices | Str | OpenCL devices to use, separate with comma | -d 1",
|
||||
" -D, --opencl-device-types | Str | OpenCL device-types to use, separate with comma | -D 1",
|
||||
|
Loading…
Reference in New Issue
Block a user