Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hashcat
GitHub Repository: hashcat/hashcat
Path: blob/master/tools/test.sh
5578 views
1
#!/usr/bin/env bash
2
3
##
4
## Author......: See docs/credits.txt
5
## License.....: MIT
6
##
7
8
OPTS="--quiet --potfile-disable --logfile-disable"
9
10
FORCE=0
11
RUNTIME=400
12
13
TDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
14
15
# List of TrueCrypt modes which have test containers
16
TC_MODES="6211 6212 6213 6221 6222 6223 6231 6232 6233 6241 6242 6243 29311 29312 29313 29321 29322 29323 29331 29332 29333 29341 29342 29343"
17
18
# List of VeraCrypt modes which have test containers
19
VC_MODES="13711 13712 13713 13721 13722 13723 13731 13732 13733 13741 13742 13743 13751 13752 13753 13761 13762 13763 13771 13772 13773 13781 13782 13783 29411 29412 29413 29421 29422 29423 29431 29432 29433 29441 29442 29443 29451 29452 29453 29461 29462 29463 29471 29472 29473 29481 29482 29483"
20
21
# List of modes which return a different output hash format than the input hash format
22
NOCHECK_ENCODING="16800 22000"
23
24
# List of LUKS modes which have test containers
25
LUKS_MODES="14600 29511 29512 29513 29521 29522 29523 29531 29532 29533 29541 29542 29543"
26
27
# Cryptoloop mode which have test containers
28
CL_MODES="14511 14512 14513 14521 14522 14523 14531 14532 14533 14541 14542 14543 14551 14552 14553"
29
30
HASH_TYPES=$(ls "${TDIR}"/test_modules/*.pm | sed -E 's/.*m0*([0-9]+).pm/\1/')
31
HASH_TYPES="${HASH_TYPES} ${TC_MODES} ${VC_MODES} ${LUKS_MODES} ${CL_MODES}"
32
HASH_TYPES=$(echo -n "${HASH_TYPES}" | tr ' ' '\n' | sort -u -n | tr '\n' ' ')
33
34
VECTOR_WIDTHS="1 2 4 8 16"
35
36
KEEP_GUESSING=$(grep -l OPTS_TYPE_SUGGEST_KG "${TDIR}"/../src/modules/module_*.c | sed -E 's/.*module_0*([0-9]+).c/\1/' | tr '\n' ' ')
37
HASHFILE_ONLY=$(grep -l OPTS_TYPE_BINARY_HASHFILE "${TDIR}"/../src/modules/module_*.c | sed -E 's/.*module_0*([0-9]+).c/\1/' | tr '\n' ' ')
38
SLOW_ALGOS=$( grep -l ATTACK_EXEC_OUTSIDE_KERNEL "${TDIR}"/../src/modules/module_*.c | sed -E 's/.*module_0*([0-9]+).c/\1/' | tr '\n' ' ')
39
40
# fake slow algos, due to specific password pattern (e.g. ?d from "mask_3" is invalid):
41
# ("only" drawback is that just -a 0 is tested with this workaround)
42
43
SLOW_ALGOS="${SLOW_ALGOS} 28501 28502 28503 28504 28505 28506 30901 30902 30903 30904 30905 30906"
44
45
OUTD="test_$(date +%s)"
46
47
PACKAGE_CMD="7z a"
48
PACKAGE_FOLDER=""
49
50
EXTRACT_CMD="7z x"
51
52
mask_3[0]=""
53
mask_3[1]="?d"
54
mask_3[2]="?d?d"
55
mask_3[3]="?d?d?d"
56
mask_3[4]="?d?d?d?d"
57
mask_3[5]="?d?d?d?d?d"
58
mask_3[6]="?d?d?d?d?d?d"
59
mask_3[7]="?d?d?d?d?d?d?d"
60
mask_3[8]="?d?d?d?d?d?d?d?d"
61
mask_3[9]="?d?d?d?d?d?d?d?d?d"
62
mask_3[10]="?d?d?d?d?d?d?d?d?d?d"
63
mask_3[11]="?d?d?d?d?d?d?d?d?d?d?d"
64
mask_3[12]="?d?d?d?d?d?d?d?d?d?d?d?d"
65
mask_3[13]="?d?d?d?d?d?d?d?d?d?d?d?d?d"
66
mask_3[14]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d"
67
mask_3[15]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d"
68
mask_3[16]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d0"
69
mask_3[17]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d00"
70
mask_3[18]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d000"
71
mask_3[19]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d0000"
72
mask_3[20]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d00000"
73
mask_3[21]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d000000"
74
mask_3[22]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d0000000"
75
mask_3[23]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d00000000"
76
mask_3[24]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d000000000"
77
mask_3[25]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d0000000000"
78
mask_3[26]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d00000000000"
79
mask_3[27]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d000000000000"
80
mask_3[28]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d0000000000000"
81
mask_3[29]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d00000000000000"
82
mask_3[30]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d000000000000000"
83
mask_3[31]="?d?d?d?d?d?d?d?d?d?d?d?d?d?d?d0000000000000000"
84
85
mask_6[0]=""
86
mask_6[1]=""
87
mask_6[2]="?d"
88
mask_6[3]="?d?d"
89
mask_6[4]="?d?d"
90
mask_6[5]="?d?d?d"
91
mask_6[6]="?d?d?d"
92
mask_6[7]="?d?d?d?d"
93
mask_6[8]="?d?d?d?d"
94
mask_6[9]="?d?d?d?d?d"
95
mask_6[10]="?d?d?d?d?d"
96
mask_6[11]="?d?d?d?d?d?d"
97
mask_6[12]="?d?d?d?d?d?d"
98
mask_6[13]="?d?d?d?d?d?d?d"
99
mask_6[14]="?d?d?d?d?d?d?d"
100
mask_6[15]="?d?d?d?d?d?d?d?d"
101
mask_6[16]="?d?d?d?d?d?d?d?d"
102
mask_6[17]="?d?d?d?d?d?d?d?d0"
103
mask_6[18]="?d?d?d?d?d?d?d?d0"
104
mask_6[19]="?d?d?d?d?d?d?d?d00"
105
mask_6[20]="?d?d?d?d?d?d?d?d00"
106
mask_6[21]="?d?d?d?d?d?d?d?d000"
107
mask_6[22]="?d?d?d?d?d?d?d?d000"
108
mask_6[23]="?d?d?d?d?d?d?d?d0000"
109
mask_6[24]="?d?d?d?d?d?d?d?d0000"
110
mask_6[25]="?d?d?d?d?d?d?d?d00000"
111
mask_6[26]="?d?d?d?d?d?d?d?d00000"
112
mask_6[27]="?d?d?d?d?d?d?d?d000000"
113
mask_6[28]="?d?d?d?d?d?d?d?d000000"
114
mask_6[29]="?d?d?d?d?d?d?d?d0000000"
115
mask_6[30]="?d?d?d?d?d?d?d?d0000000"
116
mask_6[31]="?d?d?d?d?d?d?d?d00000000"
117
118
mask_7[0]=""
119
mask_7[1]=""
120
mask_7[2]="?d"
121
mask_7[3]="?d"
122
mask_7[4]="?d?d"
123
mask_7[5]="?d?d"
124
mask_7[6]="?d?d?d"
125
mask_7[7]="?d?d?d"
126
mask_7[8]="?d?d?d?d"
127
mask_7[9]="?d?d?d?d"
128
mask_7[10]="?d?d?d?d?d"
129
mask_7[11]="?d?d?d?d?d"
130
mask_7[12]="?d?d?d?d?d?d"
131
mask_7[13]="?d?d?d?d?d?d"
132
mask_7[14]="?d?d?d?d?d?d?d"
133
mask_7[15]="?d?d?d?d?d?d?d"
134
mask_7[16]="?d?d?d?d?d?d?d?d"
135
mask_7[17]="?d?d?d?d?d?d?d?d"
136
mask_7[18]="?d?d?d?d?d?d?d?d0"
137
mask_7[19]="?d?d?d?d?d?d?d?d0"
138
mask_7[20]="?d?d?d?d?d?d?d?d00"
139
mask_7[21]="?d?d?d?d?d?d?d?d00"
140
mask_7[22]="?d?d?d?d?d?d?d?d000"
141
mask_7[23]="?d?d?d?d?d?d?d?d000"
142
mask_7[24]="?d?d?d?d?d?d?d?d0000"
143
mask_7[25]="?d?d?d?d?d?d?d?d0000"
144
mask_7[26]="?d?d?d?d?d?d?d?d00000"
145
mask_7[27]="?d?d?d?d?d?d?d?d00000"
146
mask_7[28]="?d?d?d?d?d?d?d?d000000"
147
mask_7[29]="?d?d?d?d?d?d?d?d000000"
148
mask_7[30]="?d?d?d?d?d?d?d?d0000000"
149
mask_7[31]="?d?d?d?d?d?d?d?d0000000"
150
151
# Array lookup
152
# $1: value
153
# $2: array
154
# Returns 0 (SUCCESS) if the value is found, 1 otherwise
155
156
function is_in_array()
157
{
158
for e in "${@:2}"; do
159
[ "$e" = "$1" ] && return 0
160
done
161
162
return 1
163
}
164
165
function init()
166
{
167
if [ "${PACKAGE}" -eq 1 ]; then
168
echo "[ ${OUTD} ] > Generate tests for hash type $hash_type."
169
else
170
echo "[ ${OUTD} ] > Init test for hash type $hash_type."
171
fi
172
173
rm -rf "${OUTD}/${hash_type}.sh" "${OUTD}/${hash_type}_passwords.txt" "${OUTD}/${hash_type}_hashes.txt"
174
175
# Exclude TrueCrypt, VeraCrypt and CryptoLoop testing modes
176
if is_in_array "${hash_type}" ${TC_MODES}; then
177
return 0
178
fi
179
if is_in_array "${hash_type}" ${VC_MODES}; then
180
return 0
181
fi
182
if is_in_array "${hash_type}" ${CL_MODES}; then
183
return 0
184
fi
185
186
if is_in_array "${hash_type}" ${LUKS_MODES}; then
187
which 7z &>/dev/null
188
if [ $? -eq 1 ]; then
189
echo "ATTENTION: 7z is missing. Skipping download and extract luks test files."
190
return 0
191
fi
192
193
luks_tests_folder="${TDIR}/luks_tests/"
194
195
if [ ! -d "${luks_tests_folder}" ]; then
196
mkdir -p "${luks_tests_folder}"
197
fi
198
199
luks_first_test_file="${luks_tests_folder}/hashcat_ripemd160_aes_cbc-essiv_128.luks"
200
201
if [ ! -f "${luks_first_test_file}" ]; then
202
luks_tests="hashcat_luks_testfiles.7z"
203
luks_tests_url="https://hashcat.net/misc/example_hashes/${luks_tests}"
204
205
cd "${TDIR}" || exit
206
207
# if the file already exists, but was not successfully extracted, we assume it's a broken
208
# downloaded file and therefore it should be deleted
209
210
if [ -f "${luks_tests}" ]; then
211
rm -f "${luks_tests}"
212
fi
213
214
echo ""
215
echo "ATTENTION: the luks test files (for -m ${hash_type}) are currently missing on your system."
216
echo "They will be fetched from ${luks_tests_url}"
217
echo "Note: this needs to be done only once and could take a little bit to download/extract."
218
echo "These luks test files are not shipped directly with hashcat because the file sizes are"
219
echo "particularly large and therefore a bandwidth burner for users who do not run these tests."
220
echo ""
221
222
# download:
223
wget -q "${luks_tests_url}"
224
225
if [ $? -ne 0 ] || [ ! -f "${luks_tests}" ]; then
226
cd - >/dev/null
227
echo "ERROR: Could not fetch the luks test files from this url: ${luks_tests_url}"
228
return 0
229
fi
230
231
# extract:
232
233
${EXTRACT_CMD} "${luks_tests}" &>/dev/null
234
235
# cleanup:
236
237
rm -f "${luks_tests}"
238
cd - >/dev/null || exit
239
240
# just to be very sure, check again that (one of) the files now exist:
241
242
if [ ! -f "${luks_first_test_file}" ]; then
243
echo "ERROR: downloading and extracting ${luks_tests} into ${luks_tests_folder} did not complete successfully"
244
return 0
245
fi
246
fi
247
248
return 0
249
fi
250
251
# create list of password and hashes of same type
252
cmd_file=${OUTD}/${hash_type}.sh
253
254
grep " ${hash_type} '" "${OUTD}/all.sh" > "${cmd_file}" 2>/dev/null
255
256
# create separate list of password and hashes
257
sed 's/^echo *|.*$//' "${cmd_file}" | awk '{print $2}' > "${OUTD}/${hash_type}_passwords.txt"
258
sed 's/^echo *|/echo "" |/' "${cmd_file}" | awk '{t="";for(i=10;i<=NF;i++){if(t){t=t" "$i}else{t=$i}};print t}' | cut -d"'" -f2 > "${OUTD}/${hash_type}_hashes.txt"
259
260
if [ "${hash_type}" -eq 10300 ]; then
261
#cat ${OUTD}/${hash_type}.sh | cut -d' ' -f11- | cut -d"'" -f2 > ${OUTD}/${hash_type}_hashes.txt
262
cut -d"'" -f2 "${OUTD}/${hash_type}.sh" > "${OUTD}/${hash_type}_hashes.txt"
263
fi
264
265
# truncate dicts
266
rm -rf "${OUTD}/${hash_type}_dict1" "${OUTD}/${hash_type}_dict2"
267
touch "${OUTD}/${hash_type}_dict1" "${OUTD}/${hash_type}_dict2"
268
269
# minimum password length
270
271
min=1 # minimum line number from start of the file
272
min_offset=0 # minimum offset starting from ${min} lines
273
274
if [ "${hash_type}" -eq 2500 ]; then
275
min_offset=7 # means length 8, since we start with 0
276
elif [ "${hash_type}" -eq 14000 ]; then
277
min=0
278
min_offset=4
279
elif [ "${hash_type}" -eq 14100 ]; then
280
min=0
281
min_offset=3
282
elif [ "${hash_type}" -eq 14900 ]; then
283
min=0
284
min_offset=5
285
elif [ "${hash_type}" -eq 15400 ]; then
286
min=0
287
min_offset=3
288
elif [ "${hash_type}" -eq 16800 ]; then
289
min_offset=7 # means length 8, since we start with 0
290
elif [ "${hash_type}" -eq 22000 ]; then
291
min_offset=7 # means length 8, since we start with 0
292
fi
293
294
# foreach password entry split password in 2 (skip first entry, is len 1)
295
296
i=1
297
298
while read -r -u 9 pass; do
299
300
if [ ${i} -gt ${min} ]; then
301
302
# split password, 'i' is the len
303
p0=$((i / 2))
304
p1=$((p0 + 1))
305
306
# special case (passwords longer than expected)
307
pass_len=${#pass}
308
309
if [ "${pass_len}" -gt 1 ]; then
310
311
p1=$((p1 + min_offset))
312
p0=$((p0 + min_offset))
313
314
if [ "${p1}" -gt "${pass_len}" ]; then
315
p1=${pass_len}
316
p0=$((p1 - 1))
317
fi
318
319
# add splitted password to dicts
320
echo "${pass}" | cut -c -${p0} >> "${OUTD}/${hash_type}_dict1"
321
echo "${pass}" | cut -c ${p1}- >> "${OUTD}/${hash_type}_dict2"
322
elif [ "${pass_len}" -eq 1 ]; then
323
echo "${pass}" >> "${OUTD}/${hash_type}_dict1"
324
echo >> "${OUTD}/${hash_type}_dict2"
325
else
326
echo >> "${OUTD}/${hash_type}_dict1"
327
echo >> "${OUTD}/${hash_type}_dict2"
328
fi
329
330
fi
331
332
i=$((i + 1))
333
334
done 9< "${OUTD}/${hash_type}_passwords.txt"
335
336
min_len=0
337
fixed_len=0
338
339
if [ "${hash_type}" -eq 2500 ]; then
340
min_len=7 # means length 8, since we start with 0
341
elif [ "${hash_type}" -eq 14000 ]; then
342
min_len=7
343
elif [ "${hash_type}" -eq 14100 ]; then
344
min_len=23
345
elif [ "${hash_type}" -eq 14900 ]; then
346
min_len=9
347
elif [ "${hash_type}" -eq 15400 ]; then
348
min_len=31
349
elif [ "${hash_type}" -eq 16800 ]; then
350
min_len=7 # means length 8, since we start with 0
351
elif [ "${hash_type}" -eq 22000 ]; then
352
min_len=7 # means length 8, since we start with 0
353
elif [ "${hash_type}" -eq 33500 ]; then
354
fixed_len=5
355
elif [ "${hash_type}" -eq 33501 ]; then
356
min_len=5
357
fixed_len=9
358
elif [ "${hash_type}" -eq 33502 ]; then
359
min_len=5
360
fixed_len=13
361
fi
362
363
# generate multiple pass/hash foreach len (2 to 8)
364
if [ "${MODE}" -ge 1 ]; then
365
366
i=2
367
368
while [ "$i" -lt 9 ]; do
369
370
cmd_file=${OUTD}/${hash_type}_multi_${i}.txt
371
372
rm -rf "${cmd_file}" "${OUTD}/${hash_type}_passwords_multi_${i}.txt" "${OUTD}/${hash_type}_hashes_multi_${i}.txt"
373
rm -rf "${OUTD}/${hash_type}_dict1_multi_${i}" "${OUTD}/${hash_type}_dict2_multi_${i}"
374
touch "${OUTD}/${hash_type}_dict1_multi_${i}" "${OUTD}/${hash_type}_dict2_multi_${i}"
375
376
if [ "${fixed_len}" -ne 0 ]; then
377
if [ "${fixed_len}" -eq "${i}" ]; then
378
perl tools/test.pl single "${hash_type}" ${i} > "${cmd_file}"
379
else
380
perl tools/test.pl single "${hash_type}" ${fixed_len} > "${cmd_file}"
381
fi
382
else
383
perl tools/test.pl single "${hash_type}" ${i} > "${cmd_file}"
384
fi
385
386
sed 's/^echo *|.*$//' "${cmd_file}" | awk '{print $2}' > "${OUTD}/${hash_type}_passwords_multi_${i}.txt"
387
sed 's/^echo *|/echo "" |/' "${cmd_file}" | awk '{t="";for(i=10;i<=NF;i++){if(t){t=t" "$i}else{t=$i}};print t}' | cut -d"'" -f2 > "${OUTD}/${hash_type}_hashes_multi_${i}.txt"
388
389
if [ "${hash_type}" -eq 10300 ]; then
390
#cat ${OUTD}/${hash_type}_multi_${i}.txt | cut -d' ' -f11- | cut -d"'" -f2 > ${OUTD}/${hash_type}_hashes_multi_${i}.txt
391
cut -d"'" -f2 "${OUTD}/${hash_type}_multi_${i}.txt" > "${OUTD}/${hash_type}_hashes_multi_${i}.txt"
392
fi
393
394
# split password, 'i' is the len
395
p0=$((i / 2))
396
p1=$((p0 + 1))
397
398
p0=$((p0 + min_len))
399
p1=$((p1 + min_len))
400
401
while read -r -u 9 pass; do
402
403
# add splitted password to dicts
404
echo "${pass}" | cut -c -${p0} >> "${OUTD}/${hash_type}_dict1_multi_${i}"
405
echo "${pass}" | cut -c ${p1}- >> "${OUTD}/${hash_type}_dict2_multi_${i}"
406
407
done 9< "${OUTD}/${hash_type}_passwords_multi_${i}.txt"
408
409
i=$((i + 1))
410
411
done
412
413
fi
414
}
415
416
function status()
417
{
418
RET=$1
419
420
cnt=$((cnt + 1))
421
422
if [ "${RET}" -ne 0 ]; then
423
case ${RET} in
424
246)
425
echo "autotune failure, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
426
427
e_rs=$((e_rs + 1))
428
;;
429
430
248)
431
echo "skipped by runtime (mixed backend errors detected), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
432
433
e_rs=$((e_rs + 1))
434
;;
435
436
249)
437
echo "skipped by runtime (Invalid module_extra_buffer_size), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
438
439
e_rs=$((e_rs + 1))
440
;;
441
442
250)
443
echo "skipped by runtime (Too many compute units to keep minimum kernel accel limit), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
444
445
e_rs=$((e_rs + 1))
446
;;
447
448
251)
449
echo "skipped by runtime (main kernel build error), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
450
451
e_rs=$((e_rs + 1))
452
;;
453
454
252)
455
echo "skipped by runtime (memory hit limit), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
456
457
e_rs=$((e_rs + 1))
458
;;
459
460
253)
461
echo "skipped by runtime (module_unstable_warning), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
462
463
e_rs=$((e_rs + 1))
464
;;
465
466
1)
467
# next check should not be needed anymore (NEVER_CRACK with exit code EXHAUSTED):
468
# if is_in_array "${hash_type}" ${KEEP_GUESSING_ALGOS}; then
469
# return
470
# fi
471
472
echo "password not found, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
473
e_nf=$((e_nf + 1))
474
;;
475
476
4)
477
echo "timeout reached, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
478
479
e_to=$((e_to + 1))
480
;;
481
482
10)
483
if is_in_array "${hash_type}" ${KEEP_GUESSING_ALGOS}; then
484
return
485
fi
486
487
if [ "${pass_only}" -eq 1 ]; then
488
echo "plains not found in output, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
489
else
490
echo "hash:plains not matched in output, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.tx"t
491
fi
492
493
e_nm=$((e_nm + 1))
494
;;
495
496
20)
497
echo "grep out-of-memory (cannot check if plains match in output), cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
498
499
e_ce=$((e_ce + 1))
500
e_nm=$((e_nm + 1))
501
;;
502
503
30)
504
echo "luks test files are missing, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
505
506
e_rs=$((e_rs + 1))
507
;;
508
509
*)
510
echo "! unhandled return code ${RET}, cmdline : ${CMD}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
511
echo "! unhandled return code, see ${OUTD}/logfull.txt or ${OUTD}/test_report.log for details."
512
513
e_nf=$((e_nf + 1))
514
;;
515
516
esac
517
fi
518
}
519
520
function attack_0()
521
{
522
file_only=0
523
524
if is_in_array "${hash_type}" ${FILE_BASED_ALGOS}; then
525
file_only=1
526
fi
527
528
# single hash
529
if [ "${MODE}" -ne 1 ]; then
530
531
e_ce=0
532
e_rs=0
533
e_to=0
534
e_nf=0
535
e_nm=0
536
cnt=0
537
538
echo "> Testing hash type $hash_type with attack mode 0, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}." >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
539
540
max=32
541
542
if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then
543
max=12
544
fi
545
546
i=0
547
548
while read -r -u 9 line; do
549
550
if [ "${i}" -ge ${max} ]; then
551
break
552
fi
553
554
hash="$(echo "${line}" | cut -d\' -f2)"
555
pass="$(echo "${line}" | cut -d' ' -f2)"
556
557
if [ -z "${hash}" ]; then
558
break
559
fi
560
561
if [ "${file_only}" -eq 1 ]; then
562
563
temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt"
564
565
if [ "${hash_type}" -ne 22000 ]; then
566
echo "${hash}" | base64 -d > "${temp_file}"
567
else
568
echo "${hash}" > "${temp_file}"
569
fi
570
571
hash="${temp_file}"
572
573
fi
574
575
pass_old=${pass}
576
577
if [ "${hash_type}" -eq 20510 ]; then # special case for PKZIP Master Key
578
pass=$(echo "${pass}" | cut -b 7-) # skip the first 6 chars
579
fi
580
581
CMD="echo ${pass} | ./${BIN} ${OPTS} -a 0 -m ${hash_type} '${hash}'"
582
583
echo -n "[ len $((i + 1)) ] " >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
584
585
output=$(echo "${pass}" | ./${BIN} ${OPTS} -a 0 -m ${hash_type} "${hash}" 2>&1)
586
587
ret=${?}
588
589
pass=${pass_old}
590
591
echo "${output}" >> "${OUTD}/logfull.txt"
592
593
if [ "${ret}" -eq 0 ]; then
594
595
if [ "${pass_only}" -eq 1 ]; then
596
search=":${pass}"
597
else
598
search="${hash}:${pass}"
599
fi
600
601
echo "${output}" | grep -F "${search}" &>/dev/null
602
603
newRet=$?
604
605
if [ "${newRet}" -eq 2 ]; then
606
607
# out-of-memory, workaround
608
609
echo "${output}" | grep -v "^Unsupported\|^$" | head -1 > tmp_file_out
610
echo "${search}" > tmp_file_search
611
612
out_md5=$(md5sum tmp_file_out | cut -d' ' -f1)
613
search_md5=$(md5sum tmp_file_search | cut -d' ' -f1)
614
615
rm tmp_file_out tmp_file_search
616
617
if [ "${out_md5}" == "${search_md5}" ]; then
618
newRet=0
619
fi
620
fi
621
622
if [ "${newRet}" -ne 0 ]; then
623
if [ "${newRet}" -eq 2 ]; then
624
ret=20
625
else
626
ret=10
627
fi
628
fi
629
630
fi
631
632
status ${ret}
633
634
i=$((i + 1))
635
636
done 9< "${OUTD}/${hash_type}.sh"
637
638
msg="OK"
639
640
if [ "${e_ce}" -ne 0 ]; then
641
msg="Compare Error"
642
elif [ "${e_rs}" -ne 0 ]; then
643
msg="Skip"
644
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
645
msg="Error"
646
elif [ "${e_to}" -ne 0 ]; then
647
msg="Warning"
648
fi
649
650
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
651
fi
652
653
# multihash
654
if [ "${MODE}" -ne 0 ]; then
655
656
e_ce=0
657
e_rs=0
658
e_to=0
659
e_nf=0
660
e_nm=0
661
cnt=0
662
663
echo "> Testing hash type $hash_type with attack mode 0, markov ${MARKOV}, multi hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}." >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
664
665
hash_file=${OUTD}/${hash_type}_hashes.txt
666
667
# if file_only -> decode all base64 "hashes" and put them in the temporary file
668
669
if [ "${file_only}" -eq 1 ]; then
670
671
temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt"
672
rm -f "${temp_file}"
673
674
hash_file=${temp_file}
675
676
while read -r file_only_hash; do
677
678
if [ "${hash_type}" -ne 22000 ]; then
679
echo -n "${file_only_hash}" | base64 -d >> "${temp_file}"
680
else
681
echo "${file_only_hash}" >> "${temp_file}"
682
fi
683
684
done < "${OUTD}/${hash_type}_hashes.txt"
685
686
fi
687
688
CMD="cat ${OUTD}/${hash_type}_passwords.txt | ./${BIN} ${OPTS} -a 0 -m ${hash_type} ${hash_file}"
689
690
output=$(./${BIN} ${OPTS} -a 0 -m ${hash_type} ${hash_file} < ${OUTD}/${hash_type}_passwords.txt 2>&1)
691
692
ret=${?}
693
694
echo "${output}" >> "${OUTD}/logfull.txt"
695
696
if [ "${ret}" -eq 0 ]; then
697
698
i=1
699
700
while read -r -u 9 hash; do
701
702
pass=$(sed -n ${i}p "${OUTD}/${hash_type}_passwords.txt")
703
704
if [ "${pass_only}" -eq 1 ]; then
705
search=":${pass}"
706
else
707
search="${hash}:${pass}"
708
fi
709
710
echo "${output}" | grep -F "${search}" &>/dev/null
711
712
newRet=$?
713
714
if [ "${newRet}" -ne 0 ]; then
715
if [ "${newRet}" -eq 2 ]; then
716
ret=20
717
else
718
ret=10
719
fi
720
721
break
722
fi
723
724
i=$((i + 1))
725
726
done 9< "${OUTD}/${hash_type}_hashes.txt"
727
728
fi
729
730
status ${ret}
731
732
msg="OK"
733
734
if [ "${e_ce}" -ne 0 ]; then
735
msg="Compare Error"
736
elif [ "${e_rs}" -ne 0 ]; then
737
msg="Skip"
738
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
739
msg="Error"
740
elif [ "${e_to}" -ne 0 ]; then
741
msg="Warning"
742
fi
743
744
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
745
fi
746
}
747
748
function attack_1()
749
{
750
file_only=0
751
752
if is_in_array "${hash_type}" ${FILE_BASED_ALGOS}; then
753
file_only=1
754
fi
755
756
# single hash
757
if [ "${MODE}" -ne 1 ]; then
758
759
e_ce=0
760
e_rs=0
761
e_to=0
762
e_nf=0
763
e_nm=0
764
cnt=0
765
766
min=1
767
max=8
768
769
if [ "${hash_type}" -eq 14000 ]; then
770
min=0
771
max=5
772
elif [ "${hash_type}" -eq 14100 ]; then
773
min=0
774
max=5
775
elif [ "${hash_type}" -eq 14900 ]; then
776
min=0
777
max=5
778
elif [ "${hash_type}" -eq 15400 ]; then
779
min=0
780
max=5
781
elif [ "${hash_type}" -eq 20510 ]; then
782
min=2
783
fi
784
785
echo "> Testing hash type $hash_type with attack mode 1, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}." >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
786
787
i=1
788
while read -r -u 9 hash; do
789
790
if [ $i -gt ${min} ]; then
791
792
if [ "${file_only}" -eq 1 ]; then
793
794
temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt"
795
796
if [ "${hash_type}" -ne 22000 ]; then
797
echo "${hash}" | base64 -d > "${temp_file}"
798
else
799
echo "${hash}" > "${temp_file}"
800
fi
801
802
hash="${temp_file}"
803
804
fi
805
806
line_nr=1
807
808
if [ "$min" -eq 0 ]; then
809
line_nr=$i
810
elif [ "${i}" -gt 1 ]; then
811
line_nr=$((i - 1))
812
fi
813
814
dict1="${OUTD}/${hash_type}_dict1"
815
dict2="${OUTD}/${hash_type}_dict2"
816
817
if [ "${hash_type}" -eq 20510 ]; then # special case for PKZIP Master Key
818
line_dict1=$(sed -n ${line_nr}p "${dict1}")
819
line_dict2=$(sed -n ${line_nr}p "${dict2}")
820
line_num=$(wc -l "${dict1}" | sed -E 's/ *([0-9]+) .*$/\1/')
821
822
line_dict1_orig=${line_dict1}
823
line_dict2_orig=${line_dict2}
824
825
if [ "${#line_dict1}" -ge 6 ]; then
826
line_dict1=$(echo "${line_dict1}" | cut -b 7-) # skip the first 6 chars
827
else
828
# we need to also "steal" some chars from the second dict
829
num_to_steal=$((6 - ${#line_dict1}))
830
num_steal_start=$((num_to_steal + 1))
831
832
if [ "${#line_dict2}" -ge 6 ]; then
833
num_to_steal_new=$(((${#line_dict2} - num_to_steal) / 2))
834
835
if [ "${num_to_steal_new}" -gt ${num_to_steal} ]; then
836
num_to_steal=${num_to_steal_new}
837
fi
838
fi
839
840
line_chars_stolen=$(echo "${line_dict2}" | cut -b -${num_to_steal} | cut -b ${num_steal_start}-)
841
842
line_dict1="${line_chars_stolen}"
843
line_dict2=$(echo "${line_dict2}" | cut -b $((num_to_steal + 1))-)
844
fi
845
846
# finally, modify the dicts accordingly:
847
848
tmp_file="${dict1}_mod"
849
head -n $((line_nr - 1)) "${dict1}" > "${tmp_file}"
850
echo "${line_dict1}" >> "${tmp_file}"
851
tail -n $((line_num - line_nr - 1)) "${dict1}" >> "${tmp_file}"
852
853
dict1=${tmp_file}
854
855
tmp_file="${dict2}_mod"
856
857
head -n $((line_nr - 1)) "${dict2}" > "${tmp_file}"
858
echo "${line_dict2}" >> "${tmp_file}"
859
tail -n $((line_num - line_nr - 1)) "${dict2}" >> "${tmp_file}"
860
861
dict2=${tmp_file}
862
fi
863
864
CMD="./${BIN} ${OPTS} -a 1 -m ${hash_type} '${hash}' ${dict1} ${dict2}"
865
866
echo -n "[ len $i ] " >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
867
868
output=$(./${BIN} ${OPTS} -a 1 -m ${hash_type} "${hash}" ${dict1} ${dict2} 2>&1)
869
870
ret=${?}
871
872
echo "${output}" >> "${OUTD}/logfull.txt"
873
874
if [ "${ret}" -eq 0 ]; then
875
876
line_dict1=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict1")
877
line_dict2=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict2")
878
879
if [ "${pass_only}" -eq 1 ]; then
880
search=":${line_dict1}${line_dict2}"
881
else
882
search="${hash}:${line_dict1}${line_dict2}"
883
fi
884
885
echo "${output}" | grep -F "${search}" &>/dev/null
886
887
newRet=$?
888
889
if [ "${newRet}" -eq 2 ]; then
890
891
# out-of-memory, workaround
892
893
echo "${output}" | grep -v "^Unsupported\|^$" | head -1 > tmp_file_out
894
echo "${search}" > tmp_file_search
895
896
out_md5=$(md5sum tmp_file_out | cut -d' ' -f1)
897
search_md5=$(md5sum tmp_file_search | cut -d' ' -f1)
898
899
rm tmp_file_out tmp_file_search
900
901
if [ "${out_md5}" == "${search_md5}" ]; then
902
newRet=0
903
fi
904
fi
905
906
if [ "${newRet}" -ne 0 ]; then
907
if [ "${newRet}" -eq 2 ]; then
908
ret=20
909
else
910
ret=10
911
fi
912
fi
913
914
fi
915
916
status ${ret}
917
918
fi
919
920
if [ $i -eq ${max} ]; then break; fi
921
922
i=$((i + 1))
923
924
done 9< "${OUTD}/${hash_type}_hashes.txt"
925
926
msg="OK"
927
928
if [ "${e_ce}" -ne 0 ]; then
929
msg="Compare Error"
930
elif [ "${e_rs}" -ne 0 ]; then
931
msg="Skip"
932
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
933
msg="Error"
934
elif [ "${e_to}" -ne 0 ]; then
935
msg="Warning"
936
fi
937
938
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 1, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
939
fi
940
941
# multihash
942
if [ "${MODE}" -ne 0 ]; then
943
944
# no multi hash checks for these modes (because we only have 1 hash for each of them)
945
946
if [ "${hash_type}" -eq 14000 ]; then
947
return
948
elif [ "${hash_type}" -eq 14100 ]; then
949
return
950
elif [ "${hash_type}" -eq 14900 ]; then
951
return
952
elif [ "${hash_type}" -eq 15400 ]; then
953
return
954
fi
955
956
e_ce=0
957
e_rs=0
958
e_to=0
959
e_nf=0
960
e_nm=0
961
cnt=0
962
963
offset=7
964
965
if [ "${hash_type}" -eq 5800 ]; then
966
offset=6
967
elif [ "${hash_type}" -eq 3000 ]; then
968
offset=6
969
fi
970
971
hash_file=${OUTD}/${hash_type}_multihash_combi.txt
972
973
tail -n ${offset} "${OUTD}/${hash_type}_hashes.txt" > "${hash_file}"
974
975
# if file_only -> decode all base64 "hashes" and put them in the temporary file
976
977
if [ "${file_only}" -eq 1 ]; then
978
979
temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt"
980
rm -f "${temp_file}"
981
982
hash_file=${temp_file}
983
984
while read -r file_only_hash; do
985
986
if [ "${hash_type}" -ne 22000 ]; then
987
echo -n "${file_only_hash}" | base64 -d >> "${temp_file}"
988
else
989
echo "${file_only_hash}" >> "${temp_file}"
990
fi
991
992
done < "${OUTD}/${hash_type}_multihash_combi.txt"
993
994
fi
995
996
CMD="./${BIN} ${OPTS} -a 1 -m ${hash_type} ${hash_file} ${OUTD}/${hash_type}_dict1 ${OUTD}/${hash_type}_dict2"
997
998
echo "> Testing hash type $hash_type with attack mode 1, markov ${MARKOV}, multi hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}." >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
999
1000
output=$(./${BIN} ${OPTS} -a 1 -m ${hash_type} ${hash_file} ${OUTD}/${hash_type}_dict1 ${OUTD}/${hash_type}_dict2 2>&1)
1001
1002
ret=${?}
1003
1004
echo "${output}" >> "${OUTD}/logfull.txt"
1005
1006
if [ "${ret}" -eq 0 ]; then
1007
1008
i=0
1009
1010
while read -r -u 9 hash; do
1011
1012
line_nr=1
1013
1014
if [ "${offset}" -gt ${i} ]; then
1015
line_nr=$((offset - i))
1016
fi
1017
1018
line_dict1=$(tail -n ${line_nr} "${OUTD}/${hash_type}_dict1" | head -1)
1019
line_dict2=$(tail -n ${line_nr} "${OUTD}/${hash_type}_dict2" | head -1)
1020
1021
if [ "${pass_only}" -eq 1 ]; then
1022
search=":${line_dict1}${line_dict2}"
1023
else
1024
search="${hash}:${line_dict1}${line_dict2}"
1025
fi
1026
1027
echo "${output}" | grep -F "${search}" &>/dev/null
1028
1029
newRet=$?
1030
1031
if [ "${newRet}" -ne 0 ]; then
1032
if [ "${newRet}" -eq 2 ]; then
1033
ret=20
1034
else
1035
ret=10
1036
fi
1037
1038
break
1039
fi
1040
1041
i=$((i + 1))
1042
1043
done 9< "${OUTD}/${hash_type}_multihash_combi.txt"
1044
fi
1045
1046
status ${ret}
1047
1048
msg="OK"
1049
1050
if [ "${e_ce}" -ne 0 ]; then
1051
msg="Compare Error"
1052
elif [ "${e_rs}" -ne 0 ]; then
1053
msg="Skip"
1054
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
1055
msg="Error"
1056
elif [ "${e_to}" -ne 0 ]; then
1057
msg="Warning"
1058
fi
1059
1060
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 1, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
1061
fi
1062
}
1063
1064
function attack_3()
1065
{
1066
file_only=0
1067
1068
if is_in_array "${hash_type}" ${FILE_BASED_ALGOS}; then
1069
file_only=1
1070
fi
1071
1072
# single hash
1073
if [ "${MODE}" -ne 1 ]; then
1074
1075
e_ce=0
1076
e_rs=0
1077
e_to=0
1078
e_nf=0
1079
e_nm=0
1080
cnt=0
1081
1082
echo "> Testing hash type $hash_type with attack mode 3, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}." >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
1083
1084
max=8
1085
1086
# some algos have a minimum password length
1087
1088
if [ "${hash_type}" -eq 2500 ]; then
1089
max=7
1090
elif [ "${hash_type}" -eq 14000 ]; then
1091
max=1
1092
elif [ "${hash_type}" -eq 14100 ]; then
1093
max=1
1094
elif [ "${hash_type}" -eq 14900 ]; then
1095
max=1
1096
elif [ "${hash_type}" -eq 15400 ]; then
1097
max=1
1098
elif [ "${hash_type}" -eq 16800 ]; then
1099
max=7
1100
elif [ "${hash_type}" -eq 22000 ]; then
1101
max=7
1102
fi
1103
1104
i=1
1105
1106
while read -r -u 9 hash; do
1107
1108
if [ "${i}" -gt 6 ]; then
1109
if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then
1110
break
1111
fi
1112
fi
1113
1114
if [ "${file_only}" -eq 1 ]; then
1115
1116
temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt"
1117
1118
if [ "${hash_type}" -ne 22000 ]; then
1119
echo "${hash}" | base64 -d > "${temp_file}"
1120
else
1121
echo "${hash}" > "${temp_file}"
1122
fi
1123
1124
hash="${temp_file}"
1125
fi
1126
1127
# construct a meaningful mask from the password itself:
1128
1129
dict="${OUTD}/${hash_type}_passwords.txt"
1130
1131
pass=$(sed -n ${i}p "${dict}")
1132
1133
# passwords can't be smaller than mask in -a 3 = mask attack
1134
1135
if [ "${#pass}" -lt ${i} ]; then
1136
i=$((i + 1))
1137
continue
1138
fi
1139
1140
pass_part_2=$(echo -n "${pass}" | cut -b $((i + 1))-)
1141
1142
mask=""
1143
1144
if [ "${hash_type}" -eq 14000 ]; then
1145
mask="${pass}"
1146
elif [ "${hash_type}" -eq 14100 ]; then
1147
mask="${pass}"
1148
else
1149
for i in $(seq 1 ${i}); do
1150
mask="${mask}?d"
1151
done
1152
1153
mask="${mask}${pass_part_2}"
1154
fi
1155
1156
if [ "${hash_type}" -eq 20510 ]; then # special case for PKZIP Master Key
1157
if [ "${i}" -le 1 ]; then
1158
i=$((i + 1))
1159
continue
1160
fi
1161
1162
cut_pos=$((i * 2 + 6 - i + 1)) # skip it in groups of 2 ("?d"), at least 6, offset +1 for cut to work
1163
1164
if [ "${i}" -gt 6 ]; then
1165
cut_pos=13 # 6 * ?d + 1 (6 * 2 + 1)
1166
fi
1167
1168
mask=$(echo "${mask}" | cut -b ${cut_pos}-)
1169
fi
1170
1171
CMD="./${BIN} ${OPTS} -a 3 -m ${hash_type} '${hash}' ${mask}"
1172
1173
echo -n "[ len $i ] " >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
1174
1175
output=$(./${BIN} ${OPTS} -a 3 -m ${hash_type} "${hash}" ${mask} 2>&1)
1176
1177
ret=${?}
1178
1179
echo "${output}" >> "${OUTD}/logfull.txt"
1180
1181
if [ "${ret}" -eq 0 ]; then
1182
1183
line_dict=$(sed -n ${i}p "${dict}")
1184
1185
if [ "${pass_only}" -eq 1 ]; then
1186
search=":${line_dict}"
1187
else
1188
search="${hash}:${line_dict}"
1189
fi
1190
1191
echo "${output}" | grep -F "${search}" &>/dev/null
1192
1193
newRet=$?
1194
1195
if [ "${newRet}" -eq 2 ]; then
1196
1197
# out-of-memory, workaround
1198
1199
echo "${output}" | grep -v "^Unsupported\|^$" | head -1 > tmp_file_out
1200
echo "${search}" > tmp_file_search
1201
1202
out_md5=$(md5sum tmp_file_out | cut -d' ' -f1)
1203
search_md5=$(md5sum tmp_file_search | cut -d' ' -f1)
1204
1205
rm tmp_file_out tmp_file_search
1206
1207
if [ "${out_md5}" == "${search_md5}" ]; then
1208
newRet=0
1209
fi
1210
fi
1211
1212
if [ "${newRet}" -ne 0 ]; then
1213
if [ "${newRet}" -eq 2 ]; then
1214
ret=20
1215
else
1216
ret=10
1217
fi
1218
fi
1219
1220
fi
1221
1222
status ${ret}
1223
1224
if [ $i -eq ${max} ]; then break; fi
1225
1226
i=$((i + 1))
1227
1228
done 9< "${OUTD}/${hash_type}_hashes.txt"
1229
1230
msg="OK"
1231
1232
if [ "${e_ce}" -ne 0 ]; then
1233
msg="Compare Error"
1234
elif [ "${e_rs}" -ne 0 ]; then
1235
msg="Skip"
1236
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
1237
msg="Error"
1238
elif [ "${e_to}" -ne 0 ]; then
1239
msg="Warning"
1240
fi
1241
1242
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
1243
fi
1244
1245
# multihash
1246
if [ "${MODE}" -ne 0 ]; then
1247
1248
# no multi hash checks for these modes (because we only have 1 hash for each of them)
1249
1250
if [ "${hash_type}" -eq 14000 ]; then
1251
return
1252
elif [ "${hash_type}" -eq 14100 ]; then
1253
return
1254
elif [ "${hash_type}" -eq 14900 ]; then
1255
return
1256
elif [ "${hash_type}" -eq 15400 ]; then
1257
return
1258
fi
1259
1260
e_ce=0
1261
e_rs=0
1262
e_to=0
1263
e_nf=0
1264
e_nm=0
1265
cnt=0
1266
1267
increment_max=8
1268
1269
if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then
1270
increment_max=5
1271
fi
1272
1273
increment_min=1
1274
1275
if [ "${hash_type}" -eq 2500 ]; then
1276
increment_min=8
1277
increment_max=9
1278
fi
1279
1280
if [ "${hash_type}" -eq 16800 ]; then
1281
increment_min=8
1282
increment_max=9
1283
fi
1284
1285
if [ "${hash_type}" -eq 22000 ]; then
1286
increment_min=8
1287
increment_max=9
1288
fi
1289
1290
# if file_only -> decode all base64 "hashes" and put them in the temporary file
1291
1292
if [ "${file_only}" -eq 1 ]; then
1293
1294
temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt"
1295
rm -f "${temp_file}"
1296
1297
hash_file=${temp_file}
1298
1299
while read -r file_only_hash; do
1300
1301
if [ "${hash_type}" -ne 22000 ]; then
1302
echo -n "${file_only_hash}" | base64 -d >> "${temp_file}"
1303
else
1304
echo "${file_only_hash}" >> "${temp_file}"
1305
fi
1306
1307
done < "${OUTD}/${hash_type}_multihash_bruteforce.txt"
1308
1309
fi
1310
1311
hash_file=${OUTD}/${hash_type}_multihash_bruteforce.txt
1312
1313
tail_hashes=$(awk "length >= ${increment_min} && length <= ${increment_max}" "${OUTD}/${hash_type}_passwords.txt" | wc -l)
1314
head_hashes=$(awk "length <= ${increment_max}" "${OUTD}/${hash_type}_passwords.txt" | wc -l)
1315
1316
# in very rare cases (e.g. without -O and long passwords) we need to use .hcmask files with the passwords in it
1317
# otherwise there are no good masks we can test for such long passwords
1318
1319
need_hcmask=0
1320
1321
if [ "${tail_hashes}" -gt "${head_hashes}" ]; then
1322
need_hcmask=1
1323
fi
1324
1325
if [ "${tail_hashes}" -lt 1 ]; then
1326
need_hcmask=1
1327
fi
1328
1329
if [ ${need_hcmask} -eq 0 ]; then
1330
head -n "${head_hashes}" "${OUTD}/${hash_type}_hashes.txt" | tail -n "${tail_hashes}" > "${hash_file}"
1331
else
1332
tail_hashes=$(awk "length >= ${increment_min}" "${OUTD}/${hash_type}_passwords.txt" | wc -l)
1333
1334
if [ "${tail_hashes}" -lt 1 ]; then
1335
return
1336
fi
1337
1338
tail -n "${tail_hashes}" "${OUTD}/${hash_type}_hashes.txt" > "${hash_file}"
1339
fi
1340
1341
mask_pos=8
1342
1343
if [ "${increment_min}" -gt ${mask_pos} ]; then
1344
mask_pos=${increment_min}
1345
fi
1346
1347
mask=""
1348
cracks_offset=0
1349
1350
if [ ${need_hcmask} -eq 0 ]; then
1351
cracks_offset=$((head_hashes - tail_hashes))
1352
1353
mask=${mask_3[${mask_pos}]}
1354
else
1355
num_hashes=$(wc -l < "${OUTD}/${hash_type}_hashes.txt")
1356
cracks_offset=$((num_hashes - tail_hashes))
1357
1358
mask=${OUTD}/${hash_type}_passwords.txt # fake hcmask file (i.e. the original dict)
1359
fi
1360
1361
custom_charsets=""
1362
1363
# modify "default" mask if needed (and set custom charset to reduce keyspace)
1364
1365
if [ "${hash_type}" -eq 2500 ]; then
1366
1367
mask="?d?d?d?d?d?1?2?3?4"
1368
1369
charset_1=""
1370
charset_2=""
1371
charset_3=""
1372
charset_4=""
1373
1374
# check positions (here we assume that mask is always composed of non literal chars
1375
# i.e. something like ?d?l?u?s?1 is possible, but ?d?dsuffix not
1376
charset_1_pos=$(expr index "${mask}" 1)
1377
charset_2_pos=$(expr index "${mask}" 2)
1378
charset_3_pos=$(expr index "${mask}" 3)
1379
charset_4_pos=$(expr index "${mask}" 4)
1380
1381
# divide each charset position by 2 since each of them occupies 2 positions in the mask
1382
1383
charset_1_pos=$((charset_1_pos / 2))
1384
charset_2_pos=$((charset_2_pos / 2))
1385
charset_3_pos=$((charset_3_pos / 2))
1386
charset_4_pos=$((charset_4_pos / 2))
1387
1388
i=1
1389
1390
while read -r -u 9 hash; do
1391
1392
pass=$(sed -n ${i}p "${OUTD}/${hash_type}_passwords.txt")
1393
1394
# charset 1
1395
char=$(echo "${pass}" | cut -b ${charset_1_pos})
1396
charset_1=$(printf "%s\n%s\n" "${charset_1}" "${char}")
1397
1398
# charset 2
1399
char=$(echo "${pass}" | cut -b ${charset_2_pos})
1400
charset_2=$(printf "%s\n%s\n" "${charset_2}" "${char}")
1401
1402
# charset 3
1403
char=$(echo "${pass}" | cut -b ${charset_3_pos})
1404
charset_3=$(printf "%s\n%s\n" "${charset_3}" "${char}")
1405
1406
# charset 4
1407
char=$(echo "${pass}" | cut -b ${charset_4_pos})
1408
charset_4=$(printf "%s\n%s\n" "${charset_4}" "${char}")
1409
1410
i=$((i + 1))
1411
1412
done 9< "${OUTD}/${hash_type}_multihash_bruteforce.txt"
1413
1414
# just make sure that all custom charset fields are initialized
1415
1416
if [ -z "${charset_1}" ]; then
1417
charset_1="1"
1418
fi
1419
1420
if [ -z "${charset_2}" ]; then
1421
charset_2="2"
1422
fi
1423
1424
if [ -z "${charset_3}" ]; then
1425
charset_3="3"
1426
fi
1427
1428
if [ -z "${charset_4}" ]; then
1429
charset_4="4"
1430
fi
1431
1432
# unique and remove new lines
1433
1434
charset_1=$(echo "${charset_1}" | sort -u | tr -d '\n')
1435
charset_2=$(echo "${charset_2}" | sort -u | tr -d '\n')
1436
charset_3=$(echo "${charset_3}" | sort -u | tr -d '\n')
1437
charset_4=$(echo "${charset_4}" | sort -u | tr -d '\n')
1438
1439
custom_charsets="-1 ${charset_1} -2 ${charset_2} -3 ${charset_3} -4 ${charset_4}"
1440
fi
1441
1442
if [ "${hash_type}" -eq 16800 ]; then
1443
1444
mask="?d?d?d?d?d?1?2?3?4"
1445
1446
charset_1=""
1447
charset_2=""
1448
charset_3=""
1449
charset_4=""
1450
1451
# check positions (here we assume that mask is always composed of non literal chars
1452
# i.e. something like ?d?l?u?s?1 is possible, but ?d?dsuffix not
1453
charset_1_pos=$(expr index "${mask}" 1)
1454
charset_2_pos=$(expr index "${mask}" 2)
1455
charset_3_pos=$(expr index "${mask}" 3)
1456
charset_4_pos=$(expr index "${mask}" 4)
1457
1458
# divide each charset position by 2 since each of them occupies 2 positions in the mask
1459
1460
charset_1_pos=$((charset_1_pos / 2))
1461
charset_2_pos=$((charset_2_pos / 2))
1462
charset_3_pos=$((charset_3_pos / 2))
1463
charset_4_pos=$((charset_4_pos / 2))
1464
1465
i=1
1466
1467
while read -r -u 9 hash; do
1468
1469
pass=$(sed -n ${i}p "${OUTD}/${hash_type}_passwords.txt")
1470
1471
# charset 1
1472
char=$(echo "${pass}" | cut -b ${charset_1_pos})
1473
charset_1=$(printf "%s\n%s\n" "${charset_1}" "${char}")
1474
1475
# charset 2
1476
char=$(echo "${pass}" | cut -b ${charset_2_pos})
1477
charset_2=$(printf "%s\n%s\n" "${charset_2}" "${char}")
1478
1479
# charset 3
1480
char=$(echo "${pass}" | cut -b ${charset_3_pos})
1481
charset_3=$(printf "%s\n%s\n" "${charset_3}" "${char}")
1482
1483
# charset 4
1484
char=$(echo "${pass}" | cut -b ${charset_4_pos})
1485
charset_4=$(printf "%s\n%s\n" "${charset_4}" "${char}")
1486
1487
i=$((i + 1))
1488
1489
done 9< "${OUTD}/${hash_type}_multihash_bruteforce.txt"
1490
1491
# just make sure that all custom charset fields are initialized
1492
1493
if [ -z "${charset_1}" ]; then
1494
charset_1="1"
1495
fi
1496
1497
if [ -z "${charset_2}" ]; then
1498
charset_2="2"
1499
fi
1500
1501
if [ -z "${charset_3}" ]; then
1502
charset_3="3"
1503
fi
1504
1505
if [ -z "${charset_4}" ]; then
1506
charset_4="4"
1507
fi
1508
1509
# unique and remove new lines
1510
1511
charset_1=$(echo "${charset_1}" | sort -u | tr -d '\n')
1512
charset_2=$(echo "${charset_2}" | sort -u | tr -d '\n')
1513
charset_3=$(echo "${charset_3}" | sort -u | tr -d '\n')
1514
charset_4=$(echo "${charset_4}" | sort -u | tr -d '\n')
1515
1516
custom_charsets="-1 ${charset_1} -2 ${charset_2} -3 ${charset_3} -4 ${charset_4}"
1517
fi
1518
1519
if [ "${hash_type}" -eq 22000 ]; then
1520
1521
mask="?d?d?d?d?d?1?2?3?4"
1522
1523
charset_1=""
1524
charset_2=""
1525
charset_3=""
1526
charset_4=""
1527
1528
# check positions (here we assume that mask is always composed of non literal chars
1529
# i.e. something like ?d?l?u?s?1 is possible, but ?d?dsuffix not
1530
charset_1_pos=$(expr index "${mask}" 1)
1531
charset_2_pos=$(expr index "${mask}" 2)
1532
charset_3_pos=$(expr index "${mask}" 3)
1533
charset_4_pos=$(expr index "${mask}" 4)
1534
1535
# divide each charset position by 2 since each of them occupies 2 positions in the mask
1536
1537
charset_1_pos=$((charset_1_pos / 2))
1538
charset_2_pos=$((charset_2_pos / 2))
1539
charset_3_pos=$((charset_3_pos / 2))
1540
charset_4_pos=$((charset_4_pos / 2))
1541
1542
i=1
1543
1544
while read -r -u 9 hash; do
1545
1546
pass=$(sed -n ${i}p "${OUTD}/${hash_type}_passwords.txt")
1547
1548
# charset 1
1549
char=$(echo "${pass}" | cut -b ${charset_1_pos})
1550
charset_1=$(printf "%s\n%s\n" "${charset_1}" "${char}")
1551
1552
# charset 2
1553
char=$(echo "${pass}" | cut -b ${charset_2_pos})
1554
charset_2=$(printf "%s\n%s\n" "${charset_2}" "${char}")
1555
1556
# charset 3
1557
char=$(echo "${pass}" | cut -b ${charset_3_pos})
1558
charset_3=$(printf "%s\n%s\n" "${charset_3}" "${char}")
1559
1560
# charset 4
1561
char=$(echo "${pass}" | cut -b ${charset_4_pos})
1562
charset_4=$(printf "%s\n%s\n" "${charset_4}" "${char}")
1563
1564
i=$((i + 1))
1565
1566
done 9< "${OUTD}/${hash_type}_multihash_bruteforce.txt"
1567
1568
# just make sure that all custom charset fields are initialized
1569
1570
if [ -z "${charset_1}" ]; then
1571
charset_1="1"
1572
fi
1573
1574
if [ -z "${charset_2}" ]; then
1575
charset_2="2"
1576
fi
1577
1578
if [ -z "${charset_3}" ]; then
1579
charset_3="3"
1580
fi
1581
1582
if [ -z "${charset_4}" ]; then
1583
charset_4="4"
1584
fi
1585
1586
# unique and remove new lines
1587
1588
charset_1=$(echo "${charset_1}" | sort -u | tr -d '\n')
1589
charset_2=$(echo "${charset_2}" | sort -u | tr -d '\n')
1590
charset_3=$(echo "${charset_3}" | sort -u | tr -d '\n')
1591
charset_4=$(echo "${charset_4}" | sort -u | tr -d '\n')
1592
1593
custom_charsets="-1 ${charset_1} -2 ${charset_2} -3 ${charset_3} -4 ${charset_4}"
1594
fi
1595
1596
increment_charset_opts=""
1597
1598
if [ ${need_hcmask} -eq 0 ]; then # the "normal" case without .hcmask file
1599
increment_charset_opts="--increment --increment-min ${increment_min} --increment-max ${increment_max}"
1600
1601
if [ -n "${custom_charsets}" ]; then
1602
increment_charset_opts="${increment_charset_opts} ${custom_charsets}"
1603
fi
1604
fi
1605
1606
CMD="./${BIN} ${OPTS} -a 3 -m ${hash_type} ${increment_charset_opts} ${hash_file} ${mask} "
1607
1608
echo "> Testing hash type $hash_type with attack mode 3, markov ${MARKOV}, multi hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}." >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
1609
1610
output=$(./${BIN} ${OPTS} -a 3 -m ${hash_type} ${increment_charset_opts} ${hash_file} ${mask} 2>&1)
1611
1612
ret=${?}
1613
1614
echo "${output}" >> "${OUTD}/logfull.txt"
1615
1616
if [ "${ret}" -eq 0 ]; then
1617
1618
i=1
1619
1620
while read -r -u 9 hash; do
1621
line_nr=$((i + cracks_offset))
1622
1623
pass=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_passwords.txt")
1624
1625
if [ "${pass_only}" -eq 1 ]; then
1626
search=":${pass}"
1627
else
1628
search="${hash}:${pass}"
1629
fi
1630
1631
echo "${output}" | grep -F "${search}" &>/dev/null
1632
1633
newRet=$?
1634
1635
if [ "${newRet}" -ne 0 ]; then
1636
if [ "${newRet}" -eq 2 ]; then
1637
ret=20
1638
else
1639
ret=10
1640
fi
1641
1642
break
1643
fi
1644
1645
i=$((i + 1))
1646
1647
done 9< "${OUTD}/${hash_type}_multihash_bruteforce.txt"
1648
1649
fi
1650
1651
status ${ret}
1652
1653
msg="OK"
1654
1655
if [ "${e_ce}" -ne 0 ]; then
1656
msg="Compare Error"
1657
elif [ "${e_rs}" -ne 0 ]; then
1658
msg="Skip"
1659
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
1660
msg="Error"
1661
elif [ "${e_to}" -ne 0 ]; then
1662
msg="Warning"
1663
fi
1664
1665
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
1666
fi
1667
}
1668
1669
function attack_6()
1670
{
1671
file_only=0
1672
1673
if is_in_array "${hash_type}" ${FILE_BASED_ALGOS}; then
1674
file_only=1
1675
fi
1676
1677
# single hash
1678
if [ "${MODE}" -ne 1 ]; then
1679
1680
e_ce=0
1681
e_rs=0
1682
e_to=0
1683
e_nf=0
1684
e_nm=0
1685
cnt=0
1686
1687
echo "> Testing hash type $hash_type with attack mode 6, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}." >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
1688
1689
min=1
1690
max=8
1691
mask_offset=0
1692
1693
if [ "${hash_type}" -eq 2500 ]; then
1694
max=6
1695
elif [ "${hash_type}" -eq 14000 ]; then
1696
min=0
1697
max=1
1698
mask_offset=4
1699
elif [ "${hash_type}" -eq 14100 ]; then
1700
min=0
1701
max=1
1702
mask_offset=21
1703
elif [ "${hash_type}" -eq 14900 ]; then
1704
min=0
1705
max=1
1706
mask_offset=5
1707
elif [ "${hash_type}" -eq 15400 ]; then
1708
min=0
1709
max=1
1710
mask_offset=29
1711
elif [ "${hash_type}" -eq 16800 ]; then
1712
max=6
1713
elif [ "${hash_type}" -eq 22000 ]; then
1714
max=6
1715
fi
1716
1717
# special case: we need to split the first line
1718
1719
if [ "${min}" -eq 0 ]; then
1720
pass_part_1=$(sed -n 1p "${OUTD}/${hash_type}_dict1")
1721
pass_part_2=$(sed -n 1p "${OUTD}/${hash_type}_dict2")
1722
1723
pass="${pass_part_1}${pass_part_2}"
1724
1725
echo -n "${pass}" | cut -b -$((mask_offset + 0)) > "${OUTD}/${hash_type}_dict1_custom"
1726
echo -n "${pass}" | cut -b $((mask_offset + 1))- > "${OUTD}/${hash_type}_dict2_custom"
1727
1728
mask_custom=""
1729
1730
for i in $(seq 1 $((${#pass} - mask_offset))); do
1731
1732
if [ "${hash_type}" -eq 14000 ]; then
1733
char=$(echo -n "${pass}" | cut -b $((i + mask_offset)))
1734
mask_custom="${mask_custom}${char}"
1735
elif [ "${hash_type}" -eq 14100 ]; then
1736
char=$(echo -n "${pass}" | cut -b $((i + mask_offset)))
1737
mask_custom="${mask_custom}${char}"
1738
else
1739
mask_custom="${mask_custom}?d"
1740
fi
1741
1742
done
1743
fi
1744
1745
i=1
1746
1747
while read -r -u 9 hash; do
1748
1749
if [ "${i}" -gt 6 ]; then
1750
if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then
1751
break
1752
fi
1753
fi
1754
1755
if [ ${i} -gt ${min} ]; then
1756
1757
if [ "${file_only}" -eq 1 ]; then
1758
1759
temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt"
1760
1761
if [ "${hash_type}" -ne 22000 ]; then
1762
echo "${hash}" | base64 -d > "${temp_file}"
1763
else
1764
echo "${hash}" > "${temp_file}"
1765
fi
1766
1767
hash="${temp_file}"
1768
1769
fi
1770
1771
dict1=${OUTD}/${hash_type}_dict1
1772
dict2=${OUTD}/${hash_type}_dict2
1773
1774
dict1_a6=${OUTD}/${hash_type}_dict1_a6
1775
1776
cp "${dict1}" "${dict1_a6}"
1777
1778
pass=$(sed -n ${i}p "${OUTD}/${hash_type}_passwords.txt")
1779
1780
if [ "${hash_type}" -eq 20510 ]; then # special case for PKZIP Master Key
1781
pass=$(echo "${pass}" | cut -b 7-) # skip the first 6 chars
1782
fi
1783
1784
if [ ${#pass} -le ${i} ]; then
1785
i=$((i + 1))
1786
continue
1787
fi
1788
1789
echo "${pass}" | cut -b -$((${#pass} - i)) >> "${dict1_a6}"
1790
1791
# the block below is just a fancy way to do a "shuf" (or sort -R) because macOS doesn't really support it natively
1792
# we do not really need a shuf, but it's actually better for testing purposes
1793
1794
rm -f "${dict1_a6}.txt" # temporary file
1795
1796
line_num=$(wc -l "${dict1_a6}" | sed -E 's/ *([0-9]+) .*$/\1/')
1797
1798
sorted_lines=$(seq 1 "${line_num}")
1799
1800
for lines in $(seq 1 "${line_num}"); do
1801
1802
random_num=$((RANDOM % line_num))
1803
random_num=$((random_num + 1)) # sed -n [n]p starts counting with 1 (not 0)
1804
1805
random_line=$(echo -n "${sorted_lines}" | sed -n ${random_num}p)
1806
1807
sed -n ${random_line}p "${dict1_a6}" >> "${dict1_a6}.txt"
1808
1809
# update the temp list of lines
1810
1811
sorted_lines=$(echo -n "${sorted_lines}" | grep -v "^${random_line}$")
1812
1813
line_num=$((line_num - 1))
1814
1815
done
1816
1817
mv "${dict1_a6}.txt" "${dict1_a6}"
1818
1819
# end of shuf/sort -R
1820
1821
mask=""
1822
1823
for j in $(seq 1 ${i}); do
1824
mask="${mask}?d"
1825
done
1826
1827
CMD="./${BIN} ${OPTS} -a 6 -m ${hash_type} '${hash}' ${dict1_a6} ${mask}"
1828
1829
echo -n "[ len $i ] " >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
1830
1831
output=$(./${BIN} ${OPTS} -a 6 -m ${hash_type} "${hash}" ${dict1_a6} ${mask} 2>&1)
1832
1833
ret=${?}
1834
1835
echo "${output}" >> "${OUTD}/logfull.txt"
1836
1837
if [ "${ret}" -eq 0 ]; then
1838
1839
line_nr=1
1840
1841
if [ "${i}" -gt 1 ]; then
1842
line_nr=$((i - 1))
1843
fi
1844
1845
line_dict1=$(sed -n ${line_nr}p "${dict1}")
1846
line_dict2=$(sed -n ${line_nr}p "${dict2}")
1847
1848
if [ "${pass_only}" -eq 1 ]; then
1849
search=":${line_dict1}${line_dict2}"
1850
else
1851
search="${hash}:${line_dict1}${line_dict2}"
1852
fi
1853
1854
echo "${output}" | grep -F "${search}" &>/dev/null
1855
1856
newRet=$?
1857
1858
if [ "${newRet}" -eq 2 ]; then
1859
1860
# out-of-memory, workaround
1861
1862
echo "${output}" | grep -v "^Unsupported\|^$" | head -1 > tmp_file_out
1863
echo "${search}" > tmp_file_search
1864
1865
out_md5=$(md5sum tmp_file_out | cut -d' ' -f1)
1866
search_md5=$(md5sum tmp_file_search | cut -d' ' -f1)
1867
1868
rm tmp_file_out tmp_file_search
1869
1870
if [ "${out_md5}" == "${search_md5}" ]; then
1871
newRet=0
1872
fi
1873
fi
1874
1875
if [ "${newRet}" -ne 0 ]; then
1876
if [ "${newRet}" -eq 2 ]; then
1877
ret=20
1878
else
1879
ret=10
1880
fi
1881
fi
1882
1883
fi
1884
1885
status ${ret}
1886
fi
1887
1888
if [ "${i}" -eq ${max} ]; then break; fi
1889
1890
i=$((i + 1))
1891
1892
done 9< "${OUTD}/${hash_type}_hashes.txt"
1893
1894
msg="OK"
1895
1896
if [ "${e_ce}" -ne 0 ]; then
1897
msg="Compare Error"
1898
elif [ "${e_rs}" -ne 0 ]; then
1899
msg="Skip"
1900
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
1901
msg="Error"
1902
elif [ "${e_to}" -ne 0 ]; then
1903
msg="Warning"
1904
fi
1905
1906
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 6, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
1907
1908
rm -f "${OUTD}/${hash_type}_dict1_custom"
1909
rm -f "${OUTD}/${hash_type}_dict2_custom"
1910
fi
1911
1912
# multihash
1913
if [ "${MODE}" -ne 0 ]; then
1914
1915
# no multi hash checks for these modes (because we only have 1 hash for each of them)
1916
1917
if [ "${hash_type}" -eq 14000 ]; then
1918
return
1919
elif [ "${hash_type}" -eq 14100 ]; then
1920
return
1921
elif [ "${hash_type}" -eq 14900 ]; then
1922
return
1923
elif [ "${hash_type}" -eq 15400 ]; then
1924
return
1925
fi
1926
1927
e_ce=0
1928
e_rs=0
1929
e_to=0
1930
e_nf=0
1931
e_nm=0
1932
cnt=0
1933
1934
min=1
1935
max=9
1936
1937
if [ "${hash_type}" -eq 2500 ]; then
1938
max=5
1939
elif [ "${hash_type}" -eq 3000 ]; then
1940
max=8
1941
elif [ "${hash_type}" -eq 7700 ] || [ "${hash_type}" -eq 7701 ]; then
1942
max=8
1943
elif [ "${hash_type}" -eq 8500 ]; then
1944
max=8
1945
elif [ "${hash_type}" -eq 16800 ]; then
1946
max=5
1947
elif [ "${hash_type}" -eq 22000 ]; then
1948
max=5
1949
elif [ "${hash_type}" -eq 33500 ]; then
1950
min=5
1951
elif [ "${hash_type}" -eq 33501 ]; then
1952
min=8
1953
elif [ "${hash_type}" -eq 33502 ]; then
1954
min=8
1955
fi
1956
1957
if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then
1958
max=5
1959
if [ "${hash_type}" -eq 3200 ]; then
1960
max=3
1961
fi
1962
fi
1963
1964
i=2
1965
while [ "$i" -lt "$max" ]; do
1966
1967
if [ "$i" -lt "$min" ]; then
1968
i=$((i + 1))
1969
continue
1970
fi
1971
1972
hash_file=${OUTD}/${hash_type}_hashes_multi_${i}.txt
1973
1974
# if file_only -> decode all base64 "hashes" and put them in the temporary file
1975
1976
if [ "${file_only}" -eq 1 ]; then
1977
1978
temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt"
1979
rm -f "${temp_file}"
1980
1981
hash_file=${temp_file}
1982
1983
while read -r file_only_hash; do
1984
1985
if [ "${hash_type}" -ne 22000 ]; then
1986
echo -n "${file_only_hash}" | base64 -d >> "${temp_file}"
1987
else
1988
echo "${file_only_hash}" >> "${temp_file}"
1989
fi
1990
1991
done < "${OUTD}/${hash_type}_hashes_multi_${i}.txt"
1992
1993
fi
1994
1995
mask=${mask_6[$i]}
1996
1997
CMD="./${BIN} ${OPTS} -a 6 -m ${hash_type} ${hash_file} ${OUTD}/${hash_type}_dict1_multi_${i} ${mask}"
1998
1999
echo "> Testing hash type $hash_type with attack mode 6, markov ${MARKOV}, multi hash with word len ${i}." >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
2000
2001
output=$(./${BIN} ${OPTS} -a 6 -m ${hash_type} ${hash_file} ${OUTD}/${hash_type}_dict1_multi_${i} ${mask} 2>&1)
2002
2003
ret=${?}
2004
2005
echo "${output}" >> "${OUTD}/logfull.txt"
2006
2007
if [ "${ret}" -eq 0 ]; then
2008
2009
j=1
2010
2011
while read -r -u 9 hash; do
2012
2013
line_dict1=$(sed -n ${j}p "${OUTD}/${hash_type}_dict1_multi_${i}")
2014
line_dict2=$(sed -n ${j}p "${OUTD}/${hash_type}_dict2_multi_${i}")
2015
2016
if [ "${pass_only}" -eq 1 ]; then
2017
search=":${line_dict1}${line_dict2}"
2018
else
2019
search="${hash}:${line_dict1}${line_dict2}"
2020
fi
2021
2022
echo "${output}" | grep -F "${search}" &>/dev/null
2023
2024
newRet=$?
2025
2026
if [ "${newRet}" -ne 0 ]; then
2027
if [ "${newRet}" -eq 2 ]; then
2028
ret=20
2029
else
2030
ret=10
2031
fi
2032
2033
break
2034
fi
2035
2036
j=$((j + 1))
2037
2038
done 9< "${OUTD}/${hash_type}_hashes_multi_${i}.txt"
2039
fi
2040
2041
status ${ret}
2042
i=$((i + 1))
2043
2044
done
2045
2046
msg="OK"
2047
2048
if [ "${e_ce}" -ne 0 ]; then
2049
msg="Compare Error"
2050
elif [ "${e_rs}" -ne 0 ]; then
2051
msg="Skip"
2052
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
2053
msg="Error"
2054
elif [ "${e_to}" -ne 0 ]; then
2055
msg="Warning"
2056
fi
2057
2058
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 6, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
2059
fi
2060
}
2061
2062
function attack_7()
2063
{
2064
file_only=0
2065
2066
if is_in_array "${hash_type}" ${FILE_BASED_ALGOS}; then
2067
file_only=1
2068
fi
2069
2070
# single hash
2071
if [ "${MODE}" -ne 1 ]; then
2072
2073
e_ce=0
2074
e_rs=0
2075
e_to=0
2076
e_nf=0
2077
e_nm=0
2078
cnt=0
2079
2080
echo "> Testing hash type $hash_type with attack mode 7, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}." >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
2081
2082
min=1
2083
max=8
2084
2085
mask_offset=0
2086
2087
if [ "${hash_type}" -eq 2500 ]; then
2088
max=5
2089
elif [ "${hash_type}" -eq 14000 ]; then
2090
mask_offset=4
2091
min=0
2092
max=1
2093
elif [ "${hash_type}" -eq 14100 ]; then
2094
mask_offset=3
2095
min=0
2096
max=1
2097
elif [ "${hash_type}" -eq 14900 ]; then
2098
mask_offset=5
2099
min=0
2100
max=1
2101
elif [ "${hash_type}" -eq 15400 ]; then
2102
mask_offset=3
2103
min=0
2104
max=1
2105
elif [ "${hash_type}" -eq 16800 ]; then
2106
max=5
2107
elif [ "${hash_type}" -eq 22000 ]; then
2108
max=5
2109
fi
2110
2111
# special case: we need to split the first line
2112
2113
if [ "${min}" -eq 0 ]; then
2114
2115
pass_part_1=$(sed -n 1p "${OUTD}/${hash_type}_dict1")
2116
pass_part_2=$(sed -n 1p "${OUTD}/${hash_type}_dict2")
2117
2118
pass="${pass_part_1}${pass_part_2}"
2119
2120
echo -n "${pass}" | cut -b -$((mask_offset + 0)) > "${OUTD}/${hash_type}_dict1_custom"
2121
echo -n "${pass}" | cut -b $((mask_offset + 1))- > "${OUTD}/${hash_type}_dict2_custom"
2122
2123
mask_custom=""
2124
2125
for i in $(seq 1 ${mask_offset}); do
2126
2127
if [ "${hash_type}" -eq 14000 ]; then
2128
char=$(echo -n "${pass}" | cut -b ${i})
2129
mask_custom="${mask_custom}${char}"
2130
elif [ "${hash_type}" -eq 14100 ]; then
2131
char=$(echo -n "${pass}" | cut -b ${i})
2132
mask_custom="${mask_custom}${char}"
2133
else
2134
mask_custom="${mask_custom}?d"
2135
fi
2136
2137
done
2138
2139
fi
2140
2141
i=1
2142
2143
while read -r -u 9 hash; do
2144
2145
if [ ${i} -gt ${min} ]; then
2146
2147
if [ "${file_only}" -eq 1 ]; then
2148
2149
temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt"
2150
2151
if [ "${hash_type}" -ne 22000 ]; then
2152
echo "${hash}" | base64 -d > "${temp_file}"
2153
else
2154
echo "${hash}" > "${temp_file}"
2155
fi
2156
2157
hash="${temp_file}"
2158
2159
fi
2160
2161
mask=${mask_7[$i]}
2162
2163
# adjust mask if needed
2164
2165
line_nr=1
2166
2167
if [ "${i}" -gt 1 ]; then
2168
line_nr=$((i - 1))
2169
fi
2170
2171
if [ "${hash_type}" -eq 2500 ]; then
2172
2173
pass_part_1=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict1")
2174
pass_part_2=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict2")
2175
2176
pass_part_2_len=${#pass_part_2}
2177
2178
pass=${pass_part_1}${pass_part_2}
2179
2180
pass_len=${#pass}
2181
2182
# add first x chars of password to mask and append the (old) mask
2183
2184
mask_len=${#mask}
2185
mask_len=$((mask_len / 2))
2186
2187
mask_prefix=$(echo ${pass} | cut -b -$((pass_len - mask_len - pass_part_2_len)))
2188
mask=${mask_prefix}${mask}
2189
2190
fi
2191
2192
if [ "${hash_type}" -eq 16800 ]; then
2193
2194
pass_part_1=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict1")
2195
pass_part_2=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict2")
2196
2197
pass_part_2_len=${#pass_part_2}
2198
2199
pass=${pass_part_1}${pass_part_2}
2200
pass_len=${#pass}
2201
2202
# add first x chars of password to mask and append the (old) mask
2203
2204
mask_len=${#mask}
2205
mask_len=$((mask_len / 2))
2206
2207
mask_prefix=$(echo "${pass}" | cut -b -$((pass_len - mask_len - pass_part_2_len)))
2208
mask=${mask_prefix}${mask}
2209
2210
fi
2211
2212
if [ "${hash_type}" -eq 22000 ]; then
2213
2214
pass_part_1=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict1")
2215
pass_part_2=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict2")
2216
2217
pass_part_2_len=${#pass_part_2}
2218
2219
pass=${pass_part_1}${pass_part_2}
2220
pass_len=${#pass}
2221
2222
# add first x chars of password to mask and append the (old) mask
2223
2224
mask_len=${#mask}
2225
mask_len=$((mask_len / 2))
2226
2227
mask_prefix=$(echo "${pass}" | cut -b -$((pass_len - mask_len - pass_part_2_len)))
2228
mask=${mask_prefix}${mask}
2229
2230
fi
2231
2232
if [ "${hash_type}" -eq 20510 ]; then
2233
2234
pass_part_1=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict1")
2235
pass_part_2=$(sed -n ${line_nr}p "${OUTD}/${hash_type}_dict2")
2236
2237
pass=${pass_part_1}${pass_part_2}
2238
2239
pass_len=${#pass}
2240
2241
if [ "${pass_len}" -le 6 ]; then
2242
i=$((i + 1))
2243
continue
2244
fi
2245
2246
pass_old=${pass}
2247
2248
pass=$(echo "${pass}" | cut -b 7-) # skip the first 6 chars
2249
2250
mask_len=$((${#mask} / 2))
2251
2252
echo "${pass_old}" | cut -b -$((6 + mask_len)) > "${OUTD}/${hash_type}_dict1_custom"
2253
echo "${pass}" | cut -b $((mask_len + 1))- > "${OUTD}/${hash_type}_dict2_custom"
2254
2255
min=0 # hack to use the custom dict
2256
mask_custom=${mask}
2257
2258
fi
2259
2260
dict1=${OUTD}/${hash_type}_dict1
2261
dict2=${OUTD}/${hash_type}_dict2
2262
2263
if [ "${min}" -eq 0 ]; then
2264
mask=${mask_custom}
2265
2266
dict1=${OUTD}/${hash_type}_dict1_custom
2267
dict2=${OUTD}/${hash_type}_dict2_custom
2268
fi
2269
2270
CMD="./${BIN} ${OPTS} -a 7 -m ${hash_type} '${hash}' ${mask} ${dict2}"
2271
2272
echo -n "[ len $i ] " >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
2273
2274
output=$(./${BIN} ${OPTS} -a 7 -m ${hash_type} "${hash}" ${mask} ${dict2} 2>&1)
2275
2276
ret=${?}
2277
2278
echo "${output}" >> "${OUTD}/logfull.txt"
2279
2280
if [ "${ret}" -eq 0 ]; then
2281
2282
line_nr=1
2283
2284
if [ "${i}" -gt 1 ]; then
2285
line_nr=$((i - 1))
2286
fi
2287
2288
line_dict1=$(sed -n ${line_nr}p "${dict1}")
2289
line_dict2=$(sed -n ${line_nr}p "${dict2}")
2290
2291
if [ "${pass_only}" -eq 1 ]; then
2292
search=":${line_dict1}${line_dict2}"
2293
else
2294
search="${hash}:${line_dict1}${line_dict2}"
2295
fi
2296
2297
echo "${output}" | grep -F "${search}" &>/dev/null
2298
2299
newRet=$?
2300
2301
if [ "${newRet}" -eq 2 ]; then
2302
2303
# out-of-memory, workaround
2304
2305
echo "${output}" | grep -v "^Unsupported\|^$" | head -1 > tmp_file_out
2306
echo "${search}" > tmp_file_search
2307
2308
out_md5=$(md5sum tmp_file_out | cut -d' ' -f1)
2309
search_md5=$(md5sum tmp_file_search | cut -d' ' -f1)
2310
2311
rm tmp_file_out tmp_file_search
2312
2313
if [ "${out_md5}" == "${search_md5}" ]; then
2314
newRet=0
2315
fi
2316
fi
2317
2318
if [ "${newRet}" -ne 0 ]; then
2319
if [ "${newRet}" -eq 2 ]; then
2320
ret=20
2321
else
2322
ret=10
2323
fi
2324
fi
2325
2326
fi
2327
2328
status ${ret}
2329
fi
2330
2331
if [ $i -eq ${max} ]; then break; fi
2332
2333
i=$((i + 1))
2334
2335
done 9< "${OUTD}/${hash_type}_hashes.txt"
2336
2337
msg="OK"
2338
2339
if [ "${e_ce}" -ne 0 ]; then
2340
msg="Compare Error"
2341
elif [ "${e_rs}" -ne 0 ]; then
2342
msg="Skip"
2343
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
2344
msg="Error"
2345
elif [ "${e_to}" -ne 0 ]; then
2346
msg="Warning"
2347
fi
2348
2349
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 7, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
2350
2351
rm -f "${OUTD}/${hash_type}_dict1_custom"
2352
rm -f "${OUTD}/${hash_type}_dict2_custom"
2353
fi
2354
2355
# multihash
2356
if [ "${MODE}" -ne 0 ]; then
2357
2358
# no multi hash checks for these modes (because we only have 1 hash for each of them)
2359
2360
if [ "${hash_type}" -eq 14000 ]; then
2361
return
2362
elif [ "${hash_type}" -eq 14100 ]; then
2363
return
2364
elif [ "${hash_type}" -eq 14900 ]; then
2365
return
2366
elif [ "${hash_type}" -eq 15400 ]; then
2367
return
2368
fi
2369
2370
e_ce=0
2371
e_rs=0
2372
e_to=0
2373
e_nf=0
2374
e_nm=0
2375
cnt=0
2376
2377
max=9
2378
2379
if [ "${hash_type}" -eq 2500 ]; then
2380
max=5
2381
elif [ "${hash_type}" -eq 3000 ]; then
2382
max=8
2383
elif [ "${hash_type}" -eq 7700 ] || [ "${hash_type}" -eq 7701 ]; then
2384
max=8
2385
elif [ "${hash_type}" -eq 8500 ]; then
2386
max=8
2387
elif [ "${hash_type}" -eq 14000 ]; then
2388
max=5
2389
elif [ "${hash_type}" -eq 14100 ]; then
2390
max=5
2391
elif [ "${hash_type}" -eq 14900 ]; then
2392
max=5
2393
elif [ "${hash_type}" -eq 15400 ]; then
2394
max=5
2395
elif [ "${hash_type}" -eq 16800 ]; then
2396
max=5
2397
elif [ "${hash_type}" -eq 22000 ]; then
2398
max=5
2399
elif [ "${hash_type}" -eq 33500 ]; then
2400
min=5
2401
elif [ "${hash_type}" -eq 33501 ]; then
2402
max=3
2403
elif [ "${hash_type}" -eq 33502 ]; then
2404
max=3
2405
fi
2406
2407
if is_in_array "${hash_type}" ${TIMEOUT_ALGOS}; then
2408
max=7
2409
if [ "${hash_type}" -eq 3200 ]; then
2410
max=4
2411
fi
2412
fi
2413
2414
i=2
2415
while [ "$i" -lt "$max" ]; do
2416
2417
hash_file=${OUTD}/${hash_type}_hashes_multi_${i}.txt
2418
dict_file=${OUTD}/${hash_type}_dict2_multi_${i}
2419
2420
if [ "${hash_type}" -eq 40001 ]; then
2421
mask=${mask_7[((i+10))]}
2422
elif [ "${hash_type}" -eq 40002 ]; then
2423
mask=${mask_7[((i+10))]}
2424
else
2425
mask=${mask_7[$i]}
2426
fi
2427
2428
# if file_only -> decode all base64 "hashes" and put them in the temporary file
2429
2430
if [ "${file_only}" -eq 1 ]; then
2431
2432
temp_file="${OUTD}/${hash_type}_filebased_only_temp.txt"
2433
rm -f "${temp_file}"
2434
2435
hash_file=${temp_file}
2436
2437
while read -r file_only_hash; do
2438
2439
if [ "${hash_type}" -ne 22000 ]; then
2440
echo -n "${file_only_hash}" | base64 -d >> "${temp_file}"
2441
else
2442
echo "${file_only_hash}" >> "${temp_file}"
2443
fi
2444
2445
done < "${OUTD}/${hash_type}_hashes_multi_${i}.txt"
2446
2447
# a little hack: since we don't want to have a very large mask (and wpa has minimum length of 8),
2448
# we need to create a temporary dict file on-the-fly and use it like this: [small mask] [long(er) words in dict]
2449
2450
dict_file=${OUTD}/${hash_type}_dict2_multi_${i}_longer
2451
rm -f "${dict_file}"
2452
2453
mask_len=${#mask}
2454
mask_len=$((mask_len / 2))
2455
2456
j=1
2457
2458
while read -r -u 9 hash; do
2459
2460
pass_part_1=$(sed -n ${j}p "${OUTD}/${hash_type}_dict1_multi_${i}")
2461
pass_part_2=$(sed -n ${j}p "${OUTD}/${hash_type}_dict2_multi_${i}")
2462
2463
pass="${pass_part_1}${pass_part_2}"
2464
2465
pass_suffix=$(echo "${pass}" | cut -b $((mask_len + 1))-)
2466
2467
echo "${pass_suffix}" >> "${dict_file}"
2468
2469
j=$((j + 1))
2470
2471
done 9< "${OUTD}/${hash_type}_hashes_multi_${i}.txt"
2472
2473
fi
2474
2475
CMD="./${BIN} ${OPTS} -a 7 -m ${hash_type} ${hash_file} ${mask} ${dict_file}"
2476
2477
echo "> Testing hash type $hash_type with attack mode 7, markov ${MARKOV}, multi hash with word len ${i}." >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
2478
2479
output=$(./${BIN} ${OPTS} -a 7 -m ${hash_type} ${hash_file} ${mask} ${dict_file} 2>&1)
2480
2481
ret=${?}
2482
2483
echo "${output}" >> "${OUTD}/logfull.txt"
2484
2485
if [ "${ret}" -eq 0 ]; then
2486
2487
j=1
2488
2489
while read -r -u 9 hash; do
2490
2491
line_dict1=$(sed -n ${j}p "${OUTD}/${hash_type}_dict1_multi_${i}")
2492
line_dict2=$(sed -n ${j}p "${OUTD}/${hash_type}_dict2_multi_${i}")
2493
2494
if [ "${pass_only}" -eq 1 ]; then
2495
search=":${line_dict1}${line_dict2}"
2496
else
2497
search="${hash}:${line_dict1}${line_dict2}"
2498
fi
2499
2500
echo "${output}" | grep -F "${search}" &>/dev/null
2501
2502
newRet=$?
2503
2504
if [ "${newRet}" -ne 0 ]; then
2505
if [ "${newRet}" -eq 2 ]; then
2506
ret=20
2507
else
2508
ret=10
2509
fi
2510
2511
break
2512
fi
2513
2514
j=$((j + 1))
2515
2516
done 9< "${OUTD}/${hash_type}_hashes_multi_${i}.txt"
2517
fi
2518
2519
status ${ret}
2520
i=$((i + 1))
2521
2522
done
2523
2524
msg="OK"
2525
2526
if [ "${e_ce}" -ne 0 ]; then
2527
msg="Compare Error"
2528
elif [ "${e_rs}" -ne 0 ]; then
2529
msg="Skip"
2530
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
2531
msg="Error"
2532
elif [ "${e_to}" -ne 0 ]; then
2533
msg="Warning"
2534
fi
2535
2536
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 7, Mode multi, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
2537
fi
2538
}
2539
2540
function cryptoloop_test()
2541
{
2542
hashType=$1
2543
keySize=$2
2544
CMD="unset"
2545
2546
mkdir -p ${OUTD}/cl_tests
2547
chmod u+x "${TDIR}/cryptoloop2hashcat.py"
2548
2549
case $hashType in
2550
2551
14511)
2552
case $keySize in
2553
128|192|256)
2554
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha1_aes_${keySize}.img\" --hash sha1 --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha1_aes_${keySize}.hash
2555
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha1_aes_${keySize}.hash hashca?l"
2556
;;
2557
esac
2558
;;
2559
2560
14512)
2561
case $keySize in
2562
128|192|256)
2563
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha1_serpent_${keySize}.img\" --hash sha1 --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha1_serpent_${keySize}.hash
2564
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha1_serpent_${keySize}.hash hashca?l"
2565
;;
2566
esac
2567
;;
2568
2569
14513)
2570
case $keySize in
2571
128|192|256)
2572
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha1_twofish_${keySize}.img\" --hash sha1 --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha1_twofish_${keySize}.hash
2573
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha1_twofish_${keySize}.hash hashca?l"
2574
;;
2575
esac
2576
;;
2577
2578
14521)
2579
case $keySize in
2580
128|192|256)
2581
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha256_aes_${keySize}.img\" --hash sha256 --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha256_aes_${keySize}.hash
2582
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha256_aes_${keySize}.hash hashca?l"
2583
;;
2584
esac
2585
;;
2586
2587
14522)
2588
case $keySize in
2589
128|192|256)
2590
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha256_serpent_${keySize}.img\" --hash sha256 --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha256_serpent_${keySize}.hash
2591
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha256_serpent_${keySize}.hash hashca?l"
2592
;;
2593
esac
2594
;;
2595
2596
14523)
2597
case $keySize in
2598
128|192|256)
2599
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha256_twofish_${keySize}.img\" --hash sha256 --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha256_twofish_${keySize}.hash
2600
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha256_twofish_${keySize}.hash hashca?l"
2601
;;
2602
esac
2603
;;
2604
2605
14531)
2606
case $keySize in
2607
128|192|256)
2608
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha512_aes_${keySize}.img\" --hash sha512 --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha512_aes_${keySize}.hash
2609
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha512_aes_${keySize}.hash hashca?l"
2610
;;
2611
esac
2612
;;
2613
2614
14532)
2615
case $keySize in
2616
128|192|256)
2617
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha512_serpent_${keySize}.img\" --hash sha512 --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha512_serpent_${keySize}.hash
2618
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha512_serpent_${keySize}.hash hashca?l"
2619
;;
2620
esac
2621
;;
2622
2623
14533)
2624
case $keySize in
2625
128|192|256)
2626
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_sha512_twofish_${keySize}.img\" --hash sha512 --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_sha512_twofish_${keySize}.hash
2627
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_sha512_twofish_${keySize}.hash hashca?l"
2628
;;
2629
esac
2630
;;
2631
2632
14541)
2633
case $keySize in
2634
128|192|256)
2635
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_ripemd160_aes_${keySize}.img\" --hash ripemd160 --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_ripemd160_aes_${keySize}.hash
2636
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_ripemd160_aes_${keySize}.hash hashca?l"
2637
;;
2638
esac
2639
;;
2640
2641
14542)
2642
case $keySize in
2643
128|192|256)
2644
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_ripemd160_serpent_${keySize}.img\" --hash ripemd160 --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_ripemd160_serpent_${keySize}.hash
2645
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_ripemd160_serpent_${keySize}.hash hashca?l"
2646
;;
2647
esac
2648
;;
2649
2650
14543)
2651
case $keySize in
2652
128|192|256)
2653
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_ripemd160_twofish_${keySize}.img\" --hash ripemd160 --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_ripemd160_twofish_${keySize}.hash
2654
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_ripemd160_twofish_${keySize}.hash hashca?l"
2655
;;
2656
esac
2657
;;
2658
2659
14551)
2660
case $keySize in
2661
128|192|256)
2662
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_whirlpool_aes_${keySize}.img\" --hash whirlpool --cipher aes --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_whirlpool_aes_${keySize}.hash
2663
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_whirlpool_aes_${keySize}.hash hashca?l"
2664
;;
2665
esac
2666
;;
2667
2668
14552)
2669
case $keySize in
2670
128|192|256)
2671
eval \"${TDIR}/cryptoloop2hashcat.py\" --source \"${TDIR}/cl_tests/hashcat_whirlpool_serpent_${keySize}.img\" --hash whirlpool --cipher serpent --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_whirlpool_serpent_${keySize}.hash
2672
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_whirlpool_serpent_${keySize}.hash hashca?l"
2673
;;
2674
esac
2675
;;
2676
2677
14553)
2678
case $keySize in
2679
128|192|256)
2680
eval \"${TDIR}/cryptoloop2hashcat.py --source ${TDIR}/cl_tests/hashcat_whirlpool_twofish_${keySize}.img\" --hash whirlpool --cipher twofish --keysize ${keySize} > ${OUTD}/cl_tests/hashcat_whirlpool_twofish_${keySize}.hash
2681
CMD="./${BIN} ${OPTS} -a 3 -m 14500 ${OUTD}/cl_tests/hashcat_whirlpool_twofish_${keySize}.hash hashca?l"
2682
;;
2683
esac
2684
;;
2685
esac
2686
2687
if [ ${#CMD} -gt 5 ]; then
2688
echo "> Testing hash type $hashType with attack mode 3, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, Key-Size ${keySize}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
2689
2690
output=$(${CMD} 2>&1)
2691
2692
ret=${?}
2693
2694
echo "${output}" >> "${OUTD}/logfull.txt"
2695
2696
e_ce=0
2697
e_rs=0
2698
e_to=0
2699
e_nf=0
2700
e_nm=0
2701
cnt=0
2702
2703
status ${ret}
2704
2705
cnt=1
2706
2707
msg="OK"
2708
2709
if [ "${e_ce}" -ne 0 ]; then
2710
msg="Compare Error"
2711
elif [ "${e_rs}" -ne 0 ]; then
2712
msg="Skip"
2713
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
2714
msg="Error"
2715
elif [ "${e_to}" -ne 0 ]; then
2716
msg="Warning"
2717
fi
2718
2719
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, Key-Size ${keySize} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
2720
fi
2721
}
2722
2723
function truecrypt_test()
2724
{
2725
hashType=$1
2726
tcMode=$2
2727
CMD="unset"
2728
2729
mkdir -p ${OUTD}/tc_tests
2730
chmod u+x "${TDIR}/truecrypt2hashcat.py"
2731
2732
case $hashType in
2733
2734
6211)
2735
case $tcMode in
2736
0)
2737
CMD="./${BIN} ${OPTS} -a 3 -m 6211 '${TDIR}/tc_tests/hashcat_ripemd160_aes.tc' hashca?l"
2738
;;
2739
1)
2740
CMD="./${BIN} ${OPTS} -a 3 -m 6211 '${TDIR}/tc_tests/hashcat_ripemd160_serpent.tc' hashca?l"
2741
;;
2742
2)
2743
CMD="./${BIN} ${OPTS} -a 3 -m 6211 '${TDIR}/tc_tests/hashcat_ripemd160_twofish.tc' hashca?l"
2744
;;
2745
esac
2746
;;
2747
2748
6212)
2749
case $tcMode in
2750
0)
2751
CMD="./${BIN} ${OPTS} -a 3 -m 6212 '${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish.tc' hashca?l"
2752
;;
2753
1)
2754
CMD="./${BIN} ${OPTS} -a 3 -m 6212 '${TDIR}/tc_tests/hashcat_ripemd160_serpent-aes.tc' hashca?l"
2755
;;
2756
2)
2757
CMD="./${BIN} ${OPTS} -a 3 -m 6212 '${TDIR}/tc_tests/hashcat_ripemd160_twofish-serpent.tc' hashca?l"
2758
;;
2759
esac
2760
;;
2761
2762
6213)
2763
case $tcMode in
2764
0)
2765
CMD="./${BIN} ${OPTS} -a 3 -m 6213 '${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish-serpent.tc' hashca?l"
2766
;;
2767
1)
2768
CMD="./${BIN} ${OPTS} -a 3 -m 6213 '${TDIR}/tc_tests/hashcat_ripemd160_serpent-twofish-aes.tc' hashca?l"
2769
;;
2770
esac
2771
;;
2772
2773
6221)
2774
case $tcMode in
2775
0)
2776
CMD="./${BIN} ${OPTS} -a 3 -m 6221 '${TDIR}/tc_tests/hashcat_sha512_aes.tc' hashca?l"
2777
;;
2778
1)
2779
CMD="./${BIN} ${OPTS} -a 3 -m 6221 '${TDIR}/tc_tests/hashcat_sha512_serpent.tc' hashca?l"
2780
;;
2781
2)
2782
CMD="./${BIN} ${OPTS} -a 3 -m 6221 '${TDIR}/tc_tests/hashcat_sha512_twofish.tc' hashca?l"
2783
;;
2784
esac
2785
;;
2786
2787
6222)
2788
case $tcMode in
2789
0)
2790
CMD="./${BIN} ${OPTS} -a 3 -m 6222 '${TDIR}/tc_tests/hashcat_sha512_aes-twofish.tc' hashca?l"
2791
;;
2792
1)
2793
CMD="./${BIN} ${OPTS} -a 3 -m 6222 '${TDIR}/tc_tests/hashcat_sha512_serpent-aes.tc' hashca?l"
2794
;;
2795
2)
2796
CMD="./${BIN} ${OPTS} -a 3 -m 6222 '${TDIR}/tc_tests/hashcat_sha512_twofish-serpent.tc' hashca?l"
2797
;;
2798
esac
2799
;;
2800
2801
6223)
2802
case $tcMode in
2803
0)
2804
CMD="./${BIN} ${OPTS} -a 3 -m 6223 '${TDIR}/tc_tests/hashcat_sha512_aes-twofish-serpent.tc' hashca?l"
2805
;;
2806
1)
2807
CMD="./${BIN} ${OPTS} -a 3 -m 6223 '${TDIR}/tc_tests/hashcat_sha512_serpent-twofish-aes.tc' hashca?l"
2808
;;
2809
esac
2810
;;
2811
2812
6231)
2813
case $tcMode in
2814
0)
2815
CMD="./${BIN} ${OPTS} -a 3 -m 6231 '${TDIR}/tc_tests/hashcat_whirlpool_aes.tc' hashca?l"
2816
;;
2817
1)
2818
CMD="./${BIN} ${OPTS} -a 3 -m 6231 '${TDIR}/tc_tests/hashcat_whirlpool_serpent.tc' hashca?l"
2819
;;
2820
2)
2821
CMD="./${BIN} ${OPTS} -a 3 -m 6231 '${TDIR}/tc_tests/hashcat_whirlpool_twofish.tc' hashca?l"
2822
;;
2823
esac
2824
;;
2825
2826
6232)
2827
case $tcMode in
2828
0)
2829
CMD="./${BIN} ${OPTS} -a 3 -m 6232 '${TDIR}/tc_tests/hashcat_whirlpool_aes-twofish.tc' hashca?l"
2830
;;
2831
1)
2832
CMD="./${BIN} ${OPTS} -a 3 -m 6232 '${TDIR}/tc_tests/hashcat_whirlpool_serpent-aes.tc' hashca?l"
2833
;;
2834
2)
2835
CMD="./${BIN} ${OPTS} -a 3 -m 6232 '${TDIR}/tc_tests/hashcat_whirlpool_twofish-serpent.tc' hashca?l"
2836
;;
2837
esac
2838
;;
2839
2840
6233)
2841
case $tcMode in
2842
0)
2843
CMD="./${BIN} ${OPTS} -a 3 -m 6233 '${TDIR}/tc_tests/hashcat_whirlpool_aes-twofish-serpent.tc' hashca?l"
2844
;;
2845
1)
2846
CMD="./${BIN} ${OPTS} -a 3 -m 6233 '${TDIR}/tc_tests/hashcat_whirlpool_serpent-twofish-aes.tc' hashca?l"
2847
;;
2848
esac
2849
;;
2850
2851
6241)
2852
case $tcMode in
2853
0)
2854
CMD="./${BIN} ${OPTS} -a 3 -m 6241 '${TDIR}/tc_tests/hashcat_ripemd160_aes_boot.tc' hashca?l"
2855
;;
2856
1)
2857
CMD="./${BIN} ${OPTS} -a 3 -m 6241 '${TDIR}/tc_tests/hashcat_ripemd160_serpent_boot.tc' hashca?l"
2858
;;
2859
2)
2860
CMD="./${BIN} ${OPTS} -a 3 -m 6241 '${TDIR}/tc_tests/hashcat_ripemd160_twofish_boot.tc' hashca?l"
2861
;;
2862
esac
2863
;;
2864
2865
6242)
2866
case $tcMode in
2867
0)
2868
CMD="./${BIN} ${OPTS} -a 3 -m 6242 '${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish_boot.tc' hashca?l"
2869
;;
2870
1)
2871
CMD="./${BIN} ${OPTS} -a 3 -m 6242 '${TDIR}/tc_tests/hashcat_ripemd160_serpent-aes_boot.tc' hashca?l"
2872
;;
2873
esac
2874
;;
2875
2876
6243)
2877
case $tcMode in
2878
0)
2879
CMD="./${BIN} ${OPTS} -a 3 -m 6243 '${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish-serpent_boot.tc' hashca?l"
2880
;;
2881
esac
2882
;;
2883
2884
29311)
2885
case $tcMode in
2886
0)
2887
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_aes.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_aes.hash
2888
CMD="./${BIN} ${OPTS} -a 3 -m 29311 '${OUTD}/tc_tests/hashcat_ripemd160_aes.hash' hashca?l"
2889
;;
2890
1)
2891
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_serpent.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_serpent.hash
2892
CMD="./${BIN} ${OPTS} -a 3 -m 29311 '${OUTD}/tc_tests/hashcat_ripemd160_serpent.hash' hashca?l"
2893
;;
2894
2)
2895
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_twofish.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_twofish.hash
2896
CMD="./${BIN} ${OPTS} -a 3 -m 29311 '${OUTD}/tc_tests/hashcat_ripemd160_twofish.hash' hashca?l"
2897
;;
2898
esac
2899
;;
2900
2901
29312)
2902
case $tcMode in
2903
0)
2904
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_aes-twofish.hash
2905
CMD="./${BIN} ${OPTS} -a 3 -m 29312 '${OUTD}/tc_tests/hashcat_ripemd160_aes-twofish.hash' hashca?l"
2906
;;
2907
1)
2908
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_serpent-aes.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_serpent-aes.hash
2909
CMD="./${BIN} ${OPTS} -a 3 -m 29312 '${OUTD}/tc_tests/hashcat_ripemd160_serpent-aes.hash' hashca?l"
2910
;;
2911
2)
2912
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_twofish-serpent.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_twofish-serpent.hash
2913
CMD="./${BIN} ${OPTS} -a 3 -m 29312 '${OUTD}/tc_tests/hashcat_ripemd160_twofish-serpent.hash' hashca?l"
2914
;;
2915
esac
2916
;;
2917
2918
29313)
2919
case $tcMode in
2920
0)
2921
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish-serpent.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_aes-twofish-serpent.hash
2922
CMD="./${BIN} ${OPTS} -a 3 -m 29313 '${OUTD}/tc_tests/hashcat_ripemd160_aes-twofish-serpent.hash' hashca?l"
2923
;;
2924
1)
2925
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_serpent-twofish-aes.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_serpent-twofish-aes.hash
2926
CMD="./${BIN} ${OPTS} -a 3 -m 29313 '${OUTD}/tc_tests/hashcat_ripemd160_serpent-twofish-aes.hash' hashca?l"
2927
;;
2928
esac
2929
;;
2930
2931
29321)
2932
case $tcMode in
2933
0)
2934
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_sha512_aes.tc\" > ${OUTD}/tc_tests/hashcat_sha512_aes.hash
2935
CMD="./${BIN} ${OPTS} -a 3 -m 29321 '${OUTD}/tc_tests/hashcat_sha512_aes.hash' hashca?l"
2936
;;
2937
1)
2938
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_sha512_serpent.tc\" > ${OUTD}/tc_tests/hashcat_sha512_serpent.hash
2939
CMD="./${BIN} ${OPTS} -a 3 -m 29321 '${OUTD}/tc_tests/hashcat_sha512_serpent.hash' hashca?l"
2940
;;
2941
2)
2942
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_sha512_twofish.tc\" > ${OUTD}/tc_tests/hashcat_sha512_twofish.hash
2943
CMD="./${BIN} ${OPTS} -a 3 -m 29321 '${OUTD}/tc_tests/hashcat_sha512_twofish.hash' hashca?l"
2944
;;
2945
esac
2946
;;
2947
2948
29322)
2949
case $tcMode in
2950
0)
2951
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_sha512_aes-twofish.tc\" > ${OUTD}/tc_tests/hashcat_sha512_aes-twofish.hash
2952
CMD="./${BIN} ${OPTS} -a 3 -m 29322 '${OUTD}/tc_tests/hashcat_sha512_aes-twofish.hash' hashca?l"
2953
;;
2954
1)
2955
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_sha512_serpent-aes.tc\" > ${OUTD}/tc_tests/hashcat_sha512_serpent-aes.hash
2956
CMD="./${BIN} ${OPTS} -a 3 -m 29322 '${OUTD}/tc_tests/hashcat_sha512_serpent-aes.hash' hashca?l"
2957
;;
2958
2)
2959
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_sha512_twofish-serpent.tc\" > ${OUTD}/tc_tests/hashcat_sha512_twofish-serpent.hash
2960
CMD="./${BIN} ${OPTS} -a 3 -m 29322 '${OUTD}/tc_tests/hashcat_sha512_twofish-serpent.hash' hashca?l"
2961
;;
2962
esac
2963
;;
2964
2965
29323)
2966
case $tcMode in
2967
0)
2968
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_sha512_aes-twofish-serpent.tc\" > ${OUTD}/tc_tests/hashcat_sha512_aes-twofish-serpent.hash
2969
CMD="./${BIN} ${OPTS} -a 3 -m 29323 '${OUTD}/tc_tests/hashcat_sha512_aes-twofish-serpent.hash' hashca?l"
2970
;;
2971
1)
2972
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_sha512_serpent-twofish-aes.tc\" > ${OUTD}/tc_tests/hashcat_sha512_serpent-twofish-aes.hash
2973
CMD="./${BIN} ${OPTS} -a 3 -m 29323 '${OUTD}/tc_tests/hashcat_sha512_serpent-twofish-aes.hash' hashca?l"
2974
;;
2975
esac
2976
;;
2977
2978
29331)
2979
case $tcMode in
2980
0)
2981
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_whirlpool_aes.tc\" > ${OUTD}/tc_tests/hashcat_whirlpool_aes.hash
2982
CMD="./${BIN} ${OPTS} -a 3 -m 29331 '${OUTD}/tc_tests/hashcat_whirlpool_aes.hash' hashca?l"
2983
;;
2984
1)
2985
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_whirlpool_serpent.tc\" > ${OUTD}/tc_tests/hashcat_whirlpool_serpent.hash
2986
CMD="./${BIN} ${OPTS} -a 3 -m 29331 '${OUTD}/tc_tests/hashcat_whirlpool_serpent.hash' hashca?l"
2987
;;
2988
2)
2989
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_whirlpool_twofish.tc\" > ${OUTD}/tc_tests/hashcat_whirlpool_twofish.hash
2990
CMD="./${BIN} ${OPTS} -a 3 -m 29331 '${OUTD}/tc_tests/hashcat_whirlpool_twofish.hash' hashca?l"
2991
;;
2992
esac
2993
;;
2994
2995
29332)
2996
case $tcMode in
2997
0)
2998
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_whirlpool_aes-twofish.tc\" > ${OUTD}/tc_tests/hashcat_whirlpool_aes-twofish.hash
2999
CMD="./${BIN} ${OPTS} -a 3 -m 29332 '${OUTD}/tc_tests/hashcat_whirlpool_aes-twofish.hash' hashca?l"
3000
;;
3001
1)
3002
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_whirlpool_serpent-aes.tc\" > ${OUTD}/tc_tests/hashcat_whirlpool_serpent-aes.hash
3003
CMD="./${BIN} ${OPTS} -a 3 -m 29332 '${OUTD}/tc_tests/hashcat_whirlpool_serpent-aes.hash' hashca?l"
3004
;;
3005
2)
3006
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_whirlpool_twofish-serpent.tc\" > ${OUTD}/tc_tests/hashcat_whirlpool_twofish-serpent.hash
3007
CMD="./${BIN} ${OPTS} -a 3 -m 29332 '${OUTD}/tc_tests/hashcat_whirlpool_twofish-serpent.hash' hashca?l"
3008
;;
3009
esac
3010
;;
3011
3012
29333)
3013
case $tcMode in
3014
0)
3015
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_whirlpool_aes-twofish-serpent.tc\" > ${OUTD}/tc_tests/hashcat_whirlpool_aes-twofish-serpent.hash
3016
CMD="./${BIN} ${OPTS} -a 3 -m 29333 '${OUTD}/tc_tests/hashcat_whirlpool_aes-twofish-serpent.hash' hashca?l"
3017
;;
3018
1)
3019
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_whirlpool_serpent-twofish-aes.tc\" > ${OUTD}/tc_tests/hashcat_whirlpool_serpent-twofish-aes.hash
3020
CMD="./${BIN} ${OPTS} -a 3 -m 29333 '${OUTD}/tc_tests/hashcat_whirlpool_serpent-twofish-aes.hash' hashca?l"
3021
;;
3022
esac
3023
;;
3024
3025
29341)
3026
case $tcMode in
3027
0)
3028
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_aes_boot.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_aes_boot.hash
3029
CMD="./${BIN} ${OPTS} -a 3 -m 29341 '${OUTD}/tc_tests/hashcat_ripemd160_aes_boot.hash' hashca?l"
3030
;;
3031
1)
3032
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_serpent_boot.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_serpent_boot.hash
3033
CMD="./${BIN} ${OPTS} -a 3 -m 29341 '${OUTD}/tc_tests/hashcat_ripemd160_serpent_boot.hash' hashca?l"
3034
;;
3035
2)
3036
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_twofish_boot.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_twofish_boot.hash
3037
CMD="./${BIN} ${OPTS} -a 3 -m 29341 '${OUTD}/tc_tests/hashcat_ripemd160_twofish_boot.hash' hashca?l"
3038
;;
3039
esac
3040
;;
3041
3042
29342)
3043
case $tcMode in
3044
0)
3045
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish_boot.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_aes-twofish_boot.hash
3046
CMD="./${BIN} ${OPTS} -a 3 -m 29342 '${OUTD}/tc_tests/hashcat_ripemd160_aes-twofish_boot.hash' hashca?l"
3047
;;
3048
1)
3049
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_serpent-aes_boot.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_serpent-aes_boot.hash
3050
CMD="./${BIN} ${OPTS} -a 3 -m 29342 '${OUTD}/tc_tests/hashcat_ripemd160_serpent-aes_boot.hash' hashca?l"
3051
;;
3052
esac
3053
;;
3054
3055
29343)
3056
case $tcMode in
3057
0)
3058
eval \"${TDIR}/truecrypt2hashcat.py\" \"${TDIR}/tc_tests/hashcat_ripemd160_aes-twofish-serpent_boot.tc\" > ${OUTD}/tc_tests/hashcat_ripemd160_aes-twofish-serpent_boot.hash
3059
CMD="./${BIN} ${OPTS} -a 3 -m 29343 '${OUTD}/tc_tests/hashcat_ripemd160_aes-twofish-serpent_boot.hash' hashca?l"
3060
;;
3061
esac
3062
;;
3063
esac
3064
3065
if [ ${#CMD} -gt 5 ]; then
3066
echo "> Testing hash type $hashType with attack mode 3, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, tcMode ${tcMode}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
3067
3068
output=$(eval ${CMD} 2>&1)
3069
3070
ret=${?}
3071
3072
echo "${output}" >> "${OUTD}/logfull.txt"
3073
3074
e_ce=0
3075
e_rs=0
3076
e_to=0
3077
e_nf=0
3078
e_nm=0
3079
cnt=0
3080
3081
status ${ret}
3082
3083
cnt=1
3084
3085
msg="OK"
3086
3087
if [ "${e_ce}" -ne 0 ]; then
3088
msg="Compare Error"
3089
elif [ "${e_rs}" -ne 0 ]; then
3090
msg="Skip"
3091
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
3092
msg="Error"
3093
elif [ "${e_to}" -ne 0 ]; then
3094
msg="Warning"
3095
fi
3096
3097
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 3, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, tcMode ${tcMode} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
3098
fi
3099
}
3100
3101
# Compose and execute hashcat command on a VeraCrypt test container
3102
# Must not be called for hash types other than 137XY/294XY
3103
# $1: cipher variation, can be 0-6
3104
function veracrypt_test()
3105
{
3106
cipher_variation=$1
3107
3108
hash_function=""
3109
3110
hash_digit="${hash_type:3:1}"
3111
[ "$hash_digit" -eq "1" ] && hash_function="ripemd160"
3112
[ "$hash_digit" -eq "2" ] && hash_function="sha512"
3113
[ "$hash_digit" -eq "3" ] && hash_function="whirlpool"
3114
[ "$hash_digit" -eq "5" ] && hash_function="sha256"
3115
[ "$hash_digit" -eq "7" ] && hash_function="streebog"
3116
3117
[ -n "$hash_function" ] || return
3118
3119
cipher_cascade=""
3120
3121
cipher_digit="${hash_type:4:1}"
3122
case $cipher_digit in
3123
1)
3124
[ "$cipher_variation" -eq "0" ] && cipher_cascade="aes"
3125
[ "$cipher_variation" -eq "1" ] && cipher_cascade="serpent"
3126
[ "$cipher_variation" -eq "2" ] && cipher_cascade="twofish"
3127
[ "$cipher_variation" -eq "3" ] && cipher_cascade="camellia"
3128
[ "$cipher_variation" -eq "5" ] && cipher_cascade="kuznyechik"
3129
;;
3130
2)
3131
[ "$cipher_variation" -eq "0" ] && cipher_cascade="aes-twofish"
3132
[ "$cipher_variation" -eq "1" ] && cipher_cascade="serpent-aes"
3133
[ "$cipher_variation" -eq "2" ] && cipher_cascade="twofish-serpent"
3134
[ "$cipher_variation" -eq "3" ] && cipher_cascade="camellia-kuznyechik"
3135
[ "$cipher_variation" -eq "4" ] && cipher_cascade="camellia-serpent"
3136
[ "$cipher_variation" -eq "5" ] && cipher_cascade="kuznyechik-aes"
3137
[ "$cipher_variation" -eq "6" ] && cipher_cascade="kuznyechik-twofish"
3138
;;
3139
3)
3140
[ "$cipher_variation" -eq "0" ] && cipher_cascade="aes-twofish-serpent"
3141
[ "$cipher_variation" -eq "1" ] && cipher_cascade="serpent-twofish-aes"
3142
[ "$cipher_variation" -eq "5" ] && cipher_cascade="kuznyechik-serpent-camellia"
3143
;;
3144
esac
3145
3146
[ -n "$cipher_cascade" ] || return
3147
3148
filename="${TDIR}/vc_tests/hashcat_${hash_function}_${cipher_cascade}.vc"
3149
3150
# The hash-cipher combination might be invalid (e.g. RIPEMD-160 + Kuznyechik)
3151
[ -f "${filename}" ] || return
3152
3153
case "${hash_type:0:3}" in
3154
137)
3155
CMD="./${BIN} ${OPTS} -a 3 -m ${hash_type} '${filename}' hashc?lt"
3156
;;
3157
3158
294)
3159
mkdir -p ${OUTD}/vc_tests
3160
chmod u+x "${TDIR}/veracrypt2hashcat.py"
3161
3162
eval \"${TDIR}/veracrypt2hashcat.py\" \"${TDIR}/vc_tests/hashcat_${hash_function}_${cipher_cascade}.vc\" > ${OUTD}/vc_tests/hashcat_${hash_function}_${cipher_cascade}.hash
3163
CMD="./${BIN} ${OPTS} -a 3 -m ${hash_type} '${OUTD}/vc_tests/hashcat_${hash_function}_${cipher_cascade}.hash' hashc?lt"
3164
;;
3165
esac
3166
3167
echo "> Testing hash type ${hash_type} with attack mode 0, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, Cipher ${cipher_cascade}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
3168
3169
output=$(eval ${CMD} 2>&1)
3170
3171
ret=${?}
3172
3173
echo "${output}" >> "${OUTD}/logfull.txt"
3174
3175
e_ce=0
3176
e_rs=0
3177
e_to=0
3178
e_nf=0
3179
e_nm=0
3180
cnt=0
3181
3182
status ${ret}
3183
3184
cnt=1
3185
3186
msg="OK"
3187
3188
if [ "${e_ce}" -ne 0 ]; then
3189
msg="Compare Error"
3190
elif [ "${e_rs}" -ne 0 ]; then
3191
msg="Skip"
3192
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
3193
msg="Error"
3194
elif [ "${e_to}" -ne 0 ]; then
3195
msg="Warning"
3196
fi
3197
3198
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack 0, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, Cipher ${cipher_cascade} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
3199
}
3200
3201
function luks_test()
3202
{
3203
hashType=$1
3204
attackType=$2
3205
3206
# if -m all was set let us default to -a 3 only. You could specify the attack type directly, e.g. -m 0
3207
# the problem with defaulting to all=0,1,3,6,7 is that it could take way too long
3208
3209
if [ "${attackType}" -eq 65535 ]; then
3210
attackType=3
3211
fi
3212
3213
mkdir -p "${OUTD}/luks_tests"
3214
chmod u+x "${TDIR}/luks2hashcat.py"
3215
3216
for luksMode in "cbc-essiv" "cbc-plain64" "xts-plain64"; do
3217
for luksKeySize in "128" "256" "512"; do
3218
CMD="unset"
3219
3220
# filter out not supported combinations:
3221
3222
case "${luksKeySize}" in
3223
128)
3224
case "${luksMode}" in
3225
cbc-essiv|cbc-plain64)
3226
;;
3227
*)
3228
continue
3229
;;
3230
esac
3231
;;
3232
256)
3233
case "${luksMode}" in
3234
cbc-essiv|cbc-plain64|xts-plain64)
3235
;;
3236
*)
3237
continue
3238
;;
3239
esac
3240
;;
3241
512)
3242
case "${luksMode}" in
3243
xts-plain64)
3244
;;
3245
*)
3246
continue
3247
;;
3248
esac
3249
;;
3250
esac
3251
3252
case $hashType in
3253
29511)
3254
luksHash="sha1"
3255
luksCipher="aes"
3256
;;
3257
3258
29512)
3259
luksHash="sha1"
3260
luksCipher="serpent"
3261
;;
3262
3263
29513)
3264
luksHash="sha1"
3265
luksCipher="twofish"
3266
;;
3267
3268
29521)
3269
luksHash="sha256"
3270
luksCipher="aes"
3271
;;
3272
3273
29522)
3274
luksHash="sha256"
3275
luksCipher="serpent"
3276
;;
3277
3278
29523)
3279
luksHash="sha256"
3280
luksCipher="twofish"
3281
;;
3282
3283
29531)
3284
luksHash="sha512"
3285
luksCipher="aes"
3286
;;
3287
3288
29532)
3289
luksHash="sha512"
3290
luksCipher="serpent"
3291
;;
3292
3293
29533)
3294
luksHash="sha512"
3295
luksCipher="twofish"
3296
;;
3297
3298
29541)
3299
luksHash="ripemd160"
3300
luksCipher="aes"
3301
;;
3302
3303
29542)
3304
luksHash="ripemd160"
3305
luksCipher="serpent"
3306
;;
3307
3308
29543)
3309
luksHash="ripemd160"
3310
luksCipher="twofish"
3311
;;
3312
3313
esac
3314
3315
luksMainMask="?l"
3316
luksMask="${luksMainMask}"
3317
3318
# for combination or hybrid attacks
3319
luksPassPartFile1="${OUTD}/${hashType}_dict1"
3320
luksPassPartFile2="${OUTD}/${hashType}_dict2"
3321
3322
luksContainer="${TDIR}/luks_tests/hashcat_${luksHash}_${luksCipher}_${luksMode}_${luksKeySize}.luks"
3323
luksHashFile="${OUTD}/luks_tests/hashcat_${luksHash}_${luksCipher}_${luksMode}_${luksKeySize}.hash"
3324
3325
case $attackType in
3326
0)
3327
CMD="./${BIN} ${OPTS} -a 0 -m ${hashType} '${luksHashFile}' '${TDIR}/luks_tests/pw'"
3328
;;
3329
1)
3330
luksPassPart1Len=$((${#LUKS_PASSWORD} / 2))
3331
luksPassPart2Start=$((luksPassPart1Len + 1))
3332
3333
echo "${LUKS_PASSWORD}" | cut -c-${luksPassPart1Len} > "${luksPassPartFile1}" 2>/dev/null
3334
echo "${LUKS_PASSWORD}" | cut -c${luksPassPart2Start}- > "${luksPassPartFile2}" 2>/dev/null
3335
3336
CMD="./${BIN} ${OPTS} -a 6 -m ${hashType} '${luksHashFile}' ${luksPassPartFile1} ${luksPassPartFile2}"
3337
;;
3338
3)
3339
luksMaskFixedLen=$((${#LUKS_PASSWORD} - 1))
3340
3341
luksMask="$(echo "${LUKS_PASSWORD}" | cut -c-${luksMaskFixedLen} 2>/dev/null)"
3342
luksMask="${luksMask}${luksMainMask}"
3343
3344
CMD="./${BIN} ${OPTS} -a 3 -m ${hashType} '${luksHashFile}' ${luksMask}"
3345
;;
3346
6)
3347
luksPassPart1Len=$((${#LUKS_PASSWORD} - 1))
3348
3349
echo "${LUKS_PASSWORD}" | cut -c-${luksPassPart1Len} > "${luksPassPartFile1}" 2>/dev/null
3350
3351
CMD="./${BIN} ${OPTS} -a 6 -m ${hashType} '${luksHashFile}' ${luksPassPartFile1} ${luksMask}"
3352
;;
3353
7)
3354
echo "${LUKS_PASSWORD}" | cut -c2- > "${luksPassPartFile1}" 2>/dev/null
3355
3356
CMD="./${BIN} ${OPTS} -a 7 -m ${hashType} '${luksHashFile}' ${luksMask} ${luksPassPartFile1}"
3357
;;
3358
esac
3359
3360
eval \"${TDIR}/luks2hashcat.py\" \"${luksContainer}\" > "${luksHashFile}"
3361
3362
luksMode="${luksHash}-${luksCipher}-${luksMode}-${luksKeySize}"
3363
3364
if [ -n "${CMD}" ] && [ ${#CMD} -gt 5 ]; then
3365
echo "> Testing hash type ${hashType} with attack mode ${attackType}, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, Luks-Mode ${luksMode}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
3366
3367
if [ -f "${luks_first_test_file}" ]; then
3368
output=$(eval ${CMD} 2>&1)
3369
ret=${?}
3370
3371
echo "${output}" >> "${OUTD}/logfull.txt"
3372
else
3373
ret=30
3374
fi
3375
3376
e_ce=0
3377
e_rs=0
3378
e_to=0
3379
e_nf=0
3380
e_nm=0
3381
cnt=0
3382
3383
status ${ret}
3384
3385
cnt=1
3386
3387
msg="OK"
3388
3389
if [ "${e_ce}" -ne 0 ]; then
3390
msg="Compare Error"
3391
elif [ "${e_rs}" -ne 0 ]; then
3392
msg="Skip"
3393
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
3394
msg="Error"
3395
elif [ "${e_to}" -ne 0 ]; then
3396
msg="Warning"
3397
fi
3398
3399
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack ${attackType}, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, Luks-Mode ${luksMode} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
3400
3401
status ${ret}
3402
fi
3403
done
3404
done
3405
}
3406
3407
function luks_legacy_test()
3408
{
3409
hashType=$1
3410
attackType=$2
3411
3412
# if -m all was set let us default to -a 3 only. You could specify the attack type directly, e.g. -m 0
3413
# the problem with defaulting to all=0,1,3,6,7 is that it could take way too long
3414
3415
if [ "${attackType}" -eq 65535 ]; then
3416
attackType=3
3417
fi
3418
3419
#LUKS_HASHES="sha1 sha256 sha512 ripemd160 whirlpool"
3420
LUKS_HASHES="sha1 sha256 sha512 ripemd160"
3421
LUKS_CIPHERS="aes serpent twofish"
3422
LUKS_CIPHER_MODES="cbc-essiv cbc-plain64 xts-plain64"
3423
LUKS_KEYSIZES="128 256 512"
3424
3425
LUKS_PASSWORD=$(cat "${TDIR}/luks_tests/pw" 2>/dev/null)
3426
3427
for luks_h in ${LUKS_HASHES}; do
3428
for luks_c in ${LUKS_CIPHERS}; do
3429
for luks_m in ${LUKS_CIPHER_MODES}; do
3430
for luks_k in ${LUKS_KEYSIZES}; do
3431
3432
CMD=""
3433
3434
# filter out not supported combinations:
3435
3436
case "${luks_k}" in
3437
128)
3438
case "${luks_m}" in
3439
cbc-essiv|cbc-plain64)
3440
;;
3441
*)
3442
continue
3443
;;
3444
esac
3445
;;
3446
256)
3447
case "${luks_m}" in
3448
cbc-essiv|cbc-plain64|xts-plain64)
3449
;;
3450
*)
3451
continue
3452
;;
3453
esac
3454
;;
3455
512)
3456
case "${luks_m}" in
3457
xts-plain64)
3458
;;
3459
*)
3460
continue
3461
;;
3462
esac
3463
;;
3464
esac
3465
3466
luks_mode="${luks_h}-${luks_c}-${luks_m}-${luks_k}"
3467
luks_file="${TDIR}/luks_tests/hashcat_${luks_h}_${luks_c}_${luks_m}_${luks_k}.luks"
3468
luks_main_mask="?l"
3469
luks_mask="${luks_main_mask}"
3470
3471
# for combination or hybrid attacks
3472
luks_pass_part_file1="${OUTD}/${hashType}_dict1"
3473
luks_pass_part_file2="${OUTD}/${hashType}_dict2"
3474
3475
case $attackType in
3476
0)
3477
CMD="./${BIN} ${OPTS} -a 0 -m ${hashType} '${luks_file}' '${TDIR}/luks_tests/pw'"
3478
;;
3479
1)
3480
luks_pass_part1_len=$((${#LUKS_PASSWORD} / 2))
3481
luks_pass_part2_start=$((luks_pass_part1_len + 1))
3482
3483
echo "${LUKS_PASSWORD}" | cut -c-${luks_pass_part1_len} > "${luks_pass_part_file1}" 2>/dev/null
3484
echo "${LUKS_PASSWORD}" | cut -c${luks_pass_part2_start}- > "${luks_pass_part_file2}" 2>/dev/null
3485
3486
CMD="./${BIN} ${OPTS} -a 6 -m ${hashType} '${luks_file}' ${luks_pass_part_file1} ${luks_pass_part_file2}"
3487
;;
3488
3)
3489
luks_mask_fixed_len=$((${#LUKS_PASSWORD} - 1))
3490
3491
luks_mask="$(echo "${LUKS_PASSWORD}" | cut -c-${luks_mask_fixed_len} 2>/dev/null)"
3492
luks_mask="${luks_mask}${luks_main_mask}"
3493
3494
CMD="./${BIN} ${OPTS} -a 3 -m ${hashType} '${luks_file}' ${luks_mask}"
3495
;;
3496
6)
3497
luks_pass_part1_len=$((${#LUKS_PASSWORD} - 1))
3498
3499
echo "${LUKS_PASSWORD}" | cut -c-${luks_pass_part1_len} > "${luks_pass_part_file1}" 2>/dev/null
3500
3501
CMD="./${BIN} ${OPTS} -a 6 -m ${hashType} '${luks_file}' ${luks_pass_part_file1} ${luks_mask}"
3502
;;
3503
7)
3504
echo "${LUKS_PASSWORD}" | cut -c2- > "${luks_pass_part_file1}" 2>/dev/null
3505
3506
CMD="./${BIN} ${OPTS} -a 7 -m ${hashType} '${luks_file}' ${luks_mask} ${luks_pass_part_file1}"
3507
;;
3508
esac
3509
3510
if [ -n "${CMD}" ]; then
3511
echo "> Testing hash type ${hashType} with attack mode ${attackType}, markov ${MARKOV}, single hash, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, luksMode ${luks_mode}" >> "${OUTD}/logfull.txt" 2>> "${OUTD}/logfull.txt"
3512
3513
if [ -f "${luks_first_test_file}" ]; then
3514
output=$(eval ${CMD} 2>&1)
3515
ret=${?}
3516
3517
echo "${output}" >> "${OUTD}/logfull.txt"
3518
else
3519
ret=30
3520
fi
3521
3522
e_ce=0
3523
e_rs=0
3524
e_to=0
3525
e_nf=0
3526
e_nm=0
3527
cnt=0
3528
3529
status ${ret}
3530
3531
cnt=1
3532
3533
msg="OK"
3534
3535
if [ "${e_ce}" -ne 0 ]; then
3536
msg="Compare Error"
3537
elif [ "${e_rs}" -ne 0 ]; then
3538
msg="Skip"
3539
elif [ "${e_nf}" -ne 0 ] || [ "${e_nm}" -ne 0 ]; then
3540
msg="Error"
3541
elif [ "${e_to}" -ne 0 ]; then
3542
msg="Warning"
3543
fi
3544
3545
echo "[ ${OUTD} ] [ Type ${hash_type}, Attack ${attackType}, Mode single, Device-Type ${DEVICE_TYPE}, Kernel-Type ${KERNEL_TYPE}, Vector-Width ${VECTOR}, luksMode ${luks_mode} ] > $msg : ${e_nf}/${cnt} not found, ${e_nm}/${cnt} not matched, ${e_to}/${cnt} timeout, ${e_rs}/${cnt} skipped"
3546
3547
status ${ret}
3548
fi
3549
done
3550
done
3551
done
3552
done
3553
}
3554
3555
function usage()
3556
{
3557
cat << EOF
3558
> Usage : ${0} <options>
3559
3560
OPTIONS:
3561
3562
-V Backend vector-width (either 1, 2, 4 or 8), overrides value from device query :
3563
'1' => vector-width 1
3564
'2' => vector-width 2 (default)
3565
'4' => vector-width 4
3566
'8' => vector-width 8
3567
'all' => test sequentially vector-width ${VECTOR_WIDTHS}
3568
3569
-t Select test mode :
3570
'single' => single hash (default)
3571
'multi' => multi hash
3572
'all' => single and multi hash
3573
3574
-m Select hash type :
3575
'all' => all hash type supported
3576
(int) => hash type integer code (default : 0)
3577
(int)-(int) => hash type integer range
3578
3579
-a Select attack mode :
3580
'all' => all attack modes
3581
(int) => attack mode integer code (default : 0)
3582
3583
-x Select cpu architecture :
3584
'32' => 32 bit architecture
3585
'64' => 64 bit architecture (default)
3586
3587
-o Select operating system :
3588
'win' => Windows operating system (use .exe file extension)
3589
'linux' => Linux operating system (use .bin file extension)
3590
'macos' => macOS operating system (use .app file extension)
3591
3592
-d Select the Backend device :
3593
(int)[,int] => comma separated list of devices (default : 1)
3594
3595
-D Select the OpenCL device types :
3596
'1' => CPU
3597
'2' => GPU (default)
3598
'3' => FPGA, DSP, Co-Processor
3599
(int)[,int] => multiple comma separated device types from the list above
3600
3601
-O Use optimized kernels (default : -O)
3602
3603
-P Use pure kernels instead of optimized kernels (default : -O)
3604
3605
-s Use this session name instead of the default one (default : "hashcat")
3606
3607
-c Disables markov-chains
3608
3609
-f Use --force to ignore hashcat warnings (default : disabled)
3610
3611
-r Setup max runtime limit (default: 400)
3612
3613
-p Package the tests into a .7z file
3614
3615
-F Use this folder as test folder instead of the default one
3616
(string) => path to folder
3617
3618
-I Use this folder as input/output folder for packaged tests
3619
(string) => path to folder
3620
3621
-h Show this help
3622
3623
EOF
3624
3625
exit 1
3626
}
3627
3628
BIN="hashcat"
3629
MARKOV="enabled"
3630
ATTACK=0
3631
MODE=0
3632
DEVICE_TYPE="null"
3633
KERNEL_TYPE="Optimized"
3634
VECTOR="default"
3635
HT=0
3636
PACKAGE=0
3637
OPTIMIZED=1
3638
3639
while getopts "V:t:m:a:b:hcpd:x:o:d:D:F:POI:s:fr:" opt; do
3640
3641
case ${opt} in
3642
"V")
3643
if [ "${OPTARG}" = "1" ]; then
3644
VECTOR=1
3645
elif [ "${OPTARG}" = "2" ]; then
3646
VECTOR=2
3647
elif [ "${OPTARG}" = "4" ]; then
3648
VECTOR=4
3649
elif [ "${OPTARG}" = "8" ]; then
3650
VECTOR=8
3651
elif [ "${OPTARG}" = "16" ]; then
3652
VECTOR=16
3653
elif [ "${OPTARG}" = "all" ]; then
3654
VECTOR="all"
3655
else
3656
usage
3657
fi
3658
;;
3659
3660
"t")
3661
if [ "${OPTARG}" = "single" ]; then
3662
MODE=0
3663
elif [ "${OPTARG}" = "multi" ]; then
3664
MODE=1
3665
elif [ "${OPTARG}" = "all" ]; then
3666
MODE=2
3667
else
3668
usage
3669
fi
3670
;;
3671
3672
"m")
3673
if [ "${OPTARG}" = "all" ]; then
3674
HT=65535
3675
else
3676
HT=${OPTARG}
3677
fi
3678
;;
3679
3680
"a")
3681
if [ "${OPTARG}" = "all" ]; then
3682
ATTACK=65535
3683
elif [ "${OPTARG}" = "0" ]; then
3684
ATTACK=0
3685
elif [ "${OPTARG}" = "1" ]; then
3686
ATTACK=1
3687
elif [ "${OPTARG}" = "3" ]; then
3688
ATTACK=3
3689
elif [ "${OPTARG}" = "6" ]; then
3690
ATTACK=6
3691
elif [ "${OPTARG}" = "7" ]; then
3692
ATTACK=7
3693
else
3694
usage
3695
fi
3696
;;
3697
3698
"c")
3699
OPTS="${OPTS} --markov-disable"
3700
MARKOV="disabled"
3701
;;
3702
3703
"I")
3704
PACKAGE_FOLDER=$( echo "${OPTARG}" | sed 's!/$!!g' )
3705
;;
3706
3707
"s")
3708
OPTS="${OPTS} --session \"${OPTARG}\""
3709
;;
3710
3711
"p")
3712
PACKAGE=1
3713
;;
3714
3715
"x")
3716
if [ "${OPTARG}" = "32" ]; then
3717
ARCHITECTURE=32
3718
elif [ "${OPTARG}" = "64" ]; then
3719
ARCHITECTURE=64
3720
else
3721
usage
3722
fi
3723
;;
3724
3725
"o")
3726
if [ "${OPTARG}" = "win" ]; then
3727
EXTENSION="exe"
3728
elif [ "${OPTARG}" = "linux" ]; then
3729
EXTENSION="bin"
3730
elif [ "${OPTARG}" = "macos" ]; then
3731
EXTENSION="app"
3732
else
3733
usage
3734
fi
3735
;;
3736
3737
"O")
3738
# optimized is already default, ignore it
3739
;;
3740
3741
"d")
3742
OPTS="${OPTS} -d ${OPTARG}"
3743
;;
3744
3745
"D")
3746
if [ "${OPTARG}" = "1" ]; then
3747
OPTS="${OPTS} -D 1"
3748
DEVICE_TYPE="Cpu"
3749
elif [ "${OPTARG}" = "2" ]; then
3750
OPTS="${OPTS} -D 2"
3751
DEVICE_TYPE="Gpu"
3752
else
3753
OPTS="${OPTS} -D ${OPTARG}"
3754
DEVICE_TYPE="Cpu + Gpu"
3755
fi
3756
;;
3757
3758
"F")
3759
OUTD=$( echo "${OPTARG}" | sed 's!/$!!g' )
3760
;;
3761
3762
"P")
3763
OPTIMIZED=0
3764
KERNEL_TYPE="Pure"
3765
;;
3766
3767
"f")
3768
FORCE=1
3769
;;
3770
3771
"r")
3772
RUNTIME=${OPTARG}
3773
;;
3774
3775
\?)
3776
usage
3777
;;
3778
3779
"h")
3780
usage
3781
;;
3782
esac
3783
3784
done
3785
3786
# handle Apple Silicon
3787
3788
IS_APPLE_SILICON=0
3789
3790
if [ $(uname) == "Darwin" ]; then
3791
BIN_sysctl=$(which sysctl)
3792
if [ $? -eq 0 ]; then
3793
CPU_TYPE=$(sysctl hw.cputype | awk '{print $2}')
3794
3795
if [ ${CPU_TYPE} -eq 16777228 ]; then
3796
IS_APPLE_SILICON=1
3797
fi
3798
fi
3799
fi
3800
3801
export IS_OPTIMIZED=${OPTIMIZED}
3802
3803
if [ "${OPTIMIZED}" -eq 1 ]; then
3804
OPTS="${OPTS} -O"
3805
fi
3806
3807
# set max-runtime
3808
3809
OPTS="${OPTS} --runtime ${RUNTIME}"
3810
3811
# set default device-type to CPU with Apple Intel, else GPU
3812
3813
if [ "${DEVICE_TYPE}" = "null" ]; then
3814
if [ $(uname) == "Darwin" ] && [ ${IS_APPLE_SILICON} -eq 0 ]; then
3815
OPTS="${OPTS} -D 1"
3816
DEVICE_TYPE="Cpu"
3817
else
3818
OPTS="${OPTS} -D 2"
3819
DEVICE_TYPE="Gpu"
3820
fi
3821
fi
3822
3823
if [ ${FORCE} -eq 1 ]; then
3824
OPTS="${OPTS} --force"
3825
fi
3826
3827
if [ -n "${ARCHITECTURE}" ]; then
3828
BIN="${BIN}${ARCHITECTURE}"
3829
fi
3830
3831
if [ -n "${EXTENSION}" ]; then
3832
BIN="${BIN}.${EXTENSION}"
3833
fi
3834
3835
if [ -n "${PACKAGE_FOLDER}" ]; then
3836
if [ ! -e "${PACKAGE_FOLDER}" ]; then
3837
echo "! folder '${PACKAGE_FOLDER}' does not exist"
3838
exit 1
3839
fi
3840
fi
3841
3842
if [ "${PACKAGE}" -eq 0 ] || [ -z "${PACKAGE_FOLDER}" ]; then
3843
3844
# check existence of binary
3845
if [ ! -e "${BIN}" ]; then
3846
echo "! ${BIN} not found, please build binary before run test."
3847
exit 1
3848
fi
3849
3850
HT_MIN=0
3851
HT_MAX=0
3852
3853
if echo -n "${HT}" | grep -q '^[0-9]\+$'; then
3854
HT_MIN=${HT}
3855
HT_MAX=${HT}
3856
elif echo -n "${HT}" | grep -q '^[0-9]\+-[1-9][0-9]*$'; then
3857
HT_MIN=$(echo -n ${HT} | sed "s/-.*//")
3858
HT_MAX=$(echo -n ${HT} | sed "s/.*-//")
3859
3860
if [ "${HT_MIN}" -gt "${HT_MAX}" ]; then
3861
echo "! hash type range -m ${HT} is not valid ..."
3862
usage
3863
fi
3864
else
3865
echo "! hash type is not a number ..."
3866
usage
3867
fi
3868
3869
HT=${HT_MIN}
3870
3871
# filter by hash_type
3872
if [ "${HT}" -ne 65535 ]; then
3873
3874
# validate filter
3875
3876
if ! is_in_array "${HT_MIN}" ${HASH_TYPES}; then
3877
echo "! invalid hash type selected ..."
3878
usage
3879
fi
3880
3881
if ! is_in_array "${HT_MAX}" ${HASH_TYPES}; then
3882
echo "! invalid hash type selected ..."
3883
usage
3884
fi
3885
fi
3886
3887
if [ -z "${PACKAGE_FOLDER}" ]; then
3888
3889
# make new dir
3890
mkdir -p "${OUTD}"
3891
3892
# generate random test entry
3893
if [ "${HT}" -eq 65535 ]; then
3894
for TMP_HT in ${HASH_TYPES}; do
3895
if ! is_in_array "${TMP_HT}" ${LUKS_MODES}; then
3896
if ! is_in_array "${TMP_HT}" ${TC_MODES}; then
3897
if ! is_in_array "${TMP_HT}" ${VC_MODES}; then
3898
if ! is_in_array "${TMP_HT}" ${CL_MODES}; then
3899
perl tools/test.pl single "${TMP_HT}" >> "${OUTD}/all.sh"
3900
fi
3901
fi
3902
fi
3903
fi
3904
done
3905
else
3906
for TMP_HT in $(seq "${HT_MIN}" "${HT_MAX}"); do
3907
if ! is_in_array "${TMP_HT}" ${HASH_TYPES}; then
3908
continue
3909
fi
3910
3911
if ! is_in_array "${TMP_HT}" ${LUKS_MODES}; then
3912
# Exclude TrueCrypt and VeraCrypt testing modes
3913
if ! is_in_array "${TMP_HT}" ${TC_MODES}; then
3914
if ! is_in_array "${TMP_HT}" ${VC_MODES}; then
3915
if ! is_in_array "${TMP_HT}" ${CL_MODES}; then
3916
perl tools/test.pl single "${TMP_HT}" >> "${OUTD}/all.sh"
3917
fi
3918
fi
3919
fi
3920
fi
3921
done
3922
fi
3923
3924
else
3925
3926
OUTD=${PACKAGE_FOLDER}
3927
3928
fi
3929
3930
rm -rf "${OUTD}/logfull.txt" && touch "${OUTD}/logfull.txt"
3931
3932
# populate array of hash types where we only should check if pass is in output (not both hash:pass)
3933
IFS=';' read -ra PASS_ONLY <<< "${HASHFILE_ONLY} ${NOCHECK_ENCODING}"
3934
IFS=';' read -ra TIMEOUT_ALGOS <<< "${SLOW_ALGOS}"
3935
3936
IFS=';' read -ra KEEP_GUESSING_ALGOS <<< "${KEEP_GUESSING}"
3937
3938
# for these particular algos we need to save the output to a temporary file
3939
IFS=';' read -ra FILE_BASED_ALGOS <<< "${HASHFILE_ONLY}"
3940
3941
for hash_type in $HASH_TYPES; do
3942
3943
if [ "${HT}" -ne 65535 ]; then
3944
# check if the loop variable "hash_type" is between HT_MIN and HT_MAX (both included)
3945
3946
if [ "${hash_type}" -lt "${HT_MIN}" ]; then
3947
continue
3948
elif [ "${hash_type}" -gt "${HT_MAX}" ]; then
3949
# we are done because hash_type is larger than range:
3950
break
3951
fi
3952
fi
3953
3954
if [ "${hash_type}" -eq 20510 ]; then # special case for PKZIP Master Key
3955
if [ "${MODE}" -eq 1 ]; then # if "multi" was forced we need to skip it
3956
if [ "${HT_MIN}" -eq 20510 ]; then
3957
if [ "${HT_MAX}" -eq 20510 ]; then
3958
echo "ERROR: -m 20510 = PKZIP Master Key can only be run with a single hash"
3959
fi
3960
fi
3961
3962
continue
3963
fi
3964
fi
3965
3966
# skip deprecated hash-types
3967
if [ "${hash_type}" -eq 2500 ] || [ "${hash_type}" -eq 2501 ] || [ "${hash_type}" -eq 16800 ] || [ "${hash_type}" -eq 16801 ] ; then
3968
continue
3969
fi
3970
3971
# test.pl produce wrong hashes with Apple
3972
# would be necessary to investigate to understand why
3973
if [ "${hash_type}" -eq 1800 ]; then
3974
if [[ "$OSTYPE" == "darwin"* ]]; then
3975
continue
3976
fi
3977
fi
3978
3979
# Digest::BLAKE2 is broken on Apple Silicon
3980
if [ "${hash_type}" -eq 600 ]; then
3981
if [ "${IS_APPLE_SILICON}" -eq 1 ]; then
3982
continue
3983
fi
3984
fi
3985
3986
# Digest::GOST is broken on Apple Silicon
3987
if [ "${hash_type}" -eq 6900 ]; then
3988
if [ "${IS_APPLE_SILICON}" -eq 1 ]; then
3989
continue
3990
fi
3991
fi
3992
3993
# Crypt::GCrypt is broken on Apple
3994
if [ "${hash_type}" -eq 18600 ]; then
3995
if [[ "$OSTYPE" == "darwin"* ]]; then
3996
continue
3997
fi
3998
fi
3999
4000
if [ -z "${PACKAGE_FOLDER}" ]; then
4001
# init test data
4002
init
4003
else
4004
echo "[ ${OUTD} ] > Run packaged test for hash type $hash_type."
4005
fi
4006
4007
if [ "${PACKAGE}" -eq 0 ]; then
4008
4009
# should we check only the pass?
4010
pass_only=0
4011
is_in_array "${hash_type}" ${PASS_ONLY} && pass_only=1
4012
4013
IS_SLOW=0
4014
is_in_array "${hash_type}" ${SLOW_ALGOS} && IS_SLOW=1
4015
4016
# we use phpass as slow hash for testing the AMP kernel
4017
[ "${hash_type}" -eq 400 ] && IS_SLOW=0
4018
4019
OPTS_OLD=${OPTS}
4020
VECTOR_OLD=${VECTOR}
4021
MODE_OLD=${MODE}
4022
4023
if [ "${hash_type}" -eq 20510 ]; then # special case for PKZIP Master Key
4024
if [ "${MODE}" -eq 1 ]; then # if "multi" was forced we need to skip it
4025
continue
4026
fi
4027
4028
MODE=0 # force single only
4029
fi
4030
4031
for CUR_WIDTH in $VECTOR_WIDTHS; do
4032
4033
if [ "${VECTOR_OLD}" = "all" ] || [ "${VECTOR_OLD}" = "default" ] || [ "${VECTOR_OLD}" = "${CUR_WIDTH}" ]; then
4034
4035
if [ "${VECTOR_OLD}" = "default" ] && \
4036
[ "${CUR_WIDTH}" != "1" ] && \
4037
[ "${CUR_WIDTH}" != "4" ]; then
4038
4039
continue
4040
fi
4041
4042
VECTOR=${CUR_WIDTH}
4043
OPTS="${OPTS_OLD} --backend-vector-width ${VECTOR}"
4044
4045
if [ ${IS_SLOW} -eq 1 ]; then
4046
4047
# Look up if this is one of supported VeraCrypt modes
4048
if is_in_array "${hash_type}" ${VC_MODES}; then
4049
veracrypt_test 0 # aes
4050
veracrypt_test 1 # serpent
4051
veracrypt_test 2 # twofish
4052
veracrypt_test 3 # camellia
4053
veracrypt_test 4 # camellia (alternative cascade)
4054
veracrypt_test 5 # kuznyechik
4055
veracrypt_test 6 # kuznyechik (alternative cascade)
4056
elif is_in_array "${hash_type}" ${TC_MODES}; then
4057
# run truecrypt tests
4058
truecrypt_test "${hash_type}" 0
4059
truecrypt_test "${hash_type}" 1
4060
truecrypt_test "${hash_type}" 2
4061
elif is_in_array "${hash_type}" ${LUKS_MODES}; then
4062
# run luks tests
4063
if [ ${hash_type} -eq 14600 ]; then
4064
# for legacy mode
4065
luks_legacy_test "${hash_type}" ${ATTACK}
4066
else
4067
# for new modes
4068
luks_test "${hash_type}" ${ATTACK}
4069
fi
4070
else
4071
# run attack mode 0 (stdin)
4072
if [ ${ATTACK} -eq 65535 ] || [ ${ATTACK} -eq 0 ]; then attack_0; fi
4073
fi
4074
4075
else
4076
4077
if is_in_array "${hash_type}" ${CL_MODES}; then
4078
# run cryptoloop tests
4079
cryptoloop_test "${hash_type}" 128
4080
cryptoloop_test "${hash_type}" 192
4081
cryptoloop_test "${hash_type}" 256
4082
else
4083
# run attack mode 0 (stdin)
4084
if [ ${ATTACK} -eq 65535 ] || [ ${ATTACK} -eq 0 ]; then attack_0; fi
4085
4086
# run attack mode 1 (combinator)
4087
if [ ${ATTACK} -eq 65535 ] || [ ${ATTACK} -eq 1 ]; then attack_1; fi
4088
4089
# run attack mode 3 (bruteforce)
4090
if [ ${ATTACK} -eq 65535 ] || [ ${ATTACK} -eq 3 ]; then attack_3; fi
4091
4092
# run attack mode 6 (dict+mask)
4093
if [ ${ATTACK} -eq 65535 ] || [ ${ATTACK} -eq 6 ]; then attack_6; fi
4094
4095
# run attack mode 7 (mask+dict)
4096
if [ ${ATTACK} -eq 65535 ] || [ ${ATTACK} -eq 7 ]; then attack_7; fi
4097
fi
4098
4099
fi
4100
fi
4101
done
4102
OPTS="${OPTS_OLD}"
4103
VECTOR="${VECTOR_OLD}"
4104
MODE=${MODE_OLD}
4105
fi
4106
done
4107
4108
else
4109
4110
OUTD=${PACKAGE_FOLDER}
4111
4112
fi
4113
4114
# fix logfile
4115
if [ "${PACKAGE}" -eq 0 ]; then
4116
cat -vet "${OUTD}/logfull.txt" | sed -e 's/\^M \^M//g' | sed -e 's/\$$//g' > "${OUTD}/test_report.log"
4117
fi
4118
4119
rm -rf "${OUTD}/logfull.txt"
4120
4121
if [ "${PACKAGE}" -eq 1 ]; then
4122
4123
echo "[ ${OUTD} ] > Generate package ${OUTD}/${OUTD}.7z"
4124
4125
cp "${BASH_SOURCE[0]}" "${OUTD}/test.sh"
4126
4127
copy_luks_dir=0
4128
copy_tc_dir=0
4129
copy_vc_dir=0
4130
copy_cl_dir=0
4131
4132
if [ "${HT}" -eq 65535 ]; then
4133
copy_luks_dir=1
4134
copy_tc_dir=1
4135
copy_vc_dir=1
4136
copy_cl_dir=1
4137
else
4138
for TMP_HT in $(seq "${HT_MIN}" "${HT_MAX}"); do
4139
if is_in_array "${TMP_HT}" "${LUKS_MODES}"; then
4140
copy_luks_dir=1
4141
elif is_in_array "${TMP_HT}" ${TC_MODES}; then
4142
copy_tc_dir=1
4143
elif is_in_array "${TMP_HT}" ${VC_MODES}; then
4144
copy_vc_dir=1
4145
elif is_in_array "${TMP_HT}" ${CL_MODES}; then
4146
copy_cl_dir=1
4147
fi
4148
done
4149
fi
4150
4151
if [ "${copy_luks_dir}" -eq 1 ]; then
4152
mkdir "${OUTD}/luks_tests/"
4153
cp ${TDIR}/luks_tests/* "${OUTD}/luks_tests/"
4154
fi
4155
4156
if [ "${copy_tc_dir}" -eq 1 ]; then
4157
mkdir "${OUTD}/tc_tests/"
4158
cp ${TDIR}/tc_tests/* "${OUTD}/tc_tests/"
4159
fi
4160
4161
if [ "${copy_vc_dir}" -eq 1 ]; then
4162
mkdir "${OUTD}/vc_tests/"
4163
cp ${TDIR}/vc_tests/* "${OUTD}/vc_tests/"
4164
fi
4165
4166
if [ "${copy_cl_dir}" -eq 1 ]; then
4167
mkdir "${OUTD}/cl_tests/"
4168
cp ${TDIR}/cl_tests/* "${OUTD}/cl_tests/"
4169
fi
4170
4171
# if we package from a given folder, we need to check if e.g. the files needed for multi mode are there
4172
4173
if [ -n "${PACKAGE_FOLDER}" ]; then
4174
4175
MODE=2
4176
4177
ls "${PACKAGE_FOLDER}"/*multi* &>/dev/null
4178
4179
if [ "${?}" -ne 0 ]; then
4180
MODE=0
4181
fi
4182
4183
HT=$(grep -o -- "-m *[0-9]*" "${PACKAGE_FOLDER}/all.sh" | sort -u | sed 's/-m //' 2> /dev/null)
4184
4185
if [ -n "${HT}" ]; then
4186
HT_COUNT=$(echo "${HT}" | wc -l)
4187
4188
if [ "${HT_COUNT}" -gt 1 ]; then
4189
HT=65535
4190
fi
4191
fi
4192
4193
#ATTACK=65535 # more appropriate ?
4194
fi
4195
4196
# for convenience: 'run package' is default action for packaged test.sh ( + add other defaults too )
4197
4198
SED_IN_PLACE='-i'
4199
4200
UNAME=$(uname -s)
4201
4202
# of course macOS requires us to implement a special case (sed -i "" for the backup file)
4203
if [ "${UNAME}" = "Darwin" ] ; then
4204
SED_IN_PLACE='-i ""'
4205
fi
4206
4207
HT_PACKAGED=${HT}
4208
4209
if [ "${HT_MIN}" -ne "${HT_MAX}" ]; then
4210
HT_PACKAGED=${HT_MIN}-${HT_MAX}
4211
fi
4212
4213
HASH_TYPES_PACKAGED=$( echo "${HASH_TYPES}" | tr '\n' ' ' | sed 's/ *$//')
4214
HASHFILE_ONLY_PACKAGED=$(echo "${HASHFILE_ONLY}" | tr '\n' ' ' | sed 's/ *$//')
4215
KEEP_GUESSING_PACKAGED=$(echo "${KEEP_GUESSING}" | tr '\n' ' ' | sed 's/ *$//')
4216
SLOW_ALGOS_PACKAGED=$( echo "${SLOW_ALGOS}" | tr '\n' ' ' | sed 's/ *$//')
4217
4218
sed "${SED_IN_PLACE}" -e 's/^\(PACKAGE_FOLDER\)=""/\1="$( echo "${BASH_SOURCE[0]}" | sed \"s!test.sh\\$!!\" )"/' \
4219
-e "s/^\(HASH_TYPES\)=\$(.*/\1=\"${HASH_TYPES_PACKAGED}\"/" \
4220
-e "s/^\(HASHFILE_ONLY\)=\$(.*/\1=\"${HASHFILE_ONLY_PACKAGED}\"/" \
4221
-e "s/^\(KEEP_GUESSING\)=\$(.*/\1=\"${KEEP_GUESSING_PACKAGED}\"/" \
4222
-e "s/^\(SLOW_ALGOS\)=\$(.*/\1=\"${SLOW_ALGOS_PACKAGED}\"/" \
4223
-e "s/^\(HT\)=0/\1=${HT_PACKAGED}/" \
4224
-e "s/^\(MODE\)=0/\1=${MODE}/" \
4225
-e "s/^\(ATTACK\)=0/\1=${ATTACK}/" \
4226
"${OUTD}/test.sh"
4227
4228
${PACKAGE_CMD} "${OUTD}/${OUTD}.7z" "${OUTD}/" &>/dev/null
4229
fi
4230
4231