IbaadShaikh/aws-cloud-threat-detection-lab
GitHub: IbaadShaikh/aws-cloud-threat-detection-lab
基于 AWS 安全服务构建的云原生威胁检测与自动化修复实验平台,演示从检测、路由到响应的完整安全运营工作流。
Stars: 0 | Forks: 0
# AWS 云威胁检测实验
## 项目概述
本项目演示了一个基于 AWS 构建的云原生威胁检测和自动化响应工作流。该实验使用 AWS 安全服务来检测可疑活动,通过 EventBridge 路由调查结果,通过 SNS 发送警报,并触发 Lambda 函数执行自动化修复操作。
该项目的目标是展示云安全团队如何结合检测工程、事件响应、Infrastructure-as-Code 和自动化,以提高 AWS 环境中的可见性并缩短响应时间。
## 功能
- 云原生威胁检测工作流
- 事件驱动的安全自动化
- Terraform 和 CloudFormation 部署
- 基于 Lambda 的修复
- GuardDuty 和 Security Hub 集成
- SNS 警报通知
- CloudTrail 审计日志
## 架构概述
```
CloudTrail / GuardDuty / Security Hub
↓
Amazon EventBridge Rules
↓
AWS Lambda Remediation Function
↓
Amazon SNS Email Alerts
```
该工作流旨在模拟一个云原生安全运营 pipeline:
- CloudTrail 记录 AWS API 活动
- GuardDuty 检测可疑行为
- Security Hub 集中处理安全调查结果
- EventBridge 匹配安全调查结果
- Lambda 执行自动化修复逻辑
- SNS 发送电子邮件警报通知
## 架构图

## 使用的 AWS 服务
- AWS CloudTrail
- Amazon GuardDuty
- AWS Security Hub
- Amazon EventBridge
- AWS Lambda
- Amazon SNS
- AWS IAM
- Amazon CloudWatch
- Amazon S3
## 使用的技术
- AWS
- Terraform
- CloudFormation
- Python
- Infrastructure-as-Code (IaC)
- 事件驱动架构
- 安全自动化
## 演示的关键安全概念
- 云威胁检测
- 事件驱动的安全自动化
- GuardDuty 调查结果响应
- Security Hub 警报聚合
- IAM 最小权限
- 自动化事件响应
- CloudTrail 审计日志
- SNS 警报
- 基于 Lambda 的修复
- Infrastructure-as-Code 部署
## 仓库结构
```
aws-cloud-threat-detection-lab/
│
├── README.md
│
├── cloudformation/
│ └── aws-threat-detection-lab.yaml
│
├── terraform/
│ ├── README.md
│ ├── main.tf
│ ├── provider.tf
│ ├── variables.tf
│ ├── outputs.tf
│ ├── terraform.tfvars
│ └── lambda/
│ └── remediation_function.py
│
├── architecture/
│ └── aws-threat-detection-architecture.png
│
├── lambda/
│ └── remediation_function.py
│
├── screenshots/
│ ├── cloudformation-stack.png
│ ├── cloudtrail-events.png
│ ├── cloudwatch-logs.png
│ ├── eventbridge-rule.png
│ ├── guardduty-findings.png
│ ├── lambda-remediation.png
│ ├── security-hub.png
│ └── sns-alert.png
│
├── policies/
│ └── lambda-remediation-policy.json
│
└── .gitignore
```
## Lambda 修复逻辑
包含的 Lambda 函数会解析 GuardDuty 和 Security Hub 的调查结果,提取关键事件详细信息,记录事件,并通过 SNS 发布通知。
潜在的修复操作包括:
- 隔离可疑的 EC2 实例
- 禁用暴露的 IAM 访问密钥
- 移除公开的 S3 存储桶权限
- 为可疑资源添加标签以进行调查
- 创建事件响应工单
## 检测流程示例
### 场景
GuardDuty 生成了一个可疑的 AWS 活动调查结果。
### 检测
GuardDuty 创建调查结果并将其发送到 EventBridge。
### 路由
EventBridge 匹配调查结果模式并触发 Lambda 修复函数。
### 响应
Lambda 记录调查结果详细信息并发布 SNS 警报。
### 通知
SNS 将警报发送到已订阅的电子邮件 endpoint。
# CloudFormation 部署
本仓库包含一个 CloudFormation 部署选项:
```
cloudformation/aws-threat-detection-lab.yaml
```
CloudFormation 模板部署了:
- SNS 主题和电子邮件订阅
- Lambda 修复函数
- IAM 角色和权限
- EventBridge 规则
- 可选的 CloudTrail 路径和加密 S3 日志存储桶
### 使用 AWS Console 部署
1. 打开 AWS CloudFormation
2. 选择 Create Stack
3. 上传 aws-threat-detection-lab.yaml
4. 输入您的电子邮件地址以接收警报
5. 确认 SNS 订阅电子邮件
### 使用 AWS CLI 部署
```
aws cloudformation create-stack \
--stack-name aws-cloud-threat-detection-lab \
--template-body file://cloudformation/aws-threat-detection-lab.yaml \
--parameters ParameterKey=AlertEmail,ParameterValue=your-email@example.com \
--capabilities CAPABILITY_NAMED_IAM
```
# Terraform 部署
本仓库还包含一个 Terraform 部署选项:
```
terraform/
```
Terraform 部署提供:
- GuardDuty detector
- Security Hub 集成
- SNS 警报
- Lambda 修复函数
- IAM 角色和策略
- EventBridge 规则
- 可选的 CloudTrail 日志记录基础设施
### 使用 Terraform 部署
1. 导航到 Terraform 文件夹
```
cd terraform
```
2. 初始化 Terraform
```
terraform init
```
3. 审查执行计划
```
terraform plan
```
4. 部署基础设施
```
terraform apply
```
5. 确认 SNS 电子邮件订阅
## 截图
### GuardDuty 调查结果

### EventBridge 规则

### Lambda 修复函数

### CloudWatch 日志

### CloudTrail 事件历史

### CloudFormation Stack 部署

### SNS 警报配置

## 未来改进
- 添加自动化 EC2 隔离工作流
- 添加 Slack 或 Microsoft Teams 警报
- 通过 Jira 或 ServiceNow 添加工单创建
- 添加 Security Hub 自定义操作
- 添加 AWS Config 合规规则
- 添加 CloudWatch 安全仪表板
## 作者
**Ibaad Shaikh**
标签:AMSI绕过, AWS, DPI, ECS, Terraform, 事件驱动架构, 威胁检测, 漏洞利用检测, 漏洞探索, 自动化响应, 逆向工具