首页 > 数据库 >navicat解密mysql

navicat解密mysql

时间:2022-09-22 22:44:24浏览次数:68  
标签:function return string currentVector 解密 navicat protected result mysql

先获取mysql加密密码,在使用php解密程序解出密码,1.使用navicat导出连接,文件中有加密密码,2.在注册表中,计算机\HKEY_CURRENT_USER\SOFTWARE\PremiumSoft\Navicat\Servers\{连接名},点击找到pwd对应的值,即为加密密码

<?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 FatSmallTools\NavicatPassword;
//需要指定版本,11或12
//$navicatPassword = new NavicatPassword(12);
$navicatPassword = new NavicatPassword(11);
//解密,15057D7BA390=密码
$decode = $navicatPassword->decrypt('加密密码');
echo $decode."\n";

 

标签:function,return,string,currentVector,解密,navicat,protected,result,mysql
From: https://www.cnblogs.com/zhangshaui/p/16721112.html

相关文章

  • MySQL及MySQL Workbench下载与安装
     安装MySQLWorkbench参考链接:https://blog.csdn.net/qq_51813155/article/details/121705128一、下载MSI文件下载地址:https://dev.mysql.com/downloads/workbench/......
  • MySQL日期类型介绍及格式化
    1、MySQL中常用的几种时间类型有:date、datetime、time、year、timestamp数据类型占用字节最小值最大值零值表示备注date41000-01-019999-12-310000-00-0......
  • MySQL InnoDB 锁的二三事
    近日, 在一个小型项目中, 遇到了一个触及我知识盲区的bug. 项目用的是MySQL5.7.25, 其中有一张表 config_data,包含四个字段,id,name,value,expireAt.其中id......
  • 脚本二进制编译安装Mysql
    mysql二进制安装脚本部署目录mysql二进制安装脚本部署单实例使用函数的单实例使用函数的单实例或者多实例单实例[root@localhost~]#mkdirmysql//创建存......
  • centos6创建mysql开机自启动
    环境:OS:centos6db:5.6.40 1.修改/etc/init.d/mysqld文件,默认文件以及存在,该文件内容如下:#!/bin/sh#CopyrightAbandoned1996TCXDataKonsultAB&MontyPro......
  • MySQL中datetime和timestemp类型23:59:59秒入库后会变成下一天的00:00:00
    1.问题现象业务中需要记录一个价格的生效时间和失效时间,对应的是MySQL表中的datetime类型。前端传入的失效时间是日期,如2022-09-2023:59:59,在java程序中时间也是正确......
  • JavaWeb--MySql基础:数据库概念、MySql前期基础、SQL基础语句、Navicat使用--2022年9月
    第一节  数据库1、数据库是什么存储和管理数据的仓库,数据是有组织的进行存储。数据库英文名是DataBase,简称DB2、数据库管理系统......
  • mysql设置远程主机访问
    mysql设置远程主机访问环境说明:mysql:8.0.28forWin64onx86_64当自己搭建mysql,其他主机需要连接时,可能会报错[1130-host...isnotallowedtoconnecttothis......
  • MySQL存储引擎中的MyISAM和InnoDB区别详解
    MyISAM是MySQL的默认数据库引擎(5.5版之前),由早期的ISAM(IndexedSequentialAccessMethod:有索引的顺序访问方法)所改良。虽然性能极佳,但却有一个缺点:不支持事务处理(transacti......
  • mysql07--主从搭建、Django实现mysql读写分离
    1mysql--单主N从搭建https://www.liuqingzheng.top/python/其他/02-MySQL主从搭建基于docker/1.1基本介绍MySQL支持单向、异步复制,复制过程中一个服务器充当主服务器,......