]> eyrie.org Git - kerberos/krb5-strength.git/blobdiff - tools/cdbmake-wordlist
Support a maximum word length in cdbmake-wordlist
[kerberos/krb5-strength.git] / tools / cdbmake-wordlist
index 557ca60fd1f70eb0dd4c01f02a4fce90bdf60be6..c0ca0c4f2559b0fb68c015d8c1bd0bfefb7f9995 100755 (executable)
@@ -42,10 +42,11 @@ my $fullpath = $0;
 local $0 = basename($0);
 
 # Parse the argument list.
-my ($ascii, $min_length, $manual);
+my ($ascii, $max_length, $min_length, $manual);
 Getopt::Long::config('bundling', 'no_ignore_case');
 GetOptions(
     'ascii|a'        => \$ascii,
+    'max-length|L=i' => \$max_length,
     'min-length|l=i' => \$min_length,
     'manual|man|m'   => \$manual
 );
@@ -75,6 +76,7 @@ while (defined(my $word = <$in>)) {
     chomp($word);
     my $length = length($word);
     next if (defined($min_length) && $length < $min_length);
+    next if (defined($max_length) && $length > $max_length);
     if ($ascii) {
         next if $word =~ m{ [^[:ascii:]] }xms;
         next if $word =~ m{ [[:cntrl:]] }xms;
@@ -106,7 +108,8 @@ cdbmake-wordlist - Create a cdb database from a wordlist
 
 =head1 SYNOPSIS
 
-B<cdbmake-wordlist> [B<-am>] [B<-l> I<length>] I<wordlist>
+B<cdbmake-wordlist> [B<-am>] [B<-l> I<min-length>] [B<-L> I<max-length>]
+    I<wordlist>
 
 =head1 DESCRIPTION
 
@@ -133,6 +136,17 @@ Filter all words that contain non-ASCII characters or control characters
 from the resulting cdb file, leaving only words that consist solely of
 ASCII non-control characters.
 
+=item B<-L> I<maximum>, B<--max-length>=I<maximum>
+
+Filter all words of length greater than I<maximum> from the resulting cdb
+database.  The length of each line (minus the separating newline) in the
+input wordlist will be checked against I<minimum> and will be filtered out
+of the resulting database if it is shorter.  Useful for generating
+password dictionaries from word lists that contain random noise that's
+highly unlikely to be used as a password.
+
+The default is to not filter out any words for maximum length.
+
 =item B<-l> I<minimum>, B<--min-length>=I<minimum>
 
 Filter all words of length less than I<minimum> from the resulting cdb