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
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.

Link to comment
Share on other sites

Try

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

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.