Jump to content

md5() Decrypt Problem


shah_ankitb

Recommended Posts

In the PHP File i have two fields Login & Password. I am Storing Password in md5($_REQUEST['vPassword']) form in the database, so the Password is md5 it stores hexadecimal value like '21232f297a57a5a743894a0e4a801fc3' which is decrypt of 'admin'. Now problem starts i forgot the password. I would like to do reverse process. I want to decrypt '21232f297a57a5a743894a0e4a801fc3' which is value from DB & i want the Password Back saying 'admin'. So How can i decrypt md5() or sha1()?

Link to comment
Share on other sites

If i forgot the Password then how can i get the value of '21232f297a57a5a743894a0e4a801fc3' encrypted code.There should be some method to Decrypt It to Get the Original Ones.If we can Encrypt it then We can DEFINATELY Decrypt It. Only things that we don't know the method of that.

Link to comment
Share on other sites

OK buddy, if you think you can come up with an algorithm to decrpyt MD5, go right ahead, and when you're done, make sure you notify the National Security Agency and the Central Intelligence Agency, because their cryptanalysts have been trying to decrypt it and they aren't able to. The specific point of MD5 is so that it cannot be decrypted. Not only that, but the nature of the algorithm makes it so. Consider this. If you have a 1-gigabyte file, and you take the MD5 hash of it, which is 32 bytes, how the heck are you supposed to convert those 32 bytes into the original 1073741824 bytes? How does that work? How can you map 32 bytes to 1073741824 bytes? I'll save you the time, the answer is you can't. The same thing with a password, if someone types in a password that is 255 bytes, and it gets hashed into a 32 byte hash, how are you supposed to convert those 32 bytes into the original 255 bytes? It doesn't work that way, that's not what MD5 is supposed to be used for. Just because the passwords you are using might be less then 32 bytes does not mean that there exists any algorithm to convert the hash to the original. But, like I said, if you figure out a way to de-hash MD5 or SHA then please do notify the NSA and the CIA, they will probably be interested in hiring you.If you want alternatives to decrypting MD5, feel free to ask. But if you want to argue about whether or not MD5 is reversible, go ahead and do a Google search on the topic before you say that there DEFINATELY must be a way to reverse the hash. MD5 and SHA are not encryption/decryption, they are hashing. Those are not nearly the same thing.

Link to comment
Share on other sites

http://www.md5encryption.com/Ok Just Visit Above Site.In Encrypt Type :demo After typing that they r producing 'MD5 Hash: fe01ce2a7fbac8fafaed7c982a04e229'Now put 'fe01ce2a7fbac8fafaed7c982a04e229' In the Decrypt text Box it returns me My Word 'demo. Now write my key without encrypt 'admin' in Decrypt text box '21232f297a57a5a743894a0e4a801fc3' it gives me my Word 'admin'. I would just wanna to know how they do it?
Link to comment
Share on other sites

They have a database full of hashes.

we will look into our database
So, in the database they have a record that says the string "fe01ce2a7fbac8fafaed7c982a04e229" corresponds to the word "demo". They don't do decryption there, they just do a database lookup.To prove that, take a look at this example. First, load this page to do an MD5 hash:http://choice.server.tracorp.com/vartest.phpDon't use the site you linked to, because if you hash something they probably store it in their database for lookup later. So, use that link to do the hash. Just type in a bunch of random characters like ksljhdfklsfjas into the text box, select the MD5 button, and hit submit. Copy and paste the hash into the decryption box on the md5encryption.com site and tell them to decrypt it, and you will see that they could not find a match for it. All they are doing is a database lookup, there are actually quite a few sites out there that have databases full of MD5 or SHA hashes that you can use to lookup passwords and try to break into something. Here is another example of an MD5 lookup site that searches in several different databases:http://md5.dustinfineout.com/It's useful to use these sites to check your own passwords. If you want to know if it's easy for someone to guess your password, hash it and then paste the hash into that site and see if it shows up in their database. If it does, you may want to choose a different password.
Link to comment
Share on other sites

So the only way to have a new password when using md5() is to create a new one! is using the date, time and an extra word is good thing to do for password generator?

Link to comment
Share on other sites

But yes, the way to reset a user's password is to give them a new one, not recover the old one. It's useful to store the user's email address for this purpose. You can either generate a new password and send it to the user's email address, or you can send the user a link with a random ID on it that you save in the database, and when they click the link and load the page you will do a database lookup on the ID to find out which user to change the password for and give them a box to type in the new password they want. All you're trying to do is verify that the user is who they say they are, an email address helps. If you want something that can generate a new password, you can use this:

################################################################################ generate_password#  this function generates a random alphanumeric password###############################################################################function generate_password ($length = 8){  $user_pw = "";  while (strlen($user_pw) < $length)  {	$char = mt_rand(49, 122);	if (($char > 57 && $char < 65) ||		($char > 90 && $char < 97))	{	  continue;	}	$user_pw .= chr($char);  }  return $user_pw;}//generate a random password that is 12 characters long:$pw = generate_password(12);//generate a random password that is the default length (8):$pw = generate_password();

It's not a very good idea to have another database field for verification, like a "forgot password question", where you have to say what your favorite pet was, or first car, or whatever. The reason that is not a good idea is because it doesn't add any security, in fact it adds a vulnerability. You may remember several years ago that Paris Hilton claimed her cell phone got "hacked". No one hacked anything, someone logged onto the T-Mobile website, typed in Paris' phone number, clicked the "Forgot Password" link, and the answer to Paris' "secret" question was the name of her dog that she carried everywhere. They typed in the dog's name and got access to everything on the girl's phone. Granted, Paris is most certainly not the brightest bulb in the pack, but having this type of question-response system for validation doesn't make anything more secure.

Link to comment
Share on other sites

I understand the if condition, what I don't get is the continue; in it.is it the same as :

if (($char > 57 && $char < 65) ||		($char > 90 && $char < 97))	{	  // keep those character	} else {	  // keep searching	}

because it will keep looping if the if statement is false isn't?Sorry but I'm lost.

Link to comment
Share on other sites

Haha. No, this guy designed MD5:http://en.wikipedia.org/wiki/Ronald_RivestI still have hair.As for the continue statement, continue will cause the current loop to re-start from the beginning without finishing the current iteration (there's no good word for that). So this loop would print every number from 1 to 10 except 7:

for ($i = 1; $i <= 10; $i++){  if ($i == 7) //go back to the top of the loop if $i == 7	continue;  print $i;}

Continue "continues" the loop. You can also use break inside a loop to stop it. So, you could set up an infinite loop and use break to control when the loop ends:

while (true){  ...  if ($time_to_end_the_loop)	break;  ...}

So, back to the loop for that function..

  while (strlen($user_pw) < $length)  {	$char = mt_rand(49, 122);	if (($char > 57 && $char < 65) ||		($char > 90 && $char < 97))	{	  continue;	}	$user_pw .= chr($char);  }

The loop condition is while (strlen($user_pw) < $length), so the loop will run until the $user_pw variable reaches the desired length. The first statement in the loop generates a random number between 49 and 122. You can see from asciitable.com that ASCII character 49 is the character 1, and ASCII 122 is lowercase z. I left out the number 0 because it looks like the letter O. The if statement containing the continue is checking if the character is in range. If the character is greater then 57 and less then 65 then it is punction like :;<>= etc and I don't want to use those. If it is greater than 90 and less then 97, those characters are [\]^_ and `. Since I don't want to use any of those characters in the password, the continue statement causes the loop to start over and another random number gets generated. Else, the character is added to the end of the password. It's a pretty efficient way to create the string, if I collapse the code and remove the brackets it's only 5 lines of code (including the while statement) to generate a random alphanumeric string:

while (strlen($user_pw) < $length) {  $char = mt_rand(49, 122);  if (($char > 57 && $char < 65) || ($char > 90 && $char < 97))	continue;  $user_pw .= chr($char); }

Link to comment
Share on other sites

Instead of decrypting it if you have lost your password, just to maximize(?) the safety, you should i.e get a message like this:Please type in your username: "input here"And then it selects:

$username = mysql_real_escape_string($_POST['username']);SELECT * FROM users WHERE username = '$username'

And then it deletes the password this persons had for... a long time, and use rand(); to make a random password and add that to the database and then send this password on a mail to the username's email :)Ok, this was bad explained, but if you understand it: applause for you

Link to comment
Share on other sites

You cannot decrypt MD5 or any SHA variant, they are one-way hash algorithms.
Clarification of Anders Moen's example:1. User click's forgot password2. User is asked for their email address and username3. If username and email are both in the same record, go to step 4. If not, spit out an error.4. Email the user with a random password that the they can change when they log in.
Link to comment
Share on other sites

Archived

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

×
×
  • Create New...