MySQL Weak Password Hash Detection
MySQL stores account credentials as hashes in the mysql.user system table. The hash format depends on the authentication plugin in use. mysql_native_password uses a double SHA1 hash that is fast to crack and has well-known weaknesses. caching_sha2_password uses SHA256 which is stronger but still crackable offline. Empty password hashes are immediately exploitable without cracking. Identifying the hash type and extracting hashes for offline cracking is possible from any account with SELECT access to mysql.user, which is typically limited to privileged accounts but worth checking whenever access is obtained.
Check Access to mysql.user
First confirm whether the current account can read the user table:
+------------------+-----------+-----------------------+-------------------------------------------+ | user | host | plugin | authentication_string | +------------------+-----------+-----------------------+-------------------------------------------+ | root | localhost | caching_sha2_password | $A$005$randomsalt...hashedvalue | | app_user | % | mysql_native_password | *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19 | | backup | localhost | mysql_native_password | * | +------------------+-----------+-----------------------+-------------------------------------------+
Three things to note from the output:
- Accounts with
plugin = mysql_native_passwordand a hash starting with*followed by 40 hex characters are double SHA1 hashes — the fastest MySQL hash format to crack. - Accounts where
authentication_stringis empty or just*have no password set and are directly accessible. - Accounts with
plugin = caching_sha2_passworduse SHA256 — slower to crack but still worth extracting for offline attempts.
Extract Hashes for Offline Cracking
Extract all hashes in a format suitable for hashcat:
root $A$005$randomsalt...hashedvalue app_user *2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19
Identify Hash Types for Hashcat
Match the hash format to the correct hashcat mode:
mysql_native_passwordhashes start with*followed by 40 hex chars — hashcat mode300caching_sha2_passwordhashes start with$A$— hashcat mode7401- Old pre-4.1 MySQL hashes are 16 hex characters — hashcat mode
200(rare, legacy only)
Identify Accounts with No Password
Flag accounts where the authentication string is empty or represents no credential:
+--------+-----------+-----------------------+ | user | host | plugin | +--------+-----------+-----------------------+ | backup | localhost | mysql_native_password | +--------+-----------+-----------------------+
Any account with an empty authentication string is directly accessible without a password. Even accounts restricted to localhost are reachable if you have any local code execution on the host. Hash extraction and offline cracking is covered in the exploitation phase.
References
-
Hashcat — documentationhashcat.net/wiki/doku.php?id=hashcat (opens in new tab)
Mode 300 for mysql_native_password and mode 7401 for caching_sha2_password
-
MySQL — Pluggable Authenticationdev.mysql.com/doc/refman/8.0/en/pluggable-authentication.html (opens in new tab)
Authentication plugin types, hash formats, and caching_sha2_password reference
Was this helpful?
Your feedback helps improve this page.