Simple script if you have a md5 hash and want to crack it !
#attempts to crack a md5 hash using a dictionary file
#you run the program this way
# perl md5 hash_to_crack dictionary_file
use Digest::MD5 qw(md5_hex);
my $hash=shift || die "Give me a hash to crack\n";
my $file=shift || die "Give me a dictionary file\n";
open(F,$file) || die "can't open the file\n";
print "Processing $_";
print " $t\n";
die "Found it -> $_\n" if($t eq $hash);
You have several issues with your post. First, you aren't following some best practices:
3 arg open (fenLisesi points out the danger above)
Additionally, you fail to mention Salt (cryptography). Your title is also misleading. It seems to imply you can crack any MD5 hash when in fact it could only find entries in the user provided dictionary.
Could someone call this with a filename such as '> $INTERESTING_FILE'? Cheers.
Update: I see that I did not explain my point well at all ($INTERESTING_FILE is meant to be a shell var, for one). Let me put forth a worst case scenario: A crazed admin installs this utility setuid root and a user calls it with a string that will cause this utility to open the system password file in write mode. Typically, it would just be able to mess up the files on which the user already has write access, which is not a big problem. It is probably best, though, to always keep in mind the concentric-circles approach to security and use Taint, avoid the shell, etc. Also, Corion mentioned in the CB that a self-respecting developer would salt the data passed by the user, so even if the data were a dictionary word, this utility would not work.