【Vulnhub】HarryPotter Nagini

【Vulnhub】HarryPotter: Nagini

Description:
Nagini is the 2nd VM of 3-box HarryPotter VM series in which you need to find 3 horcruxes hidden inside the machine (total 8 horcruxes hidden across 3 VMs of the HarryPotter Series) and ultimately defeat Voldemort.

信息收集

fscan 扫描靶机目标IP为:192.168.1.5

image-20241128173903026

nmap 扫描目标IP全端口和服务

image-20241128173926234

发现开放了 22 和 80

查看 80 端口开放的 web 服务页面

image-20241128175132217

dirsearch 扫描目标目录

image-20241128175120491

分别访问两个目录 /joomla/ 和 /joomla/administrator/

image-20241128175352352

image-20241128175410666

发现是 Joomla CMS

那就用 joomscan 工具

joomscan -u http://192.168.1.5/joomla

这里能下载 joomscan 的配置文件看看

image-20241210110708622

在 configuration.php.bak 里看到了 user 用户名,数据库名 joomla

image-20241210111604848

然后就没有别的信息了,,,之后我又用 ffuf 和 gobuster 分别都尝试目录扫描

可以看到有一个 note.txt 文件,查看

image-20241210112043703

翻译过来

“开发人员你们好,我将使用我们新的 HTTP3 服务器 https://quic.nagini.hogwarts 进行进一步交流。
请所有开发人员定期访问该服务器,查看最新公告。谢谢,site_amdin”

这里需要搭建 quiche

搭建完成之后,进入 quiche/target/debug/examples 目录,使用 http3 访问一下靶机

/http3-client https://192.168.1.5

能看到返回的 html 代码中提到了 /internalResourceFeTcher.php 页面和 bak 文件,先访问一下 internalResourceFeTcher.php 页面
image-20241210152211471

随便输入一个 111

image-20241210152240638

可以看到 url 发生变化了,也就是说传入参数为 url=111 了

那么试试是不是 ssrf,看看服务器是不是会想目标url发送请求

image-20241210152425507

漏洞利用

根据前面收集到的信息

使用 Gopherus 工具进行攻击

git clone https://github.com/tarunkant/Gopherus.git  #使用python2运行
python2 gopherus.py --exploit mysql
goblin
show databases;

image-20241210153246673

将产生的 payload 粘贴到输入框中(点击 Fetch 之后多刷新几次就出现了)

image-20241210153559871

可以看到出来的结果是 information_schema、joomla

接下来继续生成 payload:查看 joomla 数据库中的数据表

image-20241210153921874

image-20241210153904172

继续生成 payload:查看 joomla_user 表中的数据

image-20241210154128049

image-20241210154143607

这里倒数第二行看到一个用户邮箱 sit_admin@nagini.hogwarts 还有后面的加密后的密码

尝试了一下无法解密,那就自己生成一个加密后的密码,更改上去

image-20241210154429812

构造更改用户密码 payload:use joomla; update joomla_users set password='76a2173be6393254e72ffa4d6df1030a' where email='site_admin@nagini.hogwarts';

image-20241210154828488

image-20241210154748702

可以看到更换成功

使用 site_adminpasswd登录 /joomla/administrator 管理员页面

image-20241210155356912

点击 Templates 进入 Protostar Details and Files 中,可以看到这里全是 php 文件管理,可以添加编辑 php 文件

将 kali 自带的反弹shell 文件(/usr/share/webshell文件夹中的)内容编辑进新建立的 shell.php 文件

image-20241210161112858

之后,kali 进行 nc 监听,进入http://192.168.1.5/joomla/templates/protostar/shell.php

image-20241210161248075

反弹成功

提权

在 var/www/html/ 文件夹中发现第一个 flog

image-20241210161523833

在 home 中发现 hermoine 和 snape 两个用户目录,进入 hermoine 中发现第二个 flog 但是没有权限访问

image-20241210161615535

进入 snape 目录 ls -la 发现一个隐藏的 txt 文件,cat一下

image-20241210161805383

base64解码得到密码:Love@lilly

image-20241210161856609

那就应该是 snape 用户的ssh密码了,连接

image-20241210162039713

然后再次进入 hermoine 查看 flog,失败...但是发现 bin 文件夹中有一个 su_cp

image-20241210162319127

经过查看 --help 发现 su_sp 功能就是复制粘贴。

那么我们生成 ssh 密钥,复制到 hermoine 用户中

先生成 ssh 密钥

image-20241210173059275

将 abc.pub 复制成 authorized_keys 文件,然后 python3 开启本地 http 服务

在 snape 用户上将文件 wget 下来

image-20241210173812913

然后文件复制到 hermoine 的 .ssh 目录中

./su_cp /home/snape/authorized_keys /home/hermoine/.ssh/authorized_keys

image-20241210174049755

ssh hermoine@192.168.1.5 -i abc

image-20241210174117716

成功 hermoine 用户 ssh 登录

image-20241210174153849

拿到第二个 flog。

查看用户目录中所有隐藏文件

image-20241210174914359

看到有一个 .mozilla 文件夹(另一个 .gnupg 文件夹已经看过了,是空的),里面有一个 firefox 文件夹

开启个 http 服务,然后在 kali 里面将其 wget 下来

wget -r -np -nH -R index.html http://192.168.1.5:8888/.mozilla/

image-20241210180410603

使用 firefox_decrypt 工具解析

python firefox_decrypt.py 1/.mozilla/firefox

image-20241210180420131

得到 root 用户名的密码 @Alohomora#123

image-20241210180556577

连接成功!获取最后的 flog

posted @ 2024-12-10 18:07  酷比灯  阅读(35)  评论(0)    收藏  举报