K8s Network Recon logo

K8s Network Recon

OrganizationPopular
wgpsec
k8s-network-recon

Kubernetes 集群内网络侦察与服务发现。当已获得 Pod Shell、需要发现集群内其他服务、执行 K8s 内网扫描时使用。覆盖 DNS PTR 反查、SRV 记录枚举、AXFR 域传输、K8Spider 使用。任何在 Pod 中需要横向侦察、寻找隐藏服务、确定攻击目标的场景都应使用此技能,即使用户没有明确提到 DNS

Overview

Publisherwgpsec
RepositoryAboutSecurity
Skill namek8s-network-recon
Stars
1.7K
Forks
242
Bundled files
1
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by wgpsec on GitHub. Read the source before you install it.

Installation

Install the K8s Network Recon AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/wgpsec/AboutSecurity.git /tmp/AboutSecurity
mkdir -p .claude/skills
cp -r /tmp/AboutSecurity/skills/cloud/k8s-network-recon .claude/skills/k8s-network-recon
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable K8s Network Recon in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads K8s Network Recon on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so K8s Network Recon is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

→ 读 references/network-attacks.md

Kubernetes 集群内网络侦察

在 K8s 集群中横向移动的第一步是弄清楚还有哪些服务在运行。因为 K8s 用 DNS 做服务发现,每个 Service 和 Pod 都有可预测的 DNS 名称,这意味着通过 DNS 反查就能系统性地枚举整个集群。

K8s DNS 命名规则

资源类型DNS 格式示例
Service<svc>.<ns>.svc.cluster.localredis.default.svc.cluster.local
Pod<pod-ip-dashed>.<ns>.pod.cluster.local10-244-0-5.default.pod.cluster.local
Headless Service<pod-name>.<svc>.<ns>.svc.cluster.localweb-0.nginx.default.svc.cluster.local

注意: DNS 后缀不一定是 cluster.local,由集群配置决定。检查 /etc/resolv.conf 中的 search 行。

SRV 记录

Service 的 SRV 记录暴露端口信息:

bash
nslookup -type=srv <service>.<namespace>.svc.cluster.local
# 输出示例: service = 0 50 80 svc.ns.svc.cluster.local
# 即使没有 _proto 前缀,也能查到所有有效端口

Phase 1: 确定扫描范围

DNS PTR 反查是逐 IP 的——/16 范围有 65535 个 IP,盲扫可能需要几十分钟。先花 30 秒确定 Service CIDR,能把扫描时间从分钟级降到秒级。

先获取入口点信息(按可靠度从高到低)

bash
# 1. 环境变量(最快,几乎必有)
echo $KUBERNETES_SERVICE_HOST
env | grep -i service_host

# 2. DNS 配置(nameserver 地址通常在 Service CIDR 内)
cat /etc/resolv.conf

# 3. DNS 查询(返回的 API Server IP 暴露 CIDR 段)
nslookup kubernetes.default.svc.cluster.local

# 4. 路由表/ARP(辅助推断)
cat /etc/hosts && ip route && arp -a 2>/dev/null

# 5. 避免用 ip addr — sidecar 注入的虚拟网卡会干扰判断

从获取到的 IP 推断 Service CIDR。

子网范围选择策略

⚠️ 禁止用 /8 或更大范围 — 16M+ IP 永远扫不完,会浪费整轮时间。

推荐扫描粒度:

  1. 先用上面获取的 KUBERNETES_SERVICE_HOST 确定 Service CIDR
  2. /24 开始(256 IP,秒级完成),无结果则扩到 /16(65K IP,分钟级)
  3. 常见 Service CIDR:10.96.0.0/1610.100.0.0/1610.43.0.0/16(K3s)
  4. 如果 KUBERNETES_SERVICE_HOST10.96.0.1,扫 10.96.0.0/16

Phase 2: DNS 批量扫描

使用 K8Spider(推荐)

bash
# PTR 反查 + SRV 记录 + 多线程,一条命令完成全部扫描
k8spider scan -subnet 10.100.0.0/24

# 更大的范围
k8spider scan -subnet 10.96.0.0/12    # 默认 Service CIDR
k8spider scan -subnet 10.244.0.0/16   # Pod CIDR (Flannel 默认)
k8spider scan -subnet 10.42.0.0/16    # Pod CIDR (K3s 默认)

备选: 部分 CTF 环境预装了 dnscan(用法: dnscan -subnet <cidr>),功能类似但不支持 SRV 记录枚举。优先用 K8Spider。

无工具时的手动方法

bash
# PTR 反查 (逐个 IP)
for i in $(seq 1 254); do
  nslookup 10.100.0.$i 2>/dev/null | grep -v "NXDOMAIN" | grep "name =" &
done; wait

# AXFR 域传输(如果 CoreDNS 允许)
dig axfr cluster.local @$(grep nameserver /etc/resolv.conf | awk '{print $2}')

# Wildcard DNS(已被新版 CoreDNS 废弃,但老版本可能有效)
nslookup any.any.svc.cluster.local

Phase 3: 服务利用

发现服务后,按攻击价值优先级排序:

  1. 直接 flag/数据服务(名称含 flag、secret、internal)→ 立即 curl 访问
  2. 集群管控面(API Server 6443、etcd 2379、kubelet 10250)→ 未授权访问 = 集群接管
  3. 策略/Webhook 服务(kyverno-svc、gatekeeper)→ 可提取注入的 Secret
  4. 监控/运维(prometheus 9090、grafana 3000、dashboard 8443)→ 信息泄露 + 凭据
  5. 业务服务(其他自定义服务)→ 根据名称和端口判断
bash
# 访问发现的服务
curl <service>.<namespace>.svc.cluster.local
curl <service>.<namespace>.svc.cluster.local:<port>

# 对高价值目标尝试多个路径
curl -s http://<svc>:<port>/
curl -s http://<svc>:<port>/flag
curl -s http://<svc>:<port>/api/v1
curl -sk https://<svc>:<port>/

相关技能

发现服务后,根据目标类型加载对应技能:

  • Istio/Envoy 相关服务 → Skill(skill="k8s-istio-bypass")
  • Kyverno/OPA Webhook → Skill(skill="k8s-webhook-abuse")
  • NFS/EFS 存储 → Skill(skill="k8s-storage-exploit")
  • API Server/Kubelet → Skill(skill="k8s-container-escape")
  • K8Spider 工具详细用法 → Skill(skill="k8spider")

工具速查

工具用途安装
K8SpiderK8s DNS 批量扫描(PTR+SRV+AXFR+多线程)go install github.com/Esonhugh/k8spider@latest
nslookup/dig手动 DNS 查询系统自带
CDK容器渗透工具集(含服务发现)f8x 安装

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the K8s Network Recon AI skill do?

Kubernetes 集群内网络侦察与服务发现。当已获得 Pod Shell、需要发现集群内其他服务、执行 K8s 内网扫描时使用。覆盖 DNS PTR 反查、SRV 记录枚举、AXFR 域传输、K8Spider 使用。任何在 Pod 中需要横向侦察、寻找隐藏服务、确定攻击目标的场景都应使用此技能,即使用户没有明确提到 DNS

Why use K8s Network Recon on TypingMind?

Because you install it once and use it with any model. K8s Network Recon is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install K8s Network Recon in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/wgpsec/AboutSecurity/tree/master/skills/cloud/k8s-network-recon. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use K8s Network Recon?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with K8s Network Recon?

As many as you like. As long as a model supports skills, you can use K8s Network Recon with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the K8s Network Recon AI skill free?

It is published on GitHub by wgpsec. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇