#!/usr/bin/perl use Proc::Background; my $jtrbin = './john'; my ($hashfile, $outfile, $testtype, @intervals, $endtime, %data, %data2); unless (@ARGV) { usage(); } while (@ARGV) { $arg = shift(@ARGV); if ($arg eq '-h') { $hashfile = shift(@ARGV); } if ($arg eq '-t') { $testtype = shift(@ARGV); } if ($arg eq '-o') { $outfile = shift(@ARGV); } if ($arg eq '-i') { @intervals = split(':',shift(@ARGV)); $endtime = $intervals[(scalar(@intervals) - 1)]; #foreach $time (@i) { #$intervals{$time} = 0; #} } } unless ($hashfile) { print "no hashfile specified, aborted\n"; exit} unless ($testtype) { print "no test type specified, aborted\n"; exit} foreach $i (@intervals) {print "interval: $i\n";} my $temp = './temphash'; print "Beginning on hash #" . $count . ". " . scalar(@hashes) . " left to go!\n"; my $passedtype; if($testtype eq 'single') { $passedtype = '--single' } if($testtype eq 'wordlist') { $passedtype = '--wordlist=password.lst --rules' } if($testtype eq 'incremental') { $passedtype = '-i' } my $starttime = time(); my $jtr = Proc::Background->new($jtrbin, $passedtype, $hashfile, '--session=BAM 1>2>jtrout'); for($d2,$ctime = time(); ($ctime - $starttime) < ($endtime + 1); $ctime = time(), $diff = ($ctime - $starttime)) { my $flag; if ($diff > $d2) { print "Heartbeat $diff seconds ($diff>$d2)\n"; if ($diff == $intervals[0]) { #dump the results for this time, and then remove the interval my @results = `$jtrbin --show $hashfile`; $data{$intervals[0]} = [ @results ]; shift(@intervals); } } $d2 = $diff; } if ($jtr->alive) { $endtime = time(); $jtr->die(); } else { $endtime = time(); } #craziness inspired by tom christiansens class foreach $time (keys %data) { foreach $entry (@{$data{$time}}) { my @tuples = split(':',$entry); #now it's possible someone set their pass to "???????", in which case they are very clever #we're also going to count "NO PASSWORD" as cracked. unless($tuples[1] =~ /\?\?\?\?\?\?\?/ || $tuples[1] =~/NO PASSWORD/) { $data2{$time}++; #print "FOUND PASSWORD! $tuples[1]\n\n\n"; } } } open(OUT, ">>$outfile") or die ("can't append to $outfile: $!\n"); foreach $time (keys %data2) { print OUT "$data2{$time}:$time\n"; } close OUT; sub usage { my $usage = qq~ Tests each hash (from a file) and remembers how long it took to crack.\n USAGE [$0 -h hashfile -t single -i 30:300:900:7200]: \t-h\t[hashfile] \t-t\t[single|wordlist|incremental] \t-o\t[outfile] \t-i\t[intervals (seconds) seperated by colon] ~; print $usage; exit; }