解决方法
一:通过注册表找到数据库连接的密码,再通过php解密
具体操作:
1.用 win + r 快捷键打开运行窗口,输入 regedit 打开注册表

2.在注册表地址栏输入下面内容,查找navicat密码保存位置,回车:
计算机\hkey_current_user\software\premiumsoft\navicat\servers

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



4.使用 https://tool.lu/coderunner/ 在线工具,对复制下来的密码15057d7ba390进行解密
5.将以下php解密代码复制到在线工具中,将复制的数据粘贴到代码的倒数第二行,点击执行,即可得到密码
ps:该工具首行不能空行,否则执行会报错;另外,在代码倒数五六行需要指定navicat版本
<?php
namespace fatsmalltools;
class navicatpassword
{
protected $version = 0;
protected $aeskey = 'libcckeylibcckey';
protected $aesiv = 'libcciv libcciv ';
protected $blowstring = '3dc5ca39';
protected $blowkey = null;
protected $blowiv = null;
public function __construct($version = 12)
{
$this->version = $version;
$this->blowkey = sha1('3dc5ca39', true);
$this->blowiv = hex2bin('d9c7c3c8870d64bd');
}
public function encrypt($string)
{
$result = false;
switch ($this->version) {
case 11:
$result = $this->encrypteleven($string);
break;
case 12:
$result = $this->encrypttwelve($string);
break;
default:
break;
}
return $result;
}
protected function encrypteleven($string)
{
$round = intval(floor(strlen($string) / 8));
$leftlength = strlen($string) % 8;
$result = '';
$currentvector = $this->blowiv;
for ($i = 0; $i < $round; $i++) {
$temp = $this->encryptblock($this->xorbytes(substr($string, 8 * $i, 8), $currentvector));
$currentvector = $this->xorbytes($currentvector, $temp);
$result .= $temp;
}
if ($leftlength) {
$currentvector = $this->encryptblock($currentvector);
$result .= $this->xorbytes(substr($string, 8 * $i, $leftlength), $currentvector);
}
return strtoupper(bin2hex($result));
}
protected function encryptblock($block)
{
return openssl_encrypt($block, 'bf-ecb', $this->blowkey, openssl_raw_data|openssl_no_padding);
}
protected function decryptblock($block)
{
return openssl_decrypt($block, 'bf-ecb', $this->blowkey, openssl_raw_data|openssl_no_padding);
}
protected function xorbytes($str1, $str2)
{
$result = '';
for ($i = 0; $i < strlen($str1); $i++) {
$result .= chr(ord($str1[$i]) ^ ord($str2[$i]));
}
return $result;
}
protected function encrypttwelve($string)
{
$result = openssl_encrypt($string, 'aes-128-cbc', $this->aeskey, openssl_raw_data, $this->aesiv);
return strtoupper(bin2hex($result));
}
public function decrypt($string)
{
$result = false;
switch ($this->version) {
case 11:
$result = $this->decrypteleven($string);
break;
case 12:
$result = $this->decrypttwelve($string);
break;
default:
break;
}
return $result;
}
protected function decrypteleven($upperstring)
{
$string = hex2bin(strtolower($upperstring));
$round = intval(floor(strlen($string) / 8));
$leftlength = strlen($string) % 8;
$result = '';
$currentvector = $this->blowiv;
for ($i = 0; $i < $round; $i++) {
$encryptedblock = substr($string, 8 * $i, 8);
$temp = $this->xorbytes($this->decryptblock($encryptedblock), $currentvector);
$currentvector = $this->xorbytes($currentvector, $encryptedblock);
$result .= $temp;
}
if ($leftlength) {
$currentvector = $this->encryptblock($currentvector);
$result .= $this->xorbytes(substr($string, 8 * $i, $leftlength), $currentvector);
}
return $result;
}
protected function decrypttwelve($upperstring)
{
$string = hex2bin(strtolower($upperstring));
return openssl_decrypt($string, 'aes-128-cbc', $this->aeskey, openssl_raw_data, $this->aesiv);
}
}
use fatsmalltools\navicatpassword;
//需要指定版本,11或12
//$navicatpassword = new navicatpassword(12);
$navicatpassword = new navicatpassword(11);
//解密
$decode = $navicatpassword->decrypt('15057d7ba390');
echo $decode."\n";
二:通过navicat导出连接,找到连接密码,再通过php进行解密
具体操作:
1.打开navicat,导航栏点击“文件”,点击“导出连接”,

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

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

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

以上就是解决navicat数据库连接成功但密码忘记的问题的详细内容,更多关于navicat数据库密码忘记的资料请关注代码网其它相关文章!
发表评论