1
mirror of https://github.com/hashcat/hashcat synced 2024-11-24 14:27:14 +01:00

update test cases format for tools/test_rules.pl

This commit is contained in:
mhasbini 2017-05-24 17:19:12 +03:00
parent ef33544bfa
commit b1fee3b9f7
2 changed files with 323 additions and 98 deletions

View File

@ -5,7 +5,12 @@
abcd abcd
ABCD ABCD
expected_output: | expected_cpu: |
AbCd
abcd
ABCD
expected_opencl: |
AbCd AbCd
abcd abcd
ABCD ABCD
@ -16,7 +21,12 @@ l:
abcd abcd
ABCD ABCD
expected_output: | expected_cpu: |
abcd
abcd
abcd
expected_opencl: |
abcd abcd
abcd abcd
abcd abcd
@ -27,7 +37,12 @@ u:
abcd abcd
ABCD ABCD
expected_output: | expected_cpu: |
ABCD
ABCD
ABCD
expected_opencl: |
ABCD ABCD
ABCD ABCD
ABCD ABCD
@ -38,7 +53,12 @@ c:
abcd abcd
ABCD ABCD
expected_output: | expected_cpu: |
Abcd
Abcd
Abcd
expected_opencl: |
Abcd Abcd
Abcd Abcd
Abcd Abcd
@ -49,7 +69,12 @@ C:
abcd abcd
ABCD ABCD
expected_output: | expected_cpu: |
aBCD
aBCD
aBCD
expected_opencl: |
aBCD aBCD
aBCD aBCD
aBCD aBCD
@ -60,7 +85,12 @@ t:
abcd abcd
ABCD ABCD
expected_output: | expected_cpu: |
aBcD
ABCD
abcd
expected_opencl: |
aBcD aBcD
ABCD ABCD
abcd abcd
@ -71,7 +101,12 @@ T5:
abcdef abcdef
ABCDEFg ABCDEFg
expected_output: | expected_cpu: |
AbCde
abcdeF
ABCDEfg
expected_opencl: |
AbCde AbCde
abcdeF abcdeF
ABCDEfg ABCDEfg
@ -81,7 +116,11 @@ r:
AbCd AbCd
abcd abcd
expected_output: | expected_cpu: |
dCbA
dcba
expected_opencl: |
dCbA dCbA
dcba dcba
@ -89,35 +128,50 @@ d:
input: | input: |
3abc 3abc
expected_output: | expected_cpu: |
3abc3abc
expected_opencl: |
3abc3abc 3abc3abc
ddd: ddd:
input: | input: |
3ab 3ab
expected_output: | expected_cpu: |
3ab3ab3ab3ab3ab3ab3ab3ab
expected_opencl: |
3ab3ab3ab3ab3ab3ab3ab3ab 3ab3ab3ab3ab3ab3ab3ab3ab
p0: p0:
input: | input: |
3abc 3abc
expected_output: | expected_cpu: |
3abc
expected_opencl: |
3abc 3abc
p3: p3:
input: | input: |
3abc 3abc
expected_output: | expected_cpu: |
3abc3abc3abc3abc
expected_opencl: |
3abc3abc3abc3abc 3abc3abc3abc3abc
f: f:
input: | input: |
3abc 3abc
expected_output: | expected_cpu: |
3abccba3
expected_opencl: |
3abccba3 3abccba3
'{': '{':
@ -125,7 +179,11 @@ f:
3abc 3abc
a a
expected_output: | expected_cpu: |
abc3
a
expected_opencl: |
abc3 abc3
a a
@ -134,7 +192,11 @@ f:
3abc 3abc
a a
expected_output: | expected_cpu: |
c3ab
a
expected_opencl: |
c3ab c3ab
a a
@ -142,22 +204,34 @@ $1$2:
input: | input: |
abc abc
expected_output: | expected_cpu: |
abc12
expected_opencl: |
abc12 abc12
^1^2: ^1^2:
input: | input: |
abc abc
expected_output: | expected_cpu: |
21abc
expected_opencl: |
21abc 21abc
'[': '[':
input: | input: |
a a
abc abc
123456790abcdefghijklmnopqrstuvw
expected_output: | expected_cpu: |
bc
23456790abcdefghijklmnopqrstuvw
expected_opencl: |
bc bc
@ -165,8 +239,14 @@ $1$2:
input: | input: |
a a
abc abc
123456790abcdefghijklmnopqrstuvw
expected_output: | expected_cpu: |
ab
123456790abcdefghijklmnopqrstuv
expected_opencl: |
ab ab
@ -175,8 +255,15 @@ D3:
abc abc
abcd abcd
abcde abcde
123456790abcdefghijklmnopqrstuvw
expected_output: | expected_cpu: |
abc
abc
abce
12356790abcdefghijklmnopqrstuvw
expected_opencl: |
abc abc
abc abc
abce abce
@ -187,8 +274,16 @@ x14:
abc abc
abcde abcde
abcdef abcdef
123456790abcdefghijklmnopqrstuvw
expected_output: | expected_cpu: |
a
abc
bcde
bcde
2345
expected_opencl: |
a a
abc abc
bcde bcde
@ -201,8 +296,17 @@ O22:
abc abc
abcd abcd
abcde abcde
123456790abcdefghijklmnopqrstuvw
expected_output: | expected_cpu: |
a
ab
abc
ab
abe
1256790abcdefghijklmnopqrstuvw
expected_opencl: |
a a
ab ab
abc abc
@ -216,8 +320,17 @@ O04:
abcd abcd
abcde abcde
abcdef abcdef
123456790abcdefghijklmnopqrstuvw
expected_output: | expected_cpu: |
a
abc
e
ef
56790abcdefghijklmnopqrstuvw
expected_opencl: |
a a
abc abc
@ -231,7 +344,13 @@ i3!:
abcd abcd
abcde abcde
expected_output: | expected_cpu: |
a
abc!
abc!d
abc!de
expected_cpu: |
a a
abc! abc!
abc!d abc!d
@ -244,7 +363,13 @@ o3!:
abcd abcd
abcde abcde
expected_output: | expected_cpu: |
a
abc
abc!
abc!e
expected_cpu: |
a a
abc abc
abc! abc!
@ -258,7 +383,14 @@ o3!:
abcde abcde
abcdef abcdef
expected_output: | expected_cpu: |
a
abc
abcd
abcd
abcd
expected_opencl: |
a a
abc abc
abcd abcd
@ -270,7 +402,11 @@ sab:
123b 123b
a123ba a123ba
expected_output: | expected_cpu: |
123b
b123bb
expected_opencl: |
123b 123b
b123bb b123bb
@ -279,17 +415,29 @@ saa:
123b 123b
a123ba a123ba
expected_output: | expected_cpu: |
123b 123b
a123ba a123ba
expected_opencl: |
123b
a123ba
'@a': '@a':
input: | input: |
123b 123b
aaa aaa
a123ba a123ba
123456790abcdefghijklmnopqrstuvw
expected_output: | expected_cpu: |
123b
123b
123456790bcdefghijklmnopqrstuvw
expected_opencl: |
123b 123b
123b 123b
@ -298,28 +446,40 @@ z0:
input: | input: |
abc abc
expected_output: | expected_cpu: |
abc
expected_opencl: |
abc abc
z3: z3:
input: | input: |
abc abc
expected_output: | expected_cpu: |
aaaabc
expected_opencl: |
aaaabc aaaabc
Z0: Z0:
input: | input: |
abc abc
expected_output: | expected_cpu: |
abc
expected_opencl: |
abc abc
Z3: Z3:
input: | input: |
abc abc
expected_output: | expected_cpu: |
abcccc
expected_opencl: |
abcccc abcccc
q: q:
@ -327,7 +487,11 @@ q:
a a
abc abc
expected_output: | expected_cpu: |
aa
aabbcc
expected_opencl: |
aa aa
aabbcc aabbcc
@ -336,116 +500,109 @@ qqq:
a a
abc abc
expected_output: | expected_cpu: |
aaaaaaaa
aaaaaaaabbbbbbbbcccccccc
expected_opencl: |
aaaaaaaa aaaaaaaa
aaaaaaaabbbbbbbbcccccccc aaaaaaaabbbbbbbbcccccccc
uMlX134: uMlX134:
mode: 1
input: | input: |
a a
abc abc
abcd abcd
abcdef abcdef
expected_output: | expected_cpu: |
abcdBCD abcdBCD
abcdBCDef abcdBCDef
uMl4: uMl4:
mode: 1
input: | input: |
a a
abc abc
expected_output: | expected_cpu: |
aA aA
abcABC abcABC
uMl6: uMl6:
mode: 1
input: | input: |
a a
abc abc
expected_output: | expected_cpu: |
Aa Aa
ABCabc ABCabc
<0: <0:
mode: 1
input: | input: |
a a
abc abc
expected_output: | expected_cpu: |
<1: <1:
mode: 1
input: | input: |
a a
abc abc
expected_output: | expected_cpu: |
a a
'>0': '>0':
mode: 1
input: | input: |
a a
abc abc
expected_output: | expected_cpu: |
a a
abc abc
'>2': '>2':
mode: 1
input: | input: |
a a
ab ab
abc abc
expected_output: | expected_cpu: |
ab ab
abc abc
_2: _2:
mode: 1
input: | input: |
a a
ab ab
abc abc
expected_output: | expected_cpu: |
ab ab
'!a': '!a':
mode: 1
input: | input: |
1 1
ab ab
abc abc
bcde bcde
expected_output: | expected_cpu: |
1 1
bcde bcde
/a: /a:
mode: 1
input: | input: |
1 1
ab ab
abc abc
bcde bcde
expected_output: | expected_cpu: |
ab ab
abc abc
(a: (a:
mode: 1
input: | input: |
1 1
ab ab
@ -453,12 +610,11 @@ _2:
abc abc
bcde bcde
expected_output: | expected_cpu: |
ab ab
abc abc
)c: )c:
mode: 1
input: | input: |
1 1
ab ab
@ -466,12 +622,11 @@ _2:
abc abc
bcde bcde
expected_output: | expected_cpu: |
bac bac
abc abc
=2c: =2c:
mode: 1
input: | input: |
1 1
ab ab
@ -479,12 +634,11 @@ _2:
abc abc
bcde bcde
expected_output: | expected_cpu: |
bac bac
abc abc
'%2a': '%2a':
mode: 1
input: | input: |
a a
aa aa
@ -492,27 +646,25 @@ _2:
aaaa aaaa
bcde bcde
expected_output: | expected_cpu: |
aaa aaa
aaaa aaaa
Q: Q:
mode: 1
input: | input: |
a a
abc abc
expected_output: | expected_cpu: |
a a
abc abc
rMrQ: rMrQ:
mode: 1
input: | input: |
ab ab
abcba abcba
expected_output: | expected_cpu: |
ab ab
k: k:
@ -521,7 +673,12 @@ k:
ab ab
abc abc
expected_output: | expected_cpu: |
a
ba
bac
expected_opencl: |
a a
ba ba
bac bac
@ -532,7 +689,12 @@ K:
ab ab
abc abc
expected_output: | expected_cpu: |
a
ba
acb
expected_opencl: |
a a
ba ba
acb acb
@ -546,7 +708,15 @@ K:
abcde abcde
abcdef abcdef
expected_output: | expected_cpu: |
a
ab
abc
abcd
abedc
abedcf
expected_opencl: |
a a
ab ab
abc abc
@ -560,7 +730,12 @@ L2:
ab ab
ab! ab!
expected_output: | expected_cpu: |
a
ab
abB
expected_opencl: |
a a
ab ab
abB abB
@ -571,7 +746,12 @@ R2:
ab ab
abB abB
expected_output: | expected_cpu: |
a
ab
ab!
expected_cpu: |
a a
ab ab
ab! ab!
@ -582,7 +762,12 @@ R2:
ab ab
abc abc
expected_output: | expected_cpu: |
a
ab
abd
expected_opencl: |
a a
ab ab
abd abd
@ -593,7 +778,12 @@ R2:
ab ab
abc abc
expected_output: | expected_cpu: |
a
ab
abb
expected_opencl: |
a a
ab ab
abb abb
@ -605,7 +795,13 @@ R2:
abc abc
abcd abcd
expected_output: | expected_cpu: |
a
ab
abc
abdd
expected_opencl: |
a a
ab ab
abc abc
@ -618,7 +814,13 @@ R2:
abc abc
abcd abcd
expected_output: | expected_cpu: |
a
ab
abb
abbd
expected_opencl: |
a a
ab ab
abb abb
@ -629,31 +831,49 @@ y2:
a a
ab ab
abc abc
123456790abcdefghijklmnopqrstuv
expected_cpu: |
expected_output: |
a a
abab abab
ababc ababc
expected_opencl: |
a
abab
ababc
123456790abcdefghijklmnopqrstuv
Y2: Y2:
input: | input: |
a a
ab ab
abc abc
123456790abcdefghijklmnopqrstuv
expected_output: | expected_cpu: |
a a
abab abab
abcbc abcbc
expected_opencl: |
a
abab
abcbc
123456790abcdefghijklmnopqrstuv
E: E:
input: | input: |
a bc a bc
ab c ab c
abc abc
expected_output: | expected_cpu: |
A Bc
Ab C
Abc
expected_opencl: |
A Bc A Bc
Ab C Ab C
Abc Abc
@ -664,7 +884,12 @@ e-:
ab-c ab-c
abc abc
expected_output: | expected_cpu: |
A-Bc
Ab-C
Abc
expected_opencl: |
A-Bc A-Bc
Ab-C Ab-C
Abc Abc

View File

@ -85,13 +85,16 @@ sub run_case_mode1
{ {
my $rule = shift; my $rule = shift;
my $case = $cases{$rule}; my $case = $cases{$rule};
die("Expected output for mode 1 (expected_cpu) isn't defined for rule: $rule") unless defined $case->{expected_cpu};
my $input_file = input_to_file ($case, $rule); my $input_file = input_to_file ($case, $rule);
my $quoted_rule = quotemeta ($rule); my $quoted_rule = quotemeta ($rule);
my $actual_output = qx($hashcat $OPTS -j $quoted_rule $input_file); my $actual_output = qx($hashcat $OPTS -j $quoted_rule $input_file);
eq_or_diff ($actual_output, $case->{expected_output}, $rule . " - mode 1"); eq_or_diff ($actual_output, $case->{expected_cpu}, $rule . " - mode 1");
} }
# Mode 2: GPU mode, using -r # Mode 2: GPU mode, using -r
@ -100,14 +103,17 @@ sub run_case_mode2
{ {
my $rule = shift; my $rule = shift;
my $case = $cases{$rule}; my $case = $cases{$rule};
die("Expected output for mode 2 (expected_opencl) isn't defined for rule: $rule") unless defined $case->{expected_opencl};
my $input_file = input_to_file ($case, $rule); my $input_file = input_to_file ($case, $rule);
my $rule_file = rule_to_file ($rule); my $rule_file = rule_to_file ($rule);
my $quoted_rule = quotemeta ($rule); my $quoted_rule = quotemeta ($rule);
my $actual_output = qx($hashcat $OPTS -r $rule_file $input_file); my $actual_output = qx($hashcat $OPTS -r $rule_file $input_file);
eq_or_diff ($actual_output, $case->{expected_output}, $rule . " - mode 2"); eq_or_diff ($actual_output, $case->{expected_opencl}, $rule . " - mode 2");
} }
sub run_case_all_mods sub run_case_all_mods
@ -116,16 +122,8 @@ sub run_case_all_mods
my $case = $cases{$rule}; my $case = $cases{$rule};
if (defined $case->{mode}) run_case_mode1 ($rule) if defined $case->{expected_cpu};
{ run_case_mode2 ($rule) if defined $case->{expected_opencl};
run_case_mode1 ($rule) if $case->{mode} == 1;
run_case_mode2 ($rule) if $case->{mode} == 2;
}
else
{
run_case_mode1 ($rule);
run_case_mode2 ($rule);
}
} }
sub input_to_file sub input_to_file
@ -164,11 +162,13 @@ sub rule_file_name
sub usage_die sub usage_die
{ {
die ("usage: $0 [rule] [mode] \n" . die ("usage: $0 [rule] [mode] \n" .
" [mode]: 1 for host mode, 2 for GPU mode \n" . " [mode]: 1 for host/cpu mode, 2 for GPU/opencl mode \n" .
" If [rule] was not specified, run all test cases \n" . " run all test cases if [rule] was not specified \n" .
" If [mode] was not specified, run test for all modes \n" . " run test for both modes if [mode] was not specified \n" .
" --help will show this help message \n" .
"\n" . "\n" .
"examples: \n" . "examples: \n" .
"run all available cases : perl $0 \n" .
"run i3! case on modes 1 & 2 : perl $0 i3! \n" . "run i3! case on modes 1 & 2 : perl $0 i3! \n" .
"run O04 case on mode 1 : perl $0 O04 1 \n" . "run O04 case on mode 1 : perl $0 O04 1 \n" .
"run sab case on mode 2 : perl $0 sab 2 \n"); "run sab case on mode 2 : perl $0 sab 2 \n");