• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

在Navicat查看已保存的数据库密码

武飞扬头像
区块链搬运工
帮助1

1、将数据库连接导出,导出时勾选密码。

2、将导出的文件用记事本打开,可以看到root账号下对应的密码已经被加密。

3、解密。

需要在下面的网址下,运行此PHP代码。

改最下面的密文即可。

网站连接:代码在线运行 - 在线工具

  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('6E3CD79374732F89F047B5316FD28637');
  143.  
    echo $decode."\n";
学新通

运行即可看到原密码。

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgaejce
系列文章
更多 icon
同类精品
更多 icon
继续加载