line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Authen::Simple::Password; |
2
|
|
|
|
|
|
|
|
3
|
6
|
|
|
6
|
|
787
|
use strict; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
195
|
|
4
|
6
|
|
|
6
|
|
54
|
use warnings; |
|
6
|
|
|
|
|
11
|
|
|
6
|
|
|
|
|
172
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
5717
|
use Crypt::PasswdMD5 qw[]; |
|
6
|
|
|
|
|
7392
|
|
|
6
|
|
|
|
|
124
|
|
7
|
6
|
|
|
6
|
|
40
|
use Digest::MD5 qw[]; |
|
6
|
|
|
|
|
10
|
|
|
6
|
|
|
|
|
100
|
|
8
|
6
|
|
|
6
|
|
13670
|
use Digest::SHA qw[]; |
|
6
|
|
|
|
|
28877
|
|
|
6
|
|
|
|
|
325
|
|
9
|
6
|
|
|
6
|
|
5963
|
use MIME::Base64 qw[]; |
|
6
|
|
|
|
|
4870
|
|
|
6
|
|
|
|
|
4631
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub check { |
12
|
16
|
|
|
16
|
1
|
23129
|
my ( $class, $password, $encrypted ) = @_; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Plain |
15
|
16
|
100
|
|
|
|
60
|
return 1 if $password eq $encrypted; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# L S |
18
|
|
|
|
|
|
|
# Des 13 2 |
19
|
|
|
|
|
|
|
# Extended DES 20 9 |
20
|
|
|
|
|
|
|
# $1$ MD5 34 12 |
21
|
|
|
|
|
|
|
# $2$ Blowfish 34 16 |
22
|
|
|
|
|
|
|
# $3$ NT-Hash ? ? |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Crypt |
25
|
15
|
100
|
|
|
|
1824
|
return 1 if crypt( $password, $encrypted ) eq $encrypted; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# Crypt Modular Format |
28
|
13
|
100
|
|
|
|
50
|
if ( $encrypted =~ /^\$(\w+)\$/ ) { |
29
|
1
|
50
|
|
|
|
9
|
return 1 if $class->_check_modular( $password, $encrypted, lc($1) ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# LDAP Format |
33
|
12
|
100
|
|
|
|
49
|
if ( $encrypted =~ /^\{(\w+)\}/ ) { |
34
|
6
|
50
|
|
|
|
27
|
return 1 if $class->_check_ldap( $password, $encrypted, lc($1) ); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# MD5 |
38
|
6
|
100
|
|
|
|
23
|
if ( length($encrypted) == 16 ) { |
39
|
1
|
50
|
|
|
|
14
|
return 1 if Digest::MD5::md5($password) eq $encrypted; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
5
|
100
|
|
|
|
13
|
if ( length($encrypted) == 22 ) { |
43
|
1
|
50
|
|
|
|
16
|
return 1 if Digest::MD5::md5_base64($password) eq $encrypted; |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
4
|
100
|
|
|
|
11
|
if ( length($encrypted) == 32 ) { |
47
|
1
|
50
|
|
|
|
13
|
return 1 if Digest::MD5::md5_hex($password) eq $encrypted; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
# SHA-1 |
51
|
3
|
100
|
|
|
|
9
|
if ( length($encrypted) == 20 ) { |
52
|
1
|
50
|
|
|
|
45
|
return 1 if Digest::SHA::sha1($password) eq $encrypted; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
2
|
100
|
|
|
|
7
|
if ( length($encrypted) == 27 ) { |
56
|
1
|
50
|
|
|
|
18
|
return 1 if Digest::SHA::sha1_base64($password) eq $encrypted; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
1
|
50
|
|
|
|
4
|
if ( length($encrypted) == 40 ) { |
60
|
1
|
50
|
|
|
|
13
|
return 1 if Digest::SHA::sha1_hex($password) eq $encrypted; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# SHA-2 256 |
64
|
0
|
0
|
|
|
|
0
|
if ( length($encrypted) == 32 ) { |
65
|
0
|
0
|
|
|
|
0
|
return 1 if Digest::SHA::sha256($password) eq $encrypted; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
0
|
0
|
|
|
|
0
|
if ( length($encrypted) == 43 ) { |
69
|
0
|
0
|
|
|
|
0
|
return 1 if Digest::SHA::sha256_base64($password) eq $encrypted; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
0
|
if ( length($encrypted) == 64 ) { |
73
|
0
|
0
|
|
|
|
0
|
return 1 if Digest::SHA::sha256_hex($password) eq $encrypted; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
0
|
return 0; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _check_ldap { |
80
|
6
|
|
|
6
|
|
9
|
my ( $class, $password, $encrypted, $scheme ) = @_; |
81
|
|
|
|
|
|
|
|
82
|
6
|
100
|
|
|
|
16
|
if ( $scheme eq 'cleartext' ) { |
83
|
1
|
|
|
|
|
3
|
my $hash = substr( $encrypted, 11 ); |
84
|
1
|
50
|
|
|
|
11
|
return 1 if $password eq $hash; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
5
|
100
|
|
|
|
13
|
if ( $scheme eq 'crypt' ) { |
88
|
1
|
|
|
|
|
3
|
my $hash = substr( $encrypted, 7 ); |
89
|
1
|
50
|
|
|
|
77
|
return 1 if crypt( $password, $hash ) eq $hash; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
4
|
100
|
|
|
|
10
|
if ( $scheme eq 'md5' ) { |
93
|
1
|
|
|
|
|
17
|
my $hash = MIME::Base64::decode( substr( $encrypted, 5 ) ); |
94
|
1
|
50
|
|
|
|
15
|
return 1 if Digest::MD5::md5($password) eq $hash; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
3
|
100
|
|
|
|
10
|
if ( $scheme eq 'smd5' ) { |
98
|
1
|
|
|
|
|
6
|
my $hash = MIME::Base64::decode( substr( $encrypted, 6 ) ); |
99
|
1
|
|
|
|
|
4
|
my $salt = substr( $hash, 16 ); |
100
|
1
|
50
|
|
|
|
15
|
return 1 if Digest::MD5::md5( $password, $salt ) . $salt eq $hash; |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
2
|
100
|
|
|
|
6
|
if ( $scheme eq 'sha' ) { |
104
|
1
|
|
|
|
|
6
|
my $hash = MIME::Base64::decode( substr( $encrypted, 5 ) ); |
105
|
1
|
50
|
|
|
|
22
|
return 1 if Digest::SHA::sha1($password) eq $hash; |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
1
|
50
|
|
|
|
4
|
if ( $scheme eq 'ssha' ) { |
109
|
1
|
|
|
|
|
6
|
my $hash = MIME::Base64::decode( substr( $encrypted, 6 ) ); |
110
|
1
|
|
|
|
|
3
|
my $salt = substr( $hash, 20 ); |
111
|
1
|
50
|
|
|
|
15
|
return 1 if Digest::SHA::sha1( $password, $salt ) . $salt eq $hash; |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
0
|
|
|
|
|
0
|
return 0; |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub _check_modular { |
118
|
1
|
|
|
1
|
|
4
|
my ( $class, $password, $encrypted, $format ) = @_; |
119
|
|
|
|
|
|
|
|
120
|
1
|
50
|
|
|
|
4
|
if ( $format eq '1' ) { |
121
|
0
|
0
|
|
|
|
0
|
return 1 if Crypt::PasswdMD5::unix_md5_crypt( $password, $encrypted ) eq $encrypted; |
122
|
|
|
|
|
|
|
} |
123
|
|
|
|
|
|
|
|
124
|
1
|
50
|
|
|
|
4
|
if ( $format eq 'apr1' ) { |
125
|
1
|
50
|
|
|
|
8
|
return 1 if Crypt::PasswdMD5::apache_md5_crypt( $password, $encrypted ) eq $encrypted; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
0
|
|
|
|
|
|
return 0; |
129
|
|
|
|
|
|
|
} |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |