经验首页 前端设计 程序设计 Java相关 移动开发 数据库/运维 软件/图像 大数据/云计算 其他经验
当前位置:技术经验 » 数据库/运维 » MySQL » 查看文章
navicat~导出数据库密码
来源:cnblogs  作者:张占岭  时间:2021/12/15 8:58:35  对本文有异议

当我们mysql密码忘记了,而在navicat里有记录,我们应该如何导出这个密码呢?

  • 第一步:文件菜单,导出链接,导出连接获取到 connections.ncx 文件
    这里需要勾选 导出密码!!! 不然导出的文件里不包含加密的密码

  • 第二步:找到加密密码,进行破解
    在导出的connections.ncx文件中找到password,然后复制出来

  • 打开这个网址:https://tool.lu/coderunner,输入PHP代码

  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('复制出来的密码');
  115. echo $decode."\n";
  116. ?>
  • 将如下刚刚密码复制进去,
    $decode = $navicatPassword->decrypt('复制出来的密码');

原文链接:http://www.cnblogs.com/lori/p/15686959.html

本站QQ群:前端 618073944 | Java 606181507 | Python 626812652 | C/C++ 612253063 | 微信 634508462 | 苹果 692586424 | C#/.net 182808419 | PHP 305140648 | 运维 608723728

W3xue 的所有内容仅供测试,对任何法律问题及风险不承担任何责任。通过使用本站内容随之而来的风险与本站无关。
关于我们  |  意见建议  |  捐助我们  |  报错有奖  |  广告合作、友情链接(目前9元/月)请联系QQ:27243702 沸活量
皖ICP备17017327号-2 皖公网安备34020702000426号