Werbung / Banner buchen
Neuigkeiten
  • Die modified eCommerce Shopsoftware ist kostenlos, aber nicht umsonst.
    Spenden
  • Damit wir die modified eCommerce Shopsoftware auch zukünftig kostenlos anbieten können:
    Spenden
  • Thema: Passwortverschlüsselung

    Q

    • Fördermitglied
    • Beiträge: 1.531
    Passwortverschlüsselung
    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":
    Code: PHP  [Auswählen]
      // 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?

    Code: PHP  [Auswählen]
          // 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

    Q

    • Fördermitglied
    • Beiträge: 1.531
    Re: Passwortverschlüsselung
    Antwort #1 am: 30. April 2020, 15:23:05
    Ich hab es jetzt doch hinbekommen. Es ist ja ein Hoock-Point in der Datei. Also eine eigene Datei im entsprechenden Ordner angelegt und schon klappt es, sogar updatesicher.
    Trade Republic - Provisionsfrei Aktien handeln
               
    anything