08-20-2012, 03:17 PM
OK, I finished a perl version capable of doing width > 3. It works, but is a lot slower than the C version. Have fun, it works pretty nice
I will add it to hashcat-utils as morph2.pl
Code:
#!/usr/bin/env perl
use strict;
use warnings;
my @intpos_to_rulepos =
(
'0', '1', '2', '3', '4',
'5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E',
'F', 'G', 'H', 'I', 'J',
);
my $function = "i";
#my $function = "o";
if (scalar @ARGV != 5)
{
print "usage: $0 dictionary depth width pos_min pos_max\n";
exit -1;
}
my ($dictionary, $depth, $width, $pos_min, $pos_max) = @ARGV;
if ($width > 20)
{
print "width > 20\n";
exit -1;
}
for (my $pos = $pos_min; $pos <= $pos_max; $pos++)
{
my $table;
open (IN, $dictionary) or die "$dictionary: $!\n";
while (my $line = <IN>)
{
chomp $line;
my $len = length $line;
next if (($len - $pos) < $width);
my $word = substr ($line, $pos, $width);
next unless defined $word;
$table->{$word}++;
}
close (IN);
my @keys = sort { $table->{$b} <=> $table->{$a} } keys %{$table};
for (my $i = 0; $i < $depth; $i++)
{
my @chars = split "", $keys[$i];
my @rule;
for (my $j = 0; $j < $width; $j++)
{
my $step = join "", $function, $intpos_to_rulepos[$pos + $j], $chars[$j];
push @rule, $step;
}
print join (" ", @rule), "\n";
}
}
I will add it to hashcat-utils as morph2.pl