MD5 cracker
I'm having some trouble with my MD5 cracker function I'm trying to create in PHP. Not sure why it's not working, but here's the code:
<?
function hashcrack($string) {
$words = str_ireplace(",", " ", file("http://www.site.com/wordlist.txt"));
foreach ($words as $word) {
$word = trim($word);
if (md5($word) == $hash) {
return $word;
}
}
return false;
}
if ($result == $hash) {
echo "hash matches $result";
} else {
echo "No match found";
}
?>
Hope this doesn't look familiar. :ninja:
sharpskater80 wrote: $hash and $result aren't declared
might consider using else if instead of two "if"s
just after a quick glance, don't hold me to it
According to others, that's correct. The variables are declared there. But that had me for a while as I was trying to figure out how to extract the info from above. :angry: And I closed the first if, I believe it needs to be closed there. I could be wrong though.
heres a snippet from a larger code i had that may help you at least a little
function md5crack($hash, $words) {
if (strlen($hash) == 32) {
$words = file("$words");
foreach ($words as $word) {
$word = rtrim($word);
if (md5($word) == $hash) {
return "
<b>Plaintext found!</b>
<br />
<br />
$hash = <b>$word</b>"
exit;
}
}
} else {
return "String is not md5!";
exit;
}
return "Not found!";
}
?>```
KAC7 wrote: [color=pink]www.Google.com/[/color]
Why would I need google? There's was no error in my syntax I simply left something out, something that should have been easily spotted ;) what can I say I was tired. Here's the working function:
function hashcrack($hash) {
$words = explode(",",file_get_contents("site.com/dictionary.txt");
$i = 0;
foreach ($words as $word){
if (md5($word) == $hash)
return $word;
else
$i++;
}
}
//end hashcrack function