1
0
mirror of https://github.com/hashcat/hashcat.git synced 2025-02-02 02:41:35 +00:00

Enforce a certain number of entries in random selected password and salt length selection buffers in test.pl

This commit is contained in:
jsteube 2019-02-20 13:37:34 +01:00
parent a1b72fc93a
commit cec4aeac10

View File

@ -340,19 +340,20 @@ sub init_db_word_rand
} }
} }
my $outputs_possible = $len_max - $len_min;
my $outputs = ($single_outputs < $outputs_possible) ? $single_outputs : $outputs_possible;
my @pool; my @pool;
for (my $len = $len_min + 1; $len <= $len_max - 1; $len++) for (my $len = $len_min; $len <= $len_max; $len++)
{ {
push @pool, $len; push @pool, $len;
} }
while (scalar @pool < $single_outputs)
{
@pool = shuffle (@pool); @pool = shuffle (@pool);
push @pool, $pool[0];
}
my $db_out; my $db_out;
my $idx = 0; my $idx = 0;
@ -360,7 +361,7 @@ sub init_db_word_rand
$db_out->[$idx++] = $len_min; $db_out->[$idx++] = $len_min;
$db_out->[$idx++] = $len_max; $db_out->[$idx++] = $len_max;
for ($idx .. $outputs) for ($idx .. $single_outputs)
{ {
$db_out->[$idx++] = shift @pool; $db_out->[$idx++] = shift @pool;
} }
@ -389,19 +390,20 @@ sub init_db_salt_rand
$len_max = ($len_max >= 51) ? 51 : $len_max; $len_max = ($len_max >= 51) ? 51 : $len_max;
} }
my $outputs_possible = $len_max - $len_min;
my $outputs = ($single_outputs < $outputs_possible) ? $single_outputs : $outputs_possible;
my @pool; my @pool;
for (my $len = $len_min + 1; $len <= $len_max - 1; $len++) for (my $len = $len_min; $len <= $len_max; $len++)
{ {
push @pool, $len; push @pool, $len;
} }
while (scalar @pool < $single_outputs)
{
@pool = shuffle (@pool); @pool = shuffle (@pool);
push @pool, $pool[0];
}
my $db_out; my $db_out;
my $idx = 0; my $idx = 0;
@ -409,7 +411,7 @@ sub init_db_salt_rand
$db_out->[$idx++] = $len_min; $db_out->[$idx++] = $len_min;
$db_out->[$idx++] = $len_max; $db_out->[$idx++] = $len_max;
for ($idx .. $outputs) for ($idx .. $single_outputs)
{ {
$db_out->[$idx++] = shift @pool; $db_out->[$idx++] = shift @pool;
} }