
Enumeration
nmap
已知目标开放了22,80,8089端口,扫描详细情况如下

可以看到对外开放了22,80,8089三个端口
TCP/80 SSTI
访问80端口,有一个info@doctors.htb的电子邮件,点击其他的也没有什么反应,猜测有可能需要域名访问

在/etc/hosts中增加主机与域名

然后在浏览器中访问该域名,进入了Doctor Secure Messaging登录页面,还可以注册新用户

先注册一个新用户,填好信息后显示账户被创建,但是只有20分钟

在New Message处创建的内容会在首页显示

并没有发现什么东西,但是在查看源代码发现了一个新的目录/archive

访问该页面却发现该页面是空白的,只有标题写着archive

但是在查看源代码时会显示xml输出,且之前创建的message标题test也包含在xml代码中

如果用户提供的标题值未经清理,则该页面容易受到服务器端模版注入(SSTI),如果能控制一个模版变量并插入 一个payload,有可能会被传入服务器执行
https://swisskyrepo.github.io/PayloadsAllTheThings/Server Side Template Injection/中详细讲述了如何检测是否存在该漏洞

首先,创建一个新的message,让标题为${7*7}

可以看到该代码只是原样输出,似乎并没有被执行,按照红线走下面那条路,再次创建标题为{{7*7}}的message

这次的得到的标题并不是输入的东西,而是真的计算了7*7=49,并返回了结果,可以判断存在SSTI注入,因为成功 执行了输入,所以顺着绿色剪头,这次输入{{7*'7'}}

得到了输出7次的结果,根据文章中描述,如果执行结果如上图所示,则很有可能使用的模板引擎为Jinja2

然后找到针对该引擎模板的反弹shell脚本并修改

在本地开启监听,然后在标题中输入以上代码,在刷新/archive页面即可得到shell

Lateral Movement
在目标系统上传linpeas来检查,先在本地开启http服务,然后将linpeas下载至目标,然后添加执行权限,最后执行

使用linpeas,在日志中发现了一个疑似密码Guitar123,但是这根本就不是邮箱的格式

使用该密码成功登录

Privilege Escalation
Splunk 8089
刚开始时枚举时,发现Splunk Forwarder实例正在端口8089上运行
Splunk是一种日志分析工具,用于收集、分析和可视化数据。尽管 Splunk 最初并非旨在成为 SIEM 工具,但它通常 用于安全监控和业务分析。Splunk 部署通常用于存储敏感数据,如果受到威胁,可能会为攻击者提供大量信息。 可以看到该程序以root身份运行,利用它可以使我们的权限升级,在本地克隆版本库,并输入 Python 版本漏洞利用 程序的文件夹

运行脚本,返回未认证

再次尝试使用刚刚获取的shaun:Guitar123来利用脚本,显示已经成功执行了指令

在kali中开启监听,然后执行一个反向shell

最终成功得到了一个shell,拥有root权限
