一直想写一下这篇文章的总结,因为有时真的忘记了,要去网上重新搜索一下之前用过的方法,因此这里记录一下,也为了以后遇到这种问题可以直接看我的文章,而不是到处找,以下为实践篇。
1. 如果是win,通过注册表里去找对应的数据,用php解码
去cmd里输入
regedit
去到对应的注册表

查找navicat的密码保存位置
去到对应的路径下面
计算机\hkey_current_user\software\premiumsoft
可以看到

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

寻找pwd找出来,复制数据

去到
https://tool.lu/coderunner/
复制黏贴一下php解密的代码
<?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";
将15057d7ba390复制到倒数第二行
点击执行,得到密码

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


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

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

3. 直接登录navicat,用命令去改密码
通过navicat premium能登陆mysql,但root用户密码忘记了
方法: 用update直接编辑user表
mysql -u root
mysql> use mysql;
mysql> update user set password = password('newpass') where user = 'root'; mysql> flush privileges;
总结
- 从操作上没有卡手的地方
- 不太明白为什么说php是最好的语言,猜测用java写出来也是可以解密的
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论