Navicat已经成功连接,找回密码

 在已经连接数据库的情况下,但是密码忘记了,该如何解决呢,这里记录了windows的解决办法

通过注册表去找对应的数据,用php进行解码
WINDOWS+R 输入 regedit,找到对应的注册表

找到Navicat保存密码的位置,复制下面的路径

在这里插入图片描述

找到servers对应数据库,复制 pwd 里面的数值

在这里插入图片描述​ 

然后去到
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 
 48         return strtoupper(bin2hex($result));
 49 
 50     }
 51 
 52     protected function encryptBlock($block)
 53     {
 54         return openssl_encrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING); 
 55     }
 56 
 57     protected function decryptBlock($block)
 58     {
 59         return openssl_decrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING); 
 60     }
 61 
 62     protected function xorBytes($str1, $str2)
 63     {
 64         $result = '';
 65         for ($i = 0; $i < strlen($str1); $i++) {
 66             $result .= chr(ord($str1[$i]) ^ ord($str2[$i]));
 67         }
 68         return $result;
 69     }
 70 
 71     protected function encryptTwelve($string)
 72     {
 73         $result = openssl_encrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
 74         return strtoupper(bin2hex($result));
 75     }
 76     
 77     public function decrypt($string)
 78     {
 79         $result = FALSE;
 80         switch ($this->version) {
 81             case 11:
 82                 $result = $this->decryptEleven($string);
 83                 break;
 84             case 12:
 85                 $result = $this->decryptTwelve($string);
 86                 break;
 87             default:
 88                 break;
 89         }
 90         return $result;
 91     }
 92     
 93     protected function decryptEleven($upperString)
 94     {
 95         $string = hex2bin(strtolower($upperString));
 96         $round = intval(floor(strlen($string) / 8));
 97         $leftLength = strlen($string) % 8;
 98         $result = '';
 99         $currentVector = $this->blowIv;
100         for ($i = 0; $i < $round; $i++) {
101             $encryptedBlock = substr($string, 8 * $i, 8);
102             $temp = $this->xorBytes($this->decryptBlock($encryptedBlock), $currentVector);
103             $currentVector = $this->xorBytes($currentVector, $encryptedBlock);
104             $result .= $temp;
105         }
106         if ($leftLength) {
107             $currentVector = $this->encryptBlock($currentVector);
108             $result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
109         }
110         return $result;
111     }
112 
113     
114 
115     protected function decryptTwelve($upperString)
116     {
117         $string = hex2bin(strtolower($upperString));
118         return openssl_decrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
119     }
120 }
121 
122  
123 
124 use FatSmallTools\NavicatPassword;
125  
126 //需要指定版本,11或12
127 
128 //$navicatPassword = new NavicatPassword(12);
129 
130 $navicatPassword = new NavicatPassword(11);
131 
132  
133 
134 //解密
135 $decode = $navicatPassword->decrypt('5658213B');
136 echo $decode."\n";

将你复制的数值粘贴到倒数第二行点击执行,得到密码

在这里插入图片描述


posted @ 2022-01-14 23:12  sky2022  阅读(300)  评论(0)    收藏  举报