Mihirajmera/guardduty-siem-automation

GitHub: Mihirajmera/guardduty-siem-automation

基于 AWS GuardDuty、EventBridge 和 Lambda 构建的企业级 SIEM 解决方案,实现威胁检测、自动隔离受损实例与实时告警的全流程安全事件自动化响应。

Stars: 0 | Forks: 0

# 🛡️ GuardDuty SIEM 与事件响应自动化 企业级安全信息与事件管理 (SIEM) 解决方案,具备自动化事件响应、威胁检测和实时安全监控功能 ## 🎯 项目概述 本项目使用 AWS GuardDuty、CloudTrail 和 EventBridge 实现了一套全面的安全信息与事件管理 (SIEM) 解决方案。它具有由 Lambda 函数驱动的自动化事件响应功能,可以隔离受损的 EC2 实例,并通过 SNS 发送实时警报。该解决方案还包含一个可选的 React 仪表板,用于安全监控和日志分析。 ## 🏆 主要成就 - ✅ 自动化威胁检测 - 带有恶意软件防护的 GuardDuty - ✅ 实时事件响应 - 自动隔离受损实例 - ✅ 全面日志记录 - 集成 CloudTrail 和 CloudWatch - ✅ 事件驱动架构 - 使用 EventBridge 进行安全事件路由 - ✅ 安全仪表板 - 基于 React 的 SIEM 监控界面 ## 🏗️ 架构图 ``` graph TD classDef source fill:#e1f5fe,stroke:#0288d1,stroke-width:2px; classDef router fill:#fff9c4,stroke:#fbc02d,stroke-width:2px; classDef action fill:#e8f5e9,stroke:#388e3c,stroke-width:2px; GD[GuardDuty
Threat Detection] --> EB CT[CloudTrail
API Activity Logging] --> EB CW[CloudWatch
Logs Monitoring] --> EB subgraph Router [EventBridge Router] EB{Severity Routing} EB -->|High| Q[Quarantine] EB -->|Medium| A[Alert] EB -->|Low| L[Log] end Q --> Lambda[Lambda
Quarantine Function] A --> SNS[SNS
Alert Notifications] L --> Dash[React Dashboard
SIEM UI] class GD,CT,CW source; class EB,Q,A,L router; class Lambda,SNS,Dash action; ``` ## 🔀 事件响应序列 ``` sequenceDiagram participant GD as GuardDuty participant EB as EventBridge participant L as Lambda (Quarantine) participant EC2 as EC2 Instance participant SNS as SNS GD->>EB: Finding published (severity: HIGH) EB->>L: Route to quarantine function L->>EC2: modify_instance_attribute(sg=quarantine) L->>SNS: Publish incident notification SNS-->>GD: (async) Security team alerted Note over L,EC2: Instance isolated in ~seconds,
no manual intervention required ``` ## 🚀 功能与技术 ### 🛡️ 安全功能 - 威胁检测 - 具备恶意软件防护和威胁情报的 GuardDuty - 自动化响应 - 用于即时事件响应的 Lambda 函数 - 实时警报 - 针对安全事件的 SNS 通知 - 日志聚合 - 使用 CloudWatch 进行集中式日志记录 - API 监控 - 使用 CloudTrail 进行完整的 API 活动跟踪 ### 🛠️ AWS 服务集成 - GuardDuty - 威胁检测和安全监控 - CloudTrail - API 活动记录和审计跟踪 - EventBridge - 事件路由和处理 - Lambda - Serverless 事件响应自动化 - SNS - 实时警报通知 - CloudWatch - 日志聚合和监控 ### 📊 监控与分析 - 安全仪表板 - 基于 React 的 SIEM 界面 - 威胁情报 - GuardDuty 发现与分析 - 事件时间线 - 自动化响应跟踪 - 日志分析 - CloudWatch 日志洞察与查询 ## 🏃‍♂️ 快速开始 ### 前置条件 - Terraform >= 1.7 - 已配置 AWS CLI - Node.js >= 16(用于 React 仪表板) - 拥有 GuardDuty 和 Config 权限的 AWS 账户 ### 🚀 部署 **克隆并导航** ``` git clone cd guardduty-siem ``` **部署基础设施** ``` # 初始化 Terraform terraform init # 计划 deployment terraform plan # 应用更改 terraform apply -auto-approve ``` **部署 React 仪表板(可选)** ``` cd react-dashboard npm install npm start ``` **验证部署** ``` # 检查 GuardDuty 状态 aws guardduty list-detectors # 检查 EventBridge 规则 aws events list-rules # 检查 Lambda 函数 aws lambda list-functions ``` ### 🧹 清理 ``` terraform destroy -auto-approve ``` ## 💰 成本分析 | 资源 | 月度成本 | 用途 | |---|---|---| | GuardDuty | ~$30 | 威胁检测(前 30 天免费) | | CloudTrail | ~$2 | API 活动记录 | | EventBridge | ~$1 | 事件路由 | | Lambda | ~$0.20 | 事件响应自动化 | | SNS | ~$0.50 | 警报通知 | | CloudWatch | ~$3 | 日志存储和监控 | | **总计** | **~$37** | 完整的 SIEM 解决方案 | 💡 **成本优化**:GuardDuty 提供 30 天免费试用;大部分成本来自于日志存储 ## 🔧 配置 ### 变量 (terraform.tfvars) ``` # 项目配置 project_name = "guardduty-siem" environment = "dev" # GuardDuty 配置 enable_malware_protection = true enable_s3_protection = true enable_kubernetes_protection = true # 通知配置 alert_email = "security@company.com" slack_webhook_url = "https://hooks.slack.com/..." # Auto-remediation 配置 enable_auto_quarantine = true quarantine_security_group_id = "sg-xxxxxxxxx" ``` ### EventBridge 规则 - **高严重性** - 自动隔离受损实例 - **中严重性** - 发送即时警报 - **低严重性** - 记录日志以供分析 ## 📁 项目结构 ``` guardduty-siem/ ├── versions.tf # Terraform and provider versions ├── providers.tf # AWS provider configuration ├── variables.tf # Input variables ├── guardduty.tf # GuardDuty detector configuration ├── cloudtrail.tf # CloudTrail logging setup ├── eventbridge-pipeline.tf # Event routing and processing ├── lambda-quarantine.tf # Auto-quarantine Lambda function ├── lambda-logger.tf # Logging Lambda function ├── outputs.tf # Terraform outputs ├── react-dashboard/ # SIEM monitoring dashboard │ ├── package.json # Node.js dependencies │ ├── src/App.js # React application │ └── src/App.css # Dashboard styling └── README.md # This file ``` ## 🎓 学习成果 本项目展示了对以下内容的掌握: ### 🛡️ 安全运营 - SIEM 实施 - 安全信息与事件管理 - 威胁检测 - GuardDuty 威胁情报与分析 - 事件响应 - 自动化安全事件处理 - 安全监控 - 实时威胁检测与警报 ### 🔄 自动化与编排 - 事件驱动架构 - 使用 EventBridge 处理安全事件 - Serverless 自动化 - 用于事件响应的 Lambda 函数 - 工作流自动化 - 自动化威胁响应工作流 - 集成模式 - AWS 服务集成与编排 ### 📊 监控与分析 - 日志聚合 - 集中式安全日志记录 - 威胁情报 - GuardDuty 发现与分析 - 仪表板开发 - 基于 React 的安全监控 - 警报管理 - SNS 通知系统 ### 🏢 企业安全 - 合规性监控 - 安全合规与审计跟踪 - 风险管理 - 威胁评估与缓解 - 安全运营中心 (SOC) - 安全监控实践 - 事件管理 - 安全事件响应程序 ## 🚀 未来增强功能 - 机器学习 - 自定义威胁检测模型 - 威胁狩猎 - 高级威胁追踪能力 - 集成 - 第三方 SIEM 集成 (Splunk, QRadar) - 移动应用 - 安全警报移动应用程序 - 高级分析 - 安全指标与报告 - 合规报告 - 自动化合规报告 ## 🔧 Lambda 函数 ### 自动隔离功能 ``` import json import boto3 def lambda_handler(event, context): """ Automatically quarantines EC2 instances based on GuardDuty findings """ ec2 = boto3.client('ec2') # Extract instance ID from GuardDuty finding instance_id = event['detail']['service']['resourceRoleDetails']['accessKeyDetails']['principalId'] # Apply quarantine security group response = ec2.modify_instance_attribute( InstanceId=instance_id, Groups=['sg-quarantine'] ) return { 'statusCode': 200, 'body': json.dumps(f'Instance {instance_id} quarantined successfully') } ``` ### 日志记录功能 ``` import json import boto3 def lambda_handler(event, context): """ Logs security events to CloudWatch for analysis """ cloudwatch = boto3.client('cloudwatch') # Log security event cloudwatch.put_metric_data( Namespace='Security/SIEM', MetricData=[ { 'MetricName': 'SecurityEvent', 'Value': 1, 'Unit': 'Count', 'Dimensions': [ { 'Name': 'Severity', 'Value': event['detail']['severity'] } ] } ] ) return {'statusCode': 200} ``` ## 📄 许可证 本项目基于 MIT 许可证授权 - 有关详细信息,请参阅 LICENSE 文件。 ## 👨‍💻 作者 **Mihir Ajmera** — GRC 工程师与云安全 - LinkedIn: [Mihir Ajmera](https://linkedin.com/in/mihirajmera) - GitHub: [Mihirajmera](https://github.com/Mihirajmera) - Email: ajmera.mihir.79@gmail.com ⭐ 如果您觉得本项目有帮助,请给本仓库点个 Star! *本项目展示了企业级 SIEM 的实施和自动化事件响应 — 展现了应对技术面试的安全运营专业技能。*
标签:AMSI绕过, AWS, DPI, MITM代理, PB级数据处理, SIEM系统, 威胁检测, 安全运维, 自动化响应, 逆向工具, 速率限制