Ayush145906/security-account-scanner
GitHub: Ayush145906/security-account-scanner
Python CLI 工具,用于快速扫描 AWS 账户中常见的安全配置错误并生成结构化报告。
Stars: 0 | Forks: 0
# AWS 安全账户扫描器
一个 Python CLI 工具,用于扫描 AWS 账户中常见的安全配置错误,并将结果以彩色控制台表格和机器可读的 JSON 文件的形式输出。
由安全工程师构建,旨在加速临时账户审计。
## 检查内容
| 检查项 | 严重性 | 描述 |
|---|---|---|
| 公开的 S3 存储桶 | HIGH | 向 AllUsers/AuthenticatedUsers 授予 ACL 或公开的存储桶策略 |
| 未启用 MFA 的 IAM 控制台用户 | HIGH | 拥有控制台访问权限但没有 MFA 设备的用户 |
| 过期的 IAM 访问密钥 | MEDIUM | 超过 90 天的活动密钥 |
| 开放的安全组 | CRITICAL/HIGH | 0.0.0.0/0 上的所有流量或敏感端口 (22, 3389, 3306, 5432, 1433, 6379, 27017, 9200) |
| GuardDuty 启用情况 | MEDIUM | 各区域是否存在探测器 |
| Security Hub 启用情况 | MEDIUM | 各区域是否配置了 Hub |
## 环境要求
- Python 3.9+
- 通过 `aws configure` 或命名配置文件配置的 AWS 凭证
- IAM 权限:`s3:List*`, `iam:List*`, `iam:GetLoginProfile`, `ec2:DescribeSecurityGroups`, `guardduty:ListDetectors`, `securityhub:DescribeHub`
## 安装
```
git clone https://github.com//security-account-scanner.git
cd security-account-scanner
pip install -r requirements.txt
```
## 用法
```
# 默认:使用默认凭证扫描 us-east-1
python -m scanner
# 使用命名 profile 扫描多个区域
python -m scanner --profile my-profile --regions us-east-1,us-west-2,eu-west-1
# 自定义输出文件
python -m scanner --output my-account-report.json
```
## 示例输出
```
Security Findings (42)
┌──────────┬───────────────────────────────┬───────────────────────────────┐
│ Severity │ Resource │ Issue │
├──────────┼───────────────────────────────┼───────────────────────────────┤
│ CRITICAL │ sg/sg-xxxxxxxx (us-east-1) │ All traffic open to the world │
│ HIGH │ sg/sg-yyyyyyyy (us-east-1) │ SSH (port 22) open to world │
│ HIGH │ s3://my-bucket │ Public ACL grant: READ to ... │
│ MEDIUM │ iam-user/old-user │ Access key AKIA... is 412 ... │
└──────────┴───────────────────────────────┴───────────────────────────────┘
```
## 架构
每项检查都位于 `scanners/` 目录下的独立模块中,遵循简单的接口规范:
- 全局扫描器 (S3, IAM):`scan(session) -> list[Finding]`
- 区域范围的扫描器 (EC2, GuardDuty, Security Hub):`scan(session, region) -> list[Finding]`
只需在 `scanners/` 中放入新模块并进行注册,即可添加新的检查。
## 项目结构
```
security-scanner/
├── scanner/__main__.py # CLI entry point
├── scanners/
│ ├── s3.py
│ ├── iam.py
│ ├── security_groups.py
│ └── detective_services.py
├── requirements.txt
├── LICENSE
└── README.md
```
## 规范
完整的需求记录在 [`docs/requirements.md`](docs/requirements.md) 中。该规范涵盖了以 EARS (Easy Approach to Requirements Syntax) 格式编写的 12 项可测试需求。
## 许可证
MIT — 详见 [LICENSE](LICENSE)。
标签:AWS, AWS安全审计, CSPM, DevSecOps, DPI, GuardDuty, IAM配置, MFA验证, Python, Python 3.9, S3存储桶, Security Hub, TinkerPop, 上游代理, 云基础设施安全, 云安全态势管理, 前端应用, 安全基线, 安全工程师, 安全组检测, 对称加密, 开源安全工具, 教学环境, 无后门, 网络安全, 自动化审计, 逆向工具, 逆向工程平台, 隐私保护