#!/usr/bin/perl
#

use Digest::MD5 qw(md5_hex);
use Getopt::Std;

getopts('k:m:');
our($opt_k, $opt_m);

my $wordlist = $opt_k;
my $hashku = $opt_m;

$baner=<<END
Simple MD5 hash cracker (dictionary attack) ...

by bima(iko94\@yahoo.com)
\twww.geocities.com/iko94

:))

Usage: perl $0 -k <wordlist file> -m <md5 hash>  
Example : perl $0 -k kamus.txt -m 6742923575546471370cc028f289db40 \n
END
;
print($baner);

$log="hash_md5.log";

open(UF, "<$wordlist") || die "\nI can't open the wordlist\n";
@username=<UF>;
close(UF);
$tanda=0;

foreach $elemen(@username){
 chomp($elemen);
 print "trying $elemen ::: \n";
 $kamusku=md5_hex($elemen);

 if ($kamusku eq $hashku) {
   printlog ("found string === $elemen === equal to hash $hashku \n");
   $tanda=1;
   last;
 } #of if

} #of foreach

if ($tanda==0) {print "Not success, try to choose another wordlist :(\n"}

sub printlog {
print @_[0];
open(lo,">>$log");
print lo @_[0];
close(lo);
return;
}
