Setp 1 导出connections

image.png

Setp 2 解密password

  1. 进入网站 https://tool.lu/coderunner
  2. 复制下面代码,ctrl+a + ctrl+v
  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. $navicatPassword = new NavicatPassword(11);
  112. //解密
  113. //$decode = $navicatPassword->decrypt('15057D7BA390');
  114. $decode = $navicatPassword->decrypt('E75BF077AB8BAA3AC2D5');
  115. echo $decode."\n";
  116. ?>
  1. 从Setp 1导出的文件中复制加密密码

image.png

  1. 替换 decrypt 中的密码

image.png

  1. 在右边输出窗口获得解密后的密码