0c7f7d0cc4eb652b69603e05763afec9b6538887
[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 12900 13000"
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 OPENCL_DEVICE_TYPES="1 2 3"
178 local OPENCL_VECTOR_WIDTH="1 2 4 8"
179 local DEBUG_MODE="1 2 3 4"
180 local WORKLOAD_PROFILE="1 2 3"
181 local HIDDEN_FILES="exe|bin|pot|hcstat|dictstat|accepted|sh|cmd|bat|restore"
182 local HIDDEN_FILES_AGGRESIVE="exe|bin|pot|hcstat|dictstat|hcmask|hcchr|accepted|sh|cmd|restore"
183 local BUILD_IN_CHARSETS='?l ?u ?d ?a ?b ?s'
184
185 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"
186 local LONG_OPTS="--hash-type --attack-mode --version --help --eula --quiet --benchmark --benchmark-repeats --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-platforms --opencl-device-types --opencl-vector-width --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"
187 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 --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 --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"
188
189 COMPREPLY=()
190 local cur="${COMP_WORDS[COMP_CWORD]}"
191 local prev="${COMP_WORDS[COMP_CWORD-1]}"
192
193 # if cur is just '=', ignore the '=' and treat it as only the prev was provided
194 if [[ "${cur}" == '=' ]]; then
195
196 cur=""
197
198 elif [[ "${prev}" == '=' ]]; then
199
200 if [ "${COMP_CWORD}" -gt 2 ]; then
201
202 prev="${COMP_WORDS[COMP_CWORD-2]}"
203
204 fi
205
206 fi
207
208 case "${prev}" in
209
210 -m|--hash-type)
211 COMPREPLY=($(compgen -W "${HASH_MODES}" -- ${cur}))
212 return 0
213 ;;
214
215 -a|--attack-mode)
216 COMPREPLY=($(compgen -W "${ATTACK_MODES}" -- ${cur}))
217 return 0
218 ;;
219
220 --outfile-format)
221 COMPREPLY=($(compgen -W "${OUTFILE_FORMATS}" -- ${cur}))
222 return 0
223 ;;
224
225 -w|--workload-profile)
226 COMPREPLY=($(compgen -W "${WORKLOAD_PROFILE}" -- ${cur}))
227 return 0
228 ;;
229
230 -o|--outfile|-r|--rules-file|--debug-file)
231 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
232 COMPREPLY=($(compgen -W "${files}" -- ${cur})) # or $(compgen -f -X '*.+('${HIDDEN_FILES_AGGRESIVE}')' -- ${cur})
233 return 0
234 ;;
235
236 --markov-hcstat)
237 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null)
238 COMPREPLY=($(compgen -W "${files}" -- ${cur})) # or $(compgen -f -X '*.+('${HIDDEN_FILES_AGGRESIVE}')' -- ${cur})
239 return 0
240 ;;
241
242 -d|--opencl-devices)
243 _oclHashcat_opencl_devices
244 local num_devices=${?}
245
246 _oclHashcat_get_permutations ${num_devices}
247
248 COMPREPLY=($(compgen -W "${oclHashcat_devices_permutation}" -- ${cur}))
249 return 0
250 ;;
251
252 --opencl-device-types)
253 COMPREPLY=($(compgen -W "${OPENCL_DEVICE_TYPES}" -- ${cur}))
254 return 0
255 ;;
256
257 --opencl-vector-width)
258 COMPREPLY=($(compgen -W "${OPENCL_VECTOR_WIDTH}" -- ${cur}))
259 return 0
260 ;;
261
262 --opencl-platforms)
263 local icd_list=$(ls -1 /etc/OpenCL/vendors/*.icd 2> /dev/null)
264
265 local architecture=$(getconf LONG_BIT 2> /dev/null)
266
267 if [ -z "${architecture}" ]; then
268 return 0
269 fi
270
271 # filter the icd_list (do not show 32 bit on 64bit systems and vice versa)
272
273 if [ "${architecture}" -eq 64 ]; then
274
275 icd_list=$(echo "${icd_list}" | grep -v "32.icd")
276
277 else
278
279 icd_list=$(echo "${icd_list}" | grep -v "64.icd")
280
281 fi
282
283 local number_icds=$(seq 1 $(echo "${icd_list}" | wc -l))
284
285 COMPREPLY=($(compgen -W "${number_icds}" -- ${cur}))
286
287 return 0
288 ;;
289
290 --cpu-affinity)
291 _oclHashcat_cpu_devices
292 local num_devices=${?}
293
294 _oclHashcat_get_permutations ${num_devices}
295
296 COMPREPLY=($(compgen -W "${oclHashcat_devices_permutation}" -- ${cur}))
297 return 0
298 ;;
299
300 -1|-2|-3|-4|--custom-charset1|--custom-charset2|--custom-charset3|--custom-charset4)
301 local mask=${BUILD_IN_CHARSETS}
302
303 if [ -e "${cur}" ]; then # should be hcchr file (but not enforced)
304
305 COMPREPLY=($(compgen -W "${cur}" -- ${cur}))
306 return 0
307
308 fi
309
310 if [ -n "${cur}" ]; then
311
312 local cur_var=$(echo "${cur}" | sed 's/\?$//')
313
314 mask="${mask} ${cur_var}"
315 local h
316 for h in ${mask}; do
317
318 if ! echo ${cur} | grep -q ${h} 2> /dev/null; then
319
320 if echo ${cur} | grep -q '?a' 2> /dev/null; then
321
322 if [[ "${h}" == "?l" ]] ; then
323 continue
324 elif [[ "${h}" == "?u" ]] ; then
325 continue
326 elif [[ "${h}" == "?d" ]] ; then
327 continue
328 elif [[ "${h}" == "?s" ]] ; then
329 continue
330 elif [[ "${h}" == "?b" ]] ; then
331 continue
332 fi
333
334 fi
335
336 mask="${mask} ${cur_var}${h}"
337
338 fi
339
340 done
341 fi
342
343 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null)
344
345 mask="${mask} ${files}"
346
347 COMPREPLY=($(compgen -W "${mask}" -- ${cur}))
348 return 0
349 ;;
350
351 -t|-p|-c|-j|-k|-g| \
352 --status-timer|--markov-threshold|--runtime|--session|--separator|--segment-size|--rule-left|--rule-right| \
353 --gpu-temp-abort|--gpu-temp-retain|--generate-rules|--generate-rules-func-min|--generate-rules-func-max| \
354 --increment-min|--increment-max|--remove-timer|--bitmap-min|--bitmap-max|--skip|--limit|--generate-rules-seed| \
355 --weak-hash-threshold|--outfile-check-timer|--outfile-check-dir|--induction-dir|--scrypt-tmto)
356 return 0
357 ;;
358
359 --debug-mode)
360 COMPREPLY=($(compgen -W "${DEBUG_MODE}" -- ${cur}))
361 return 0
362 ;;
363
364 --truecrypt-keyfiles)
365 # first: remove the quotes such that file matching is possible
366
367 local cur_part0=$(echo "${cur}" | grep -Eo '^("|'"'"')')
368
369 local cur_mod=$(echo "${cur}" | sed 's/^["'"'"']//')
370 local cur_part1=$(echo "${cur_mod}" | grep ',' 2> /dev/null | sed 's/^\(.*, *\)[^,]*$/\1/')
371 local cur_part2=$(echo "${cur_mod}" | sed 's/^.*, *\([^,]*\)$/\1/')
372
373 # generate lines with the file name and a duplicate of it with a comma at the end
374
375 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}/")
376 COMPREPLY=($(compgen -W "${files}" -- ${cur}))
377 return 0
378
379 esac
380
381 # allow also the VARIANTS w/o spaces
382 # we could use compgen -P prefix, but for some reason it doesn't seem to work always
383
384 case "$cur" in
385
386 -m*)
387 local hash_modes_var="$(echo -n "-m ${HASH_MODES}" | sed 's/ / -m/g')"
388 COMPREPLY=($(compgen -W "${hash_modes_var}" -- ${cur}))
389 return 0
390 ;;
391
392 -a*)
393 local attack_modes_var="$(echo -n "-a ${ATTACK_MODES}" | sed 's/ / -a/g')"
394 COMPREPLY=($(compgen -W "${attack_modes_var}" -- ${cur}))
395 return 0
396 ;;
397
398 -w*)
399 local workload_profile_var="$(echo -n "-w ${WORKLOAD_PROFILE}" | sed 's/ / -w/g')"
400 COMPREPLY=($(compgen -W "${workload_profile_var}" -- ${cur}))
401 return 0
402 ;;
403
404 -o*)
405 local outfile_var=$(ls -d ${cur:2}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
406 outfile_var="$(echo -e "\n${outfile_var}" | sed 's/^/-o/g')"
407 COMPREPLY=($(compgen -W "${outfile_var}" -- ${cur}))
408 return 0
409 ;;
410
411 -r*)
412 local outfile_var=$(ls -d ${cur:2}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
413 outfile_var="$(echo -e "\n${outfile_var}" | sed 's/^/-r/g')"
414 COMPREPLY=($(compgen -W "${outfile_var}" -- ${cur}))
415 return 0
416 ;;
417
418 -d*)
419 _oclHashcat_opencl_devices
420 local num_devices=${?}
421
422 _oclHashcat_get_permutations ${num_devices}
423
424 local opencl_devices_var="$(echo " "${oclHashcat_devices_permutation} | sed 's/ / -d/g')"
425 COMPREPLY=($(compgen -W "${opencl_devices_var}" -- ${cur}))
426 return 0
427 ;;
428 esac
429
430 # Complete options/switches (not the arguments)
431
432 if [[ "${cur}" == -* ]]; then
433
434 COMPREPLY=($(compgen -W "${SHORT_OPTS} ${LONG_OPTS}" -- ${cur}))
435 return 0
436
437 fi
438
439 # additional parameter, no switch nor option but maybe hash file, dictionary, mask, directory
440
441 # check if first option out of (hash.txt and dictionary|mask|directory)
442 # is first option iff: here
443 # 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!)
444
445 local h=1
446 local no_opts=0
447 local attack_mode=0 # also default of oclHashcat
448 local has_charset_1=0
449 local has_charset_2=0
450 local has_charset_3=0
451 local has_charset_4=0
452
453 while [ ${h} -le ${COMP_CWORD} ]; do
454
455 if [[ "${COMP_WORDS[h]}" == "-a" ]]; then
456
457 attack_mode=${COMP_WORDS[$((h + 1))]}
458
459 elif [[ "${COMP_WORDS[h]}" == -a* ]]; then
460
461 attack_mode=${COMP_WORDS[h]:2}
462
463 elif [[ "${COMP_WORDS[h]}" == "--attack-mode" ]]; then
464
465 attack_mode=${COMP_WORDS[$((h + 1))]}
466
467 elif [[ "${COMP_WORDS[h]}" == "-1" ]]; then
468
469 has_charset_1=1
470
471 elif [[ "${COMP_WORDS[h]}" == "--custom-charset1" ]]; then
472
473 has_charset_1=1
474
475 elif [[ "${COMP_WORDS[h]}" == "-2" ]]; then
476
477 has_charset_2=1
478
479 elif [[ "${COMP_WORDS[h]}" == "--custom-charset2" ]]; then
480
481 has_charset_2=1
482
483 elif [[ "${COMP_WORDS[h]}" == "-3" ]]; then
484
485 has_charset_3=1
486
487 elif [[ "${COMP_WORDS[h]}" == "--custom-charset3" ]]; then
488
489 has_charset_3=1
490
491 elif [[ "${COMP_WORDS[h]}" == "-4" ]]; then
492
493 has_charset_4=1
494
495 elif [[ "${COMP_WORDS[h]}" == "--custom-charset4" ]]; then
496
497 has_charset_4=1
498
499 fi
500
501 if _oclHashcat_contains "${OPTIONS}" "${COMP_WORDS[h]}"; then
502
503 h=$((h + 2))
504
505 else
506
507 if ! _oclHashcat_contains "${LONG_OPTS}${SHORT_OPTS}" "${COMP_WORDS[h]}"; then
508 local variants="-m -a -w -n -u -o -r -d"
509 local skip=0
510 local v
511 for v in ${variants}; do
512
513 if [[ "${COMP_WORDS[h]:0:2}" == "${v}" ]]; then
514 skip=1
515 fi
516
517 done
518
519 if [ "${skip}" -eq 0 ]; then
520
521 no_opts=$((no_opts + 1))
522
523 fi
524 fi
525
526 h=$((h + 1))
527
528 fi
529
530 done
531
532 case "${no_opts}" in
533
534 0)
535 return 0
536 ;;
537
538 1)
539 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
540 COMPREPLY=($(compgen -W "${files}" -- ${cur}))
541 return 0
542 ;;
543
544 *)
545 case "${attack_mode}" in
546
547 0)
548 # dict/directory are files here
549 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
550 COMPREPLY=($(compgen -W "${files}" -- ${cur}))
551 return 0
552 ;;
553
554 1)
555 if [ "${no_opts}" -gt 4 ]; then
556 return 0
557 fi
558
559 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
560 COMPREPLY=($(compgen -W "${files}" -- ${cur}))
561 return 0
562 ;;
563
564 3)
565 if [ "${no_opts}" -eq 2 ]; then
566 local mask=${BUILD_IN_CHARSETS}
567
568 if [ "${has_charset_1}" -eq 1 ]; then
569
570 mask="${mask} ?1"
571
572 fi
573
574 if [ "${has_charset_2}" -eq 1 ]; then
575
576 mask="${mask} ?2"
577
578 fi
579
580 if [ "${has_charset_3}" -eq 1 ]; then
581
582 mask="${mask} ?3"
583
584 fi
585
586 if [ "${has_charset_4}" -eq 1 ]; then
587
588 mask="${mask} ?4"
589
590 fi
591
592 if [ -e "${cur}" ]; then # should be hcmask file (but not enforced)
593
594 COMPREPLY=($(compgen -W "${cur}" -- ${cur}))
595 return 0
596
597 fi
598
599 if [ -n "${cur}" ]; then
600
601 local cur_var=$(echo "${cur}" | sed 's/\?$//')
602
603 mask="${mask} ${cur_var}"
604
605 local h
606 for h in ${mask}; do
607
608 mask="${mask} ${cur_var}${h}"
609
610 done
611 fi
612
613 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null)
614
615 mask="${mask} ${files}"
616
617 COMPREPLY=($(compgen -W "${mask}" -- ${cur}))
618 return 0
619 fi
620 ;;
621
622 6)
623 if [ "${no_opts}" -eq 2 ]; then
624
625 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
626 COMPREPLY=($(compgen -W "${files}" -- ${cur}))
627
628 elif [ "${no_opts}" -eq 3 ]; then
629 local mask=${BUILD_IN_CHARSETS}
630
631 if [ "${has_charset_1}" -eq 1 ]; then
632
633 mask="${mask} ?1"
634
635 fi
636
637 if [ "${has_charset_2}" -eq 1 ]; then
638
639 mask="${mask} ?2"
640
641 fi
642
643 if [ "${has_charset_3}" -eq 1 ]; then
644
645 mask="${mask} ?3"
646
647 fi
648
649 if [ "${has_charset_4}" -eq 1 ]; then
650
651 mask="${mask} ?4"
652
653 fi
654
655 if [ -e "${cur}" ]; then # should be hcmask file (but not enforced)
656
657 COMPREPLY=($(compgen -W "${cur}" -- ${cur}))
658 return 0
659
660 fi
661
662 if [ -n "${cur}" ]; then
663
664 local cur_var=$(echo "${cur}" | sed 's/\?$//')
665
666 mask="${mask} ${cur_var}"
667
668 local h
669 for h in ${mask}; do
670
671 mask="${mask} ${cur_var}${h}"
672
673 done
674 fi
675
676 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null)
677
678 mask="${mask} ${files}"
679
680 COMPREPLY=($(compgen -W "${mask}" -- ${cur}))
681 return 0
682
683 fi
684 ;;
685
686 7)
687 if [ "${no_opts}" -eq 2 ]; then
688 local mask=${BUILD_IN_CHARSETS}
689
690 if [ "${has_charset_1}" -eq 1 ]; then
691
692 mask="${mask} ?1"
693
694 fi
695
696 if [ "${has_charset_2}" -eq 1 ]; then
697
698 mask="${mask} ?2"
699
700 fi
701
702 if [ "${has_charset_3}" -eq 1 ]; then
703
704 mask="${mask} ?3"
705
706 fi
707
708 if [ "${has_charset_4}" -eq 1 ]; then
709
710 mask="${mask} ?4"
711
712 fi
713
714 if [ -e "${cur}" ]; then # should be hcmask file (but not enforced)
715
716 COMPREPLY=($(compgen -W "${cur}" -- ${cur}))
717 return 0
718
719 fi
720
721 if [ -n "${cur}" ]; then
722
723 local cur_var=$(echo "${cur}" | sed 's/\?$//')
724
725 mask="${mask} ${cur_var}"
726
727 local h
728 for h in ${mask}; do
729
730 mask="${mask} ${cur_var}${h}"
731
732 done
733 fi
734
735 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES}')' 2> /dev/null)
736
737 mask="${mask} ${files}"
738
739 COMPREPLY=($(compgen -W "${mask}" -- ${cur}))
740 return 0
741
742 elif [ "${no_opts}" -eq 3 ]; then
743
744 local files=$(ls -d ${cur}* 2> /dev/null | grep -Eiv '*\.('${HIDDEN_FILES_AGGRESIVE}')' 2> /dev/null)
745 COMPREPLY=($(compgen -W "${files}" -- ${cur}))
746 return
747
748 fi
749 ;;
750
751 esac
752
753 esac
754 }
755
756 complete -F _oclHashcat -o filenames "${OCLHASHCAT_ROOT}"/oclHashcat64.bin "${OCLHASHCAT_ROOT}"/oclHashcat32.bin "${OCLHASHCAT_ROOT}"/oclHashcat oclHashcat