MSSQL to SYSTEM via SQL Server Agent Jobs
SQL Server Agent is a job scheduling service that runs as NT AUTHORITY\SYSTEM by default. Sysadmin logins can create Agent jobs with CmdExec job steps that execute arbitrary OS commands under that SYSTEM context. This is the standard path from SQL sysadmin access to full OS control when xp_cmdshell is blocked or monitored.
The SQL Server Agent service must be running for this to work. If the service is stopped, this path is unavailable but xp_cmdshell and Ole Automation remain as alternatives.
Check Agent Service Status
Confirm the SQL Server Agent service is running before creating jobs:
STATE : 4 RUNNING
STATE 4 RUNNING confirms the Agent service is active. If it shows STOPPED, attempt to start it if you have the permissions, otherwise fall back to xp_cmdshell.
Create and Execute an Agent Job
Create a job with a CmdExec step and run it immediately. Use a callback first to confirm SYSTEM execution before sending a reverse shell:
The job executes asynchronously. Give it a few seconds before checking the listener. The connection arrives from the SQL Server Agent service context which is NT AUTHORITY\SYSTEM.
Check Job Execution Status
If the reverse shell does not connect, check the job history for error output:
run_status 0 means the step failed. The message field contains the error output from the CmdExec step. Common failures are PowerShell execution policy blocks and network egress restrictions. Try a simpler callback first to confirm outbound connectivity:
Clean Up Jobs After Use
Remove the created jobs after getting a shell to reduce evidence of the technique:
References
-
Microsoft — SQL Server Agent Jobslearn.microsoft.com/en-us/sql/ssms/agent/create-a-job (opens in new tab)
sp_add_job, sp_add_jobstep, and sp_start_job procedure reference
Was this helpful?
Your feedback helps improve this page.