【问题标题】:How to reset admin password in sysPass?如何在 sysPass 中重置管理员密码?
【发布时间】:2018-07-21 23:14:16
【问题描述】:

我自己托管密码管理器 sysPass:https://github.com/nuxsmin/sysPass

我丢失了唯一管理员帐户的密码,但我仍然拥有主密码/密钥和对数据库的完全访问权限。可惜sysPass没有密码重置功能。

我知道 sysPass 使用具有 10 次迭代的 BCrypt 和主密码来为每个用户创建密码哈希。

有几个字段显然需要更新才能做到这一点:

user_pass - varbinary - 内容以:$2y$10$...

user_mPass - varbinary - 内容开头为:def50200...

user_mKey - varbinary - 内容开头为:def10000def50200...

但我不知道如何使用该信息为我的管理员用户创建新密码。

知道怎么做吗?

谢谢

【问题讨论】:

    标签: passwords reset


    【解决方案1】:
    • 使用 bcrypt 加密您要更改的新密码(10 轮)
    • 登录到您的数据库(转到表:usrData)
    • 将新生成的哈希转换为二进制(使用 hexworkshop)

    how to generate binary

    • 复制左侧生成的文本
    • 将“user_pass”字段值替换为您从 hexworkshop 获得的新二进制字符串
    • 您可以使用新密码登录

    【讨论】:

      【解决方案2】:

      我一直在研究这个。虽然坦率地说,我不确定它是否适用于密码重置,但这是我将如何生成这些哈希,为新部署初始化数据库。带/var/www/html,syspass安装路径:

      <?php
      require_once('/var/www/html/vendor/defuse/php-encryption/src/Core.php');
      require_once('/var/www/html/vendor/defuse/php-encryption/src/Crypto.php');
      require_once('/var/www/html/vendor/defuse/php-encryption/src/DerivedKeys.php');
      require_once('/var/www/html/vendor/defuse/php-encryption/src/Encoding.php');
      require_once('/var/www/html/vendor/defuse/php-encryption/src/Exception/CryptoException.php');
      require_once('/var/www/html/vendor/defuse/php-encryption/src/Exception/WrongKeyOrModifiedCiphertextException.php');
      require_once('/var/www/html/vendor/defuse/php-encryption/src/Key.php');
      require_once('/var/www/html/vendor/defuse/php-encryption/src/KeyOrPassword.php');
      require_once('/var/www/html/vendor/defuse/php-encryption/src/KeyProtectedByPassword.php');
      require_once('/var/www/html/vendor/defuse/php-encryption/src/RuntimeTests.php');
      use Defuse\Crypto\KeyProtectedByPassword;
      use Defuse\Crypto\Crypto;
      
      $userLogin  = isset($argv[1]) ? $argv[1] : "admin";
      $userPass   = isset($argv[2]) ? $argv[2] : "blabla";
      $masterPass = isset($argv[3]) ? $argv[3] : "blabla-11-chars-long";
      $salt       = isset($argv[4]) ? $argv[4] : "be5570f6809a460bcbc5625fd3274ee0184c4164fe8707a8147dfcc84ac5";
      
      $keypw = $userPass.$userLogin.$salt;
      $mkey  = KeyProtectedByPassword::createRandomPasswordProtectedKey($keypw)->saveToAsciiSafeString();
      $k     = KeyProtectedByPassword::loadFromAsciiSafeString($mkey)->unlockkey($keypw);
      $mpass = Crypto::encrypt((string)$masterPass, $k);
      
      print "ADMIN_MKEY=$mkey\n";
      print "ADMIN_MPASS=$mpass\n";
      ?>
      

      使用您的用户名作为第一个参数调用该脚本,第二个参数是密码,第三个是主密码和一个盐(这将是来自您的 config.xmlgeneratedSalt)。

      user_mPassuser_mKey 应该使用返回的 ADMIN_MPASSADMIN_MKEY 进行初始化。

      虽然user_pass 可以使用类似的方式生成:

      htpasswd -bnBC 10 "" "<your-admin-password>" | tr -d ':\n'
      

      【讨论】:

        猜你喜欢
        • 2011-09-15
        • 1970-01-01
        • 2012-09-29
        • 2019-08-03
        • 2013-05-12
        • 2014-11-04
        • 2014-09-28
        • 2012-06-03
        相关资源
        最近更新 更多