Middleware is the runtime environment of a Web application—taking down the middleware is equivalent to directly executing code on the server.
⛔ In-depth reference (required reading)
Detailed exploitation commands and payloads for each middleware are organized by middleware type, covering Tomcat, WebLogic, JBoss, IIS, Nginx, Apache HTTPD.
Phase 1: Middleware identification
# 自动指纹
whatweb http://TARGET
curl -sI http://TARGET | grep -i "Server\|X-Powered-By"
nmap -sV -p 80,443,8080,8009,8443,9090,7001,4848,9200 TARGET
Common port fingerprints
| 端口 | 中间件 | 管理后台路径 |
|------|--------|-------------|
| 8080 | Tomcat | /manager/html |
| 7001 | WebLogic | /console |
| 8080/9990 | JBoss/WildFly | /admin-console, /management |
| 4848 | GlassFish | /common/index.jsf |
| 80/443 | IIS | — |
| 80/443 | Nginx | — |
| 80/443 | Apache | /server-status |
## Phase 2: 攻击决策树
Which middleware is identified? ├─ Tomcat │ ├─ /manager accessible → weak password → deploy WAR │ ├─ 8009 AJP open → Ghostcat file read/RCE │ └─ PUT method enabled → directly write JSP │ ├─ WebLogic │ ├─ /console accessible → weak password → deploy WAR │ └─ T3/IIOP protocol → deserialization RCE (many CVEs) │ ├─ JBoss/WildFly │ ├─ JMX Console unauthorized → deploy WAR │ └─ deserialization (JMXInvokerServlet) │ ├─ IIS │ ├─ PUT method → WebDAV upload │ ├─ short file name → information disclosure │ └─ parsing vulnerability (6.0/7.5) │ ├─ Nginx │ ├─ directory traversal (alias misconfiguration) │ ├─ parsing vulnerability (cgi.fix_pathinfo) │ └─ CRLF injection │ └─ Apache ├─ path traversal (CVE-2021-41773) └─ mod_cgi/mod_cgid → RCE
## Phase 3: 通用攻击 — 管理后台弱口令
**方法论**:针对已识别的中间件管理接口,测试默认凭据组合。
1. 确认管理接口可达(Phase 1 端口/路径表)
2. 使用默认凭据字典尝试登录(每种中间件有特定的默认用户名/密码组合)
3. 注意锁定策略——部分中间件会在多次失败后锁定账户
4. 成功登录后进入 Phase 4
## Phase 4: WAR 部署 Getshell
**方法论**:获取管理后台权限后,利用部署功能上传 webshell。
1. **Tomcat Manager** — 通过 manager 文本接口或 HTML 界面部署 WAR 包
2. **WebLogic Console** — 通过 Console 界面或 REST API 部署应用
3. **JBoss/WildFly** — 通过 JMX Console 或管理接口部署
通用流程:
- 生成 WAR 格式的 webshell(msfvenom 或手工打包 JSP)
- 通过管理接口部署到目标
- 访问部署路径触发 webshell
## Phase 5: 解析漏洞利用
**方法论**:利用中间件对文件扩展名的解析差异绕过上传限制。
核心思路:
1. **后缀欺骗** — 利用中间件对多后缀、截断符、目录的解析逻辑,使上传的图片/文本文件被作为脚本执行
2. **FastCGI/CGI 路径解析** — 利用 `cgi.fix_pathinfo` 等配置使非脚本路径被传递给解释器
3. **PUT 方法** — 直接写入可执行文件到 Web 目录