• 设为首页
  • 收藏本站
  • 积分充值
  • VIP赞助
  • 手机版
  • 微博
  • 微信
    微信公众号 添加方式:
    1:搜索微信号(888888
    2:扫描左侧二维码
  • 快捷导航
    福建二哥 门户 查看主题

    解决Navicat数据库连接成功但密码忘记的问题

    发布者: 山止川行 | 发布时间: 2025-6-20 09:12| 查看数: 154| 评论数: 0|帖子模式

    解决方法


    一:通过注册表找到数据库连接的密码,再通过PHP解密

    具体操作:
    1.用 win + R 快捷键打开运行窗口,输入 regedit 打开注册表

    2.在注册表地址栏输入下面内容,查找Navicat密码保存位置,回车:
    1. 计算机\HKEY_CURRENT_USER\SOFTWARE\PremiumSoft\Navicat\Servers 
    复制代码

    3.在servers目录下,找到需要找回密码的连接,鼠标左键点击,右侧下拉找到名称为 pwd 的一项,该项的数据即为密码。右键,点击修改,复制数据:



    4.使用 https://tool.lu/coderunner/ 在线工具,对复制下来的密码15057D7BA390进行解密
    5.将以下php解密代码复制到在线工具中,将复制的数据粘贴到代码的倒数第二行,点击执行,即可得到密码
    PS:该工具首行不能空行,否则执行会报错;另外,在代码倒数五六行需要指定Navicat版本
    1. <?php
    2. namespace FatSmallTools;
    3. class NavicatPassword
    4. {
    5.     protected $version = 0;
    6.     protected $aesKey = 'libcckeylibcckey';
    7.     protected $aesIv = 'libcciv libcciv ';
    8.     protected $blowString = '3DC5CA39';
    9.     protected $blowKey = null;
    10.     protected $blowIv = null;
    11.     public function __construct($version = 12)
    12.     {
    13.         $this->version = $version;
    14.         $this->blowKey = sha1('3DC5CA39', true);
    15.         $this->blowIv = hex2bin('d9c7c3c8870d64bd');
    16.     }
    17.     public function encrypt($string)
    18.     {
    19.         $result = FALSE;
    20.         switch ($this->version) {
    21.             case 11:
    22.                 $result = $this->encryptEleven($string);
    23.                 break;
    24.             case 12:
    25.                 $result = $this->encryptTwelve($string);
    26.                 break;
    27.             default:
    28.                 break;
    29.         }
    30.         return $result;
    31.     }
    32.     protected function encryptEleven($string)
    33.     {
    34.         $round = intval(floor(strlen($string) / 8));
    35.         $leftLength = strlen($string) % 8;
    36.         $result = '';
    37.         $currentVector = $this->blowIv;
    38.         for ($i = 0; $i < $round; $i++) {
    39.             $temp = $this->encryptBlock($this->xorBytes(substr($string, 8 * $i, 8), $currentVector));
    40.             $currentVector = $this->xorBytes($currentVector, $temp);
    41.             $result .= $temp;
    42.         }
    43.         if ($leftLength) {
    44.             $currentVector = $this->encryptBlock($currentVector);
    45.             $result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
    46.         }
    47.         return strtoupper(bin2hex($result));
    48.     }
    49.     protected function encryptBlock($block)
    50.     {
    51.         return openssl_encrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING);
    52.     }
    53.     protected function decryptBlock($block)
    54.     {
    55.         return openssl_decrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING);
    56.     }
    57.     protected function xorBytes($str1, $str2)
    58.     {
    59.         $result = '';
    60.         for ($i = 0; $i < strlen($str1); $i++) {
    61.             $result .= chr(ord($str1[$i]) ^ ord($str2[$i]));
    62.         }
    63.         return $result;
    64.     }
    65.     protected function encryptTwelve($string)
    66.     {
    67.         $result = openssl_encrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
    68.         return strtoupper(bin2hex($result));
    69.     }
    70.     public function decrypt($string)
    71.     {
    72.         $result = FALSE;
    73.         switch ($this->version) {
    74.             case 11:
    75.                 $result = $this->decryptEleven($string);
    76.                 break;
    77.             case 12:
    78.                 $result = $this->decryptTwelve($string);
    79.                 break;
    80.             default:
    81.                 break;
    82.         }
    83.         return $result;
    84.     }
    85.     protected function decryptEleven($upperString)
    86.     {
    87.         $string = hex2bin(strtolower($upperString));
    88.         $round = intval(floor(strlen($string) / 8));
    89.         $leftLength = strlen($string) % 8;
    90.         $result = '';
    91.         $currentVector = $this->blowIv;
    92.         for ($i = 0; $i < $round; $i++) {
    93.             $encryptedBlock = substr($string, 8 * $i, 8);
    94.             $temp = $this->xorBytes($this->decryptBlock($encryptedBlock), $currentVector);
    95.             $currentVector = $this->xorBytes($currentVector, $encryptedBlock);
    96.             $result .= $temp;
    97.         }
    98.         if ($leftLength) {
    99.             $currentVector = $this->encryptBlock($currentVector);
    100.             $result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
    101.         }
    102.         return $result;
    103.     }
    104.     protected function decryptTwelve($upperString)
    105.     {
    106.         $string = hex2bin(strtolower($upperString));
    107.         return openssl_decrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
    108.     }
    109. }
    110. use FatSmallTools\NavicatPassword;
    111. //需要指定版本,11或12
    112. //$navicatPassword = new NavicatPassword(12);
    113. $navicatPassword = new NavicatPassword(11);
    114. //解密
    115. $decode = $navicatPassword->decrypt('15057D7BA390');
    116. echo $decode."\n";
    复制代码


    二:通过Navicat导出连接,找到连接密码,再通过PHP进行解密

    具体操作:
    1.打开Navicat,导航栏点击“文件”,点击“导出连接”,

    2.选择自己需要找回密码的连接,并勾选左下角“导出密码”,点击“确定”

    3.打开导出的文件,找到Password这一项,将引号中的数据复制下来

    4.打开并使用方法一步骤4.中的在线工具和代码,修改倒数第二行的内容为步骤三保存的数据833E4ABBC56C89041A9070F043641E3B,点击运行
    PS:由于我使用的是Navicat 12,在这种方法中需要修改代码中倒数第五六行的版本,否则解析出来乱码

    以上就是解决Navicat数据库连接成功但密码忘记的问题的详细内容,更多关于Navicat数据库密码忘记的资料请关注脚本之家其它相关文章!

    来源:https://www.jb51.net/database/296891srg.htm
    免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    ×

    最新评论

    浏览过的版块

    QQ Archiver 手机版 小黑屋 福建二哥 ( 闽ICP备2022004717号|闽公网安备35052402000345号 )

    Powered by Discuz! X3.5 © 2001-2023

    快速回复 返回顶部 返回列表