KubeStalk 是一款从黑盒视角发现 Kubernetes 及关联基础设施攻击面的工具。该工具是在 Project Resonance - Wave 9 期间用于探测互联网上不安全 Kubernetes 集群的社区版本。
下面的 GIF 演示了该工具的使用方式:

KubeStalk 使用 Python 编写,需要 requests 库。
要安装该工具,你可以将仓库克隆到任意目录:
git clone https://github.com/redhuntlabs/kubestalk
克隆后,你需要使用 python3 -m pip install requests 安装 requests 库,或者:
python3 -m pip install -r requirements.txt
一切就绪后,你就可以直接使用该工具了。
该工具支持的命令行参数列表可以通过 -h 标志显示。
$ python3 kubestalk.py -h
+---------------------+
| K U B E S T A L K |
+---------------------+ v0.1
[!] KubeStalk by RedHunt Labs - A Modern Attack Surface (ASM) Management Company
[!] Author: 0xInfection (RHL Research Team)
[!] Continuously Track Your Attack Surface using https://redhuntlabs.com/nvadr.
usage: ./kubestalk.py <url(s)>/<cidr>
Required Arguments:
urls List of hosts to scan
Optional Arguments:
-o OUTPUT, --output OUTPUT
Output path to write the CSV file to
-f SIG_FILE, --sig-dir SIG_FILE
Signature directory path to load
-t TIMEOUT, --timeout TIMEOUT
HTTP timeout value in seconds
-ua USER_AGENT, --user-agent USER_AGENT
User agent header to set in HTTP requests
--concurrency CONCURRENCY
No. of hosts to process simultaneously
--verify-ssl Verify SSL certificates
--version Display the version of KubeStalk and exit.
要使用该工具,你可以向脚本传递一个或多个主机。传递给工具的所有目标必须符合 RFC 3986 规范,即必须包含协议和主机名(以及端口,如有需要)。
基本用法如下:
$ python3 kubestalk.py https://███.██.██.███:10250
+---------------------+
| K U B E S T A L K |
+---------------------+ v0.1
[!] KubeStalk by RedHunt Labs - A Modern Attack Surface (ASM) Management Company
[!] Author: 0xInfection (RHL Research Team)
[!] Continuously Track Your Attack Surface using https://redhuntlabs.com/nvadr.
[+] Loaded 10 signatures to scan.
[*] Processing host: https://███.██.██.██:10250
[!] Found potential issue on https://███.██.██.██:10250: Kubernetes Pod List Exposure
[*] Writing results to output file.
[+] Done.
可以通过 -t(设置 HTTP 超时时间)、-ua(指定自定义用户代理)和 --verify-ssl(在发起请求时验证 SSL 证书)对 HTTP 请求进行微调。
你可以使用 --concurrency 标志控制同时扫描的主机数量。默认值为 5。
输出结果写入 CSV 文件,可通过 --output 标志控制输出路径。
以下是以 Markdown 形式呈现的 CSV 输出示例:
该工具基于 BSD 3 条款许可证 授权,目前为 v0.1 版本。
| 主机 | 路径 | 问题 | 类型 | 严重程度 |
|---|
https://█.█.█.█:10250 | /pods | Kubernetes Pod 列表暴露 | 核心组件 | 漏洞/错误配置 |
https://█.█.█.█:443 | /api/v1/pods | Kubernetes Pod 列表暴露 | 核心组件 | 漏洞/错误配置 |
http://█.█.██.█:80 | / | etcd 查看器仪表盘暴露 | 附加组件 | 漏洞/暴露 |
http://██.██.█.█:80 | / | cAdvisor 指标 Web UI 仪表盘暴露 | 附加组件 | 漏洞/暴露 |