Merge pull request #59 from philsmd/pr-fix-opencl-platform-descripion
[hashcat.git] / extra / tab_completion / oclHashcat.sh
1 OCLHASHCAT_ROOT="."
2
3 # helper functions
4 _oclHashcat_get_permutations ()
5 {
6 local num_devices=${1}
7 oclHashcat_devices_permutation=""
8
9 # Formula: Sum (k=1...num_devices) (num_devices! / (k! * (num_devices - k)!))
10 # or ofc (2 ^ num_devices) - 1
11 if [ "${num_devices}" -gt 0 ]; then
12
13 oclHashcat_devices_permutation=$(seq 1 $num_devices)
14
15 local k
16
17 for k in $(seq 2 $num_devices); do
18
19 if [ "${k}" -eq ${num_devices} ];then
20
21 oclHashcat_devices_permutation="${oclHashcat_devices_permutation} $(seq 1 $num_devices | tr '\n' ',' | sed 's/, *$//')"
22
23 else
24
25 local j
26 local max_pos=$((num_devices - ${k} + 1))
27
28 for j in $(seq 1 ${max_pos}); do
29
30 local max_value=$((j + ${k} - 1))
31
32 # init
33 local out_str=""
34
35 local l
36 for l in $(seq ${j} ${max_value}); do
37
38 if [ ${l} -gt ${j} ]; then
39 out_str=${out_str},
40 fi
41
42 out_str=${out_str}${l}
43
44 done
45
46 local chg_len=0
47 local last=$((k - 1))
48 local max_device=$((num_devices + 1))
49 local pos_changed=0
50
51 while [ "${chg_len}" -lt ${last} ]; do
52
53 local had_pos_changed=${pos_changed}
54 local old_chg_len=${chg_len}
55
56 local idx=$(((k - chg_len)))
57 local cur_num=$(echo ${out_str} | cut -d, -f ${idx})
58 local next_num=$((cur_num + 1))
59
60 if [ "${pos_changed}" -eq 0 ]; then
61
62 oclHashcat_devices_permutation="${oclHashcat_devices_permutation} ${out_str}"
63
64 else
65
66 pos_changed=0
67
68 fi
69
70 if [ "${next_num}" -lt ${max_device} -a "${next_num}" -le "${num_devices}" ]; then
71
72 out_str=$(echo ${out_str} | sed "s/,${cur_num},/,${next_num},/;s/,${cur_num}\$/,${next_num}/")
73
74 else
75
76 pos_changed=1
77 max_device=${cur_num}
78 chg_len=$((chg_len + 1))
79
80 fi
81
82 if [ "${had_pos_changed}" -eq 1 ];then
83
84 local changed=0
85 local m
86
87 for m in $(seq 1 ${old_chg_len}); do
88
89 local reset_idx=$((k - ${old_chg_len} + ${m}))
90 local last_num=$(echo ${out_str} | cut -d, -f ${reset_idx})
91 next_num=$((next_num + 1))
92
93 if [ "${next_num}" -lt ${max_device} -a "${next_num}" -le "${num_devices}" ]; then
94
95 out_str=$(echo ${out_str} | sed "s/,${last_num},/,${next_num},/;s/,${last_num}\$/,${next_num}/")
96 max_device=$((next_num + 2))
97 changed=$((changed + 1))
98
99 else
100 break
101 fi
102
103 done
104
105 if [ "${changed}" -gt 0 ]; then
106
107 max_device=$((num_devices + 1))
108 chg_len=0
109
110 fi
111
112 fi
113
114 done
115
116 done
117
118 fi
119
120 done
121 fi
122 }
123
124 _oclHashcat_opencl_devices ()
125 {
126 local num_devices=0
127
128 if which clinfo &> /dev/null; then
129
130 num_devices=$(clinfo 2>/dev/null 2> /dev/null)
131
132 elif which nvidia-smi &> /dev/null; then
133
134 num_devices=$(nvidia-smi --list-gpus | wc -l)
135
136 fi
137
138 return ${num_devices}
139 }
140
141 _oclHashcat_cpu_devices ()
142 {
143 local num_devices=0
144
145 if [ -f "/proc/cpuinfo" ]; then
146
147 num_devices=$(cat /proc/cpuinfo | grep -c processor 2> /dev/null)
148
149 fi
150
151 return ${num_devices}
152 }
153
154 _oclHashcat_contains ()
155 {
156 local haystack=${1}
157 local needle="${2}"
158
159 if echo "${haystack}" | grep -q " ${needle} " 2> /dev/null; then
160 return 0
161 elif echo "${haystack}" | grep -q "^${needle} " 2> /dev/null; then
162 return 0
163 elif echo "${haystack}" | grep -q " ${needle}\$" 2> /dev/null; then
164 return 0
165 fi
166
167 return 1
168 }
169
170 _oclHashcat ()
171 {
172 local VERSION=2.10
173
174 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"
175 local ATTACK_MODES="0 1 3 6 7"
176 local OUTFILE_FORMATS="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15"
177 local BENCHMARK_MODE="0 1"
178 local DEBUG_MODE="1 2 3 4"
179 local WORKLOAD_PROFILE="1 2 3"
180 local KERNEL_ACCEL="1 8 16 24 32 40 48 56 64 62 80 88 96 104 112 120 128 136 144 152 160"
181 local KERNEL_LOOPS="8 16 32 64 128 256 512 1024"
182 local HIDDEN_FILES="exe|bin|pot|hcstat|dictstat|accepted|sh|cmd|bat|restore"
183 local HIDDEN_FILES_AGGRESIVE="exe|bin|pot|hcstat|dictstat|hcmask|hcchr|accepted|sh|cmd|restore"
184 local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s'
185
186 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"
187 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"
188 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"
189
190 COMPREPLY=()
191 local cur="${COMP_WORDS[COMP_CWORD]}"
192 local prev="${COMP_WORDS[COMP_CWORD-1]}"
193
194 # if cur is just '=', ignore the '=' and treat it as only the prev was provided
195 if [[ "${cur}" == '=' ]]; then
196
197 cur=""
198
199 elif [[ "${prev}" == '=' ]]; then
200
201 if [ "${COMP_CWORD}" -gt 2 ]; then
202
203 prev="${COMP_WORDS[COMP_CWORD-2]}"
204
205 fi
206
207 fi
208
209 case "${prev}" in
210
211 -m|--hash-type)
212 COMPREPLY=($(compgen -W "${HASH_MODES}" -- ${cur}))
213 return 0
214 ;;
215
216 -a|--attack-mode)
217 COMPREPLY=($(compgen -W "${ATTACK_MODES}" -- ${cur}))
218 return 0
219 ;;
220
221 --outfile-format)
222 COMPREPLY=($(compgen -W "${OUTFILE_FORMATS}" -- ${cur}))
223 return 0
224 ;;
225
226 --benchmark-mode)
227 COMPREPLY=($(compgen -W "${BENCHMARK_MODE}" -- ${cur}))
228 return 0
229 ;;
230
231 -w|--workload-profile)
232 COMPREPLY=($(compgen -W "${WORKLOAD_PROFILE}" -- ${cur}))
233 return 0
234 ;;
235
236 -n|--kernel-accel)
237 COMPREPLY=($(compgen -W "${KERNEL_ACCEL}" -- ${cur}))
238 return 0
239 ;;
240
241 -u|--kernel-loops)
242 COMPREPLY=($(compgen -W "${KERNEL_LOOPS}" -- ${cur}))
243 return 0
244 ;;
245
246 -o|--outfile|-r|--rules-file|--debug-file)
247 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
248 COMPREPLY=($(compgen -W "${files}" -- ${cur})) # or $(compgen -f -X '*.+('${HIDDEN_FILES_AGGRESIVE}')' -- ${cur})
249 return 0
250 ;;
251
252 --markov-hcstat)
253 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null)
254 COMPREPLY=($(compgen -W "${files}" -- ${cur})) # or $(compgen -f -X '*.+('${HIDDEN_FILES_AGGRESIVE}')' -- ${cur})
255 return 0
256 ;;
257
258 -d|--opencl-devices)
259 _oclHashcat_opencl_devices
260 local num_devices=${?}
261
262 _oclHashcat_get_permutations ${num_devices}
263
264 COMPREPLY=($(compgen -W "${oclHashcat_devices_permutation}" -- ${cur}))
265 return 0
266 ;;
267
268 --opencl-platform)
269 local icd_list=$(ls -1 /etc/OpenCL/vendors/*.icd 2> /dev/null)
270
271 local architecture=$(getconf LONG_BIT 2> /dev/null)
272
273 if [ -z "${architecture}" ]; then
274 return 0
275 fi
276
277 # filter the icd_list (do not show 32 bit on 64bit systems and vice versa)
278
279 if [ "${architecture}" -eq 64 ]; then
280
281 icd_list=$(echo "${icd_list}" | grep -v "32.icd")
282
283 else
284
285 icd_list=$(echo "${icd_list}" | grep -v "64.icd")
286
287 fi
288
289 local number_icds=$(seq 1 $(echo "${icd_list}" | wc -l))
290
291 COMPREPLY=($(compgen -W "${number_icds}" -- ${cur}))
292
293 return 0
294 ;;
295
296 --cpu-affinity)
297 _oclHashcat_cpu_devices
298 local num_devices=${?}
299
300 _oclHashcat_get_permutations ${num_devices}
301
302 COMPREPLY=($(compgen -W "${oclHashcat_devices_permutation}" -- ${cur}))
303 return 0
304 ;;
305
306 -1|-2|-3|-4|--custom-charset1|--custom-charset2|--custom-charset3|--custom-charset4)
307 local mask=${BUILD_IN_CHARSETS}
308
309 if [ -e "${cur}" ]; then # should be hcchr file (but not enforced)
310
311 COMPREPLY=($(compgen -W "${cur}" -- ${cur}))
312 return 0
313
314 fi
315
316 if [ -n "${cur}" ]; then
317
318 local cur_var=$(echo "${cur}" | sed 's/\?$//')
319
320 mask="${mask} ${cur_var}"
321 local h
322 for h in ${mask}; do
323
324 if ! echo ${cur} | grep -q ${h} 2> /dev/null; then
325
326 if echo ${cur} | grep -q '?a' 2> /dev/null; then
327
328 if [[ "${h}" == "?l" ]] ; then
329 continue
330 elif [[ "${h}" == "?u" ]] ; then
331 continue
332 elif [[ "${h}" == "?d" ]] ; then
333 continue
334 elif [[ "${h}" == "?s" ]] ; then
335 continue
336 elif [[ "${h}" == "?b" ]] ; then
337 continue
338 fi
339
340 fi
341
342 mask="${mask} ${cur_var}${h}"
343
344 fi
345
346 done
347 fi
348
349 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null)
350
351 mask="${mask} ${files}"
352
353 COMPREPLY=($(compgen -W "${mask}" -- ${cur}))
354 return 0
355 ;;
356
357 -t|-p|-c|-j|-k|-g| \
358 --status-timer|--markov-threshold|--runtime|--session|--separator|--segment-size|--rule-left|--rule-right| \
359 --gpu-temp-abort|--gpu-temp-retain|--generate-rules|--generate-rules-func-min|--generate-rules-func-max| \
360 --increment-min|--increment-max|--remove-timer|--bitmap-min|--bitmap-max|--skip|--limit|--generate-rules-seed| \
361 --weak-hash-threshold|--outfile-check-timer|--outfile-check-dir|--induction-dir|--scrypt-tmto)
362 return 0
363 ;;
364
365 --debug-mode)
366 COMPREPLY=($(compgen -W "${DEBUG_MODE}" -- ${cur}))
367 return 0
368 ;;
369
370 --truecrypt-keyfiles)
371 # first: remove the quotes such that file matching is possible
372
373 local cur_part0=$(echo "${cur}" | grep -Eo '^("|'"'"')')
374
375 local cur_mod=$(echo "${cur}" | sed 's/^["'"'"']//')
376 local cur_part1=$(echo "${cur_mod}" | grep ',' 2> /dev/null | sed 's/^\(.*, *\)[^,]*$/\1/')
377 local cur_part2=$(echo "${cur_mod}" | sed 's/^.*, *\([^,]*\)$/\1/')
378
379 # generate lines with the file name and a duplicate of it with a comma at the end
380
381 local files=$(ls -d ${cur_part2}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null | sed 's/^\(.*\)$/\1\n\1,\n/' | sed "s/^/${cur_part0}${cur_part1}/" | sed "s/$/${cur_part0}/")
382 COMPREPLY=($(compgen -W "${files}" -- ${cur}))
383 return 0
384
385 esac
386
387 # allow also the VARIANTS w/o spaces
388 # we could use compgen -P prefix, but for some reason it doesn't seem to work always
389
390 case "$cur" in
391
392 -m*)
393 local hash_modes_var="$(echo -n "-m ${HASH_MODES}" | sed 's/ / -m/g')"
394 COMPREPLY=($(compgen -W "${hash_modes_var}" -- ${cur}))
395 return 0
396 ;;
397
398 -a*)
399 local attack_modes_var="$(echo -n "-a ${ATTACK_MODES}" | sed 's/ / -a/g')"
400 COMPREPLY=($(compgen -W "${attack_modes_var}" -- ${cur}))
401 return 0
402 ;;
403
404 -w*)
405 local workload_profile_var="$(echo -n "-w ${WORKLOAD_PROFILE}" | sed 's/ / -w/g')"
406 COMPREPLY=($(compgen -W "${workload_profile_var}" -- ${cur}))
407 return 0
408 ;;
409
410 -n*)
411 local kernel_accel_var="$(echo -n "-n ${KERNEL_ACCEL}" | sed 's/ / -n/g')"
412 COMPREPLY=($(compgen -W "${kernel_accel_var}" -- ${cur}))
413 return 0
414 ;;
415
416 -u*)
417 local kernel_loops_var="$(echo -n "-u ${KERNEL_LOOPS}" | sed 's/ / -u/g')"
418 COMPREPLY=($(compgen -W "${kernel_loops_var}" -- ${cur}))
419 return 0
420 ;;
421
422 -o*)
423 local outfile_var=$(ls -d ${cur:2}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
424 outfile_var="$(echo -e "\n${outfile_var}" | sed 's/^/-o/g')"
425 COMPREPLY=($(compgen -W "${outfile_var}" -- ${cur}))
426 return 0
427 ;;
428
429 -r*)
430 local outfile_var=$(ls -d ${cur:2}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
431 outfile_var="$(echo -e "\n${outfile_var}" | sed 's/^/-r/g')"
432 COMPREPLY=($(compgen -W "${outfile_var}" -- ${cur}))
433 return 0
434 ;;
435
436 -d*)
437 _oclHashcat_opencl_devices
438 local num_devices=${?}
439
440 _oclHashcat_get_permutations ${num_devices}
441
442 local opencl_devices_var="$(echo " "${oclHashcat_devices_permutation} | sed 's/ / -d/g')"
443 COMPREPLY=($(compgen -W "${opencl_devices_var}" -- ${cur}))
444 return 0
445 ;;
446 esac
447
448 # Complete options/switches (not the arguments)
449
450 if [[ "${cur}" == -* ]]; then
451
452 COMPREPLY=($(compgen -W "${SHORT_OPTS} ${LONG_OPTS}" -- ${cur}))
453 return 0
454
455 fi
456
457 # additional parameter, no switch nor option but maybe hash file, dictionary, mask, directory
458
459 # check if first option out of (hash.txt and dictionary|mask|directory)
460 # is first option iff: here
461 # is second option iff: COMP_CWORD > 2 and no switch before (-*) if no option afterwards (for mask -a 3, -a 6, -a 7 - but possible for dicts!)
462
463 local h=1
464 local no_opts=0
465 local attack_mode=0 # also default of oclHashcat
466 local has_charset_1=0
467 local has_charset_2=0
468 local has_charset_3=0
469 local has_charset_4=0
470
471 while [ ${h} -le ${COMP_CWORD} ]; do
472
473 if [[ "${COMP_WORDS[h]}" == "-a" ]]; then
474
475 attack_mode=${COMP_WORDS[$((h + 1))]}
476
477 elif [[ "${COMP_WORDS[h]}" == -a* ]]; then
478
479 attack_mode=${COMP_WORDS[h]:2}
480
481 elif [[ "${COMP_WORDS[h]}" == "--attack-mode" ]]; then
482
483 attack_mode=${COMP_WORDS[$((h + 1))]}
484
485 elif [[ "${COMP_WORDS[h]}" == "-1" ]]; then
486
487 has_charset_1=1
488
489 elif [[ "${COMP_WORDS[h]}" == "--custom-charset1" ]]; then
490
491 has_charset_1=1
492
493 elif [[ "${COMP_WORDS[h]}" == "-2" ]]; then
494
495 has_charset_2=1
496
497 elif [[ "${COMP_WORDS[h]}" == "--custom-charset2" ]]; then
498
499 has_charset_2=1
500
501 elif [[ "${COMP_WORDS[h]}" == "-3" ]]; then
502
503 has_charset_3=1
504
505 elif [[ "${COMP_WORDS[h]}" == "--custom-charset3" ]]; then
506
507 has_charset_3=1
508
509 elif [[ "${COMP_WORDS[h]}" == "-4" ]]; then
510
511 has_charset_4=1
512
513 elif [[ "${COMP_WORDS[h]}" == "--custom-charset4" ]]; then
514
515 has_charset_4=1
516
517 fi
518
519 if _oclHashcat_contains "${OPTIONS}" "${COMP_WORDS[h]}"; then
520
521 h=$((h + 2))
522
523 else
524
525 if ! _oclHashcat_contains "${LONG_OPTS}${SHORT_OPTS}" "${COMP_WORDS[h]}"; then
526 local variants="-m -a -w -n -u -o -r -d"
527 local skip=0
528 local v
529 for v in ${variants}; do
530
531 if [[ "${COMP_WORDS[h]:0:2}" == "${v}" ]]; then
532 skip=1
533 fi
534
535 done
536
537 if [ "${skip}" -eq 0 ]; then
538
539 no_opts=$((no_opts + 1))
540
541 fi
542 fi
543
544 h=$((h + 1))
545
546 fi
547
548 done
549
550 case "${no_opts}" in
551
552 0)
553 return 0
554 ;;
555
556 1)
557 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
558 COMPREPLY=($(compgen -W "${files}" -- ${cur}))
559 return 0
560 ;;
561
562 *)
563 case "${attack_mode}" in
564
565 0)
566 # dict/directory are files here
567 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
568 COMPREPLY=($(compgen -W "${files}" -- ${cur}))
569 return 0
570 ;;
571
572 1)
573 if [ "${no_opts}" -gt 4 ]; then
574 return 0
575 fi
576
577 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
578 COMPREPLY=($(compgen -W "${files}" -- ${cur}))
579 return 0
580 ;;
581
582 3)
583 if [ "${no_opts}" -eq 2 ]; then
584 local mask=${BUILD_IN_CHARSETS}
585
586 if [ "${has_charset_1}" -eq 1 ]; then
587
588 mask="${mask} ?1"
589
590 fi
591
592 if [ "${has_charset_2}" -eq 1 ]; then
593
594 mask="${mask} ?2"
595
596 fi
597
598 if [ "${has_charset_3}" -eq 1 ]; then
599
600 mask="${mask} ?3"
601
602 fi
603
604 if [ "${has_charset_4}" -eq 1 ]; then
605
606 mask="${mask} ?4"
607
608 fi
609
610 if [ -e "${cur}" ]; then # should be hcmask file (but not enforced)
611
612 COMPREPLY=($(compgen -W "${cur}" -- ${cur}))
613 return 0
614
615 fi
616
617 if [ -n "${cur}" ]; then
618
619 local cur_var=$(echo "${cur}" | sed 's/\?$//')
620
621 mask="${mask} ${cur_var}"
622
623 local h
624 for h in ${mask}; do
625
626 mask="${mask} ${cur_var}${h}"
627
628 done
629 fi
630
631 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null)
632
633 mask="${mask} ${files}"
634
635 COMPREPLY=($(compgen -W "${mask}" -- ${cur}))
636 return 0
637 fi
638 ;;
639
640 6)
641 if [ "${no_opts}" -eq 2 ]; then
642
643 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
644 COMPREPLY=($(compgen -W "${files}" -- ${cur}))
645
646 elif [ "${no_opts}" -eq 3 ]; then
647 local mask=${BUILD_IN_CHARSETS}
648
649 if [ "${has_charset_1}" -eq 1 ]; then
650
651 mask="${mask} ?1"
652
653 fi
654
655 if [ "${has_charset_2}" -eq 1 ]; then
656
657 mask="${mask} ?2"
658
659 fi
660
661 if [ "${has_charset_3}" -eq 1 ]; then
662
663 mask="${mask} ?3"
664
665 fi
666
667 if [ "${has_charset_4}" -eq 1 ]; then
668
669 mask="${mask} ?4"
670
671 fi
672
673 if [ -e "${cur}" ]; then # should be hcmask file (but not enforced)
674
675 COMPREPLY=($(compgen -W "${cur}" -- ${cur}))
676 return 0
677
678 fi
679
680 if [ -n "${cur}" ]; then
681
682 local cur_var=$(echo "${cur}" | sed 's/\?$//')
683
684 mask="${mask} ${cur_var}"
685
686 local h
687 for h in ${mask}; do
688
689 mask="${mask} ${cur_var}${h}"
690
691 done
692 fi
693
694 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null)
695
696 mask="${mask} ${files}"
697
698 COMPREPLY=($(compgen -W "${mask}" -- ${cur}))
699 return 0
700
701 fi
702 ;;
703
704 7)
705 if [ "${no_opts}" -eq 2 ]; then
706 local mask=${BUILD_IN_CHARSETS}
707
708 if [ "${has_charset_1}" -eq 1 ]; then
709
710 mask="${mask} ?1"
711
712 fi
713
714 if [ "${has_charset_2}" -eq 1 ]; then
715
716 mask="${mask} ?2"
717
718 fi
719
720 if [ "${has_charset_3}" -eq 1 ]; then
721
722 mask="${mask} ?3"
723
724 fi
725
726 if [ "${has_charset_4}" -eq 1 ]; then
727
728 mask="${mask} ?4"
729
730 fi
731
732 if [ -e "${cur}" ]; then # should be hcmask file (but not enforced)
733
734 COMPREPLY=($(compgen -W "${cur}" -- ${cur}))
735 return 0
736
737 fi
738
739 if [ -n "${cur}" ]; then
740
741 local cur_var=$(echo "${cur}" | sed 's/\?$//')
742
743 mask="${mask} ${cur_var}"
744
745 local h
746 for h in ${mask}; do
747
748 mask="${mask} ${cur_var}${h}"
749
750 done
751 fi
752
753 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null)
754
755 mask="${mask} ${files}"
756
757 COMPREPLY=($(compgen -W "${mask}" -- ${cur}))
758 return 0
759
760 elif [ "${no_opts}" -eq 3 ]; then
761
762 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
763 COMPREPLY=($(compgen -W "${files}" -- ${cur}))
764 return
765
766 fi
767 ;;
768
769 esac
770
771 esac
772 }
773
774 complete -F _oclHashcat -o filenames "${OCLHASHCAT_ROOT}"/oclHashcat64.bin "${OCLHASHCAT_ROOT}"/oclHashcat32.bin "${OCLHASHCAT_ROOT}"/oclHashcat oclHashcat