当前位置: 代码网 > it编程>数据库>大数据 > 解决Navicat数据库连接成功但密码忘记的问题

解决Navicat数据库连接成功但密码忘记的问题

2024年05月18日 大数据 我要评论
解决方法一:通过注册表找到数据库连接的密码,再通过php解密具体操作:1.用 win + r 快捷键打开运行窗口,输入 regedit 打开注册表2.在注册表地址栏输入下面内容,查找navicat密码

解决方法

一:通过注册表找到数据库连接的密码,再通过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数据库密码忘记的资料请关注代码网其它相关文章!

(0)

相关文章:

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

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com