diff --git a/src/pentesting-cloud/aws-security/aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/README.md b/src/pentesting-cloud/aws-security/aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/README.md index daffbdea0..1ebffdf15 100644 --- a/src/pentesting-cloud/aws-security/aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/README.md +++ b/src/pentesting-cloud/aws-security/aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/README.md @@ -1,10 +1,10 @@ -# AWS - EC2, EBS, ELB, SSM, VPC & VPN Enum +# AWS - EC2, EBS, ELB, SSM, VPC & VPN 枚举 {{#include ../../../../banners/hacktricks-training.md}} -## VPC & Networking +## VPC 与 网络 -了解什么是 VPC 及其组件: +了解 VPC 是什么以及其组件,请参见: {{#ref}} aws-vpc-and-networking-basic-information.md @@ -12,30 +12,30 @@ aws-vpc-and-networking-basic-information.md ## EC2 -Amazon EC2 用于启动 **虚拟服务器**。它允许配置 **安全性** 和 **网络** 以及管理 **存储**。Amazon EC2 的灵活性体现在其能够向上和向下扩展资源,有效适应变化的需求或流行度的激增。此功能减少了对精确流量预测的必要性。 +Amazon EC2 用于启动 **虚拟服务器**。它允许配置 **安全** 和 **网络** 并管理 **存储**。Amazon EC2 的灵活性体现在其能够向上或向下扩展资源,以便有效适应不同的需求变化或流量激增。这一特性减少了对精确流量预测的必要性。 -在 EC2 中有趣的枚举内容: +在 EC2 中值得枚举的内容包括: - 虚拟机 -- SSH 密钥 -- 用户数据 -- 现有的 EC2/AMI/快照 +- SSH Keys +- User Data +- Existing EC2s/AMIs/Snapshots - 网络 - 网络 -- 子网络 -- 公共 IP +- 子网 +- 公共 IPs - 开放端口 -- 与 AWS 之外的其他网络的集成连接 +- 与 AWS 以外其他网络的集成连接 -### 实例配置文件 +### Instance Profiles -使用 **角色** 授予在 **EC2 实例** 上运行的应用程序权限需要额外的配置。运行在 EC2 实例上的应用程序通过虚拟化操作系统与 AWS 隔离。由于这种额外的分离,您需要额外的步骤将 AWS 角色及其相关权限分配给 EC2 实例,并使其对应用程序可用。 +使用 **roles** 将权限授予在 **EC2 instances** 上运行的应用需要一些额外配置。运行在 EC2 实例上的应用由虚拟化的操作系统将其与 AWS 抽象隔离。由于这种额外的隔离,您需要采取额外步骤将 AWS 角色及其相关权限分配给 EC2 实例,并使这些权限对实例上的应用可用。 -这个额外的步骤是 **创建一个** [_**实例配置文件**_](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html) 附加到实例。**实例配置文件包含角色,并且**可以向在实例上运行的应用程序提供角色的临时凭证。这些临时凭证可以在应用程序的 API 调用中使用,以访问资源并限制访问仅限于角色指定的那些资源。请注意,**一次只能将一个角色分配给 EC2 实例**,并且实例上的所有应用程序共享相同的角色和权限。 +This extra step is the **creation of an** [_**instance profile**_](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-ec2_instance-profiles.html) attached to the instance. The **instance profile contains the role and** can provide the role's temporary credentials to an application that runs on the instance. Those temporary credentials can then be used in the application's API calls to access resources and to limit access to only those resources that the role specifies. Note that **only one role can be assigned to an EC2 instance** at a time, and all applications on the instance share the same role and permissions. -### 元数据端点 +### Metadata Endpoint -AWS EC2 元数据是关于 Amazon Elastic Compute Cloud (EC2) 实例的信息,在运行时可供实例使用。这些元数据用于提供有关实例的信息,例如其实例 ID、它运行的可用区、与实例关联的 IAM 角色以及实例的主机名。 +AWS EC2 metadata 是在运行时可供 Amazon Elastic Compute Cloud (EC2) 实例使用的有关该实例的信息。该元数据用于提供关于实例的信息,例如其 instance ID、运行所在的 availability zone、与实例关联的 IAM role 以及实例的 hostname。 {{#ref}} https://book.hacktricks.wiki/en/pentesting-web/ssrf-server-side-request-forgery/cloud-ssrf.html @@ -81,6 +81,9 @@ aws ec2 describe-addresses # Get current output aws ec2 get-console-output --instance-id [id] +# Get a JPG-format screenshot of a running instance +aws ec2 get-console-screenshot --instance [id] + # Get VPN customer gateways aws ec2 describe-customer-gateways aws ec2 describe-vpn-gateways @@ -127,21 +130,21 @@ aws ec2 describe-route-tables aws ec2 describe-vpcs aws ec2 describe-vpc-peering-connections ``` -### 未经身份验证的访问 +### 未认证访问 {{#ref}} ../../aws-unauthenticated-enum-access/aws-ec2-unauthenticated-enum/README.md {{#endref}} -### 权限提升 +### Privesc -在以下页面中,您可以查看如何**滥用EC2权限以提升权限**: +在下面的页面你可以查看如何 **滥用 EC2 权限以提升权限**: {{#ref}} ../../aws-privilege-escalation/aws-ec2-privesc/README.md {{#endref}} -### 后期利用 +### Post-Exploitation {{#ref}} ../../aws-post-exploitation/aws-ec2-ebs-ssm-and-vpc-post-exploitation/ @@ -149,17 +152,17 @@ aws ec2 describe-vpc-peering-connections ## EBS -亚马逊**EBS**(弹性块存储)**快照**基本上是AWS EBS卷的静态**备份**。换句话说,它们是特定时间点上附加到**EC2**实例的**磁盘**的**副本**。EBS快照可以跨区域和账户复制,甚至可以下载并在本地运行。 +Amazon **EBS** (Elastic Block Store) 的 **快照 (snapshots)** 本质上是 AWS EBS 卷的静态 **备份**。换句话说,它们是在特定时间点附加到 **EC2** 实例上的 **磁盘** 的 **拷贝**。EBS snapshots 可以跨区域和账户复制,甚至可以下载并在本地运行。 -快照可能包含**敏感信息**,例如**源代码或API密钥**,因此,如果有机会,建议检查它。 +快照可能包含 **敏感信息**,例如 **源代码或 APi keys**,因此如果有机会,建议检查它们。 -### AMI与EBS的区别 +### AMI 与 EBS 的区别 -**AMI**用于**启动EC2实例**,而EC2**快照**用于**备份和恢复存储在EBS卷上的数据**。虽然EC2快照可以用于创建新的AMI,但它与AMI并不相同,并且不包含运行应用程序所需的操作系统、应用服务器或其他软件的信息。 +一个 **AMI** 用于 **启动 EC2 实例**,而 EC2 的 **Snapshot** 用于 **备份并恢复存储在 EBS 卷上的数据**。虽然 EC2 Snapshot 可以用来创建新的 AMI,但它并不是 AMI 本身,也不包含运行应用程序所需的操作系统、应用服务器或其他软件的信息。 -### 权限提升 +### Privesc -在以下页面中,您可以查看如何**滥用EBS权限以提升权限**: +在下面的页面你可以查看如何 **滥用 EBS 权限以提升权限**: {{#ref}} ../../aws-privilege-escalation/aws-ebs-privesc/README.md @@ -167,13 +170,13 @@ aws ec2 describe-vpc-peering-connections ## SSM -**亚马逊简单系统管理器(SSM)**允许远程管理EC2实例的浮动,使其管理变得更加简单。这些实例中的每一个都需要运行**SSM代理服务,因为该服务将负责从AWS API获取并执行操作**。 +**Amazon Simple Systems Manager (SSM)** 允许远程管理大量 EC2 实例,从而简化它们的管理。每个实例都需要运行 **SSM Agent service,因为该服务将接收来自 AWS API 的操作并执行它们**。 -**SSM代理**使系统管理器能够更新、管理和配置这些资源。代理**处理来自AWS云中系统管理器服务的请求**,然后按请求中指定的方式运行它们。 +**SSM Agent** 使 Systems Manager 能够更新、管理和配置这些资源。该 agent **会处理来自 AWS Cloud 中 Systems Manager 服务的请求**,然后按请求中指定的方式运行它们。 -**SSM代理**[**在某些AMI中预安装**](https://docs.aws.amazon.com/systems-manager/latest/userguide/ami-preinstalled-agent.html),或者您需要在实例上[**手动安装它们**](https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-manual-agent-install.html)。此外,实例内部使用的IAM角色需要附加**AmazonEC2RoleforSSM**策略才能进行通信。 +The **SSM Agent comes**[ **preinstalled in some AMIs**](https://docs.aws.amazon.com/systems-manager/latest/userguide/ami-preinstalled-agent.html) or you need to [**manually install them**](https://docs.aws.amazon.com/systems-manager/latest/userguide/sysman-manual-agent-install.html) on the instances. Also, the IAM Role used inside the instance needs to have the policy **AmazonEC2RoleforSSM** attached to be able to communicate. -### 枚举 +### Enumeration ```bash aws ssm describe-instance-information aws ssm describe-parameters @@ -182,13 +185,13 @@ aws ssm describe-instance-patches --instance-id aws ssm describe-instance-patch-states --instance-ids aws ssm describe-instance-associations-status --instance-id ``` -您可以通过执行以下命令检查 EC2 实例中是否正在运行 Systems Manager: +您可以在 EC2 实例中仅通过执行以下命令来检查 Systems Manager 是否正在运行: ```bash ps aux | grep amazon-ssm ``` ### Privesc -在以下页面中,您可以查看如何**滥用SSM权限以提升特权**: +在以下页面你可以查看如何 **abuse SSM permissions to escalate privileges**: {{#ref}} ../../aws-privilege-escalation/aws-ssm-privesc/README.md @@ -196,7 +199,7 @@ ps aux | grep amazon-ssm ### Perssistence -在以下页面中,您可以查看如何**滥用SSM权限以实现持久性**: +在以下页面你可以查看如何 **abuse SSM permissions to achieve persistence**: {{#ref}} ../../aws-persistence/aws-ssm-persistence/README.md @@ -204,7 +207,7 @@ ps aux | grep amazon-ssm ## ELB -**弹性负载均衡**(ELB)是**亚马逊网络服务**(AWS)部署的**负载均衡服务**。ELB自动**分配传入的应用程序流量**并根据流量需求扩展资源。 +**Elastic Load Balancing** (ELB) 是 Amazon Web Services (AWS) 部署中的负载均衡服务。ELB 会自动 **分发传入的应用流量** 并根据流量需求扩展资源以满足负载。 ### Enumeration ```bash @@ -217,7 +220,7 @@ aws elbv2 describe-load-balancers aws elbv2 describe-load-balancers | jq '.LoadBalancers[].DNSName' aws elbv2 describe-listeners --load-balancer-arn ``` -## 启动模板与自动扩展组 +## Launch Templates & Autoscaling Groups ### 枚举 ```bash @@ -236,9 +239,9 @@ aws autoscaling describe-load-balancers ``` ## Nitro -AWS Nitro 是一套 **创新技术**,构成了 AWS EC2 实例的基础平台。由亚马逊推出以 **增强安全性、性能和可靠性**,Nitro 利用定制的 **硬件组件和轻量级虚拟机监控器**。它将传统虚拟化功能抽象到专用硬件和软件上,**最小化攻击面**并提高资源效率。通过卸载虚拟化功能,Nitro 使 EC2 实例能够提供 **接近裸金属的性能**,这对资源密集型应用特别有利。此外,Nitro 安全芯片专门确保 **硬件和固件的安全性**,进一步巩固其强大的架构。 +AWS Nitro 是一套构成 AWS EC2 instances 底层平台的 **创新技术**。由 Amazon 引入以 **增强安全性、性能和可靠性**,Nitro 利用定制的 **硬件组件和轻量级 hypervisor**。它将大量传统虚拟化功能抽象到专用的硬件和软件中,**最小化攻击面**并提高资源效率。通过卸载虚拟化功能,Nitro 使 EC2 instances 能提供 **接近裸金属性能**,这对资源密集型应用尤其有利。此外,Nitro Security Chip 专门确保持有 **硬件和固件的安全性**,进一步巩固其稳健的架构。 -获取更多信息以及如何枚举它: +Get more information and how to enumerate it from: {{#ref}} aws-nitro-enum.md @@ -246,34 +249,34 @@ aws-nitro-enum.md ## VPN -VPN 允许将您的 **本地网络(站点到站点 VPN)** 或 **工作人员的笔记本电脑(客户端 VPN)** 连接到 **AWS VPC**,以便可以在不需要将其暴露于互联网的情况下访问服务。 +A VPN allows to connect your **on-premise network (site-to-site VPN)** or the **workers laptops (Client VPN)** with a **AWS VPC** so services can accessed without needing to expose them to the internet. -#### 基本 AWS VPN 组件 +#### Basic AWS VPN Components -1. **客户网关**: -- 客户网关是您在 AWS 中创建的资源,用于表示您一侧的 VPN 连接。 -- 它本质上是您一侧站点到站点 VPN 连接上的物理设备或软件应用程序。 -- 您向 AWS 提供路由信息和网络设备的公共 IP 地址(例如路由器或防火墙),以创建客户网关。 -- 它作为设置 VPN 连接的参考点,不会产生额外费用。 -2. **虚拟私有网关**: -- 虚拟私有网关(VPG)是站点到站点 VPN 连接中 Amazon 侧的 VPN 集中器。 -- 它附加到您的 VPC,并作为您的 VPN 连接的目标。 -- VPG 是 VPN 连接的 AWS 侧端点。 -- 它处理您的 VPC 和本地网络之间的安全通信。 -3. **站点到站点 VPN 连接**: -- 站点到站点 VPN 连接通过安全的 IPsec VPN 隧道将您的本地网络连接到 VPC。 -- 这种类型的连接需要客户网关和虚拟私有网关。 -- 它用于您的数据中心或网络与 AWS 环境之间的安全、稳定和一致的通信。 -- 通常用于常规的长期连接,并根据通过连接传输的数据量计费。 -4. **客户端 VPN 端点**: -- 客户端 VPN 端点是您在 AWS 中创建的资源,用于启用和管理客户端 VPN 会话。 -- 它用于允许单个设备(如笔记本电脑、智能手机等)安全地连接到 AWS 资源或您的本地网络。 -- 它与站点到站点 VPN 的不同之处在于,它是为单个客户端设计的,而不是连接整个网络。 -- 使用客户端 VPN,每个客户端设备使用 VPN 客户端软件建立安全连接。 +1. **Customer Gateway**: +- A Customer Gateway is a resource that you create in AWS to represent your side of a VPN connection. +- It is essentially a physical device or software application on your side of the Site-to-Site VPN connection. +- You provide routing information and the public IP address of your network device (such as a router or a firewall) to AWS to create a Customer Gateway. +- It serves as a reference point for setting up the VPN connection and doesn't incur additional charges. +2. **Virtual Private Gateway**: +- A Virtual Private Gateway (VPG) is the VPN concentrator on the Amazon side of the Site-to-Site VPN connection. +- It is attached to your VPC and serves as the target for your VPN connection. +- VPG is the AWS side endpoint for the VPN connection. +- It handles the secure communication between your VPC and your on-premises network. +3. **Site-to-Site VPN Connection**: +- A Site-to-Site VPN connection connects your on-premises network to a VPC through a secure, IPsec VPN tunnel. +- This type of connection requires a Customer Gateway and a Virtual Private Gateway. +- It's used for secure, stable, and consistent communication between your data center or network and your AWS environment. +- Typically used for regular, long-term connections and is billed based on the amount of data transferred over the connection. +4. **Client VPN Endpoint**: +- A Client VPN endpoint is a resource that you create in AWS to enable and manage client VPN sessions. +- It is used for allowing individual devices (like laptops, smartphones, etc.) to securely connect to AWS resources or your on-premises network. +- It differs from Site-to-Site VPN in that it is designed for individual clients rather than connecting entire networks. +- With Client VPN, each client device uses a VPN client software to establish a secure connection. -您可以 [**在这里找到有关 AWS VPN 的好处和组件的更多信息**](aws-vpc-and-networking-basic-information.md#vpn)。 +您可以在此处 [**查找有关 AWS VPN 优势和组件的更多信息**](aws-vpc-and-networking-basic-information.md#vpn)。 -### Enumeration +### 枚举 ```bash # VPN endpoints ## Check used subnetwork, authentication, SGs, connected... @@ -297,25 +300,25 @@ aws ec2 describe-vpn-gateways # Get VPN site-to-site connections aws ec2 describe-vpn-connections ``` -### 本地枚举 +### Local Enumeration **本地临时凭证** -当使用 AWS VPN 客户端连接到 VPN 时,用户通常会 **登录到 AWS** 以获取对 VPN 的访问权限。然后,一些 **AWS 凭证被创建并存储** 在本地以建立 VPN 连接。这些凭证 **存储在** `$HOME/.config/AWSVPNClient/TemporaryCredentials//temporary-credentials.txt` 中,包含 **AccessKey**、**SecretKey** 和 **Token**。 +当使用 AWS VPN Client 连接到 VPN 时,用户通常会 **登录 AWS** 以获取对 VPN 的访问权限。随后,会在本地创建并存储一些 **AWS 凭证** 以建立 VPN 连接。 这些凭证被 **存储在** `$HOME/.config/AWSVPNClient/TemporaryCredentials//temporary-credentials.txt`,并包含一个 **AccessKey**、一个 **SecretKey** 和一个 **Token**。 -这些凭证属于用户 `arn:aws:sts:::assumed-role/aws-vpn-client-metrics-analytics-access-role/CognitoIdentityCredentials` (TODO: 进一步研究这些凭证的权限)。 +这些凭证属于用户 `arn:aws:sts:::assumed-role/aws-vpn-client-metrics-analytics-access-role/CognitoIdentityCredentials`(TODO: research more about the permissions of this credentials)。 **opvn 配置文件** -如果 **VPN 连接已建立**,您应该在系统中搜索 **`.opvn`** 配置文件。此外,您可以在 **`$HOME/.config/AWSVPNClient/OpenVpnConfigs`** 中找到 **配置**。 +如果已经建立了 **VPN 连接**,应在系统中搜索 **`.opvn`** 配置文件。此外,可以在 **`$HOME/.config/AWSVPNClient/OpenVpnConfigs`** 找到这些 **配置**。 -#### **后期利用** +#### **Post Exploitaiton** {{#ref}} ../../aws-post-exploitation/aws-vpn-post-exploitation/README.md {{#endref}} -## 参考 +## 参考资料 - [https://docs.aws.amazon.com/batch/latest/userguide/getting-started-ec2.html](https://docs.aws.amazon.com/batch/latest/userguide/getting-started-ec2.html)