zoukankan      html  css  js  c++  java
  • Navicat获取密码

    Navicat获取密码


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

    导出Navicat连接

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

    解析密码

    打开ncx文件,Password里就是密码,
    <?php
     
    namespace FatSmallTools;
     
    class NavicatPassword
    {
        protected $version = 0;
        protected $aesKey = 'libcckeylibcckey';
        protected $aesIv = 'libcciv libcciv ';
        protected $blowString = '3DC5CA39';
        protected $blowKey = null;
        protected $blowIv = null;
        
        public function __construct($version = 12)
        {
            $this->version = $version;
            $this->blowKey = sha1('3DC5CA39', true);
            $this->blowIv = hex2bin('d9c7c3c8870d64bd');
        }
        
        public function encrypt($string)
        {
            $result = FALSE;
            switch ($this->version) {
                case 11:
                    $result = $this->encryptEleven($string);
                    break;
                case 12:
                    $result = $this->encryptTwelve($string);
                    break;
                default:
                    break;
            }
            
            return $result;
        }
        
        protected function encryptEleven($string)
        {
            $round = intval(floor(strlen($string) / 8));
            $leftLength = strlen($string) % 8;
            $result = '';
            $currentVector = $this->blowIv;
            
            for ($i = 0; $i < $round; $i++) {
                $temp = $this->encryptBlock($this->xorBytes(substr($string, 8 * $i, 8), $currentVector));
                $currentVector = $this->xorBytes($currentVector, $temp);
                $result .= $temp;
            }
            
            if ($leftLength) {
                $currentVector = $this->encryptBlock($currentVector);
                $result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
            }
            
            return strtoupper(bin2hex($result));
        }
        
        protected function encryptBlock($block)
        {
            return openssl_encrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING); 
        }
        
        protected function decryptBlock($block)
        {
            return openssl_decrypt($block, 'BF-ECB', $this->blowKey, OPENSSL_RAW_DATA|OPENSSL_NO_PADDING); 
        }
        
        protected function xorBytes($str1, $str2)
        {
            $result = '';
            for ($i = 0; $i < strlen($str1); $i++) {
                $result .= chr(ord($str1[$i]) ^ ord($str2[$i]));
            }
            
            return $result;
        }
        
        protected function encryptTwelve($string)
        {
            $result = openssl_encrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
            return strtoupper(bin2hex($result));
        }
        
        public function decrypt($string)
        {
            $result = FALSE;
            switch ($this->version) {
                case 11:
                    $result = $this->decryptEleven($string);
                    break;
                case 12:
                    $result = $this->decryptTwelve($string);
                    break;
                default:
                    break;
            }
            
            return $result;
        }
        
        protected function decryptEleven($upperString)
        {
            $string = hex2bin(strtolower($upperString));
            
            $round = intval(floor(strlen($string) / 8));
            $leftLength = strlen($string) % 8;
            $result = '';
            $currentVector = $this->blowIv;
            
            for ($i = 0; $i < $round; $i++) {
                $encryptedBlock = substr($string, 8 * $i, 8);
                $temp = $this->xorBytes($this->decryptBlock($encryptedBlock), $currentVector);
                $currentVector = $this->xorBytes($currentVector, $encryptedBlock);
                $result .= $temp;
            }
            
            if ($leftLength) {
                $currentVector = $this->encryptBlock($currentVector);
                $result .= $this->xorBytes(substr($string, 8 * $i, $leftLength), $currentVector);
            }
            
            return $result;
        }
        
        protected function decryptTwelve($upperString)
        {
            $string = hex2bin(strtolower($upperString));
            return openssl_decrypt($string, 'AES-128-CBC', $this->aesKey, OPENSSL_RAW_DATA, $this->aesIv);
        }
    }
     
     
    use FatSmallToolsNavicatPassword;
     
    //需要指定版本,11或12
    $navicatPassword = new NavicatPassword(12);
    //$navicatPassword = new NavicatPassword(11);
     
    //解密
    //$decode = $navicatPassword->decrypt('15057D7BA390');
    $decode = $navicatPassword->decrypt('EDB0DE94B9A53CD3F03A934A9DBE8359');
    echo $decode."
    ";
     

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


    参考:




  • 相关阅读:
    洛谷 P1919 【模板】A*B Problem升级版(FFT快速傅里叶)
    Codeforces Goodbye 2018
    ubuntu 百度云
    【UOJ 351】新年的叶子
    【SDOI2008】仪仗队
    NOI 2002 贪吃的九头龙
    最大获利
    codeforces 814E An unavoidable detour for home
    codeforces 814D An overnight dance in discotheque
    bzoj3191 [JLOI2013]卡牌游戏
  • 原文地址:https://www.cnblogs.com/ziyue7575/p/08be7f769a38eb4e13679e268fbea79c.html
Copyright © 2011-2022 走看看