awslabs/aws-cloudsaga
GitHub: awslabs/aws-cloudsaga
AWS CloudSaga 是一个用于在 AWS 环境中模拟安全事件以测试安全控制和事件响应能力的工具。
Stars: 475 | Forks: 38
# AWS CloudSaga - 在 AWS 中模拟安全事件
AWS CloudSaga 供客户测试其 Amazon Web Services (AWS) 环境中的安全控制措施和警报,使用基于 AWS 客户事件响应团队 (CIRT) 观察到的安全事件生成的警报。
## 用例
AWS 已发布安全控制措施和最佳实践以保障账户安全,然而,客户需要机制来测试其 AWS 环境中的安全性和事件响应能力,以保护自己免受已知安全事件的影响。
AWS CloudSaga 适用于希望针对 AWS CIRT 记录的安全事件测试其环境的客户。使用 AWS CloudSaga,可以针对客户环境运行模拟真实安全事件的简单场景,测试当这些事件发生时客户的响应计划和防御能力,并根据结果改进其 AWS 环境的防御。
## 使用方法
```
cloudsaga
___ ____ __ ____ _______.
/ \ \ \ / \ / / / |
/ ^ \ \ \/ \/ / | (----`
/ /_\ \ \ / \ \
/ _____ \ \ /\ / .----) |
/__/ \__\ \__/ \__/ |_______/
______ __ ______ __ __ _______ _______. ___ _______ ___
/ || | / __ \ | | | | | \ / | / \ / _____| / \
| ,----'| | | | | | | | | | | .--. | | (----` / ^ \ | | __ / ^ \
| | | | | | | | | | | | | | | | \ \ / /_\ \ | | |_ | / /_\ \
| `----.| `----.| `--' | | `--' | | '--' |.----) | / _____ \ | |__| | / _____ \
\______||_______| \______/ \______/ |_______/ |_______/ /__/ \__\ \______| /__/ \__\
Joshua "DozerCat" McKiddy - Team DragonCat - AWS
Type -h for help.
usage: cloudsaga [-h] [--scenario SCENARIO] [--chapters] [--about ABOUT]
CloudSaga - Simulate security events based on previous Ziplines
optional arguments:
-h, --help show this help message and exit
--scenario SCENARIO Perform the scenario you want to run against your AWS
environment.
--chapters List the available scenarios within CloudSaga. Use the
--about flag to read details about a specific scenario.
--about ABOUT Read about a specific scenario (e.g. --about
. For a list of available scenarios, use the
--chapters flag.
```
## 前提条件
### 权限
在 AWS IAM 中需要以下权限才能运行 CloudSaga:
* 对于 imds-reveal:
```
"ec2:DescribeInstances"
```
* 对于 network-changes:
```
"ec2:DescribeInstances",
"ec2:RunInstances",
"ec2:CreateVpc",
"ec2:DescribeVpcs",
"ec2:CreateSecurityGroup"
```
* 对于 mining-bitcoin:
```
"ec2:DescribeInstances",
"ec2:RunInstances"
```
* 对于 iam-credentials:
```
"iam:GenerateCredentialReport",
"iam:GetCredentialReport"
```
* 对于 public-resources:
```
"rds:DescribeDBInstances",
"rds:CreateDBInstance",
"rds:DeleteDBInstance",
"s3:ListBuckets",
"s3:CreateBucket",
"s3:PutPublicAccessBlock",
"s3:DeletePublicAccessBlock"
```
## 具体场景详情
```
IMDS Reveal Scenario:
This scenario is based on a server-side request forgery attack.
EC2 instances using IMDS version 1 are more likely to be subject to this
kind of software flaw, and if EC2 Role credentials are present, those
credentials can be used in AWS.
```
```
Bitcoin Mining Scenario:
This scenario simulates the creation of Bitcoin mining instances.
Attackers attempt to create Bitcoin mining instances using Amazon EC2,
in order to leverage legitimate AWS customer's resources for their own purposes.
```
```
Network Changes Scenario:
This scenario simulates the creation and modification of network resources within
AWS. This includes creating Amazon VPCs, as well as modifications to Security Groups,
for the purposes of compromising resources within the AWS account.
```
```
IAM Credentials Scenario:
This scenario attempts to grab the IAM credential report within the AWS account.
```
```
Publicly Accessible Resources Scenario:
This scenario is for creating then checking for publicly accessible resources within an AWS account.
```
## 运行代码
当前形式的代码可以在以下环境中运行:
* AWS CloudShell(首选)
* 本地运行(需要 IAM 凭证,非首选)
## 前提条件
使用 AWS CloudSaga 需要以下前提条件:
* Python 3.7 或更高版本
* boto3 1.21.7 或更高版本
* pip3(用于安装 AWS CloudSaga)
## 安装代码
代码通过 pip3 安装:
```
pip3 install cloudsaga
```
## 分步说明(在 AWS CloudShell 中运行)
1. 登录到您要运行 AWS CloudSaga 的账户的 AWS 控制台。
2. 点击搜索栏旁边的 AWS CloudShell 图标。
* 确保您所在的区域当前支持 AWS CloudShell。
3. 会话开始后,通过 pip3 安装 AWS CloudSaga:
```
pip3 install cloudsaga
```
4. 安装完成后,运行以下命令查看 AWS CloudSaga 的帮助页面。
```
cloudsaga -h
```
5. 浏览场景,选择您要运行以生成安全事件进行测试的场景。
### 日志记录
一个包含操作详细输出的日志文件将放置在 AWS CloudSaga 的根目录中。文件格式为 cloudsaga_此处为时间戳.log
日志文件中的示例输出:
```
2022-02-22 01:20:47,826 - INFO - --Checking instances in AWS region me-south-1--
2022-02-22 01:20:47,826 - INFO - DescribeInstances API Call in AWS region me-south-1--
2022-02-22 01:20:48,712 - INFO - You cannot perform lookup of IMDS versions in this region. Error message below:
2022-02-22 01:20:48,712 - ERROR - An error occurred (AuthFailure) when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials
2022-02-22 01:20:48,713 - INFO - --Checking instances in AWS region sa-east-1--
2022-02-22 01:20:48,713 - INFO - DescribeInstances API Call in AWS region sa-east-1--
2022-02-22 01:20:49,525 - INFO - --Checking instances in AWS region us-east-1--
2022-02-22 01:20:49,525 - INFO - DescribeInstances API Call in AWS region us-east-1--
2022-02-22 01:20:49,876 - INFO - --Checking instances in AWS region us-east-2--
2022-02-22 01:20:49,876 - INFO - DescribeInstances API Call in AWS region us-east-2--
2022-02-22 01:20:50,192 - INFO - --Checking instances in AWS region us-west-1--
2022-02-22 01:20:50,192 - INFO - DescribeInstances API Call in AWS region us-west-1--
2022-02-22 01:20:50,444 - INFO - --Checking instances in AWS region us-west-2--
2022-02-22 01:20:50,445 - INFO - DescribeInstances API Call in AWS region us-west-2--
2022-02-22 01:20:50,610 - INFO - Instance ID i-99999999999999999 is using IMDSv1, where no authentication header is required to access the IMDS service.
```
## 清理
启用日志后,您可以安全地从 AWS CloudShell 中删除任何下载的文件。
* 注意:包含操作详细输出的日志文件将位于 AWS CloudSaga 的根目录中。如果您想保留此文件,请将其下载到安全位置,可以是本地或 Amazon S3 存储桶,以供记录。有关如何从 AWS CloudShell 会话下载文件的信息,请参阅以下[链接](https://docs.aws.amazon.com/cloudshell/latest/userguide/working-with-cloudshell.html#files-storage)。
## 反馈
请使用 Issues 部分提交任何反馈,例如功能或建议,以及遇到的任何错误。
## 安全性
有关更多信息,请参阅[贡献指南](CONTRIBUTING.md#security-issue-notifications)。
## 许可证
本项目根据 Apache-2.0 许可证获得许可。
标签:AWS安全, AWS环境, 云计算, 安全事件模拟, 安全控制测试, 安全模拟, 安全测试, 客户安全, 攻击性安全, 模拟工具, 测试框架, 规则引擎, 逆向工具