WDef
Group: Members
Posts: 798
Joined: Sep. 2005 |
|
Posted: Jan. 15 2008,17:10 |
|
Here it is with:
1. skips strings containing 3 adjacent same chars 2. only prints current perm on receipt of SIGHUP signal (eg pkill -1 cur.pl), but can print all perms if set $printall = 1.
It's not worth filtering out single char passphrases. There's only one set of them.
So output on my test blowfish encrypted file (password = art) looks like:
Code Sample | dsl@box:~# ./cur.pl Skipping result with 3 chars ööö Skipping result with 3 chars aaa Current perm = aoc Found passphrase: art Terminated
|
Current perm = aoc was where I sent it a pkill -1 cur.pl from another shell.
Comment out the line that prints skipped perms if you wish, it's for debugging.
Code Sample | #!/usr/bin/perl # curagacrack.pl
use strict; use warnings;
my $n = 30; # max len of passphrase my $j;
my @set = ( "ö", "a" .."z" ); # ranges and lists to permute our $result = ""; my $printall = 0; # don't print perms #~ my $printall = 1; # print every perm
sub print_perm { print "Current perm = $result\n"; }
sub create_perm {
my ($cur,$max)=@_; my ($k, $str);
if($cur>=$max){ if ($printall == 1){ while ($k lt $cur){ $str .= "\b"; $k++; } print "$result$str"; } system("echo $result | 2>/dev/null openssl bf -pass stdin -d -in encryptedfile -out out.txt && file -b out.txt | grep -q '^ASCII text' && echo -n 'Found passphrase: ' && echo $result && kill 0"); return; }
foreach my $c(@set){ substr($result,$cur,1)=$c; if (($max ge 3) && ($result =~ /$c{3}$/)) { print "Skipping result with 3 chars $result\n"; next; } create_perm($cur+1,$max); } }
$SIG{'HUP'} = 'print_perm';
for ($j=1;$j<=$n;$j++){ create_perm(0,$j); }
|
|