文章转载自:Navicat已经成功连接,密码忘记的解决方法_铁打的阿秀的博客-CSDN博客
解决方法
目录
解决方法
一:通过注册表找到数据库连接的密码,再通过PHP解密
二.通过Navicat导出连接,找到连接密码,再通过PHP进行解密
一:通过注册表找到数据库连接的密码,再通过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,在这种方法中需要修改代码中倒数第五六行的版本,否则解析出来乱码
文章来源:https://www.toymoban.com/news/detail-670067.html
文章来源地址https://www.toymoban.com/news/detail-670067.html
到了这里,关于Navicat数据库连接成功,密码忘记如何解决的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!