加载中...

Navicat中怎么查看数据库密码

Navicat中怎么查看数据库密码

第一步:导出链接,导出连接获取到 connections.ncx 文件

New Image

这里需要勾选 导出密码!!! 不然导出的文件里不包含加密的密码

New Image

第二步:找到加密密码,进行破解

在导出的connections.ncx文件中找到password,然后复制出来

New Image

打开这个网址:https://tool.lu/coderunner,将如下刚刚密码复制进去,

$decode = $navicatPassword->decrypt(''复制出来的密码'');

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

然后在网页上面执行代码,就可以得到密码了

New Image