| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Data::Password::zxcvbn::Match::BruteForce; |
|
2
|
4
|
|
|
4
|
|
27
|
use Moo; |
|
|
4
|
|
|
|
|
12
|
|
|
|
4
|
|
|
|
|
40
|
|
|
3
|
|
|
|
|
|
|
with 'Data::Password::zxcvbn::Match'; |
|
4
|
4
|
|
|
4
|
|
4397
|
use List::AllUtils qw(max); |
|
|
4
|
|
|
|
|
11040
|
|
|
|
4
|
|
|
|
|
1416
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '1.1.0'; # VERSION |
|
6
|
|
|
|
|
|
|
# ABSTRACT: special match class for brute-force guesses |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
my $BRUTEFORCE_CARDINALITY = 10; |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub estimate_guesses { |
|
12
|
17315
|
|
|
17315
|
1
|
134370
|
my ($self) = @_; |
|
13
|
|
|
|
|
|
|
|
|
14
|
17315
|
|
|
|
|
55992
|
return $BRUTEFORCE_CARDINALITY ** length($self->token); |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
around guesses_for_password => sub { |
|
18
|
|
|
|
|
|
|
my ($orig,$self,$password) = @_; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# small detail: make bruteforce matches at minimum one guess bigger than |
|
21
|
|
|
|
|
|
|
# smallest allowed submatch guesses, such that non-bruteforce submatches |
|
22
|
|
|
|
|
|
|
# over the same [i..j] take precedence. |
|
23
|
|
|
|
|
|
|
my $min_guesses = $self->_min_guesses()+1; |
|
24
|
|
|
|
|
|
|
my $guesses = $self->guesses(); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
return max($min_guesses,$guesses); |
|
27
|
|
|
|
|
|
|
}; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
around BUILDARGS => sub { |
|
31
|
|
|
|
|
|
|
my ($orig,$class,@args) = @_; |
|
32
|
|
|
|
|
|
|
my $args = $class->$orig(@args); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$args->{token} = substr( |
|
35
|
|
|
|
|
|
|
delete $args->{password}, |
|
36
|
|
|
|
|
|
|
$args->{i}, |
|
37
|
|
|
|
|
|
|
$args->{j} - $args->{i} +1, |
|
38
|
|
|
|
|
|
|
); |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
return $args; |
|
41
|
|
|
|
|
|
|
}; |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
sub make { |
|
44
|
0
|
|
|
0
|
0
|
0
|
require Carp; |
|
45
|
0
|
|
|
|
|
0
|
Carp::croak('BruteForce is a special case, its ->make constructor should never be called'); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
|
49
|
322
|
|
|
322
|
1
|
1756
|
sub feedback_warning { return undef } |
|
50
|
322
|
|
|
322
|
1
|
1896
|
sub feedback_suggestions { return [] } |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
1; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
__END__ |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=pod |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=encoding UTF-8 |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 NAME |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Data::Password::zxcvbn::Match::BruteForce - special match class for brute-force guesses |
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 VERSION |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
version 1.1.0 |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
This class represents the guess that a certain substring of a password |
|
71
|
|
|
|
|
|
|
can't be guessed any other way than by going through all the |
|
72
|
|
|
|
|
|
|
characters combinations one by one. |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
This kind of matches is not generated by L<< |
|
75
|
|
|
|
|
|
|
C<omnimatch>|Data::Password::zxcvbn::MatchList/omnimatch >>: it's used |
|
76
|
|
|
|
|
|
|
internally by L<< |
|
77
|
|
|
|
|
|
|
C<most_guessable_match_list>|Data::Password::zxcvbn::MatchList/most_guessable_match_list |
|
78
|
|
|
|
|
|
|
>> to cover unmatched substrings, and as a fallback in the |
|
79
|
|
|
|
|
|
|
calculations. |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 METHODS |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 C<estimate_guesses> |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
The number of guesses is exponential on the length of the token. |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 C<new> |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
my $match = Data::Password::zxcvbn::Match::BruteForce->new( |
|
90
|
|
|
|
|
|
|
password => $password, |
|
91
|
|
|
|
|
|
|
i => 2, j => 5, |
|
92
|
|
|
|
|
|
|
); |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Returns a match object covering the substring of C<$password> between |
|
95
|
|
|
|
|
|
|
the C<i>th and C<j>th character. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 C<feedback_warning> |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 C<feedback_suggestions> |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This class does not provide any feedback. |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=for Pod::Coverage BUILDARGS |
|
104
|
|
|
|
|
|
|
make |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 AUTHOR |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
Gianni Ceccarelli <gianni.ceccarelli@broadbean.com> |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This software is copyright (c) 2022 by BroadBean UK, a CareerBuilder Company. |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
115
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=cut |