Jump to content

What am I doing wrong here?


ResistMonsanto

Recommended Posts

Hello, I've just recently started learning PHP and wanted to make a quick script to compare MD5 hash's, but I've seem to have done something wrong. This is what I've got so far, can someone point out my mistake? The $_GET is used to pass the MD5 hash which is to be tested against the given wordlist.

 

 

<html>

<body>

<?php

$hashtocrack = $_GET['crackme'];

$file = fopen("dictionary.txt","r");

if(isset($file)){

while(!feof($file)){

$hash = fgets($file);

$md5check = md5($hash);

if($md5check == $hashtocrack){

echo "Hash found! -> ", $hash;

exit(1);

}

}

}

?>

</body>

</html>

 

Any help is greatly appreciated.

Link to comment
https://forums.phpfreaks.com/topic/239951-what-am-i-doing-wrong-here/
Share on other sites

The first thing you did wrong "here" ie. phpfreaks, was to post a bunch of code with no php or code tags.  Also, where is your indentation?

 

Your 2nd mistake was not describing what the problem is.  I don't see anything in the code that jumps out at me as being obviously wrong.  Depending on the size of dictionary.txt this could take a long time to run, so it may be timing out.  The php.ini has variables that control the amount of time a script can run, how much memory it can use, etc.  The default timeout is usually pretty short.

Thanks for the second bit, forgot to specify my issue. When I put a hash in that I know has the plaintext equivalent in the worldlist, I still get no results. So I thought maybe I was making an obvious mistake somewhere.

 

And @fugix, thanks man I tried that but had no luck  :wtf:

It's just in a line format because fgets reads line by line right, so the way I have it should be hashing the word on each line and comparing it, then moving on to the next line and discarding the previous right? Or am I effin up somewhere?

 

The list is like this though;

 

This

is

my

awesome

wordlist

Right on man, that solved the issue. Thanks a ton to everyone who replied.

 

Working code;

<html>
<body>
</h1>Hash Value</h1>
<?php
$hashtocrack = $_GET['crackme'];
$file = fopen("sec.txt","r");
if(isset($file)){
while($hash = trim(fgets($file))){
$md5check = md5($hash);
if($md5check == $hashtocrack){
echo "<br />Hash found! -> ", $hash;
exit(1);
}
}
}
?>
</body>
</html>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.