am: 30. April 2020, 12:08:29
Noch eine Baustelle, die ich schon etwas vor mir herschiebe. Vor X Zeiten hatte ich die Passwortverschlüsselung in OSC mit Salt etwas "gepimmpt" und so bis zur modified Version 2.0.4.2 immer nur "mitgenommen".
Jetzt möchte ich das auf das vermutlich bessere System von modified updaten und das Fallback erweitern, damit die alten Passwörter noch funktionieren und bei der ersten korrekten Anmeldung auch neu geschrieben werden. Die alten Passwörter sind aber teilweise noch nur mit md5 verschlüsselte Passwörter - was das aktuelle Fallback glaub abfängt - und den Salt-Passwörtern.
Ich hoffe es reicht die ~/inc/xtc_validate_password.inc.php anzupassen.
Meine "Bastelversion":
// This funstion validates a plain text password with an // encrpyted password function xtc_validate_password
($plain, $encrypted) { if (xtc_not_null
($plain) && xtc_not_null
($encrypted)) {// split apart the hash / salt $stack = explode(':', $encrypted); if (sizeof($stack) != 2) return false; if (md5($stack[1] . $plain) == $stack[0]) { return true; } } return false; Ich bin mir nicht sicher, inwieweit die mit modified erstellten Passwörter den Doppelpunkt enthalten könnten und damit die Aufteilung dahin ist.
Kann man das schön in den if-Abschnitt von
// check for old passwords rein schreiben, oder lieber dahinter eine eigene zusätzliche if Funktion nehmen?
// check for old passwords if (preg_match('#^[a-z0-9]{32}$#i', $encrypted)) { if ($encrypted != md5($plain)) { return false; } elseif ($customers_id) { // auth is correct, so update to new password hash require_once (DIR_FS_INC
. 'xtc_encrypt_password.inc.php'); xtc_db_query
("UPDATE " . TABLE_CUSTOMERS
. "
SET customers_password = '" . xtc_encrypt_password
($plain) . "'
WHERE customers_id = '" . (int
)$customers_id . "'"); } return true; } else { // check for oneQ old salted passwords $stack = explode(':', $encrypted); if (md5($stack[1] . $plain) != $stack[0]) { return false; } elseif ($customers_id) { // auth is correct, so update to new password hash require_once (DIR_FS_INC
. 'xtc_encrypt_password.inc.php'); xtc_db_query
("UPDATE " . TABLE_CUSTOMERS
. "
SET customers_password = '" . xtc_encrypt_password
($plain) . "'
WHERE customers_id = '" . (int
)$customers_id . "'"); } return true; // end check for oneQ salted passwords } else { // init class $validpass = new validpass
(); // validate password return $validpass->validate_password($plain, $encrypted); } Ich hoffe das hat jetzt keine logischen Brüche. Ich hadere noch mit den if´s, else´s und elseif´s
Linkback: https://www.modified-shop.org/forum/index.php?topic=41038.0