capture0x/aws-pentest

GitHub: capture0x/aws-pentest

专业 AWS 渗透测试框架,集 IAM 权限提升检测、S3 配置错误分析、资源枚举与利用辅助于一体。

Stars: 0 | Forks: 0

# AWS 渗透测试工具 **专业 AWS 安全审计与利用框架** ![Python](https://python.org) ![License](https://raw.githubusercontent.com/capture0x/aws-pentest/main/LICENSE) AWS Pentest Agent 是一款专业的安全审计工具,用于执行 IAM 权限提升检测、S3 存储桶配置错误分析、计算资源枚举以及日志配置态势评估。 ## ✨ 功能特性 - **IAM 权限提升检测** – 通配符策略,危险操作(CreateAccessKey、AssumeRole、PassRole) - **S3 配置错误分析** – 公共读写、网站托管劫持风险 - **多区域计算资源枚举** – EC2、Lambda、SSM 管理的实例 - **网络暴露分析** – 存在管理端口暴露的安全组 - **日志与检测态势** – CloudTrail、AWS Config、GuardDuty 状态 - **专业 Markdown 报告** – 执行摘要 + 详细发现 - **利用辅助工具** – 可直接运行的 AWS CLI PoC 命令 ## 🚀 快速开始 ``` # 1. 克隆与安装 git clone https://github.com/capture0x/aws-pentest.git cd aws-pentest python3 -m venv venv source venv/bin/activate # Linux/Mac # venv\\Scripts\\activate # Windows pip install -r requirements.txt # 2. 配置凭证 python3 aws_agent.py configure # 3. 全面审计 python3 aws_agent.py audit # 4. 针对性利用 python3 aws_agent.py exploit-iam --auto-assume-role python3 aws_agent.py exploit-s3 ``` ## 📋 命令 | 命令 | 描述 | 示例 | |------------------|-----------------------------------------------|----------------------------------------------------------| | `audit` | 运行云审计并生成摘要报告 | `python3 aws_agent.py audit --mode all` | | `exploit-iam` | IAM 权限提升分析 | `python3 aws_agent.py exploit-iam --identity user/pentest-user` | | `exploit-s3` | S3 存储桶配置错误提示 | `python3 aws_agent.py exploit-s3 --bucket my-bucket` | | `backdoor-create`| 创建持久化 IAM 管理员后门 | `python3 aws_agent.py backdoor-create` | | `configure` | 将 AWS 凭证存储在 .env 中 | `python3 aws_agent.py configure` | ### 审计模式 ``` python3 aws_agent.py audit --mode recon # Fast enumeration (default) python3 aws_agent.py audit --mode loot # Sensitive data extraction python3 aws_agent.py audit --mode all # Full scan python3 aws_agent.py audit --regions us-east-1,eu-west-1 # Specific regions ``` ## 🖼️ 截图画廊
### 🔍 **进度与分析** | 审计仪表盘 | IAM 权限提升 | S3 存储桶扫描器 | |---------------|-------------------------|-------------------| | ![1. Audit Progress](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/ec7cc56d30182316.png)
*侦察模式仪表盘 + 进度条* | ![2. IAM Privesc](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/b9a8abe45c182325.png)
*检测到高风险 IAM 策略* | ![3. S3 Scanner](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/2facfd6986182334.png)
*存储桶枚举 + 风险分析* | ### ⚡ **利用与报告** | 后门创建器 | 执行报告 | CLI 输出 | |------------------|------------------|------------| | ![4. Backdoor](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/a32f9b6860182344.png)
*持久化 IAM 管理员警告提示* | ![5. Report](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/241c3fd32e182354.png)
*专业 Markdown 审计报告* | ![6. Terminal](https://static.pigsec.cn/wp-content/uploads/repos/2026/03/3165c4cea9182404.png)
*带颜色的汇总表 + 发现结果* |

**💡 截图描述:** - **1_audit_dashboard.png**: 完整的侦察扫描进度 + 服务枚举 - **2_iam_privesc.png**: AdministratorAccess 策略 + AssumeRole 风险 - **3_s3_scanner.png**: 公共存储桶检测 + 网站劫持分析 - **4_backdoor_create.png**: 实时 IAM 后门创建确认 - **5_exec_report.png**: 执行摘要 + 详细发现 Markdown - **6_cli_output.png**: Rich 终端表格 + 带颜色的风险指标 ## 📊 示例输出 ### 控制台摘要 ``` Audit Summary ┏━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┓ ┃ Module ┃ Count / Status ┃ ┡━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━┩ │ IAM Users │ 2 │ │ IAM Roles │ 3 │ │ S3 Buckets │ 1 (0 Public) │ │ EC2 Instances │ 0 │ │ Lambda Functions │ 0 │ │ SG Admin Ports Exposed │ 0 │ └────────────────────────┴────────────────┘ ``` ### 示例报告发现 ``` ## 执行摘要 - Detected 11 high/medium-high risk issues - IAM: 2 AdministratorAccess policies detected - Logging: No CloudTrail trails configured - Detection: GuardDuty disabled ``` ## ⚠️ 安全警告 1. **`backdoor-create`**: 创建 **真实的** IAM 管理员用户和访问密钥。 2. **`exploit-iam --auto-assume-role`**: 尝试实时 STS AssumeRole 调用。 3. **生产环境使用**: 请仅在您拥有或已获得明确许可的账户上使用。 ## 🛠️ 环境要求 ``` pip install click rich python-dotenv boto3 botocore ``` ## 📁 项目结构 ``` aws-pentest/ ├── aws_agent.py # Main CLI entrypoint ├── core/ # Core modules │ ├── session_manager.py │ ├── orchestrator.py │ ├── reporter.py │ └── logging.py ├── modules/ # Service modules │ ├── iam.py │ ├── s3.py │ └── compute.py ├── reports/ # Generated reports └── requirements.txt ``` ## 🎯 使用示例 ``` # 1. 初始侦察 python3 aws_agent.py audit --mode recon # 2. IAM 权限提升搜寻 python3 aws_agent.py exploit-iam --auto-assume-role # 3. S3 bucket 分析 python3 aws_agent.py exploit-s3 --bucket sensitive-data-backup # 4. 指定区域全面评估 python3 aws_agent.py audit --mode all --regions us-east-1,eu-west-1,ap-southeast-2 # 5. 创建持久化后门 (危险!) python3 aws_agent.py backdoor-create --user-name pentest-backdoor-2026 ``` ## 🔍 检测到的问题与利用路径 | 发现结果 | 严重程度 | 利用示例 | |---------------------------------|-----------:|-------------------------------------------------------------| | `AdministratorAccess` 策略 | 严重 (Critical) | `aws iam create-user --user-name backdoor` | | S3 公共读取 | 高危 | `aws s3 sync s3://bucket ./loot/` | | S3 网站 + 公共写入 | 严重 | `aws s3 cp evil.js s3://bucket/index.html` | | `sts:AssumeRole` 权限 | 高危 | 实时权限提升尝试 | | `iam:PassRole` + EC2 | 高危 | 用于持久化的恶意实例配置文件 | ## 📈 路线图 - [x] IAM 权限提升检测 - [x] S3 配置错误分析 - [x] 多区域计算资源枚举 - [x] 网络安全组分析 - [x] 日志与检测态势 - [ ] RDS/KMS 枚举 - [ ] Lambda 函数分析 - [ ] EKS / Kubernetes 安全 - [ ] CloudTrail 数据渗透分析 ## 🤝 参与贡献 1. Fork 本仓库 2. 创建功能分支:`git checkout -b feature/new-module` 3. 提交:`git commit -m "Add RDS module"` 4. 推送并打开一个 Pull Request ## 📄 许可证 MIT 许可证 – 详见 `LICENSE` 文件。 ## 🙏 致谢 专为安全研究人员、红队和 AWS 渗透测试人员构建。
标签:AWS, CloudTrail 审计, DPI, EC2 枚举, IAM 提权, Lambda 安全, PoC 利用, Python, S3 漏洞挖掘, 云环境侦察, 协议分析, 图计算, 攻击框架, 无后门, 权限提升, 网络安全, 足迹分析, 逆向工具, 配置错误检测, 隐私保护