From 0ee4a8767f91d3da40ebaf81029f0f421d578c83 Mon Sep 17 00:00:00 2001 From: Translator Date: Thu, 12 Feb 2026 12:47:03 +0000 Subject: [PATCH] Translated ['src/pentesting-cloud/aws-security/aws-post-exploitation/aws --- .../aws-ses-post-exploitation/README.md | 30 ++++-- .../aws-workmail-post-exploitation/README.md | 76 +++++++++++++++ .../aws-security/aws-services/aws-iam-enum.md | 94 +++++++++++-------- 3 files changed, 150 insertions(+), 50 deletions(-) create mode 100644 src/pentesting-cloud/aws-security/aws-post-exploitation/aws-workmail-post-exploitation/README.md diff --git a/src/pentesting-cloud/aws-security/aws-post-exploitation/aws-ses-post-exploitation/README.md b/src/pentesting-cloud/aws-security/aws-post-exploitation/aws-ses-post-exploitation/README.md index d4e332df5..32e92b4ad 100644 --- a/src/pentesting-cloud/aws-security/aws-post-exploitation/aws-ses-post-exploitation/README.md +++ b/src/pentesting-cloud/aws-security/aws-post-exploitation/aws-ses-post-exploitation/README.md @@ -4,7 +4,7 @@ ## SES -更多信息请参见: +更多信息,请查看: {{#ref}} ../../aws-services/aws-ses-enum.md @@ -25,7 +25,7 @@ aws sesv2 send-email --from sender@example.com --destination file://emails.json ```bash aws ses send-raw-email --raw-message file://message.json ``` -尚待测试。 +仍待测试。 ### `ses:SendTemplatedEmail` @@ -37,33 +37,45 @@ aws ses send-templated-email --source --destination --template ### `ses:SendBulkTemplatedEmail` -向多个目的地发送电子邮件 +向多个收件人发送电子邮件 ```bash aws ses send-bulk-templated-email --source --template ``` -仍待测试。 +尚待测试。 ### `ses:SendBulkEmail` -向多个目标发送电子邮件。 +向多个目标发送邮件。 ``` aws sesv2 send-bulk-email --default-content --bulk-email-entries ``` ### `ses:SendBounce` -对已接收的邮件发送一封**退信**(表示该邮件无法投递)。这只能在接收邮件后**最多24小时内**完成。 +对已接收的邮件发送**退信**(表示该邮件无法被接收)。这只能在收到邮件后的**24 小时内**完成。 ```bash aws ses send-bounce --original-message-id --bounce-sender --bounced-recipient-info-list ``` -仍需测试。 +尚待测试。 ### `ses:SendCustomVerificationEmail` -这将发送一个自定义的验证电子邮件。你可能还需要权限来创建模板电子邮件。 +这将发送一封自定义的验证邮件。你可能还需要权限来创建邮件模板。 ```bash aws ses send-custom-verification-email --email-address --template-name aws sesv2 send-custom-verification-email --email-address --template-name ``` -尚待测试。 +仍待测试。 + +## WorkMail pivot 绕过 SES sandbox + +当 `ses:GetAccount` 显示账户仍在 SES sandbox 中且 `ses:ListIdentities` 未返回任何已验证的发件人时,攻击者可以 **pivot to WorkMail** 来立即发送(不受 sandbox 限制且默认配额更高),方法是创建组织(orgs)、验证域名并注册邮箱。 + +{{#ref}} +../aws-workmail-post-exploitation/README.md +{{#endref}} + +## 参考资料 + +- [Threat Actors Using AWS WorkMail in Phishing Campaigns](https://www.rapid7.com/blog/post/dr-threat-actors-aws-workmail-phishing-campaigns) {{#include ../../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/aws-security/aws-post-exploitation/aws-workmail-post-exploitation/README.md b/src/pentesting-cloud/aws-security/aws-post-exploitation/aws-workmail-post-exploitation/README.md new file mode 100644 index 000000000..67bf5f7be --- /dev/null +++ b/src/pentesting-cloud/aws-security/aws-post-exploitation/aws-workmail-post-exploitation/README.md @@ -0,0 +1,76 @@ +# AWS - WorkMail Post Exploitation + +{{#include ../../../../banners/hacktricks-training.md}} + +## 利用 WorkMail 绕过 SES sandbox + +Even if SES is stuck in the **sandbox** (verified-recipient only, ~200 msgs/24h, 1 msg/s), WorkMail has no equivalent restriction. 攻击者如果拥有长期密钥,可以快速部署一次性邮件基础设施并立即开始发送: + +1. **创建一个 WorkMail 组织(按区域)** +```bash +aws workmail create-organization --region us-east-1 --alias temp-mail --directory-id +``` +2. **验证攻击者控制的域名** (WorkMail invokes SES APIs as `workmail.amazonaws.com`): +```bash +aws ses verify-domain-identity --domain attacker-domain.com +aws ses verify-domain-dkim --domain attacker-domain.com +``` +3. **配置邮箱用户并注册它们:** +```bash +aws workmail create-user --organization-id --name marketing --display-name "Marketing" +aws workmail register-to-work-mail --organization-id --entity-id --email marketing@attacker-domain.com +``` + +注意: +- 默认由 AWS 文档记录的 **接收者上限**:**每个组织每天 100,000 个外部接收者**(跨用户汇总)。 +- 域名验证活动会在 CloudTrail 中以 SES 类别出现,但带有 **`invokedBy`: `workmail..amazonaws.com`**,因此 SES 验证事件可能属于 WorkMail 的设置活动,而不是直接的 SES 活动。 +- WorkMail 的邮箱用户成为与 IAM 用户独立的 **application-layer persistence**。 + +## 发送路径与遥测盲点 + +### Web client (WorkMail UI) +- 会在 CloudTrail 中以 **`ses:SendRawEmail`** 事件表现出来。 +- `userIdentity.type` = `AWSService`, `invokedBy/sourceIPAddress/userAgent` = `workmail..amazonaws.com`,因此 **真实的客户端 IP 被隐藏**。 +- `requestParameters` 仍会 leak 发件人(`source`, `fromArn`, `sourceArn`, configuration set),可用于与新验证的域名/邮箱进行关联。 + +### SMTP (stealthiest) +- Endpoint: `smtp.mail..awsapps.com:465` (SMTP over SSL) with the mailbox password. +- **No CloudTrail data events** are generated for SMTP delivery, even when SES data events are enabled. +- 理想的检测点是 **组织/域/用户 的配置** 以及随后 Web 发送的 `SendRawEmail` 事件中引用的 SES identity ARNs。 + +
+通过 WorkMail 的 SMTP 示例发送 +```python +import smtplib +from email.message import EmailMessage + +SMTP_SERVER = "smtp.mail.us-east-1.awsapps.com" +SMTP_PORT = 465 +EMAIL_ADDRESS = "marketing@attacker-domain.com" +EMAIL_PASSWORD = "SuperSecretPassword!" + +target = "victim@example.com" # can be unverified/external +msg = EmailMessage() +msg["Subject"] = "WorkMail SMTP" +msg["From"] = EMAIL_ADDRESS +msg["To"] = target +msg.set_content("Delivered via WorkMail SMTP") + +with smtplib.SMTP_SSL(SMTP_SERVER, SMTP_PORT) as smtp: +smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD) +smtp.send_message(msg) +``` +
+ +## 检测注意事项 + +- 如果不需要 WorkMail, 在组织级别通过 **SCPs** (`workmail:*` deny) 阻止它。 +- 对预配活动发出警报:`workmail:CreateOrganization`, `workmail:CreateUser`, `workmail:RegisterToWorkMail`,以及带有 `invokedBy=workmail.amazonaws.com` 的 SES 验证(`ses:VerifyDomainIdentity`, `ses:VerifyDomainDkim`)。 +- 监控异常的 **`ses:SendRawEmail`** 事件,当 identity ARNs 引用新域且源 IP/UA 等于 `workmail..amazonaws.com` 时。 + +## References + +- [Threat Actors Using AWS WorkMail in Phishing Campaigns](https://www.rapid7.com/blog/post/dr-threat-actors-aws-workmail-phishing-campaigns) +- [AWS WorkMail limits](https://docs.aws.amazon.com/workmail/latest/adminguide/limits.html) + +{{#include ../../../../banners/hacktricks-training.md}} diff --git a/src/pentesting-cloud/aws-security/aws-services/aws-iam-enum.md b/src/pentesting-cloud/aws-security/aws-services/aws-iam-enum.md index e1b9c5610..308481b3c 100644 --- a/src/pentesting-cloud/aws-security/aws-services/aws-iam-enum.md +++ b/src/pentesting-cloud/aws-security/aws-services/aws-iam-enum.md @@ -1,10 +1,10 @@ -# AWS - IAM, 身份中心与 SSO 枚举 +# AWS - IAM, Identity Center & SSO Enum {{#include ../../../banners/hacktricks-training.md}} ## IAM -您可以在以下位置找到 **IAM 的描述**: +你可以在以下位置找到 **IAM 的描述**: {{#ref}} ../aws-basic-information/ @@ -12,9 +12,9 @@ ### 枚举 -所需的主要权限: +需要的主要权限: -- `iam:ListPolicies`, `iam:GetPolicy` 和 `iam:GetPolicyVersion` +- `iam:ListPolicies`, `iam:GetPolicy` and `iam:GetPolicyVersion` - `iam:ListRoles` - `iam:ListUsers` - `iam:ListGroups` @@ -22,9 +22,9 @@ - `iam:ListAttachedUserPolicies` - `iam:ListAttachedRolePolicies` - `iam:ListAttachedGroupPolicies` -- `iam:ListUserPolicies` 和 `iam:GetUserPolicy` -- `iam:ListGroupPolicies` 和 `iam:GetGroupPolicy` -- `iam:ListRolePolicies` 和 `iam:GetRolePolicy` +- `iam:ListUserPolicies` and `iam:GetUserPolicy` +- `iam:ListGroupPolicies` and `iam:GetGroupPolicy` +- `iam:ListRolePolicies` and `iam:GetRolePolicy` ```bash # All IAMs ## Retrieves information about all IAM users, groups, roles, and policies @@ -88,37 +88,49 @@ aws iam get-account-password-policy aws iam list-mfa-devices aws iam list-virtual-mfa-devices ``` +### 通过故意触发失败进行隐蔽权限确认 + +当 `List*` 或 模拟器 APIs 被阻止时,你可以通过触发可预测的验证错误来**在不创建持久性资源的情况下确认修改权限**。AWS 在返回这些错误之前仍会评估 IAM,因此看到该错误就证明调用者具有该操作权限: +```bash +# Confirm iam:CreateUser without creating a new principal (fails only after authz) +aws iam create-user --user-name # -> EntityAlreadyExistsException + +# Confirm iam:CreateLoginProfile while learning password policy requirements +aws iam create-login-profile --user-name --password lower --password-reset-required # -> PasswordPolicyViolationException +``` +这些尝试仍然会生成 CloudTrail 事件(带有 `errorCode` 设置),但会避免留下新的 IAM 工件,因此在交互式侦察期间对于**低噪声权限验证**很有用。 + ### 权限暴力破解 -如果您对自己的权限感兴趣,但没有访问查询 IAM 的权限,您可以尝试暴力破解它们。 +如果你想了解自己的权限,但无法访问以查询 IAM,你可以始终对其进行暴力破解。 #### bf-aws-permissions -工具 [**bf-aws-permissions**](https://github.com/carlospolop/bf-aws-permissions) 只是一个 bash 脚本,它将使用指定的配置文件运行所有可以通过 `aws` cli 帮助信息找到的 **`list*`、`describe*`、`get*`** 操作,并 **返回成功的执行结果**。 +该工具 [**bf-aws-permissions**](https://github.com/carlospolop/bf-aws-permissions) 只是一个 bash 脚本,它会使用指定的 profile 运行所有从 `aws` cli 帮助信息中找到的 **`list*`、`describe*`、`get*`** 操作,并**返回成功执行的操作**。 ```bash # Bruteforce permissions bash bf-aws-permissions.sh -p default > /tmp/bf-permissions-verbose.txt ``` #### bf-aws-perms-simulate -工具 [**bf-aws-perms-simulate**](https://github.com/carlospolop/bf-aws-perms-simulate) 可以找到您当前的权限(或其他主体的权限),前提是您拥有权限 **`iam:SimulatePrincipalPolicy`** +该工具 [**bf-aws-perms-simulate**](https://github.com/carlospolop/bf-aws-perms-simulate) 可以找出你当前的权限(或其他主体的权限),前提是你拥有权限 **`iam:SimulatePrincipalPolicy`** ```bash # Ask for permissions python3 aws_permissions_checker.py --profile [--arn ] ``` #### Perms2ManagedPolicies -如果你发现了**你的用户拥有的一些权限**,并且你认为这些权限是由**托管的 AWS 角色**授予的(而不是自定义角色)。你可以使用工具 [**aws-Perms2ManagedRoles**](https://github.com/carlospolop/aws-Perms2ManagedPolicies) 来检查所有**授予你发现的权限的 AWS 托管角色**。 +如果你发现 **你的用户拥有的一些权限**,并且你认为这些权限是由 **AWS 托管角色**(而不是自定义角色)授予的,你可以使用工具 [**aws-Perms2ManagedRoles**](https://github.com/carlospolop/aws-Perms2ManagedPolicies) 来检查所有授予你所发现权限的 **AWS 托管角色**。 ```bash # Run example with my profile python3 aws-Perms2ManagedPolicies.py --profile myadmin --permissions-file example-permissions.txt ``` > [!WARNING] -> 如果您看到**您对未使用的服务拥有权限**,则可以“知道”您拥有的权限是由AWS托管角色授予的。 +> 有时你可以“判断”你所拥有的权限是否由 AWS 管理的角色授予,例如当你发现 **你对未使用的服务拥有权限**。 #### Cloudtrail2IAM -[**CloudTrail2IAM**](https://github.com/carlospolop/Cloudtrail2IAM) 是一个Python工具,分析**AWS CloudTrail日志以提取和总结所有人或特定用户或角色所做的操作**。该工具将**解析来自指定存储桶的每个cloudtrail日志**。 +[**CloudTrail2IAM**](https://github.com/carlospolop/Cloudtrail2IAM) 是一个 Python 工具,用来分析 **从 AWS CloudTrail 日志中提取并汇总操作**,可以针对所有人或仅针对某个特定用户或角色。该工具会 **解析指定 bucket 中的每个 cloudtrail 日志**。 ```bash git clone https://github.com/carlospolop/Cloudtrail2IAM cd Cloudtrail2IAM @@ -126,16 +138,16 @@ pip install -r requirements.txt python3 cloudtrail2IAM.py --prefix PREFIX --bucket_name BUCKET_NAME --profile PROFILE [--filter-name FILTER_NAME] [--threads THREADS] ``` > [!WARNING] -> 如果你找到 .tfstate(Terraform 状态文件)或 CloudFormation 文件(这些通常是位于以 cf-templates 为前缀的桶中的 yaml 文件),你也可以读取它们以查找 aws 配置并找出哪些权限已分配给谁。 +> 如果你发现 .tfstate(Terraform 状态文件)或 CloudFormation 文件(这些通常是位于以 cf-templates 为前缀的 bucket 中的 yaml 文件),你也可以读取它们以查找 aws 配置并确定哪些权限被分配给了谁。 #### enumerate-iam -要使用工具 [**https://github.com/andresriancho/enumerate-iam**](https://github.com/andresriancho/enumerate-iam),你首先需要下载所有的 API AWS 端点,从中脚本 **`generate_bruteforce_tests.py`** 将获取所有的 **"list\_", "describe\_", 和 "get\_" 端点。** 最后,它将尝试 **使用给定的凭据访问它们** 并 **指示是否成功**。 +To use the tool [**https://github.com/andresriancho/enumerate-iam**](https://github.com/andresriancho/enumerate-iam) you first need to download all the API AWS endpoints, from those the script **`generate_bruteforce_tests.py`** will get all the **"list\_", "describe\_", and "get\_" endpoints.** And finally, it will try to **access them** with the given credentials and **indicate if it worked**. -(根据我的经验,**工具在某个时刻会挂起**, [**查看此修复**](https://github.com/andresriancho/enumerate-iam/pull/15/commits/77ad5b41216e3b5f1511d0c385da8cd5984c2d3c) 尝试修复这个问题)。 +(In my experience the **tool hangs at some point**, [**checkout this fix**](https://github.com/andresriancho/enumerate-iam/pull/15/commits/77ad5b41216e3b5f1511d0c385da8cd5984c2d3c) to try to fix that). > [!WARNING] -> 根据我的经验,这个工具与之前的工具类似,但工作效果更差,检查的权限更少。 +> 根据我的经验,这个工具类似于前一个,但表现更差并且检查的权限更少 ```bash # Install tool git clone git@github.com:andresriancho/enumerate-iam.git @@ -154,7 +166,7 @@ python3 enumerate-iam.py --access-key ACCESS_KEY --secret-key SECRET_KEY [--sess ``` #### weirdAAL -您还可以使用工具 [**weirdAAL**](https://github.com/carnal0wnage/weirdAAL/wiki)。该工具将检查 **多个常见服务上的多个常见操作**(将检查一些枚举权限和一些特权提升权限)。但它只会检查编码的检查(检查更多内容的唯一方法是编写更多测试)。 +你也可以使用工具 [**weirdAAL**](https://github.com/carnal0wnage/weirdAAL/wiki)。该工具会检查**多个常见服务上若干常见操作**(会检查一些枚举权限,也会检查一些 privesc 权限)。但它只会检查已编码的检测(要检查更多内容,唯一的方法是编写更多测试)。 ```bash # Install git clone https://github.com/carnal0wnage/weirdAAL.git @@ -178,7 +190,7 @@ python3 weirdAAL.py -m recon_all -t MyTarget # Check all permissions # [+] elbv2 Actions allowed are [+] # ['DescribeLoadBalancers', 'DescribeAccountLimits', 'DescribeTargetGroups'] ``` -#### 加固工具以暴力破解权限 +#### 针对 BF permissions 的加固工具 {{#tabs }} {{#tab name="CloudSploit" }} @@ -208,9 +220,9 @@ steampipe dashboard #### \ -之前的工具都无法检查所有权限,因此如果你知道更好的工具,请发送 PR! +Neither of the previous tools is capable of checking close to all permissions, so if you know a better tool send a PR! -### 未经身份验证的访问 +### 未认证访问 {{#ref}} ../aws-unauthenticated-enum-access/aws-iam-and-sts-unauthenticated-enum/README.md @@ -218,27 +230,27 @@ steampipe dashboard ### 权限提升 -在以下页面中,你可以查看如何 **滥用 IAM 权限以提升权限**: +在下面的页面中,你可以查看如何 **滥用 IAM 权限 来进行权限提升**: {{#ref}} ../aws-privilege-escalation/aws-iam-privesc/README.md {{#endref}} -### IAM 后期利用 +### IAM 后利用 {{#ref}} ../aws-post-exploitation/aws-iam-post-exploitation/README.md {{#endref}} -### IAM 持久性 +### IAM 持久化 {{#ref}} ../aws-persistence/aws-iam-persistence/README.md {{#endref}} -## IAM 身份中心 +## IAM Identity Center -你可以在以下位置找到 **IAM 身份中心的描述**: +关于 **IAM Identity Center** 的描述可在以下位置找到: {{#ref}} ../aws-basic-information/ @@ -257,16 +269,16 @@ sso_region = us-east-1 ``` ### 枚举 -身份中心的主要元素是: +Identity Center 的主要元素有: - 用户和组 -- 权限集:附加了策略 -- AWS 账户 +- Permission Sets:附加了策略 +- AWS Accounts -然后,创建关系,使用户/组对 AWS 账户拥有权限集。 +然后会创建关系,使用户/组在 AWS Account 上拥有 Permission Sets。 > [!NOTE] -> 请注意,有三种方法可以将策略附加到权限集。附加 AWS 管理的策略、客户管理的策略(这些策略需要在所有受权限集影响的账户中创建)和内联策略(在此定义)。 +> 注意有三种方法可以将策略附加到 Permission Set:附加 AWS managed policies、Customer managed policies(这些策略需要在 Permission Set 所影响的所有账户中创建),以及 inline policies(在其中定义)。 ```bash # Check if IAM Identity Center is used aws sso-admin list-instances @@ -302,7 +314,7 @@ aws identitystore list-group-memberships-for-member --identity-store-id --user-name privesc --display-name privesc --emails Value=sdkabflvwsljyclpma@tmmbt.net,Type=Work,Primary=True --name Formatted=privesc,FamilyName=privesc,GivenName=privesc ## After creating it try to login in the console using the selected username, you will receive an email with the code and then you will be able to select a password ``` -- 创建一个组并分配权限,并设置一个受控用户 -- 给受控用户或组额外的权限 -- 默认情况下,只有来自管理账户的用户才能访问和控制 IAM 身份中心。 +- 创建一个组并为其分配权限,并在其上设置一个受控用户 +- 向受控用户或组授予额外权限 +- 默认情况下,只有来自 Management Account 并具有权限的用户才能访问和控制 IAM Identity Center。 -然而,可以通过委派管理员允许来自不同账户的用户进行管理。他们将没有完全相同的权限,但他们将能够执行 [**管理活动**](https://docs.aws.amazon.com/singlesignon/latest/userguide/delegated-admin.html)。 +不过,可以通过 Delegate Administrator 允许来自不同账户的用户进行管理。他们不会拥有完全相同的权限,但他们将能够执行 [**management activities**](https://docs.aws.amazon.com/singlesignon/latest/userguide/delegated-admin.html)。 {{#include ../../../banners/hacktricks-training.md}}