MySQL
TCP 3306: normal- Server Config:
/etc/mysql/mysql.conf.d/mysqld.cnf
- default system schemas/databases:
mysql- is the system database that contains tables that store information required by the MySQL serverinformation_schema- provides access to database metadataperformance_schema- is a feature for monitoring MySQL Server execution at a low levelsys- a set of objects that helps DBAs and developers interpret data collected by the Performance Schema
secure_file_privmay be set as follows:- If empty, the variable has no effect, which is not a secure setting.
- If set to the name of a directory, the server limits import and export operations to work only with files in that directory. The directory must exist; the server does not create it.
- If set to NULL, the server disables import and export operations
- System Schema: https://dev.mysql.com/doc/refman/8.0/en/system-schema.html#:~:text=The%20mysql%20schema%20is%20the,used%20for%20other%20operational%20purposes
- Logical Operators: https://mariadb.com/docs/server/reference/sql-structure/operators/operator-precedence
- Cheatsheet: https://devhints.io/mysql
Database > Schema > Table > Column > Value
sqlmap’s query data has a lot of good example commands for enumeration:
Enumeration
MySQL
These commands are specific though not necessarily exclusive to MySQL
| Payload | When to Use | Expected Output | Wrong Output |
|---|---|---|---|
SELECT @@version | When we have full query output | MySQL Version ‘i.e. 10.3.22-MariaDB-1ubuntu1’ | In MSSQL it returns MSSQL version. Error with other DBMS. |
SELECT POW(1,1) | When we only have numeric output | 1 | Error with other DBMS |
SELECT SLEEP(5) | Blind/No Output | Delays page response for 5 seconds and returns 0. | Will not delay response with other DBMS |
- https://dev.mysql.com/doc/refman/8.0/en/information-schema-introduction.html
- https://dev.mysql.com/doc/refman/8.0/en/information-schema-schemata-table.html
- Default (built-in) databases:
information_schemaperformance_datamysql
Read Files
Write Files
- User with
FILEprivilege enabled - MySQL global
secure_file_privvariable not enabled - Write access to the location we want to write to on the back-end server