Skip to content

Latest commit

 

History

History
32 lines (24 loc) · 630 Bytes

SQL.md

File metadata and controls

32 lines (24 loc) · 630 Bytes

SQL

MSSQL

#Get list of databases
SELECT name FROM master.sys.databases
SELECT name FROM master.dbo.sysdatabases
EXEC sp_databases

#Get mssql verion
select @@VERSION

#Get current user
select CURRENT_USER

#Get current database
SELECT DB_NAME() AS [Current Database];

#Enable xp_cmdshell
sp_configure 'show advanced options', '1'
RECONFIGURE
sp_configure 'xp_cmdshell', '1'
RECONFIGURE


#Run xp_cmdshell
EXEC master..xp_cmdshell 'whoami'

reference

https://book.hacktricks.xyz/pentesting/pentesting-mssql-microsoft-sql-server https://stackoverflow.com/questions/147659/get-list-of-databases-from-sql-server