Skip to content

x-glacier/kali-pentest / kali-pentest-zh

kali-pentest-zh

Flagged

通过 SSH 或 Docker 使用 Kali Linux CLI 工具执行授权渗透测试。 覆盖:信息收集、漏洞分析、嗅探与欺骗、Web/API 渗透、漏洞利用、密码攻击、无线、云原生安全、RFID/NFC、VoIP/ICS、逆向工程、取证分析、后渗透/C2、报告生成。

FileKindSize
SKILL.mdskill md15.6 KB
references/cloud-native/README.mdmarkdown4.2 KB
references/cloud-native/tools/azurehound.mdmarkdown4.0 KB
references/cloud-native/tools/docker-bench-security.mdmarkdown1.9 KB
references/cloud-native/tools/kube-bench.mdmarkdown1.7 KB
references/cloud-native/tools/kubescape.mdmarkdown1.7 KB
references/cloud-native/tools/pacu.mdmarkdown3.0 KB
references/cloud-native/tools/peirates.mdmarkdown6.4 KB
references/cloud-native/tools/prowler.mdmarkdown1.5 KB
references/cloud-native/tools/scoutsuite.mdmarkdown1.2 KB
references/environment/README.mdmarkdown1.4 KB
references/environment/docker-mode-networking.mdmarkdown2.2 KB
references/environment/docker-mode-persistent-container.mdmarkdown3.8 KB
references/environment/docker-mode.mdmarkdown2.0 KB
references/environment/local-mode.mdmarkdown946 B
references/environment/server-mode.mdmarkdown4.1 KB
references/environment/state-files.mdmarkdown2.3 KB
references/exploitation/README.mdmarkdown9.6 KB
references/exploitation/tools/chisel.mdmarkdown3.2 KB
references/exploitation/tools/coercer.mdmarkdown2.5 KB
references/exploitation/tools/dns2tcp.mdmarkdown3.8 KB
references/exploitation/tools/evil-winrm.mdmarkdown2.9 KB
references/exploitation/tools/evilginx2.mdmarkdown2.2 KB
references/exploitation/tools/getsploit.mdmarkdown2.0 KB
references/exploitation/tools/gophish.mdmarkdown6.1 KB
references/exploitation/tools/impacket.mdmarkdown10.9 KB
references/exploitation/tools/iodine.mdmarkdown3.5 KB
references/exploitation/tools/ligolo-ng.mdmarkdown3.3 KB
references/exploitation/tools/metasploit.mdmarkdown11.0 KB
references/exploitation/tools/mitm6.mdmarkdown2.6 KB
references/exploitation/tools/msfconsole.mdmarkdown3.9 KB
references/exploitation/tools/msfvenom.mdmarkdown8.5 KB
references/exploitation/tools/mssqlpwner.mdmarkdown2.5 KB
references/exploitation/tools/netcat.mdmarkdown4.4 KB
references/exploitation/tools/odat.mdmarkdown3.0 KB
references/exploitation/tools/proxytunnel.mdmarkdown2.2 KB
references/exploitation/tools/routersploit.mdmarkdown2.9 KB
references/exploitation/tools/searchsploit.mdmarkdown4.7 KB
references/exploitation/tools/setoolkit.mdmarkdown1015 B
references/exploitation/tools/smbclient.mdmarkdown2.8 KB
references/exploitation/tools/socat.mdmarkdown2.8 KB
references/exploitation/tools/veil.mdmarkdown2.9 KB
references/forensics/README.mdmarkdown8.8 KB
references/forensics/tools/bulk-extractor.mdmarkdown4.5 KB
references/forensics/tools/chainsaw.mdmarkdown2.6 KB
references/forensics/tools/chkrootkit.mdmarkdown2.6 KB
references/forensics/tools/dc3dd.mdmarkdown2.9 KB
references/forensics/tools/dcfldd.mdmarkdown3.2 KB
references/forensics/tools/ddrescue.mdmarkdown3.6 KB
references/forensics/tools/exiftool.mdmarkdown2.5 KB
references/forensics/tools/foremost.mdmarkdown2.4 KB
references/forensics/tools/hashdeep.mdmarkdown3.5 KB
references/forensics/tools/plaso.mdmarkdown3.7 KB
references/forensics/tools/regripper.mdmarkdown3.4 KB
references/forensics/tools/rkhunter.mdmarkdown3.4 KB
references/forensics/tools/scalpel.mdmarkdown2.6 KB
references/forensics/tools/sleuthkit.mdmarkdown4.0 KB
references/forensics/tools/ssdeep.mdmarkdown3.1 KB
references/forensics/tools/steghide.mdmarkdown2.8 KB
references/forensics/tools/stegseek.mdmarkdown2.5 KB
references/forensics/tools/tcpdump.mdmarkdown2.8 KB
references/forensics/tools/tcpflow.mdmarkdown3.4 KB
references/forensics/tools/testdisk.mdmarkdown3.0 KB
references/forensics/tools/tshark.mdmarkdown3.0 KB
references/forensics/tools/volatility.mdmarkdown5.0 KB
references/forensics/tools/yara.mdmarkdown3.3 KB
references/information-gathering/README.mdmarkdown15.6 KB
references/information-gathering/tools/altdns.mdmarkdown1.9 KB
references/information-gathering/tools/amass.mdmarkdown9.1 KB
references/information-gathering/tools/arp-scan.mdmarkdown1.9 KB
references/information-gathering/tools/assetfinder.mdmarkdown1.9 KB
references/information-gathering/tools/autorecon.mdmarkdown2.9 KB
references/information-gathering/tools/certgraph.mdmarkdown3.3 KB
references/information-gathering/tools/cloud-enum.mdmarkdown2.1 KB
references/information-gathering/tools/cloudbrute.mdmarkdown2.1 KB
references/information-gathering/tools/dig.mdmarkdown2.3 KB
references/information-gathering/tools/dmitry.mdmarkdown2.0 KB
references/information-gathering/tools/dnsenum.mdmarkdown1.7 KB
references/information-gathering/tools/dnsgen.mdmarkdown1.5 KB
references/information-gathering/tools/dnsmap.mdmarkdown1.8 KB
references/information-gathering/tools/dnsrecon.mdmarkdown2.7 KB
references/information-gathering/tools/dnstwist.mdmarkdown3.0 KB
references/information-gathering/tools/dnsx.mdmarkdown2.8 KB
references/information-gathering/tools/eyewitness.mdmarkdown2.4 KB
references/information-gathering/tools/fierce.mdmarkdown2.5 KB
references/information-gathering/tools/finalrecon.mdmarkdown2.4 KB
references/information-gathering/tools/findomain.mdmarkdown2.5 KB
references/information-gathering/tools/fping.mdmarkdown2.3 KB
references/information-gathering/tools/getallurls.mdmarkdown2.4 KB
references/information-gathering/tools/gowitness.mdmarkdown4.8 KB
references/information-gathering/tools/h8mail.mdmarkdown3.9 KB
references/information-gathering/tools/hakrawler.mdmarkdown2.3 KB
references/information-gathering/tools/hosthunter.mdmarkdown2.6 KB
references/information-gathering/tools/httprobe.mdmarkdown2.1 KB
references/information-gathering/tools/httpx.mdmarkdown4.6 KB
references/information-gathering/tools/ldeep.mdmarkdown4.9 KB
references/information-gathering/tools/masscan.mdmarkdown3.8 KB
references/information-gathering/tools/massdns.mdmarkdown1.9 KB
references/information-gathering/tools/metagoofil.mdmarkdown3.0 KB
references/information-gathering/tools/naabu.mdmarkdown2.7 KB
references/information-gathering/tools/nbtscan.mdmarkdown2.2 KB
references/information-gathering/tools/netdiscover.mdmarkdown2.6 KB
references/information-gathering/tools/nmap.mdmarkdown8.4 KB
references/information-gathering/tools/p0f.mdmarkdown2.1 KB
references/information-gathering/tools/recon-ng.mdmarkdown6.6 KB
references/information-gathering/tools/sherlock.mdmarkdown3.7 KB
references/information-gathering/tools/shodan.mdmarkdown3.6 KB
references/information-gathering/tools/spiderfoot.mdmarkdown2.7 KB
references/information-gathering/tools/subfinder.mdmarkdown2.5 KB
references/information-gathering/tools/sublist3r.mdmarkdown1.9 KB
references/information-gathering/tools/theHarvester.mdmarkdown2.9 KB
references/information-gathering/tools/trufflehog.mdmarkdown3.1 KB
references/information-gathering/tools/wafw00f.mdmarkdown1.9 KB
references/information-gathering/tools/whatweb.mdmarkdown5.1 KB
references/information-gathering/tools/whois.mdmarkdown2.0 KB
references/password/README.mdmarkdown11.8 KB
references/password/tools/brutespray.mdmarkdown2.8 KB
references/password/tools/cewl.mdmarkdown2.1 KB
references/password/tools/changeme.mdmarkdown3.0 KB
references/password/tools/chntpw.mdmarkdown2.5 KB
references/password/tools/crowbar.mdmarkdown2.6 KB
references/password/tools/crunch.mdmarkdown2.7 KB
references/password/tools/fcrackzip.mdmarkdown2.3 KB
references/password/tools/gpp-decrypt.mdmarkdown2.6 KB
references/password/tools/hashcat.mdmarkdown4.6 KB
references/password/tools/hashid.mdmarkdown2.1 KB
references/password/tools/hydra.mdmarkdown4.4 KB
references/password/tools/john.mdmarkdown3.2 KB
references/password/tools/kerbrute.mdmarkdown2.8 KB
references/password/tools/medusa.mdmarkdown3.3 KB
references/password/tools/name-that-hash.mdmarkdown3.2 KB
references/password/tools/ncrack.mdmarkdown3.3 KB
references/password/tools/netexec.mdmarkdown3.2 KB
references/password/tools/patator.mdmarkdown2.2 KB
references/password/tools/pdfcrack.mdmarkdown2.9 KB
references/password/tools/rainbowcrack.mdmarkdown2.9 KB
references/password/tools/responder.mdmarkdown2.7 KB
references/playbooks/README.mdmarkdown8.1 KB
references/playbooks/active-directory.mdmarkdown14.0 KB
references/playbooks/api-security.mdmarkdown18.6 KB
references/playbooks/cloud-native-assessment.mdmarkdown17.6 KB
references/playbooks/external-attack-surface.mdmarkdown8.1 KB
references/playbooks/forensics-triage.mdmarkdown11.7 KB
references/playbooks/internal-network-protocols.mdmarkdown6.5 KB
references/playbooks/internal-network.mdmarkdown14.4 KB
references/playbooks/mobile-application.mdmarkdown9.8 KB
references/playbooks/password-audit.mdmarkdown9.0 KB
references/playbooks/post-exploitation.mdmarkdown11.4 KB
references/playbooks/reporting-workflow.mdmarkdown6.3 KB
references/playbooks/rfid-nfc.mdmarkdown7.2 KB
references/playbooks/source-code-audit.mdmarkdown8.4 KB
references/playbooks/voip-ics.mdmarkdown17.3 KB
references/playbooks/web-application.mdmarkdown14.7 KB
references/playbooks/wireless-assessment.mdmarkdown9.6 KB
references/post-exploitation/README.mdmarkdown11.0 KB
references/post-exploitation/tools/bloodhound.mdmarkdown4.8 KB
references/post-exploitation/tools/bloodhound.py.mdmarkdown4.0 KB
references/post-exploitation/tools/bloodyad.mdmarkdown4.1 KB
references/post-exploitation/tools/certipy-ad.mdmarkdown3.2 KB
references/post-exploitation/tools/dnscat2.mdmarkdown3.5 KB
references/post-exploitation/tools/dploot.mdmarkdown4.2 KB
references/post-exploitation/tools/havoc.mdmarkdown3.8 KB
references/post-exploitation/tools/hekatomb.mdmarkdown3.0 KB
references/post-exploitation/tools/krbrelayx.mdmarkdown7.3 KB
references/post-exploitation/tools/lapsdumper.mdmarkdown2.4 KB
references/post-exploitation/tools/linpeas.mdmarkdown3.6 KB
references/post-exploitation/tools/linux-exploit-suggester.mdmarkdown2.8 KB
references/post-exploitation/tools/lsassy.mdmarkdown2.8 KB
references/post-exploitation/tools/mimikatz.mdmarkdown4.2 KB
references/post-exploitation/tools/powershell-empire.mdmarkdown4.0 KB
references/post-exploitation/tools/powersploit.mdmarkdown5.5 KB
references/post-exploitation/tools/proxychains.mdmarkdown2.1 KB
references/post-exploitation/tools/pspy.mdmarkdown2.8 KB
references/post-exploitation/tools/pwncat.mdmarkdown6.4 KB
references/post-exploitation/tools/sliver.mdmarkdown1.4 KB
references/post-exploitation/tools/sshuttle.mdmarkdown3.2 KB
references/post-exploitation/tools/winpeas.mdmarkdown3.0 KB
references/reporting/README.mdmarkdown2.5 KB
references/reporting/tools/pandoc.mdmarkdown3.2 KB
references/reporting/tools/report-template.mdmarkdown8.5 KB
references/reverse-engineering/README.mdmarkdown5.6 KB
references/reverse-engineering/tools/apktool.mdmarkdown1.8 KB
references/reverse-engineering/tools/binwalk.mdmarkdown3.0 KB
references/reverse-engineering/tools/checksec.mdmarkdown3.5 KB
references/reverse-engineering/tools/dex2jar.mdmarkdown3.2 KB
references/reverse-engineering/tools/frida.mdmarkdown2.4 KB
references/reverse-engineering/tools/ghidra-headless.mdmarkdown3.0 KB
references/reverse-engineering/tools/jadx.mdmarkdown2.2 KB
references/reverse-engineering/tools/ldd.mdmarkdown1.9 KB
references/reverse-engineering/tools/nm.mdmarkdown2.3 KB
references/reverse-engineering/tools/objdump.mdmarkdown2.5 KB
references/reverse-engineering/tools/objection.mdmarkdown3.0 KB
references/reverse-engineering/tools/rabin2.mdmarkdown2.3 KB
references/reverse-engineering/tools/radare2.mdmarkdown1.3 KB
references/reverse-engineering/tools/readelf.mdmarkdown2.3 KB
references/reverse-engineering/tools/ropper.mdmarkdown4.1 KB
references/reverse-engineering/tools/strings.mdmarkdown2.3 KB
references/reverse-engineering/tools/xxd.mdmarkdown2.3 KB
references/rfid-nfc/README.mdmarkdown2.7 KB
references/rfid-nfc/tools/libnfc.mdmarkdown2.2 KB

references/playbooks/cloud-native-assessment.md

View on GitHub
# 云原生评估 Playbook

用于授权的云账户、Kubernetes 集群、容器镜像、镜像仓库、部署清单文件、无服务器函数、CI/CD 流水线或 Docker 主机。

## 输入

- 云服务商(AWS、Azure、GCP)、账户/项目/订阅、区域和凭据类型。
- 评估模式:只读审计、纯合规检查或包含利用的完整渗透测试。
- Kubernetes 上下文、kubeconfig、命名空间、清单文件、Helm charts 或镜像列表。
- Docker 主机或镜像仓库端点,以及允许的认证方式。
- 无服务器函数名称、CI/CD 仓库 URL 和流水线配置路径。
- 合规基线(CIS、SOC 2、PCI-DSS)、只读要求和扫描时间窗口。

## 流程

1. **范围、访问和服务商识别**
   - 确认评估边界:哪些账户、项目、订阅、集群、镜像仓库、无服务器函数和 CI/CD 流水线在范围内。
   - 确认只读与管理员访问的边界,以及是否授权利用操作(例如权限提升、容器逃逸)。
   - 扫描前记录评估者身份、凭据类型(IAM 用户、假设角色、服务主体、服务账号密钥)和权限级别。

   (云原生工具选择参见 `../cloud-native/README.md`。)

   识别云服务商并选择主要工具链:

   - **AWS** — 通过 `aws sts get-caller-identity` 验证凭据。使用 `prowler` 做合规检查,ScoutSuite(`scout`)做广泛资产清点。若授权利用,使用 `pacu` 测试权限提升。
   - **Azure** — 通过 `az account show` 验证凭据。使用 `prowler azure` 或 `scout azure`。
   - **GCP** — 通过 `gcloud auth list` 和 `gcloud config get-value project` 验证凭据。使用 `prowler gcp` 或 `scout gcp`。

   ```bash
   # AWS — 确认身份和区域
   aws sts get-caller-identity
   aws configure get region

   # Azure — 确认订阅和身份
   az account show --output json
   az ad signed-in-user show

   # GCP — 确认项目和身份
   gcloud auth list
   gcloud config get-value project
   gcloud projects get-iam-policy PROJECT_ID --format=json
   ```

   决策树:
   - 若评估仅为只读合规,直接进入第 2 阶段使用 `prowler`/ScoutSuite(`scout`),跳过利用相关阶段。
   - 若授权完整渗透测试,包含第 6 和第 7 阶段并记录所有利用尝试。
   - 若 Kubernetes 不在范围内,跳过第 4 阶段;若容器不在范围内,跳过第 5 阶段。

2. **IAM 和身份评估**
   - 枚举目标账户/项目的所有 IAM 用户、角色、组和策略。
   - 识别过度授权的角色:查找 `*` 权限、无资源约束的 `iam:PassRole`、信任策略过宽的 `sts:AssumeRole`,或具有 `Microsoft.Authorization/roleAssignments/write` 的 Azure 角色。
   - 检查权限提升路径:可以创建新角色、附加策略或修改信任关系的角色。
   - 测试服务账号和服务主体权限:验证最小权限并检查未使用或过期的凭据。
   - 检查联合身份、OIDC 信任和跨账户/跨项目信任关系是否存在过于宽泛的配置。

   ```bash
   # AWS — 枚举 IAM
   aws iam list-users --output json > /tmp/iam_users.json
   aws iam list-roles --output json > /tmp/iam_roles.json
   aws iam list-policies --scope Local --output json > /tmp/iam_policies.json
   aws iam list-role-policies --role-name ROLE_NAME
   aws iam list-attached-role-policies --role-name ROLE_NAME
   aws iam get-policy-version --policy-arn POLICY_ARN --version-id v1

   # Azure — 枚举 IAM
   az role assignment list --all --output json > /tmp/azure_roles.json
   az ad app list --output json > /tmp/azure_apps.json
   az ad sp list --all --output json > /tmp/azure_sps.json
   # Azure 攻击路径映射(类似本地 AD 的 BloodHound,使用获取到的 JWT 或刷新令牌认证)
   azurehound -j <jwt-token> list -o /tmp/azurehound.json

   # GCP — 枚举 IAM
   gcloud projects get-iam-policy PROJECT_ID --format=json > /tmp/gcp_iam.json
   gcloud iam service-accounts list --format=json > /tmp/gcp_sa.json
   gcloud iam service-accounts keys list --iam-account SA_EMAIL

   # Prowler IAM 专项检查(AWS 示例)
   prowler aws --services iam --output-formats json-ocsf --output-directory /tmp/prowler_iam
   # ScoutSuite — 审查生成报告中的 IAM 部分
   scout aws --report-dir /tmp/scoutsuite_report --no-browser
   ```

   对于 Kubernetes,测试 ServiceAccount 权限:

   ```bash
   # 检查当前 ServiceAccount 的权限
   kubectl auth can-i --list
   # 检查指定 ServiceAccount
   kubectl auth can-i --list --as=system:serviceaccount:NAMESPACE:SA_NAME
   # 查找 cluster-admin 绑定
   kubectl get clusterrolebindings -o json | jq '.items[] | select(.roleRef.name=="cluster-admin") | .subjects'
   ```

   详见 `../cloud-native/tools/prowler.md` 和 `../cloud-native/tools/scoutsuite.md` 获取完整参数说明。使用 `azurehound` 进行类似 BloodHound 的 Azure AD 攻击路径枚举(参见 `../cloud-native/tools/azurehound.md`)。

   **逐资源遍历(必须执行):** 不要抽查一个资源就推断全局。IAM:审查每个角色、用户和服务账号的附加策略和内联策略。存储:测试每个 bucket/container 的 ACL。计算:检查每个实例的安全组。使用 CLI 循环自动遍历所有枚举到的资源。

   **凭据发现处理:** 在云枚举过程中发现凭据(服务账号密钥、元数据中的访问令牌、环境变量中的密钥、存储桶中的凭据、暴露的 .env 文件)时,立即在所有已发现的云服务和 API 上测试,然后再继续下一阶段。

3. **云基础设施安全**
   - 审计安全组、网络 ACL(AWS)、NSG(Azure)或防火墙规则(GCP),重点关注过度开放的入站规则——尤其是管理端口(SSH/22、RDP/3389、数据库端口)。
   - 枚举存储资源(S3、Azure Blob、GCS)并测试 ACL 是否存在公开访问或策略错误配置。
   - 检查是否有公开暴露的快照、AMI 或虚拟机镜像以及未加密的卷。
   - 审查日志和监控配置:CloudTrail、Azure Activity Log 或 GCP Audit Log。

   ```bash
   # AWS — 查找允许 0.0.0.0/0 访问敏感端口的安全组
   aws ec2 describe-security-groups --query "SecurityGroups[?IpPermissions[?contains(IpRanges[].CidrIp, '0.0.0.0/0')]]" --output json > /tmp/open_sgs.json

   # AWS — S3 存储桶 ACL 和策略
   aws s3api list-buckets --output json > /tmp/buckets.json
   aws s3api get-bucket-acl --bucket BUCKET_NAME
   aws s3api get-bucket-policy --bucket BUCKET_NAME
   aws s3api get-public-access-block --bucket BUCKET_NAME

   # AWS — 公开快照和未加密的 EBS 卷
   aws ec2 describe-snapshots --owner-ids self --query "Snapshots[?CreateVolumePermissions[?Group=='all']]" --output json
   aws ec2 describe-volumes --query "Volumes[?!Encrypted].{ID:VolumeId,Size:Size}" --output table

   # Azure — 允许任意来源的 NSG 规则
   az network nsg list --output json > /tmp/azure_nsgs.json
   az network nsg rule list --nsg-name NSG_NAME --resource-group RG_NAME --output json
   az storage account list --query "[?allowBlobPublicAccess==\`true\`]" --output json

   # GCP — 允许 0.0.0.0/0 的防火墙规则
   gcloud compute firewall-rules list --filter="sourceRanges=0.0.0.0/0" --format=json > /tmp/gcp_fw.json
   gsutil iam get gs://BUCKET_NAME

   # Prowler — 自动化网络和存储检查
   prowler aws --services ec2 s3 vpc --output-formats json-ocsf --output-directory /tmp/prowler_infra
   ```

   如获授权进行更深入的 VPC 网络测试,可交叉参考 `internal-network.md`。

4. **Kubernetes 集群安全**
   - 使用 `kube-bench` 运行 CIS Kubernetes 基准检查,识别节点和集群配置差距。
   - 使用 `kubescape` 做 RBAC 分析、网络策略评估、暴露扫描和框架合规检查(NSA、MITRE ATT&CK)。
   - 检查是否有密钥存储在 ConfigMap 或环境变量中,而非使用 Secret 对象或外部保险库。
   - 测试网络策略:验证 Pod 无法访问非预期的服务或命名空间。
   - 评估 Pod 安全标准(PSS)或旧版 PodSecurityPolicy 的执行情况。

   ```bash
   # kube-bench — CIS 基准检查(在节点上或通过 Job 运行)
   kube-bench run --targets master,node --json > /tmp/kube_bench.json

   # kubescape — 完整框架扫描
   kubescape scan framework nsa --format json --output /tmp/kubescape_nsa.json
   kubescape scan framework mitre --format json --output /tmp/kubescape_mitre.json
   # kubescape — RBAC 分析
   kubescape scan control C-0035 --format json --output /tmp/kubescape_rbac.json
   ```

   检查工作负载中的错误配置:

   ```bash
   # 环境变量中的密钥
   kubectl get pods --all-namespaces -o json | jq '.items[].spec.containers[].env[]? | select(.valueFrom.secretKeyRef != null or (.name | test("PASSWORD|SECRET|KEY|TOKEN"; "i")))'

   # ConfigMap 中的密钥
   kubectl get configmaps --all-namespaces -o json | jq '.items[] | select(.data | to_entries[] | .value | test("password|secret|key|token|apikey"; "i")) | {namespace: .metadata.namespace, name: .metadata.name}'

   # 没有任何网络策略的命名空间
   kubectl get namespaces -o json | jq -r '.items[].metadata.name' | while read ns; do
     count=$(kubectl get networkpolicies -n "$ns" --no-headers 2>/dev/null | wc -l)
     if [ "$count" -eq 0 ]; then echo "No NetworkPolicy: $ns"; fi
   done

   # Pod 安全 — 检查特权 Pod
   kubectl get pods --all-namespaces -o json | jq '.items[] | select(.spec.containers[].securityContext.privileged == true) | {namespace: .metadata.namespace, name: .metadata.name}'

   # 查找具有 CAP_SYS_ADMIN 的容器
   kubectl get pods --all-namespaces -o json | jq '.items[] | select(.spec.containers[].securityContext.capabilities.add[]? == "SYS_ADMIN") | {namespace: .metadata.namespace, name: .metadata.name}'

   # 检查 Pod 安全准入标签
   kubectl get namespaces -o json | jq '.items[] | {name: .metadata.name, labels: (.metadata.labels // {} | with_entries(select(.key | startswith("pod-security"))))}'
   ```

   详见 `../cloud-native/tools/kube-bench.md` 和 `../cloud-native/tools/kubescape.md` 获取完整参数说明。对已授权的集群内漏洞利用,使用 `peirates`(见 `../cloud-native/tools/peirates.md`)。风险门控:`peirates` 会对 Kubernetes 服务账号和密钥执行主动利用——仅在明确的渗透测试授权下使用。

5. **容器和镜像安全**
   - 扫描容器镜像的操作系统和应用漏洞、嵌入的密钥和错误配置。
   - 检查运行中的容器是否使用特权模式、过多能力、挂载宿主机路径或暴露 `docker.sock`。
   - 当授权利用时,测试容器逃逸向量(特权 Pod 和能力查询见第 4 阶段)。
   - 测试镜像仓库认证:匿名拉取访问、凭据枚举、镜像覆写权限。

   ```bash
   # Trivy — 扫描容器镜像
   trivy image --severity HIGH,CRITICAL --format json -o /tmp/trivy_image.json IMAGE:TAG

   # Trivy — 扫描 Kubernetes 集群中的所有镜像
   kubectl get pods --all-namespaces -o json | jq -r '.items[].spec.containers[].image' | sort -u | while read img; do
     trivy image --severity HIGH,CRITICAL --format json -o "/tmp/trivy_$(echo $img | tr '/:' '__').json" "$img"
   done

   # Trivy — 扫描文件系统或 IaC
   trivy fs --scanners vuln,misconfig,secret --format json -o /tmp/trivy_fs.json /path/to/project

   # docker-bench-security — 审计 Docker 主机配置
   cd /tmp && git clone https://github.com/docker/docker-bench-security.git && cd docker-bench-security
   sudo ./docker-bench-security.sh -l /tmp/docker-bench.log
   ```

   检查宿主机路径和 `docker.sock` 逃逸向量(特权 Pod 和 `CAP_SYS_ADMIN` 查询见第 4 阶段):

   ```bash
   # 查找挂载宿主机路径的容器
   kubectl get pods --all-namespaces -o json | jq '.items[] | select(.spec.volumes[]? | .hostPath != null) | {ns: .metadata.namespace, pod: .metadata.name, hostPaths: [.spec.volumes[] | select(.hostPath != null) | .hostPath.path]}'

   # 查找挂载 docker.sock 的容器
   kubectl get pods --all-namespaces -o json | jq '.items[] | select(.spec.volumes[]? | .hostPath.path == "/var/run/docker.sock") | {ns: .metadata.namespace, pod: .metadata.name}'
   ```

   如果授权容器逃逸且发现了可利用向量,交叉参考 `post-exploitation.md` 获取利用技术。

   详见 `../vulnerability/tools/trivy.md` 和 `../cloud-native/tools/docker-bench-security.md` 获取完整参数说明。

6. **无服务器和 CI/CD**
   - 审查无服务器函数配置:执行角色、环境变量、资源策略和触发源。
   - 检查是否有密钥以明文存储在环境变量中,而非使用密钥管理器。
   - 审计 CI/CD 流水线配置中的密钥暴露、不安全的产物处理和过度宽松的 OIDC 信任。

   ```bash
   # AWS Lambda — 列出函数并检查环境变量/角色
   aws lambda list-functions --output json > /tmp/lambda_functions.json
   aws lambda get-function-configuration --function-name FUNCTION_NAME --query "Environment.Variables"
   aws lambda get-function-configuration --function-name FUNCTION_NAME --query "Role"
   aws lambda get-policy --function-name FUNCTION_NAME

   # Azure Functions — 列出函数应用
   az functionapp list --output json > /tmp/azure_functions.json
   az functionapp config appsettings list --name APP_NAME --resource-group RG_NAME

   # GCP Cloud Functions — 列出函数
   gcloud functions list --format=json > /tmp/gcp_functions.json
   gcloud functions describe FUNCTION_NAME --format=json

   # 扫描 CI/CD 配置文件中的错误配置
   trivy config --severity HIGH,CRITICAL --format json -o /tmp/trivy_cicd.json /path/to/repo/.github/workflows/
   ```

   对于 CI/CD 流水线审查,交叉参考 `source-code-audit.md` 获取流水线定义文件的 IaC 和配置扫描方法。

7. **IMDS 和云元数据**
   - 在容器、Pod 或虚拟机内测试实例元数据服务(IMDS)访问。
   - 检查 AWS 实例是否强制使用 IMDSv2(需要令牌)。
   - 测试是否存在可到达元数据端点的 SSRF 路径。
   - 尝试从元数据中获取凭据以证明影响。

   ```bash
   # AWS — 测试 IMDS 访问(IMDSv1)
   curl -s http://169.254.169.254/latest/meta-data/
   curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/
   curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/ROLE_NAME

   # AWS — 测试 IMDSv2(需要令牌)
   TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" -H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
   curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/

   # AWS — 检查实例的 IMDSv2 强制状态
   aws ec2 describe-instances --query "Reservations[].Instances[].{Id:InstanceId,IMDS:MetadataOptions}" --output json

   # Azure — 测试 IMDS
   curl -s -H "Metadata:true" "http://169.254.169.254/metadata/instance?api-version=2021-02-01"
   curl -s -H "Metadata:true" "http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https://management.azure.com/"

   # GCP — 测试元数据
   curl -s -H "Metadata-Flavor: Google" http://169.254.169.254/computeMetadata/v1/instance/service-accounts/default/token
   curl -s -H "Metadata-Flavor: Google" http://169.254.169.254/computeMetadata/v1/project/project-id
   ```

   若从 IMDS 获取到凭据,记录这些凭据提供的访问范围以及缺失的控制措施。除非获得明确授权,不要使用获取的凭据进行横向移动。

8. **验证、分段和报告**
   - 验证生产与非生产环境、管理平面和数据平面之间的网络分段。
   - 使用云服务商原生 CLI 命令重新核实高影响发现,排除工具误报。
   - 按类别汇总发现:
     - **IAM 和身份** — 过度授权的角色、权限提升路径、过期凭据。
     - **基础设施** — 暴露的管理端口、公开存储、缺少加密。
     - **Kubernetes** — CIS 基准失败项、RBAC 差距、Pod 安全违规。
     - **容器和镜像** — 严重 CVE、逃逸向量、镜像仓库暴露。
     - **无服务器和 CI/CD** — 明文密钥、过度授权的执行角色。
     - **元数据** — IMDS 暴露、凭据获取。
   - 按优先级排序:已证实的可利用发现优先,其次是确认的错误配置,最后是信息性发现。
   - 交叉参考 `reporting-workflow.md` 获取最终文档格式和交付要求。

   **零发现验证:** 当 prowler 或 ScoutSuite 报告零个高/严重发现时,不得未经验证就接受。至少手动确认:根/管理员 MFA 已启用、审计日志已激活、存储和数据库的静态加密已强制执行、没有 IAM 用户使用长期访问密钥进行控制台访问。记录每个手动验证步骤。

## 交叉引用

- `internal-network.md` — VPC 网络测试。
- `post-exploitation.md` — 容器逃逸利用。
- `source-code-audit.md` — CI/CD 流水线和 IaC 审查。
- `reporting-workflow.md` — 发现文档和交付。

## 预期产物

- 云账户/项目资产清单,包含服务商、区域和凭据范围。
- IAM 枚举结果:用户、角色、策略、权限提升路径和联合身份信任关系。
- 基础设施发现:安全组/NSG/防火墙审计、存储 ACL 结果、公开快照/AMI 暴露。
- Kubernetes 集群报告:`kube-bench` CIS 结果、`kubescape` 合规、RBAC 分析。
- 容器镜像漏洞结果、密钥发现、逃逸向量文档。
- 无服务器函数配置审计和 CI/CD 流水线安全审查。
- IMDS 访问测试结果和凭据获取证据。
- 按类别和严重程度组织的综合发现报告,含修复优先级。

## 停止条件

- 所有授权账户、集群、镜像、镜像仓库、函数、流水线和主机已完成评估。
- 后续工作需要写权限、修复操作或访问范围外的租户。
- 利用尝试已完成或未获授权,且所有发现已记录。
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: 472kUpdated Claude CodeCodexVerifiedInstall
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: 472kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 196kUpdated Claude CodeCodexVerifiedInstall