Mysql Hacktricks Verified Upd Jun 2026
Verified technique: If the secure_file_priv variable is empty (or points to a writable directory) and the MySQL service runs as root or a high‑privileged user, an attacker can:
SELECT user, host, authentication_string FROM mysql.user;
use auxiliary/scanner/mysql/mysql_login set RHOSTS set USER_FILE /usr/share/wordlists/metasploit/namelist.txt set PASS_FILE /usr/share/wordlists/rockyou.txt run Use code with caution. Hydra Brute-Forcing
The first verified area involves gaining initial access. HackTricks provides tested methods for: mysql hacktricks verified
: Convert a pre-compiled UDF exploit binary (such as those bundled with Metasploit or SQLMap) into hexadecimal format. Write Payload to Disk :
SELECT LOAD_FILE('/etc/passwd'); SELECT LOAD_FILE('C:\\Windows\\win.ini'); Use code with caution. Writing Local Files / Gaining Remote Code Execution (RCE)
Ensure you account for the root user, as well as common application service accounts like dbuser , admin , or wordpress . hydra -L usernames.txt -P passwords.txt mysql Use code with caution. Using Metasploit Using Metasploit Never expose MySQL to the public internet
Never expose MySQL to the public internet. Ensure /etc/mysql/my.cnf binds exclusively to localhost or an internal private VPC IP: bind-address = 127.0.0.1 Use code with caution.
MySQL allows developers to extend functionality by loading compiled C/C++ code via dynamically linked libraries ( .so on Linux, .dll on Windows). If an attacker can upload a compiled binary payload into the plugin directory, they can map new functions directly to OS-level system commands. Execution Workflow
: Use ORDER BY or GROUP BY to determine the number of columns in the original query before attempting a UNION attack. Exploitation Types : .dll on Windows).
If it returns , all file import and export operations are entirely disabled. Reading Files via SQL
When direct access to port 3306 is blocked by a firewall, web-facing SQL Injection vulnerabilities become the primary gateway to the database. Reading Arbitrary Files
If password policies are weak, tools like hydra can rapidly test credential lists against the service: hydra -L usernames.txt -P passwords.txt mysql:// Use code with caution. The Historical CVE-2012-2122 Bypass