[RELEASE] Secure PHP Web Change Password Script

02/14/2011 04:52 abrasive#1
This is a secure password change script meant for Shaiya private servers.

I noticed a lot of private servers do not allow regular users to change passwords. Be warned, this script is a double-edged sword in a way, ESPECIALLY since most servers do not allow for password recovery via email or some other method. By implementing this script players who have shared their account credentials with other players can now get their password changed unknowingly (and thus their account is now "stolen"). It is up to you to determine how to handle this.

I put the CAPTCHA in this to prevent other players from using a bot to brute-force passwords from other accounts.

Also some error messages are purposely generic to prevent users from verifiably guess account names from this script.

I commented these scripts fairly verbosely, so please read the comments! They are meant to tell you useful stuff.

There are seven scripts you will need to make this work:
changepassword.php
changepassword.view.php
success.view.php
db.php
db.config.php
recaptchalib.config.php
recaptchalib.php (From Google: [Only registered and activated users can see links. Click Here To Register...])

You can get success.view.php, db.php, db.config.php, recaptchalib.config.php, and recaptchalib.php from this post: [Only registered and activated users can see links. Click Here To Register...]

[changepassword.php] (Edit the SQL in this file if needed)

[changepassword.view.php] (Re-style the display in this file)
02/15/2011 11:20 ProfNerwosol#2
HINT:

Those willing to add password retrieval through email can use PHPMailer. It's a PHP script meant to send email without having to install SMTP servers and such.
02/15/2011 15:45 nevak#3
Hi Abrasive! Thanks for this script, I really appreciate your work =)

I have a question regarding security: are the passwords (old and new) with this script sent to the server in plain text? If so, how risky is that?
I also read that client side password encrypting is not that useful since anyone with the encrypted password could use it if there are not other security measures server side...
How could we work around this? https?

Maybe I'm getting the point totally wrong, if so, please excuse me ^^

Cheers and thanks again =)
02/15/2011 16:53 abrasive#4
Yes, it is sent in plain text, but someone would need to be on the same internal network as you or the server to be able to sniff your password. If they can do that, then they can probably sniff the password when you log into the game server anyways though.

Https would encrypt the password so it would not be sniffable, but I didn't think was worth the time investment to try to implement it. You can also encrypt the password with javascript before sending it to the server, but then if someone has javascript turned off, it will not work.

By "secure" in this context, I meant it was not vulnerable to SQL injection like so many other scripts.
11/08/2011 00:53 benoli105#5
can you make a video tutorial of this plz ><?
08/27/2013 21:03 ferrox1#6
Hey all anyone can help me when i tried to change pass at some acc i got this error
Fatal error: Call to undefined function mssql_escape_string() in C:\xampp\htdocs\reg\changepass.php on line 6

where is mistake
08/27/2013 23:26 castor4878#7
According to:
Code:
Fatal error: Call to [B]undefined function[/B] mssql_escape_string()
you are using an undefined function.

"mssql_escape_string" is a "mssql" function (!) and if it is undefined it is because you don't load the mssql module (!).

to repeat myself, XAMPP can be a nice tool when the user knows why he's using it and how to use it (it then allows portable installation, and so easy setup of an illimited number of configurations).
but when it is used "because it's easy", "because I can't spend 10mn to read the guide" or any other (bad) reason that leads to not know or try to understand what has been installed, it's a bad tool.

the mistake is your setup.
08/27/2013 23:57 ferrox1#8
Castor but other my scripts as register or pvp ranks working fine and only passwordchange don't working
08/28/2013 05:13 castor4878#9
ok, error in "bla foo, line 6" let me think that it was the first mssql_xx function call.
if you have several pages that work fine with the mssql-wrapper-for-php, the module is (of course) installed.

the "mysql_escape_string" still exists in the MySQL module, but may be the equivalent function was removed from the mssql module; if the page generating the issue was posted 2 or 3 years ago it's more than certain, if it's a 2 months release, it's a bit puzzling...

you can provide your own function and rename all occurences to "mssql_escape_string" by your function's name. knowning that the sole purpose of these escape functions is to replace each single-quote by two-single-quote (not a double-quote), you will provide:

Code:
function my_escape_function($inStr){
   return str_replace("'", "''", $inStr);
}