Files
hacktricks-cloud/src/pentesting-cloud/aws-security/aws-persistence/aws-ec2-persistence/README.md

2.7 KiB
Raw Blame History

AWS - EC2 Persistence

{{#include ../../../../banners/hacktricks-training.md}}

EC2

更多信息请参见:

{{#ref}} ../../aws-services/aws-ec2-ebs-elb-ssm-vpc-and-vpn-enum/ {{#endref}}

Security Group Connection Tracking Persistence

如果防御方发现某个 EC2 instance was compromised,他们很可能会尝试隔离该机器的network。他们可以通过显式的 Deny NACL(但 NACLs 会影响整个子网),或者更改 the security group使其不允许任何 kind of inbound or outbound 流量来做到这一点。

如果攻击者从该机器发起了一个 reverse shell originated from the machine,即使修改了 SG 以不允许 inbound 或 outbound 流量,连接也不会因为 Security Group Connection Tracking 而被终止。

EC2 Lifecycle Manager

该服务允许schedule创建 AMIs and snapshots,甚至share them with other accounts。攻击者可以配置对所有镜像或所有卷every week生成 AMIs 或 snapshotsshare them with his account

Scheduled Instances

可以将 instances 安排为每天、每周甚至每月运行。攻击者可以运行一台具有高权限或有价值访问权限的机器,从而能够访问目标资源。

Spot Fleet Request

Spot instances 比常规实例cheaper。攻击者可以发起一个small spot fleet request for 5 year(例如),带有automatic IP 分配和一个 user data,当 spot instance start 时向攻击者发送 IP address,并附带一个 high privileged IAM role

Backdoor Instances

攻击者可获得 instances 访问权限并对其进行 backdoor

  • 例如使用传统的 rootkit
  • 添加新的 public SSH key(查看 EC2 privesc options
  • User Data 中植入 backdoor

Backdoor Launch Configuration

  • 对所使用的 AMI 进行 backdoor
  • 对 User Data 进行 backdoor
  • 对 Key Pair 进行 backdoor

EC2 ReplaceRootVolume Task (Stealth Backdoor)

使用 CreateReplaceRootVolumeTask,将运行中实例的 root EBS volume 替换为由攻击者控制的 AMI 或 snapshot 构建的卷。实例保留其 ENIs、IPs 和 role实际上会启动到恶意代码但外观上保持不变。

{{#ref}} ../aws-ec2-replace-root-volume-persistence/README.md {{#endref}}

VPN

创建一个 VPN使攻击者能够直接通过它连接到 VPC。

VPC Peering

在受害者 VPC 与攻击者 VPC 之间创建 peering connection以便他能够访问受害者 VPC。

{{#include ../../../../banners/hacktricks-training.md}}