4-Red Teaming MS SQL Server
4-Red Teaming MS SQL Server
1 Introduction
>> Get-SQLInstanceScanUDP
>> Get-SQLInstanceLocal
>> Get-SQLInstanceDomain
Listing all SQL Server logins, through our initial foothold, can
be executed by executing the following queries.
SELECT name FROM sys.syslogins
SELECT name FROM sys.server_principals
c) Grab the first 48 bytes of the full RID, to get the SID for
the domain. Then, create a new RID (that will be
associated with a domain object) by appending a hex
number value to the abovementioned SID.
Be reminded, that the issue with the DBA’s setup is that the
web application SQL login could create a stored procedure
and be able to EXECUTE AS OWNER (sa), as follows.
Creates a stored procedure which runs as the
owner (sa) and adds the web application’s SQL
login to the sysadmin role.
auxiliary/admin/mssql/mssql_escalate_dbowner
auxiliary/admin/mssql/mssql_escalate_dbowner_sqli
https://blog.netspi.com/hacking-sql-server-stored-
procedures-part-3-sqli-and-user-impersonation/
https://www.rapid7.com/db/modules/exploit/windows/mss
ql/mssql_linkcrawler
https://blog.netspi.com/sql-server-link-crawling-
powerupsql/
PT e treme - Caendra Inc. © 2017
Remotely Executing
SQL Server Link
Crawling & ARP
Poisoning Through a
VPN Tunnel
When UNC paths are utilized on SQL Server, the remote file is
not grabbed under the context of the current user. The
remote file is grabbed under the context of the service
account that is running SQL Server.
Process Migration
x x x x x x
(Remote DLL or Shellcode Injection)
https://github.com/lgandx/Responder/pull/58
Nmap adfind.exe
Nessus Get-Spn.psm1
OSQL sqlmitm.py
SQLCMD Anitian
Hacking SQL Server Stored Procedures – Pt 3: SQL
PowerUpSQL Injection