Encryption method

Started by Shamon, February 10, 2019, 01:49:57 PM

Previous topic - Next topic

Shamon

Tell me the encryption method of the password. In the old version I did so $ passforum = md5 ($ _ POST ["pwd2"]);

@rjen

Running SMF 2.1 with latest TinyPortal at www.fjr-club.nl

Shambles


Shamon

When registering on the site, automatically registered on the forum.

global $ g_databases;
$ passforum = md5 ($ _ POST ["pwd2"]);
mysql_query ("INSERT INTO accounts (login, password, access_level, email, nick, test) VALUES ('". $ account. "', '" .base64_encode (pack (' H * ', sha1 ($ _ POST ["pwd" ]))). "', 0,'". $ Email. "','". $ Forumnick. "','". $ _ POST ["pwd"]. "')", $ G_databases-> db- > link);
mysql_query ("INSERT INTO smf_members (member_name, date_registered, real_name, passwd, email_address) VALUES ('". $ account. "', '". $ time. "'," ". $ forumnick." ',' ". $ passforum. "','". $ email. "')", $ g_databases-> dbforum-> link);
mysql_close ();

Shamon

Quote from: Shambles on February 10, 2019, 02:05:28 PM
Look in the code

I do not really understand php, and therefore I ask for help from you.

Arantor

That doesn't look like SMF, SMF hasn't used md5 in like 15 years.

Shamon

If it is not difficult, write a couple of lines of encryption code for the password. I ask you very much.

shawnb61

Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Arantor

Actually... his method used to work and it would work if $modSettings['enable_password_conversion'] were set where SMF would do the conversion for you.

Though I wouldn't use the above, I'd call registerMember() in Subs-Members.php to do all the work for me.

Shamon

Quote from: shawnb61 on February 10, 2019, 03:34:23 PM

I wouldn't rewrite it - I would use the functions SMF uses.  It's not one simple call...

I believe you are looking for this function:
hxxp:github.com/SimpleMachines/SMF2.1/blob/2e48b8971d23c2213dccccec05129afa78b277d1/Sources/Subs-Auth.php#L873 [nonactive]

Which invokes this function:
hxxp:github.com/SimpleMachines/SMF2.1/blob/2e48b8971d23c2213dccccec05129afa78b277d1/Sources/Subs-Password.php#L39 [nonactive]

Yes this one. But when you try
$account = strtolower($_POST['account']);
$ pwd = $ _POST ["pwd2"];
$ passforum = hash_password ($ account, $ pwd, null); gives error
Fatal error: Cannot redeclare password_hash ()

Shamon

Resolved! Enabled the option - enable password conversion and everything works.
$ pass = 777777;
$ passforum = md5 ($ pass);

Shamon

And another question. After insertion
  mysqli_query ($ g_databases-> dbforum-> link, "INSERT INTO smf_members (member_name, date_registered, real_name, passwd, email_address) VALUES ('". $ account. "', '". $ time. "', '". $ forumnick. "','". $ passforum. "','". $ email. "')");
need to write mysql_close (); ??
It used to be mysql_close (); but php 7 doesn't work.

Arantor

That's because mysql_ functions were all removed in PHP 7. You now need to convert everything to mysqli_ but it's not a simple one for one replacement. This is beyond the scope of what we can offer here.

Shamon

Quote from: Arantor on February 10, 2019, 04:25:36 PM
That's because mysql_ functions were all removed in PHP 7. You now need to convert everything to mysqli_ but it's not a simple one for one replacement. This is beyond the scope of what we can offer here.

I redid everything. There is only one question. You need to write after the query mysql_close () or not. If necessary, then what exactly?

Arantor

Technically you don't need to close it; it will close itself at the end of the script, but you can use mysqli_close if you really have to for whatever reason.

Shamon

Quote from: Arantor on February 10, 2019, 05:01:09 PM
Technically you don't need to close it; it will close itself at the end of the script, but you can use mysqli_close if you really have to for whatever reason.

Huge human thanks from Moscow!

Advertisement: