x-glacier/kali-pentest / kali-pentest-zh
kali-pentest-zh
Flagged通过 SSH 或 Docker 使用 Kali Linux CLI 工具执行授权渗透测试。 覆盖:信息收集、漏洞分析、嗅探与欺骗、Web/API 渗透、漏洞利用、密码攻击、无线、云原生安全、RFID/NFC、VoIP/ICS、逆向工程、取证分析、后渗透/C2、报告生成。
references/cloud-native/tools/peirates.md
View on GitHub# Peirates
- **Category**: Cloud-Native / Kubernetes Exploitation
- **Risk Level**: 🔴 Critical
---
## 描述
peirates 是一款 Kubernetes 渗透测试工具,设计用于在已被入侵的容器内运行。它在 Kubernetes 集群中执行权限提升、横向移动和凭据收集。功能包括窃取服务账户令牌、在其他 Pod 中执行命令、挂载密钥、创建特权 Pod、访问云提供商元数据服务以及在命名空间之间跳板转发。使用 Go 编写,提供交互式菜单驱动界面。
## 安装
```bash
sudo apt install peirates
```
替代方式(从 GitHub 发布页下载):
```bash
wget https://github.com/inguardians/peirates/releases/latest/download/peirates-linux-amd64.tar.xz
tar xf peirates-linux-amd64.tar.xz
chmod +x peirates
sudo mv peirates /usr/local/bin/
```
## 参数说明
### 交互菜单选项
> 已对照 Peirates **v1.1.28** 的实时菜单验证。每一项显示菜单编号和键入的命令别名。标有 `*` 的菜单项支持 `-m <module>` 命令行参数用于非交互式调用。
| # | Command alias(es) | 说明 |
|---|-------------------|------|
| 1 | `sa-menu` (`list-sa`*, `switch-sa`, `get-sa`) | 列出、维护或切换服务账户上下文 |
| 2 | `ns-menu` (`list-ns`, `switch-ns`, `get-ns`) | 列出和/或切换命名空间 |
| 3 | `list-pods`, `get-pods` | 获取当前命名空间中的 Pod 列表 |
| 4 | `dump-pod-info` | 获取所有 Pod 的完整信息(JSON) |
| 5 | `find-volume-mounts` | 检查所有 Pod 的卷挂载 |
| 6 | `aws-enter-credentials` | 手动输入 AWS IAM 凭据 |
| 7 | `aws-assume-role` | 尝试担任其他 AWS 角色 |
| 8 | `aws-empty-assumed-role` | 取消已担任的 AWS 角色 |
| 9 | `cert-menu` | 切换基于证书的认证(kubelet 或手动) |
| 10 | `list-secrets`, `get-secrets` | 从 API 服务器列出此命名空间中的密钥 |
| 11 | `secret-to-sa` | 从密钥中获取服务账户令牌 |
| 12 | `aws-get-token` * | 从 AWS 元数据 API 请求 IAM 凭据 |
| 13 | `gcp-get-token` * | 从 GCP 元数据 API 请求 IAM 凭据 |
| 14 | `gcp-attack-kube-env` | 从 GCP 元数据 API 请求 kube-env |
| 15 | `gcp-attack-kops-gcs-1` * | 从 kops 的 GCS 存储桶拉取 SA 令牌(仅 GCP) |
| 16 | `attack-kops-aws-1` | 从 kops 的 S3 存储桶拉取 SA 令牌(仅 AWS) |
| 17 | `aws-s3-ls` | 列出可访问的 AWS S3 存储桶 |
| 18 | `aws-s3-ls-objects` | 列出 AWS S3 存储桶的内容 |
| 20 | `attack-pod-hostpath-mount` | 通过挂载 hostPath 的 Pod 在节点上获取反向 root shell |
| 21 | `exec-via-api` | 通过 API 服务器在一个或所有 Pod 中运行命令 |
| 22 | `exec-via-kubelet` | 通过 Kubelet 在所有 Pod 中运行转储令牌的命令 |
| 23 | `leakyvessels` * | 利用 CVE-2024-21626(Leaky Vessels)获取主机 shell(runc <1.12) |
| 30 | `nodefs-steal-secrets` | 从节点文件系统窃取密钥 |
| 90 | `kubectl [args]` | 使用当前授权上下文运行 kubectl 命令 |
| — | `kubectl-try-all [args]` | 使用每一个授权上下文运行 kubectl 命令 |
| — | `kubectl-try-all-until-success [args]` | 同上,但在第一个可用上下文处停止 |
| 91 | `curl` | 向用户指定的 URL 发起 HTTP 请求(GET 或 POST) |
| 92 | `set-auth-can-i` | 在尝试操作前停用 `auth can-i` 检查 |
| 93 | `tcpscan` | 对某个 IP 地址运行简单的全端口 TCP 端口扫描 |
| 94 | `enumerate-dns` * | 通过 DNS 枚举服务 |
### 命令行参数
| 参数 | 说明 |
|------|------|
| `-k` | 忽略 API 服务器请求的 TLS 验证 |
| `-m <module>` | 从菜单运行指定模块(标有 `*` 的菜单项支持此选项) |
| `-t <token>` | 用于认证的 JWT 令牌 |
| `-u <url>` | API 服务器 URL,例如 `https://10.96.0.1:6443`(默认为空:`https://:`) |
| `-v` | 详细模式——显示调试信息 |
## 常用命令
### 场景 1:启动与初始侦察
```bash
# 启动 peirates(交互菜单)
peirates
# 使用指定的 API 服务器 URL 启动
peirates -u https://10.96.0.1:6443
# 使用 JWT 令牌启动
peirates -t <jwt-token>
# 忽略 TLS 验证启动
peirates -k
```
### 场景 2:服务账户令牌操作
```bash
# 在 peirates 交互菜单中:
# 列出 / 切换服务账户上下文
sa-menu
list-sa
switch-sa
# 从密钥中获取服务账户令牌
secret-to-sa
```
### 场景 3:命名空间枚举与密钥
```bash
# 在 peirates 交互菜单中:
# 列出当前命名空间中的 Pod
list-pods
# 获取当前命名空间中的密钥
get-secrets
# 切换到不同的命名空间
ns-menu
```
### 场景 4:横向移动与节点逃逸
```bash
# 在 peirates 交互菜单中:
# 通过 API 服务器在另一个 Pod 中执行命令
exec-via-api
# 或通过 Kubelet 从所有 Pod 转储令牌
exec-via-kubelet
# 通过挂载 hostPath 的 Pod 在节点上获取反向 root shell
attack-pod-hostpath-mount
# 从元数据 API 请求云 IAM 凭据
aws-get-token
gcp-get-token
```
### 场景 5:凭据收集
```bash
# 在 peirates 交互菜单中:
# 从节点文件系统窃取密钥
nodefs-steal-secrets
# 从 API 服务器列出然后读取密钥
list-secrets
get-secrets
# 如果 'auth can-i' 预检查阻碍了操作,则将其禁用
set-auth-can-i
```
## 注意事项
1. peirates 设计用于在已被入侵的容器内运行——需将二进制文件传输到目标 Pod 中,或构建包含它的容器镜像。
2. 要收集云 IAM 凭据,使用 `aws-get-token` / `gcp-get-token`(菜单 12/13),它们查询云元数据 API(169.254.169.254)——在未启用元数据保护的 EKS/GKE 集群上有效。`aws-enter-credentials` / `aws-assume-role` 涵盖手动 AWS 凭据和角色担任工作流。
3. `nodefs-steal-secrets`(菜单 30)直接从节点文件系统读取密钥;`find-volume-mounts`(菜单 5)可发现具有值得关注卷挂载的 Pod。
4. 节点逃逸影响最大:`attack-pod-hostpath-mount`(菜单 20)启动挂载 hostPath 的 Pod 以获取节点 root shell,`leakyvessels`(菜单 23)在 runc <1.12 上利用 CVE-2024-21626。两者都应在评估授权中明确定义范围。
5. 所有操作使用当前选定的服务账户上下文——使用 `sa-menu` 切换上下文,使用 `kubectl-try-all` 在每一个可用上下文中测试命令。`set-auth-can-i` 在客户端 `auth can-i` 预检查造成阻碍时将其禁用。
---
## 官方参考
- [peirates (GitHub)](https://github.com/inguardians/peirates)
- [peirates — Kali Tools](https://www.kali.org/tools/peirates/)
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics. | Stars: 472k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |