Navicat获取密码

时间:2020-05-09
本文章向大家介绍Navicat获取密码,主要包括Navicat获取密码使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

Navicat获取密码


有大神写了解析Navicat中连接的密码的PHP,想要解析密码,需要:
  • 将连接导出
  • 配置php(本地不需要安装PHP,网上有运行的网页)
  • 运行获取密码

导出Navicat连接

  • 文件-导出连接-选择想要解析的连接,导出文件即可

解析密码

打开ncx文件,Password里就是密码,
x
1
<?php
2
 
3
namespace FatSmallTools;
4
 
5
class NavicatPassword
6
{
7
    protected $version = 0;
8
    protected $aesKey = 'libcckeylibcckey';
9
    protected $aesIv = 'libcciv libcciv ';
10
    protected $blowString = '3DC5CA39';
11
    protected $blowKey = null;
12
    protected $blowIv = null;
13
    
14
    public function __construct($version = 12)
15
    {
16
        $this->version = $version;
17
        $this->blowKey = sha1('3DC5CA39', true);
18
        $this->blowIv = hex2bin('d9c7c3c8870d64bd');
19
    }
20
    
21
    public function encrypt($string)
22
    {
23
        $result = FALSE;
24
        switch ($this->version) {
25
            case 11:
26
                $result = $this->encryptEleven($string);
27
                break;
28
            case 12:
29
                $result = $this->encryptTwelve($string);
30
                break;
31
            default:
32
                break;
33
        }
34
        
35
        return $result;
36
    }
37
    
38
    protected function encryptEleven($string)
39
    {
40
        $round = intval(floor(strlen($string) / 8));
41
        $leftLength = strlen($string) % 8;
42
        $result = '';
43
        $currentVector = $this->blowIv;
44
        
45
        for ($i = 0; $i < $round; $i++) {
46
            $temp = $this->encryptBlock($this->xorBytes(substr($string, 8 * $i, 8), $currentVector));
47
            $currentVector = $this->xorBytes($currentVector, $temp);
48
            $result .= $temp;
49
        }
50
        
51
        if ($leftLength) {
52
            $currentVector = $this->encryptBlock($currentVector);
53
            $result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
54
        }
55
        
56
        return strtoupper(bin2hex($result));
57
    }
58
    
59
    protected function encryptBlock($block)
60
    {
61
        return openssl_encrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING); 
62
    }
63
    
64
    protected function decryptBlock($block)
65
    {
66
        return openssl_decrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING); 
67
    }
68
    
69
    protected function xorBytes($str1, $str2)
70
    {
71
        $result = '';
72
        for ($i = 0; $i < strlen($str1); $i++) {
73
            $result .= chr(ord($str1[$i]) ^ ord($str2[$i]));
74
        }
75
        
76
        return $result;
77
    }
78
    
79
    protected function encryptTwelve($string)
80
    {
81
        $result = openssl_encrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
82
        return strtoupper(bin2hex($result));
83
    }
84
    
85
    public function decrypt($string)
86
    {
87
        $result = FALSE;
88
        switch ($this->version) {
89
            case 11:
90
                $result = $this->decryptEleven($string);
91
                break;
92
            case 12:
93
                $result = $this->decryptTwelve($string);
94
                break;
95
            default:
96
                break;
97
        }
98
        
99
        return $result;
100
    }
101
    
102
    protected function decryptEleven($upperString)
103
    {
104
        $string = hex2bin(strtolower($upperString));
105
        
106
        $round = intval(floor(strlen($string) / 8));
107
        $leftLength = strlen($string) % 8;
108
        $result = '';
109
        $currentVector = $this->blowIv;
110
        
111
        for ($i = 0; $i < $round; $i++) {
112
            $encryptedBlock = substr($string, 8 * $i, 8);
113
            $temp = $this->xorBytes($this->decryptBlock($encryptedBlock), $currentVector);
114
            $currentVector = $this->xorBytes($currentVector, $encryptedBlock);
115
            $result .= $temp;
116
        }
117
        
118
        if ($leftLength) {
119
            $currentVector = $this->encryptBlock($currentVector);
120
            $result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
121
        }
122
        
123
        return $result;
124
    }
125
    
126
    protected function decryptTwelve($upperString)
127
    {
128
        $string = hex2bin(strtolower($upperString));
129
        return openssl_decrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
130
    }
131
}
132
 
133
 
134
use FatSmallTools\NavicatPassword;
135
 
136
//需要指定版本,11或12
137
$navicatPassword = new NavicatPassword(12);
138
//$navicatPassword = new NavicatPassword(11);
139
 
140
//解密
141
//$decode = $navicatPassword->decrypt('15057D7BA390');
142
$decode = $navicatPassword->decrypt('EDB0DE94B9A53CD3F03A934A9DBE8359');
143
echo $decode."\n";
144
 

  • 设置Navicat的版本(基本现在是12了)
  • 在 $navicatPassword->decrypt('')中设置密码
  • 执行之后,在右边就解析出密码了


参考:




原文地址:https://www.cnblogs.com/ziyue7575/p/08be7f769a38eb4e13679e268fbea79c.html