it编程 > 数据库 > 大数据

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

145人参与 2024-09-10 大数据

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

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;

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)
打赏 微信扫一扫 微信扫一扫

您想发表意见!!点此发布评论

推荐阅读

navicat导入excel文件的步骤以及可能碰到的问题

09-10

Token不够用?邀请好友注册送2000万Token/人

08-06

AI搜索Perplexity的产品构建之道

08-06

全新启航!阿里云向量检索服务Milvus版正式上线!

08-06

Elastic-Job-Cloud 任务调度流程

08-06

2024年7月117篇代码大模型论文最全整理

08-06

猜你喜欢

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论