Jump to content

MD5


eaglelegend

Recommended Posts

I know its not something I should shout out about, but I need MD5 for my login/register and cookies scripts, however, I dont know how to install it, and really I'd rather not throw all the info here with database info etc. to affect, but, my hosting people provide no php help unfortunately.

Link to comment
Share on other sites

WHat! You are making no sense. md5() is a core PHP function. Are you trying to implement md5 passwords in your existing script as currently your not using any type of encryption.

 

Also what do you mean by:

No, the guy whose I bought it off, as everyone knows, as I told them,

What did you buy? The PHP script?

Link to comment
Share on other sites

I bought most of the script, I have repaired, and gtot help from most of your guys.

right I need to have the passwords etc. that are stored in the datbases encrypted, so if anyone accesses them, they cannot get any login details, as I currently dont have that like that :/

Link to comment
Share on other sites

Login.php

 

<?php
include("header.php");

$username = $_POST['username'];
$password = $_POST['password'];

if($username && $password) {
$check = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `username`=\"$username\" AND `password`=\"$password\""));

if($check == 1) {
 	if(setcookie("ELv2",$username,time()+(3600*24))) {
 	 	Header("Location: index.php");
 	}
 	else {
 	 	print "Cant set cookie";
 	}
}
else {
 	print "Sorry, username/password mismatch!";
}

}
else {
?>
<h2>Login</h2><p>
<form action="login.php" method="post">
Username<br>
<input type="text" name="username" class="text_box" size="20" value="Username" title="Please enter the Username you registered here with." alt="Please enter the Username you registered here with."><p>
Password<br>
<input type="password" name="password" class="text_box" size="20" value="password" title="Please enter the Password you registered here with." alt="Please enter the Password you registered here with."><p>
<input type="submit" class="text_box" value=" Login " title="Click here to log in." alt="Click here to log in."></form>
<? 
}

include("footer.php");
?>

 

Register.php

<?php
include("header.php");
?>
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$password_confirm = $_POST['password_confirm'];
$email = $_POST['email'];

if($username && $password && $password_confirm && $email) {

$siteurl = preg_replace( "/[^a-zA-Z0-9s]/", "", $siteurl );

$check_user = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `username`=\"$username\""));
$check_site = mysql_num_rows(mysql_query("SELECT * FROM `members` WHERE `url`=\"$siteurl\""));

if($check_user == 0) {

 	if($password == $password_confirm) {
 	 	$newpass = $password;
 	 	$date = date("m/d/y");

		$sql = mysql_query("SELECT * FROM `sites` WHERE `url`='$Z'");
		while($r = mysql_fetch_array($sql)) {
		 	$money = $r["money"];
		 	$points = $r["points"];
		}

		$insert = mysql_query("INSERT INTO `members` (`admin`, `date`, `username`, `password`, `email`, `points`, `money`) VALUES('0', '$date', \"$username\", \"$newpass\", \"$email\", '$points', '$money')"); 

		if($insert) {


			print "<h2>Congratulations!</h2><p>
			You are now a registered member of this site!<p>
			Username: $username<br>
			Password: $password<p>
			You can login using the form to the right!";
		}
		else {
		 	print mysql_error();
		}
	}
	else {
	 	print "<p>Passwords do not match!</p>";
	}
}
else {
 	if($check_user > 0) {
 		print "<p>That username already exists!</p>"; 
 	}
}
}
else {
?>
<h2>Register</h2><p>

<img src="http://www.eaglelegend.com/images/pets/Quadra.png" title="Mr. Helpya" alt="Mr. Helpya">

<form action="register.php" method="post">
Hello. My name is Mr. Helpya and as it is says in my name, I am here to help you! As you 
play throughout the game, you will see me bringing up help or tooltips as they are 
otherwise known. Even though I am to busy to see every user on the site, you will still be
able to get the tooltips from me personally!.<br><br>

Here is an example of my work, put your mouse over my picture above here... do you see the little
box come up with my name? thats how it works, just put your mouse over any image, function or
form fields and I will tell you what it is for!.<br><br>

So, you want to register eh?, OK, the register form is another example of what I just taught 
you!, again put your mouse over the fields before you write to find out what you have to put there!
please, whatever you write, do not enter any personal info on your username, as it is viewed
by hundreds every day, and you wouldnt walk down town handing out your personal info would you?
and what would your parents think? not to happy, I should think, so...<br><br>

Please ask your parents about joining up with us, by registering we are assuming you have had 
your parents consent.<p>
<b>Username:</b> <br>
<input type="text" name="username" class="text_box" size="25" title="You need a username, it will be publically seen all over the site. 
NO personal info." alt="You need a username, it will be publically seen all over the site. 
NO personal info."><br>
<b>Password</b> <br>
<input type="password" name="password" class="text_box" size="25" title="You need a password
that you can remember but others cannot guess." alt="You need a password
that you can remember but others cannot guess."><p>
<b>Password Confirm</b><br>
<input type="password" name="password_confirm" class="text_box" size="25" title="Please enter
the password you just written above here, again." alt="Please enter
the password you just written above here, again."><p>
<b>Email</b><br>
<input type="text" name="email" class="text_box" size="30" title="Please enter your email address. 
We rarely email. Please talk to your parents first." alt="Please enter your email address. 
We rarely email. Please talk to your parents first."><p>
<input type="submit" value="Register" class="text_box" alt="Click here to register your new account!" title="Click here to register your new account!"></form> 
<?php
}
include("footer.php");
?>

 

I think there maybe more, but thats all I can think I can provide right now :/

 

ALSO, how do I query the mysql about that?

Link to comment
Share on other sites

In login.php change

$password = $_POST['password'];

to

$password = md5($_POST['password']);

 

In register.php change

$newpass = $password;

to

$newpass = md5($password);

 

Before running the following script, I advise you to backup your existing database first.

 

Now you'll need to run the following script ONLY ONCE in order for existing members logins to work:

include 'header.php';

while(list($username, $password) = mysql_fetch_assoc(mysql_query('SELECT username, password FROM members'))
{
    mysql_query('UPDATE members SET password='.md5($password).' WHERE username="'.$username.'"');
}

echo 'Passwords reset. DELETE THIS SCRIPT NOW DONOT RERUN.';

Do not run the above script more than once otherwise you'll break existing password.s

Link to comment
Share on other sites

No. Just create new php file call it md5passwords.php and add the above code to it. Upload to your website where your other PHP scripts are and go to yoursirte.com/md5passwords.php

 

Nothing will be outputted so don't refresh the page or anything. Now delete the file from your site. Existing passwords should still work.

Link to comment
Share on other sites

ok this shown include 'header.php'; while(list($username, $password) = mysql_fetch_assoc(mysql_query('SELECT username, password FROM members')) { mysql_query('UPDATE members SET password='.md5($password).' WHERE username="'.$username.'"'); }

 

should I put <?php CODE ?> in it?

Link to comment
Share on other sites

Yeah sorry. Forgot to include the php tags  ;)

 

Corrected code:

<?php

include 'header.php';

while(list($username, $password) = mysql_fetch_assoc(mysql_query('SELECT username, password FROM members'))
{
    mysql_query('UPDATE members SET password='.md5($password).' WHERE username="'.$username.'"');
}

echo 'Passwords reset. DELETE THIS SCRIPT NOW DONOT RERUN.';

?>

Link to comment
Share on other sites

ok did that sure, but now I get this :/

 

Parse error: syntax error, unexpected '{' in /misc/39/000/171/334/2/user/web/eaglelegend.com/md5.php on line 6

 

Thanks btw for hellping out! heh, I didnt think people would be so kind, but justgo to my site and abuse the security holes :/ heh I dont know what half of them are, people keep saying I have security holes, they never say what!

Link to comment
Share on other sites

Missed of a closing parenthesis on line 6, corrected code

<?php

include 'header.php';

while(list($username, $password) = mysql_fetch_row(mysql_query('SELECT username, password FROM members')))
{
    mysql_query('UPDATE members SET password='.md5($password).' WHERE username="'.$username.'"');
}

echo 'Passwords reset. DELETE THIS SCRIPT NOW DONOT RERUN.';

?>

Link to comment
Share on other sites

PROBLEM LOADING PAGE

 

The connection was reset

 

The connection to the server was reset while the page was loading.

 

    * The site could be temporarily unavailable or too busy. Try again in a few

          moments.

 

    *  If you are unable to load any pages, check your computer's network

          connection.

 

    *  If your computer or network is protected by a firewall or proxy, make sure

          that Firefox is permitted to access the Web.

 

 

 

 

     

 

 

      EDIT: I checked the database and it hasent encryped any of the passwords :/

Link to comment
Share on other sites

Before you finalise that, however, you might wish to consider adding a salt to your passwords to increase the security of the hash (i.e. prevent the use of rainbow tables).

 

Basically, you add a string before/after/in the middle or a combination to the user's password before it is hashed. This makes a reverse lookup chart useless.

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.