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

    如何解决Navicat已经成功连接,密码忘记的问题

    发布者: 404号房间 | 发布时间: 2025-6-20 09:03| 查看数: 90| 评论数: 0|帖子模式

    一直想写一下这篇文章的总结,因为有时真的忘记了,要去网上重新搜索一下之前用过的方法,因此这里记录一下,也为了以后遇到这种问题可以直接看我的文章,而不是到处找,以下为实践篇。

    1. 如果是win,通过注册表里去找对应的数据,用php解码

    去cmd里输入
    1. regedit
    复制代码
    去到对应的注册表

    查找Navicat的密码保存位置
    去到对应的路径下面
    1. 计算机\HKEY_CURRENT_USER\Software\PremiumSoft
    复制代码
    可以看到

    打开对应的目录,寻找一下servers下要找的数据库,如我要找阿里云的密码

    寻找pwd找出来,复制数据

    去到
    1. https://tool.lu/coderunner/
    复制代码
    复制黏贴一下php解密的代码
    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.    
    71.     public function decrypt($string)
    72.     {
    73.         $result = FALSE;
    74.         switch ($this->version) {
    75.             case 11:
    76.                 $result = $this->decryptEleven($string);
    77.                 break;
    78.             case 12:
    79.                 $result = $this->decryptTwelve($string);
    80.                 break;
    81.             default:
    82.                 break;
    83.         }
    84.         return $result;
    85.     }
    86.    
    87.     protected function decryptEleven($upperString)
    88.     {
    89.         $string = hex2bin(strtolower($upperString));
    90.         $round = intval(floor(strlen($string) / 8));
    91.         $leftLength = strlen($string) % 8;
    92.         $result = '';
    93.         $currentVector = $this->blowIv;
    94.         for ($i = 0; $i < $round; $i++) {
    95.             $encryptedBlock = substr($string, 8 * $i, 8);
    96.             $temp = $this->xorBytes($this->decryptBlock($encryptedBlock), $currentVector);
    97.             $currentVector = $this->xorBytes($currentVector, $encryptedBlock);
    98.             $result .= $temp;
    99.         }
    100.         if ($leftLength) {
    101.             $currentVector = $this->encryptBlock($currentVector);
    102.             $result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
    103.         }
    104.         return $result;
    105.     }

    106.    

    107.     protected function decryptTwelve($upperString)
    108.     {
    109.         $string = hex2bin(strtolower($upperString));
    110.         return openssl_decrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
    111.     }
    112. }



    113. use FatSmallTools\NavicatPassword;

    114. //需要指定版本,11或12

    115. //$navicatPassword = new NavicatPassword(12);

    116. $navicatPassword = new NavicatPassword(11);



    117. //解密
    118. $decode = $navicatPassword->decrypt('15057D7BA390');
    119. echo $decode."\n";
    复制代码
    将15057D7BA390复制到倒数第二行
    点击执行,得到密码


    2. linux/win/苹果桌面情况下,可导出连接看然后去php解密(适用)



    导出后用notepad++看里面的代码
    寻找password值

    复制888B51B60B5FF32FAF86AC去第一种方法php方法里解密


    3. 直接登录navicat,用命令去改密码

    通过Navicat Premium能登陆MySQL,但root用户密码忘记了
    方法: 用UPDATE直接编辑user表
    1. mysql -u root
    2. mysql> use mysql;
    3. mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';  mysql> FLUSH PRIVILEGES;
    复制代码
    总结


    • 从操作上没有卡手的地方
    • 不太明白为什么说php是最好的语言,猜测用java写出来也是可以解密的
    以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

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

    本帖子中包含更多资源

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

    ×

    最新评论

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

    Powered by Discuz! X3.5 © 2001-2023

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